Lesson 3 of 4 Amazon CloudWatch and Log Analysis

Analysing and Correlating Logs Across Sources

This lesson explains which tools suit interactive troubleshooting, SQL analysis of archives, and SIEM-style search and correlation, and how to normalise logs from different sources.

Learning outcomes

After completing this lesson, you will be able to:

  • Choose between CloudWatch Logs Insights, Athena, OpenSearch Service and Security Lake.
  • Explain why logs are normalised and enriched before correlation.
  • Query WAF logs to identify attacking clients.

Choosing a tool

The right log analysis tool depends on where the logs are and what you need to do with them. CloudWatch Logs Insights runs fast interactive queries over recent logs in CloudWatch log groups, using commands such as filter, stats and parse. Amazon Athena runs SQL over logs stored in S3, such as CloudTrail, ALB, CloudFront, flow logs, WAF and Security Lake data, and is cost-effective when the data is in Parquet with partition projection.

Amazon OpenSearch Service provides SIEM-like capabilities: full-text search, correlation across sources, dashboards, alerting, and security analytics with Sigma detection rules. It is fed by OpenSearch Ingestion, Firehose or Lambda, and can query Security Lake directly. Amazon Managed Grafana builds shared dashboards over CloudWatch, OpenSearch, Athena and Prometheus, with sign-in through IAM Identity Center. The following table summarises the tools.

ToolBest for
CloudWatch Logs InsightsFast interactive queries over recent log groups (fields, filter, stats, parse, sort)
Amazon AthenaSQL over logs in S3 (CloudTrail, ALB, CloudFront, flow logs, WAF, Security Lake); cost-effective with Parquet and partition projection
Amazon OpenSearch ServiceSIEM-like full-text search, correlation, dashboards, alerting and security analytics with Sigma rules; fed by OpenSearch Ingestion, Firehose or Lambda; can query Security Lake directly
Amazon Managed GrafanaShared dashboards over CloudWatch, OpenSearch, Athena and Prometheus, with Identity Center sign-in

The following diagram compares the two patterns that a CloudWatch Logs Insights query of blocked web requests can reveal.

Reading the Logs Insights breakdown of blocked requests by IP, country and rule. A handful of IP addresses under a rate-based rule means the rule is working. Thousands of addresses each sending a few requests to /login is distributed credential stuffing, better met by Account Takeover Prevention or aggregation by JA4 fingerprint.
JA4 is a TLS client fingerprint.
Sort into groups

Which analysis tool?

Exam skills 1.2.4 · 1.2.5

Choose the log analysis tool for each need.

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

Normalising and enriching

Different log sources describe the same event in different ways: CloudTrail records an IP address as sourceIPAddress, VPC Flow Logs as srcaddr, and application logs in their own format. To correlate them, records are first normalised into a common schema, such as the Open Cybersecurity Schema Framework (OCSF) used by Amazon Security Lake. They can also be enriched with context that the raw record lacks, such as account names, geolocation of IP addresses or matches against threat intelligence. Lambda functions and Firehose data transformations commonly perform this processing before storage, so queries in Athena, OpenSearch or a SIEM can join sources on common fields.

True or false

Normalising logs

Exam skills 1.2.5

Check why and how logs are normalised before correlation.

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

From a WAF spike to the attacking clients

AWS WAF blocked requests jump from hundreds to tens of thousands an hour. The WAF logs are in CloudWatch Logs, so Logs Insights shows which clients and rules are involved:

fields @timestamp, httpRequest.clientIp as ip, httpRequest.country as country,
       terminatingRuleId as rule, httpRequest.uri as uri
| filter action = "BLOCK"
| stats count(*) as blocked by ip, country, rule
| sort blocked desc
| limit 20

If a handful of IP addresses dominate under a rate-based rule, the rule is working. If thousands of addresses each send a few requests to /login, it is a distributed credential-stuffing attack, and the better control is Account Takeover Prevention or aggregation by a JA4 fingerprint rather than by IP. For the same question over months of history in S3, Athena replaces Logs Insights.

Check yourself

Which service gives SIEM-like search, correlation and dashboards on AWS?

Show answer

Amazon OpenSearch Service.

Exam Tips

Remember for the exam

  • For SIEM-like search, correlation and dashboards on AWS, use OpenSearch Service.
  • For SQL over historical logs in S3, use Athena.
  • For a quick query over recent log groups, use Logs Insights.
  • To enrich records in flight, use Firehose with a Lambda transformation.
  • For unified dashboards across data sources, use Managed Grafana.