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

Amazon IoT Analytics 不再向新客户提供。的现有客户 Amazon IoT Analytics 可以继续照常使用该服务。了解更多

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

使用 Amazon CloudWatch Events 监控

当 Amazon Lambda 活动期间发生运行时系统错误时,Amazon IoT Analytics 会自动将事件发布到 Amazon CloudWatch Events。此事件包含详细的错误消息以及存储未处理通道消息的 Amazon Simple Storage Service (Amazon S3)对象的密钥。您可使用 Amazon S3 密钥重新处理未处理的通道消息。有关更多信息,请参阅 重新处理通道消息《Amazon IoT Analytics API 参考》中的 StartPipelineReprocessing《Amazon CloudWatch Events 用户指南》中的“什么是 Amazon CloudWatch Events”

您还可以配置目标,使 Amazon CloudWatch Events 能够发送通知或执行后续操作。例如,您可以发送通知到 Amazon Simple Queue Service (Amazon SQS) 队列中,然后调用 StartReprocessingMessage API 来处理保存在 Amazon S3 对象中的通道消息。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 Events 资源及关联目标必须位于所创建 Amazon IoT Analytics 资源的 Amazon 区域。有关更多信息,请参阅 Amazon Web Services 一般参考 中的服务端点和配额

针对 Amazon Lambda 活动中运行时系统错误发送给 Amazon CloudWatch Events 的通知使用以下格式。

{ "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" } }