使用 Amazon CloudWatch Events 监控 - AWS IoT Analytics

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

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

使用 Amazon CloudWatch Events 监控

当 AWS Lambda 活动期间发生运行时系统错误时,AWS IoT Analytics 会自动将事件发布到 Amazon CloudWatch Events。此事件包含详细的错误消息以及存储未处理通道消息的 Amazon Simple Storage Service (Amazon S3)对象的密钥。您可使用 Amazon S3 密钥重新处理未处理的通道消息。有关更多信息,请参阅 重新处理通道消息《AWS 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

  • AWS Lambda 函数

  • Amazon Simple Notification Service (Amazon SNS) 主题

  • Amazon Simple Queue Service (Amazon SQS) 队列

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

CloudWatch Events 资源及关联目标必须位于所创建 AWS IoT Analytics 资源的 AWS 区域。有关更多信息,请参阅 AWS 一般参考 中的服务端点和配额

针对 AWS 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" } }