Logging Amazon IoT Analytics API calls with Amazon CloudTrail - 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).

Logging Amazon IoT Analytics API calls with Amazon CloudTrail

Amazon IoT Analytics is integrated with Amazon CloudTrail, a service that provides a record of actions taken by a user, role, or an Amazon service in Amazon IoT Analytics. CloudTrail captures a subset of API calls for Amazon IoT Analytics as events, including calls from the Amazon IoT Analytics console and from code calls to the Amazon IoT Analytics APIs. If you create a trail, you can enable continuous delivery of CloudTrail events to an Amazon S3 bucket, including events for Amazon IoT Analytics. If you don't configure a trail, you can still view the most recent events in the CloudTrail console in Event history. Using the information collected by CloudTrail, you can determine the request that was made to Amazon IoT Analytics, the IP address from which the request was made, who made the request, when it was made, and additional details.

To learn more about CloudTrail, see the Amazon CloudTrail User Guide.

Amazon IoT Analytics information in Amazon CloudTrail

CloudTrail is enabled on your Amazon account when you create the account. When activity occurs in Amazon IoT Analytics, that activity is recorded in a CloudTrail event along with other Amazon service events in Event history. You can view, search, and download recent events in your Amazon account. For more information, see Viewing events with CloudTrail event history.

For an ongoing record of events in your Amazon account, including events for Amazon IoT Analytics, create a trail. A trail enables CloudTrail to deliver log files to an Amazon S3 bucket. By default, when you create a trail in the console, the trail applies to all Regions. The trail logs events from all Regions in the Amazon partition and delivers the log files to the Amazon S3 bucket that you specify. Additionally, you can configure other Amazon services to further analyze and act upon the event data collected in CloudTrail logs. For more information, see:

Amazon IoT Analytics supports logging the following actions as events in CloudTrail log files:

Every event or log entry contains information about who generated the request. The identity information helps you determine the following:

  • Whether the request was made with root or Amazon Identity and Access Management user credentials.

  • Whether the request was made with temporary security credentials for a role or federated user.

  • Whether the request was made by another Amazon service.

For more information, see the CloudTrail userIdentity element.

Understanding Amazon IoT Analytics log file entries

A trail is a configuration that enables delivery of events as log files to an S3 bucket that you specify. CloudTrail log files contain one or more log entries. An event represents single request from any source and includes information about the requested action, the date and time of the action, request parameters, and so on. CloudTrail log files are not an ordered stack trace of the public API calls, so they do not appear in any specific order.

The following example shows a CloudTrail log entry that demonstrates the CreateChannel action.

{ "eventVersion": "1.05", "userIdentity": { "type": "AssumedRole", "principalId": "ABCDE12345FGHIJ67890B:AnalyticsChannelTestFunction", "arn": "arn:aws:sts::123456789012:assumed-role/AnalyticsRole/AnalyticsChannelTestFunction", "accountId": "123456789012", "accessKeyId": "ABCDE12345FGHIJ67890B", "sessionContext": { "attributes": { "mfaAuthenticated": "false", "creationDate": "2018-02-14T23:43:12Z" }, "sessionIssuer": { "type": "Role", "principalId": "ABCDE12345FGHIJ67890B", "arn": "arn:aws:iam::123456789012:role/AnalyticsRole", "accountId": "123456789012", "userName": "AnalyticsRole" } } }, "eventTime": "2018-02-14T23:55:14Z", "eventSource": "iotanalytics.amazonaws.com", "eventName": "CreateChannel", "awsRegion": "us-east-1", "sourceIPAddress": "", "userAgent": "aws-internal/3 exec-env/AWS_Lambda_java8", "requestParameters": { "channelName": "channel_channeltest" }, "responseElements": { "retentionPeriod": { "unlimited": true }, "channelName": "channel_channeltest", "channelArn": "arn:aws:iotanalytics:us-east-1:123456789012:channel/channel_channeltest" }, "requestID": "7f871429-11e2-11e8-9eee-0781b5c0ac59", "eventID": "17885899-6977-41be-a6a0-74bb95a78294", "eventType": "AwsApiCall", "recipientAccountId": "123456789012" }

The following example shows a CloudTrail log entry that demonstrates the CreateDataset action.

{ "eventVersion": "1.05", "userIdentity": { "type": "AssumedRole", "principalId": "ABCDE12345FGHIJ67890B:AnalyticsDatasetTestFunction", "arn": "arn:aws:sts::123456789012:assumed-role/AnalyticsRole/AnalyticsDatasetTestFunction", "accountId": "123456789012", "accessKeyId": "ABCDE12345FGHIJ67890B", "sessionContext": { "attributes": { "mfaAuthenticated": "false", "creationDate": "2018-02-14T23:41:36Z" }, "sessionIssuer": { "type": "Role", "principalId": "ABCDE12345FGHIJ67890B", "arn": "arn:aws:iam::123456789012:role/AnalyticsRole", "accountId": "123456789012", "userName": "AnalyticsRole" } } }, "eventTime": "2018-02-14T23:53:39Z", "eventSource": "iotanalytics.amazonaws.com", "eventName": "CreateDataset", "awsRegion": "us-east-1", "sourceIPAddress": "", "userAgent": "aws-internal/3 exec-env/AWS_Lambda_java8", "requestParameters": { "datasetName": "dataset_datasettest" }, "responseElements": { "datasetArn": "arn:aws:iotanalytics:us-east-1:123456789012:dataset/dataset_datasettest", "datasetName": "dataset_datasettest" }, "requestID": "46ee8dd9-11e2-11e8-979a-6198b668c3f0", "eventID": "5abe21f6-ee1a-48ef-afc5-c77211235303", "eventType": "AwsApiCall", "recipientAccountId": "123456789012" }