CloudWatch 公制流輸出格JSON式 - Amazon CloudWatch

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

CloudWatch 公制流輸出格JSON式

在使用該JSON格式的 CloudWatch 度量串流中,每個 Firehose 記錄都包含多個JSON物件,並以換行字元 (\ n) 分隔。每個物件都包含單一指標的單一資料點。

使用的JSON格式完全兼容 AWS Glue 和 Amazon Athena。如果您有「Firehose」交付串流和 AWS Glue 表格格式正確,格式可以在存儲在 S3 之前自動轉換為實木複合格式或優化行單欄(ORC)格式。如需有關轉換格式的詳細資訊,請參閱在 Firehose 中轉換輸入記錄格式。如需有關正確格式的詳細資訊 AWS Glue,請參閱影響 AWS Glue 我應該使用模式JSON輸出格式嗎?

在JSON格式中,的unit有效值與結MetricDatumAPI構unit中的值相同。如需詳細資訊,請參閱 MetricDatumtimestamp 欄位的值以 epoch 毫秒為單位,例如 1616004674229

以下是格式的範例。在這個例子中,格式化JSON為了方便閱讀,但實際上整個格式是在一行上。

{ "metric_stream_name": "MyMetricStream", "account_id": "1234567890", "region": "us-east-1", "namespace": "AWS/EC2", "metric_name": "DiskWriteOps", "dimensions": { "InstanceId": "i-123456789012" }, "timestamp": 1611929698000, "value": { "count": 3.0, "sum": 20.0, "max": 18.0, "min": 0.0, "p99": 17.56, "p99.9": 17.8764, "TM(25%:75%)": 16.43 }, "unit": "Seconds" }

影響 AWS Glue 我應該使用模式JSON輸出格式嗎?

以下是StorageDescriptor針對的JSON表示的範例 AWS Glue 表格,然後會由 Firehose 使用。如需有關的更多資訊StorageDescriptor,請參閱 StorageDescriptor

{ "Columns": [ { "Name": "metric_stream_name", "Type": "string" }, { "Name": "account_id", "Type": "string" }, { "Name": "region", "Type": "string" }, { "Name": "namespace", "Type": "string" }, { "Name": "metric_name", "Type": "string" }, { "Name": "timestamp", "Type": "timestamp" }, { "Name": "dimensions", "Type": "map<string,string>" }, { "Name": "value", "Type": "struct<min:double,max:double,count:double,sum:double,p99:double,p99.9:double>" }, { "Name": "unit", "Type": "string" } ], "Location": "s3://amzn-s3-demo-bucket/", "InputFormat": "org.apache.hadoop.mapred.TextInputFormat", "OutputFormat": "org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat", "SerdeInfo": { "SerializationLibrary": "org.apache.hive.hcatalog.data.JsonSerDe" }, "Parameters": { "classification": "json" } }

上述範例適用於在 Amazon S3 上以JSON格式寫入的資料。將下列欄位中的值取代為指示的值,以 Parquet 格式或「最佳化列欄」(ORC) 格式儲存資料。

  • Parquet:

    • inputFormat: 或者. 阿帕奇 .hadoop.hive.io. MapredParquetInputFormat

    • outputFormat: 或者. 阿帕奇 .hadoop.hive.io. MapredParquetOutputFormat

    • SerDeInfo。 serializationLib: 或者. 阿帕奇 .hadoop.hive.ql.io.parquet.serde. ParquetHiveSerDe

    • parameters.classification: parquet

  • ORC:

    • inputFormat: 組織. 阿帕奇 .hadoop.hive.io. OrcInputFormat

    • outputFormat: 組織. 阿帕奇 .hadoop.hive.io. OrcOutputFormat

    • SerDeInfo。 serializationLib: 組織. 阿帕奇 .hadoop.hive.io. OrcSerde

    • parameters.classification: orc