Skip to main content

AWS CloudTrail

AWS CloudTrail records the API activity in an AWS account and delivers it as log files to an S3 bucket. Fluency collects those files as they arrive:

  1. The bucket sends an "object created" notification to an SQS queue.
  2. Fluency reads the queue.
  3. Fluency downloads each new file the queue points to.

There are two ways to give Fluency access, as described in Connecting to AWS:

  • Assumed role (recommended). A role in your account that Fluency assumes. One CloudFormation template adds the queue, the bucket notification and the read permissions for an existing trail's bucket.
  • IAM user and access key (alternative). A single CloudFormation template creates everything in one stack: the trail, its bucket, the queue, and an IAM user with an access key. This is also the only method for AWS GovCloud accounts.

Before you start​

  • The bucket must not notify another consumer. Use a bucket that doesn't already send "object created" notifications somewhere else, such as to another SIEM.
  • Leave the trail's log file SSE-KMS encryption off. The read permissions Fluency is given don't include decrypting with a KMS key.

Step 1: Create a trail​

Skip this step in either of these cases:

  • A trail already delivers to an S3 bucket in the account.
  • You are using the access-key template, which creates its own trail.

These steps create the same kind of trail that template does: logging in every region, including events from global services such as IAM. For full detail, see the AWS guide to creating a trail.

  1. In the AWS console, open CloudTrail → Trails → Create trail.

  2. Give the trail a name, such as fluency-aws-cloudtrail-import. A trail created in the console logs every region.

  3. Under Storage location:

    1. Choose Create new S3 bucket.
    2. Give the bucket a name that is unique across all of AWS. CloudTrail adds the bucket policy it needs.
    3. Note the bucket name. You need it in step 2.
  4. Under Log file SSE-KMS encryption, clear Enabled.

    Storage location section of the Create trail form, with Create new S3 bucket selected, a bucket name entered, and Log file SSE-KMS encryption cleared; the account number redacted

  5. Press Next. Under Choose log events, tick all four event types:

    • Management events, with both Read and Write API activity.
    • Data events: choose the resources to record.
    • Insights events.
    • Network activity events: choose the event sources to record.

    AWS charges for data, Insights and network activity events, and for management events beyond the first copy in the account. See AWS CloudTrail pricing.

  6. Press Next, review the trail, and press Create trail.

The access-key template also sets its bucket to delete log files after 7 days. You can add a lifecycle rule to this bucket with the same effect (S3 → the bucket → Management → Create lifecycle rule), or keep the files for as long as your own retention policy requires.

Step 2: Connect the trail's bucket​

Assumed role​

  1. Make sure the account has a registered role. If it doesn't, follow Connecting to AWS, steps 1 and 2. A role already registered for this account can be reused.

  2. Run IngextS3SqsNotification.yaml against the trail's bucket, as described in Connecting to AWS, step 3. Create it in the bucket's account and region, with these values:

    ParameterValue for CloudTrail
    S3BucketThe trail's bucket.
    S3BucketPrefixAWSLogs/<account-id>/CloudTrail/. This is where CloudTrail writes management, data and network activity events. Insights events are written under AWSLogs/<account-id>/CloudTrail-Insight/ instead.
    SQSQueueNameA name for the queue, such as ingext-cloudtrail.
    PodRoleARNLeave empty.
    IAMRoleThe Role Name of your role.
    ExternalIDThe role's External ID, or empty.
  3. Copy the QueueURL output for step 3.

Step 3: Install the Application​

Everything the AWS side produced goes into one form: the region, the SQS queue URL, and either a role or an access key pair.

In the navigation rail, open Applications and click Install Application, then choose AWS CloudTrail from the AWS Services category of the Application Catalog.

ParameterNotes
AWS RegionDrop-down, opens on US N.Virginia. The region of the SQS queue, which is the trail bucket's region.
SQS notification queue urlThe full queue URL (the QueueURL output), not the ARN.
Pre-defined AWS RoleThe recommended credential: the display name of a role registered on Configuration → AWS Roles (v1: Settings → AWS Roles).
Pre-defined AWS UserLeave empty: an advanced option. A form takes one credential, not several: here, the role or the access key.
IAM access keyAlternative: the AccessKey output of the access-key template, or an IAM user's access key ID. Use instead of a role, not as well as.
IAM access secretAlternative: the SecretKey output, or the user's secret access key.
datalakeIn the collapsed Advanced configuration section (v1: Advanced Configurations row) above the install button; expand it to see it. Pre-filled managed.
datalake index nameIn the same collapsed section. Pre-filled CloudTrail. Two applications writing to the same index name in the same lake will collide, and the second one aborts.

Install AWS CloudTrail form with the Application section&#39;s Instance name and Display name fields, the Configuration section&#39;s AWS Region, SQS notification queue url, Pre-defined AWS Role, Pre-defined AWS User, IAM access key and IAM access secret fields, and Advanced configuration expanded to datalake and datalake index name, above Cancel, Dry run and Install Application

Click Dry run first to have the platform check the form's values and credentials before anything is installed, then click Install Application. The Applications page opens with the notice Default is launching., and the application builds its data source, its router with the CloudTrail adjustment processors, and its sink as a unit.

If the index name was already taken, the application is listed with a red Error badge instead of the green Running one. Click its row to open its details: the summary card carries the error message, below Error bytes by component. Click Uninstall at the top right of that page, then install it again with a different index name.

Check that data is arriving​

  1. The role. If you used one, its Status on Configuration → AWS Roles reads Valid (v1: its Status dot on Settings → Advanced → AWS Roles is green).
  2. The queue. In the SQS console, the queue's Monitoring tab shows messages being sent and received. CloudTrail delivers log files about every 5 minutes, so allow a few minutes after the trail's first activity.
  3. The application. It is listed on Applications with a green Running badge (v1: its card on Platform → Applications).
  4. The events. Searching the CloudTrail index, or the index name you chose, returns recent events.

Troubleshooting​

SymptomLikely cause
The role's Status stays Invalid (v1: its dot stays red)The trust policy or External ID doesn't match. See Connecting to AWS, step 2.
The S3 template's stack fails because the role does not existIAMRole doesn't match the role's name. Set it to the Role Name used in Setup Role.
The S3 template's stack fails because the role already existsPodRoleARN was filled in, so the template tried to create the role. Run it again with PodRoleARN empty.
A stack fails, asking for IAM capabilitiesThe IAM acknowledgement on Configure stack options wasn't ticked.
The access-key stack fails and rolls back while creating the bucketS3Bucket was left at its default, or names a bucket that already exists. Choose a unique name.
The queue stays emptyThe notification's prefix doesn't match where CloudTrail writes; compare it with the object keys in the bucket. Or the bucket already sends its object-created notifications elsewhere.
Messages arrive, but no eventsThe read permission's prefix doesn't cover the log files, or the trail encrypts its log files with SSE-KMS.
The application shows Error (v1: Aborted)The index name is already in use. See Step 3.