Monitor with Amazon CloudWatch Events - Amazon IoT Analytics
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Monitor with Amazon CloudWatch Events

Amazon IoT Analytics automatically publishes an event to Amazon CloudWatch Events when a runtime error occurs during an Amazon Lambda activity. This event contains a detailed error message and the keys of the Amazon Simple Storage Service (Amazon S3) objects that store the unprocessed channel messages. You can use the Amazon S3 keys to reprocess the unprocessed channel messages. For more information, see Reprocessing channel messages, the StartPipelineReprocessing API in the Amazon IoT Analytics API Reference, and What Is Amazon CloudWatch Events in the Amazon CloudWatch Events User Guide.

You can also configure targets that enable Amazon CloudWatch Events to send notifications or take further actions. For example, you can send the notification to an Amazon Simple Queue Service (Amazon SQS) queue, and then invoke the StartReprocessingMessage API to process the channel messages saved in the Amazon S3 objects. Amazon CloudWatch Events supports many types of targets, such as the following:

  • Amazon Kinesis streams

  • Amazon Lambda functions

  • Amazon Simple Notification Service (Amazon SNS) topics

  • Amazon Simple Queue Service (Amazon SQS) queues

For the list of supported targets, see Amazon EventBridge Targets in the Amazon EventBridge User Guide.

Your CloudWatch Events resources and the associated targets must be in the Amazon Region where you created your Amazon IoT Analytics resources. For more information, see Service endpoints and quotas in the Amazon Web Services General Reference.

The notification sent to Amazon CloudWatch Events for runtime errors in the Amazon Lambda activity uses the following format.

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

Example notification:

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