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.

Go to Platform → Applications → Install Application From Template and choose AWS CloudTrail from the AWS Services category.

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 under Settings → AWS Roles.
Pre-defined AWs UserLeave empty: an advanced option this guide does not use.
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 Configurations row above Install; expand the row to see it. Pre-filled managed.
datalake index nameIn Advanced Configurations. Pre-filled CloudTrail. Two applications writing to the same index name in the same lake will collide, and the second one aborts.

Setup New AWS CloudTrail Application panel showing the Application, Details and Parameters sections, the collapsed Advanced Configurations row and the Install button

Press Install. The application appears under Installed Applications, and 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 card comes up with a red Aborted badge instead of the green Running one. The blue eye button at the right of the card opens a details panel whose Details section carries the Error Message in red. Uninstall the application from the bottom of that panel, then install it again with a different index name.

Viewing an Aborted application, with the Error Message shown in red under Details

Check that data is arriving​

  1. The role. If you used one, 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. Its card on Platform → Applications shows a green Running badge.
  4. The events. Searching the CloudTrail index, or the index name you chose, returns recent events.

Troubleshooting​

SymptomLikely cause
The role's Status dot stays redThe 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 AbortedThe index name is already in use. See Step 3.