监控使用 Amazon CloudWatch Events - Amazon IoT Analytics
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅中国的 Amazon Web Services 服务入门

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

监控使用 Amazon CloudWatch Events

Amazon IoT Analytics当发生运行时错误时,自动向 Amazon CloudWatch Event 发布事件Amazon Lambda一个活动。此事件包含一条详细的错误消息和存储未处理频道消息的 Amazon Simple Storage Service (Amazon S3) 对象的密钥。您可以使用 Amazon S3 密钥重新处理未处理的频道消息。有关更多信息,请参阅 。重新处理通道消息StartPipelineReprocessing中的 APIAmazon IoT AnalyticsAPI 参考, 和什么是 Amazon CloudWatch Events中的Amazon CloudWatch Events.

您还可以配置目标,使 Amazon CloudWatch Events 能够发送通知或采取进一步措施。例如,您可以将通知发送到 Amazon Simple Queue Service (Amazon SQS) 队列,然后调用StartReprocessingMessage用于处理保存在 Amazon S3 对象中的频道消息的 API。Amazon CloudWatch Events 支持多种类型的目标,例如以下目标:

  • Amazon Kinesis Streams

  • Amazon Lambda 函数

  • Amazon Simple Notification Service (Amazon SNS) 主题

  • Amazon Simple Queue Service (Amazon SQS) 队列

有关支持的目标列表,请参阅Amazon EventBridge 目标中的Amazon EventBridge 用户指南.

您的 CloudWatch Event 资源和相关目标必须位于Amazon创建您的Amazon IoT Analytics资源的费用。有关更多信息,请参阅 。服务终端节点和配额中的Amazon一般参考.

向 Amazon CloudWatch Events 发送的有关运行时错误的通知Amazon LambdaActivity 使用以下格式。

{ "version": "version-id", "id": "event-id", "detail-type": "IoT Analytics Pipeline Failure Notification", "source": "aws.iotanalytics", "account": "aws-account", "time": "timestamp", "region": "aws-region", "resources": [ "pipeline-arn" ], "detail": { "event-detail-version": "1.0", "pipeline-name": "pipeline-name", "error-code": "LAMBDA_FAILURE", "message": "error-message", "channel-messages": { "s3paths": [ "s3-keys" ] }, "activity-name": "lambda-activity-name", "lambda-function-arn": "lambda-function-arn" } }

示例通知:

{ "version": "0", "id": "204e672e-ef12-09af-4cfd-de3b53673ec6", "detail-type": "IoT Analytics Pipeline Failure Notification", "source": "aws.iotanalytics", "account": "123456789012", "time": "2020-10-15T23:47:02Z", "region": "ap-southeast-2", "resources": [ "arn:aws:iotanalytics:ap-southeast-2:123456789012:pipeline/test_pipeline_failure" ], "detail": { "event-detail-version": "1.0", "pipeline-name": "test_pipeline_failure", "error-code": "LAMBDA_FAILURE", "message": "Temp unavaliable", "channel-messages": { "s3paths": [ "test_pipeline_failure/channel/cmr_channel/__dt=2020-10-15 00:00:00/1602805530000_1602805560000_123456789012_cmr_channel_0_257.0.json.gz" ] }, "activity-name": "LambdaActivity_33", "lambda-function-arn": "arn:aws:lambda:ap-southeast-2:123456789012:function:lambda_activity" } }