Lesson 4 of 4 Amazon CloudWatch and Log Analysis

Troubleshooting Logging and Alerting Pipelines

This lesson explains how to troubleshoot monitoring and logging that does not work, logs that never arrive, alarms that stay silent and rules that never fire, which task 1.3 of the exam guide covers. Most failures come down to a missing service principal permission, a key policy, or an event arriving in an unexpected Region.

Learning outcomes

After completing this lesson, you will be able to:

  • Identify the common causes of log delivery failures for each source.
  • Explain why alerts for global service events must be created in us-east-1.
  • Diagnose an EventBridge rule that never fires.

Log delivery failures

Logs may fail to reach their destination for a small number of recurring reasons. The following table identifies the common cause and remedy for each source.

SourceCommon causeFix
CloudTrail to S3Bucket policy does not allow cloudtrail.amazonaws.com for the trail's aws:SourceArn; KMS key policy lacks CloudTrailUpdate bucket and key policies; check the trail's LatestDeliveryError
CloudTrail to CloudWatch LogsThe trail's IAM role cannot logs:PutLogEventsFix the role or recreate it
VPC Flow Logs to CloudWatch LogsDelivery role missing or not trusting vpc-flow-logs.amazonaws.comFix the role; check the flow log's DeliverLogsErrorMessage
Flow logs, Resolver logs, WAF to S3Bucket policy for delivery.logs.amazonaws.com missing (often after a policy was overwritten)Restore the log delivery statements
ALB access logs to S3Bucket policy does not allow Elastic Load Balancing to write; SSE-KMS bucketGrant the Regional ELB account or the log delivery service principal; ALB logs support only SSE-S3
CloudWatch agentInstance role lacks CloudWatchAgentServerPolicy; no route to endpoints; wrong configCheck amazon-cloudwatch-agent.log
Encrypted log groupKey policy does not allow logs.REGION.amazonaws.comAdd the service principal with the encryption context condition
Match the pairs

Why logs do not arrive

Exam skills 1.3.2

Match each log delivery failure with its usual cause.

Log in to try this activity Interactive activities are free with an account.

Alerts that never arrive

Security alerts can fail to arrive for several reasons. The following list describes the most common causes.

  • EventBridge rule in the wrong Region: API events from global services (IAM, STS global endpoint, CloudFront, Route 53, Organizations) and AWS Health global events are delivered in us-east-1.
  • Event pattern mismatch: test with the sandbox or aws events test-event-pattern; check detail-type spelling and case.
  • Target permissions: SNS topic and SQS queue policies must allow events.amazonaws.com; Lambda needs a resource policy; the rule's FailedInvocations metric and a target DLQ reveal failures.
  • Encrypted SNS topics using the AWS managed aws/sns key cannot receive from EventBridge or CloudWatch alarms; use a customer managed key whose policy allows those services.
  • Metric filters do not process past events, and their patterns must match the JSON structure exactly.
  • Security Hub controls without data: AWS Config is not recording in that account or Region.

The following diagram matches each fault to its fix.

Three faults behind an alert that never fired. IAM is global, so its events reach EventBridge in us-east-1, not eu-west-1; the SNS topic used aws/sns, which EventBridge cannot use; and the topic policy did not let EventBridge publish. The FailedInvocations metric separates pattern problems from permission problems.
The faults were found in this order.
Spot the bug

An IAM alert that never fires

Exam skills 1.3.2 · 1.1.4

Find the lines in this EventBridge setup that stop the alert for new IAM access keys.

Log in to try this activity Interactive activities are free with an account.
Worked example

An alert that never fires

A rule should notify the security team whenever someone creates an IAM access key. It was created in eu-west-1, where the company runs everything, and nothing ever arrives. Three problems are found in turn:

  1. IAM is a global service; its CloudTrail events reach EventBridge in us-east-1. The rule is recreated there (or in us-east-1 forwarding to a central bus).
  2. The SNS topic is encrypted with aws/sns, which EventBridge cannot use. The topic is re-encrypted with a customer managed key whose policy allows events.amazonaws.com to kms:GenerateDataKey* and kms:Decrypt.
  3. The topic policy allowed only the account root. A statement allowing events.amazonaws.com to publish, conditioned on the rule's ARN, is added.
aws events put-rule --region us-east-1 --name iam-access-key-created --event-pattern '{
  "source": ["aws.iam"], "detail-type": ["AWS API Call via CloudTrail"],
  "detail": { "eventSource": ["iam.amazonaws.com"], "eventName": ["CreateAccessKey"] } }'
aws cloudwatch get-metric-statistics --region us-east-1 --namespace AWS/Events \
  --metric-name FailedInvocations --dimensions Name=RuleName,Value=iam-access-key-created \
  --start-time $(date -u -d '-1 hour' +%FT%TZ) --end-time $(date -u +%FT%TZ) --period 300 --statistics Sum

The FailedInvocations metric confirms whether the rule matched but could not deliver, which separates pattern problems from permission problems.

Check yourself

An EventBridge rule for an IAM API call in eu-west-1 never matches. Why?

Show answer

Events from IAM and other global services reach EventBridge in us-east-1, so the rule must be created there.

Exam Tips

Remember for the exam

  • Events from IAM and other global services reach EventBridge in us-east-1.
  • SNS topics encrypted with aws/sns cannot receive from EventBridge or CloudWatch; use a customer managed key.
  • If a rule matches but delivers nothing, check FailedInvocations and the target's resource policy.
  • Flow log delivery to CloudWatch Logs needs a role trusted by vpc-flow-logs.amazonaws.com.
  • ALB access logs support only SSE-S3 encrypted buckets and need ELB write permission.
  • If CloudTrail stops delivering after enabling SSE-KMS, fix the key policy.