AWS Device Farm
Developer Guide (API Version 2015-06-23)

Logging AWS Device Farm API Calls by Using AWS CloudTrail

Device Farm is integrated with CloudTrail, a service that captures API calls made by or on behalf of Device Farm in your AWS account and delivers the log files to an Amazon S3 bucket you specify. Examples of these API calls include creating a new project or run in Device Farm. CloudTrail captures API calls from the Device Farm console or the Device Farm APIs. Using the information collected by CloudTrail, you can determine which request was made to Device Farm, the source IP address from which the request was made, who made the request, when it was made, and so on. To learn more about CloudTrail, including how to configure and enable it, see the AWS CloudTrail User Guide.

Device Farm Information in CloudTrail

When CloudTrail logging is enabled in your AWS account, API calls made to Device Farm actions are tracked in log files. Device Farm records are written together with other AWS service records in a log file. CloudTrail determines when to create and write to a new file based on a time period and file size.

All of the Device Farm actions are logged and documented in the AWS CLI Reference and the API Reference. For example, calls to create a new project or run in Device Farm generate entries in CloudTrail log files.

Every log entry contains information about who generated the request. The user identity information in the log helps you determine whether the request was made with root or IAM user credentials, with temporary security credentials for a role or federated user, or by another AWS service. For more information, see the userIdentity field in the CloudTrail Event Reference.

You can store log files in your bucket for as long as you want, but you can also define Amazon S3 lifecycle rules to archive or delete log files automatically. By default, your log files are encrypted by using Amazon S3 server-side encryption (SSE).

If you want to take quick action upon log file delivery, you can have CloudTrail publish Amazon SNS notifications when new log files are delivered. For more information, see Configuring Amazon SNS Notifications.

You can also aggregate Device Farm log files from multiple AWS regions and multiple AWS accounts into a single Amazon S3 bucket. For more information, see Aggregating CloudTrail Log Files to a Single Amazon S3 Bucket.

Understanding Device Farm Log File Entries

CloudTrail log files can contain one or more log entries where each entry is made up of multiple JSON-formatted events. A log entry represents a single request from any source and includes information about the requested action, any parameters, the date and time of the action, and so on. The log entries are not guaranteed to be in any particular order. That is, they are not an ordered stack trace of the public API calls.

The following example shows a CloudTrail log entry that demonstrates the Device Farm ListRuns action:

{ "Records": [ { "eventVersion": "1.03", "userIdentity": { "type": "Root", "principalId": "AKIAI44QH8DHBEXAMPLE", "arn": "arn:aws:iam::123456789012:root", "accountId": "123456789012", "accessKeyId": "AKIAIOSFODNN7EXAMPLE", "sessionContext": { "attributes": { "mfaAuthenticated": "false", "creationDate": "2015-07-08T21:13:35Z" } } }, "eventTime":"2015-07-09T00:51:22Z", "eventSource": "", "eventName":"ListRuns", "awsRegion":"us-west-2", "sourceIPAddress":"", "userAgent":"example-user-agent-string", "requestParameters": { "arn":"arn:aws:devicefarm:us-west-2:123456789012:project:a9129b8c-df6b-4cdd-8009-40a25EXAMPLE"}, "responseElements": { "runs": [ { "created": "Jul 8, 2015 11:26:12 PM", "name": "example.apk", "completedJobs": 2, "arn": "arn:aws:devicefarm:us-west-2:123456789012:run:a9129b8c-df6b-4cdd-8009-40a256aEXAMPLE/1452d105-e354-4e53-99d8-6c993EXAMPLE", "counters": { "stopped": 0, "warned": 0, "failed": 0, "passed": 4, "skipped": 0, "total": 4, "errored": 0 }, "type": "BUILTIN_FUZZ", "status": "RUNNING", "totalJobs": 3, "platform": "ANDROID_APP", "result": "PENDING" }, ... additional entries ... ] } } } ] }