Logging API calls for your Network Load Balancer using Amazon CloudTrail - Elastic Load Balancing
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 API calls for your Network Load Balancer using Amazon CloudTrail

Elastic Load Balancing is integrated with Amazon CloudTrail, a service that provides a record of actions taken by a user, role, or an Amazon Web Service in Elastic Load Balancing. CloudTrail captures all API calls for Elastic Load Balancing as events. The calls captured include calls from the Amazon Web Services Management Console and code calls to the Elastic Load Balancing API operations. If you create a trail, you can enable continuous delivery of CloudTrail events to an Amazon S3 bucket, including events for Elastic Load Balancing. 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 Elastic Load Balancing, 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.

Elastic Load Balancing information in CloudTrail

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

For an ongoing record of events in your Amazon Web Services account, including events for Elastic Load Balancing, 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 Amazon 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 Web Services to further analyze and act upon the event data collected in CloudTrail logs. For more information, see the following:

All Elastic Load Balancing actions for Network Load Balancers are logged by CloudTrail and are documented in the Elastic Load Balancing API Reference version 2015-12-01. For example, calls to the CreateLoadBalancer and DeleteLoadBalancer actions generate entries in the 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 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 Web Service.

For more information, see the CloudTrail userIdentity element.

Understanding Elastic Load Balancing log file entries

A trail is a configuration that enables delivery of events as log files to an Amazon S3 bucket that you specify. CloudTrail log files contain one or more log entries. An event represents a 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 aren't an ordered stack trace of the public API calls, so they don't appear in any specific order.

The log files include events for all Amazon API calls for your Amazon Web Services account, not just Elastic Load Balancing API calls. You can locate calls to the Elastic Load Balancing API by checking for eventSource elements with the value elasticloadbalancing.amazonaws.com. To view a record for a specific action, such as CreateLoadBalancer, check for eventName elements with the action name.

The following are example CloudTrail log records for Elastic Load Balancing for a user who created a Network Load Balancer and then deleted it using the Amazon CLI. You can identify the CLI using the userAgent elements. You can identify the requested API calls using the eventName elements. Information about the user (Alice) can be found in the userIdentity element.

Example: CreateLoadBalancer
{ "eventVersion": "1.03", "userIdentity": { "type": "IAMUser", "principalId": "123456789012", "arn": "arn:aws:iam::123456789012:user/Alice", "accountId": "123456789012", "accessKeyId": "AKIAIOSFODNN7EXAMPLE", "userName": "Alice" }, "eventTime": "2016-04-01T15:31:48Z", "eventSource": "elasticloadbalancing.amazonaws.com", "eventName": "CreateLoadBalancer", "awsRegion": "us-west-2", "sourceIPAddress": "198.51.100.1", "userAgent": "aws-cli/1.10.10 Python/2.7.9 Windows/7 botocore/1.4.1", "requestParameters": { "subnets": ["subnet-8360a9e7","subnet-b7d581c0"], "securityGroups": ["sg-5943793c"], "name": "my-load-balancer", "scheme": "internet-facing", "type": "network" }, "responseElements": { "loadBalancers":[{ "type": "network", "ipAddressType": "ipv4", "loadBalancerName": "my-load-balancer", "vpcId": "vpc-3ac0fb5f", "securityGroups": ["sg-5943793c"], "state": {"code":"provisioning"}, "availabilityZones": [ {"subnetId":"subnet-8360a9e7","zoneName":"us-west-2a"}, {"subnetId":"subnet-b7d581c0","zoneName":"us-west-2b"} ], "dNSName": "my-load-balancer-1836718677.us-west-2.elb.amazonaws.com", "canonicalHostedZoneId": "Z2P70J7HTTTPLU", "createdTime": "Apr 11, 2016 5:23:50 PM", "loadBalancerArn": "arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/net/my-load-balancer/ffcddace1759e1d0", "scheme": "internet-facing" }] }, "requestID": "b9960276-b9b2-11e3-8a13-f1ef1EXAMPLE", "eventID": "6f4ab5bd-2daa-4d00-be14-d92efEXAMPLE", "eventType": "AwsApiCall", "apiVersion": "2015-12-01", "recipientAccountId": "123456789012" }
Example: DeleteLoadBalancer
{ "eventVersion": "1.03", "userIdentity": { "type": "IAMUser", "principalId": "123456789012", "arn": "arn:aws:iam::123456789012:user/Alice", "accountId": "123456789012", "accessKeyId": "AKIAIOSFODNN7EXAMPLE", "userName": "Alice" }, "eventTime": "2016-04-01T15:31:48Z", "eventSource": "elasticloadbalancing.amazonaws.com", "eventName": "DeleteLoadBalancer", "awsRegion": "us-west-2", "sourceIPAddress": "198.51.100.1", "userAgent": "aws-cli/1.10.10 Python/2.7.9 Windows/7 botocore/1.4.1", "requestParameters": { "loadBalancerArn": "arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/net/my-load-balancer/ffcddace1759e1d0" }, "responseElements": null, "requestID": "349598b3-000e-11e6-a82b-298133eEXAMPLE", "eventID": "75e81c95-4012-421f-a0cf-babdaEXAMPLE", "eventType": "AwsApiCall", "apiVersion": "2015-12-01", "recipientAccountId": "123456789012" }