Skip to content

ALB and CloudFront logs: how to analyze web traffic with a security focus

Edge logs tell the story of every request. Learn to read them to detect abuse and investigate web attacks.

Reading time
9 min
Published

Every web application receives automated traffic all the time, and most of it only shows up in the edge logs. Application Load Balancer and CloudFront logs record every request that arrived, with source IP, response status, URI, user agent, processing time and other fields. Read with a security eye, they reveal brute force, scraping, path scanning and other anomalies that point to abuse.

The use here is defensive, for detection and investigation. In practice, it comes down to knowing which fields to look at, which patterns to search for and how to carry what shows up in the logs into the WAF rules and into the security of the application itself.

Fields that tell the story

The status code is one of the richest signals. Many 401s and 403s concentrated on the login endpoint suggest brute force or credential stuffing. A sequence of 404s, each on a different path, points to a scan looking for files and routes. Spikes of 5xx can be either an operational problem or an abuse attempt. The source IP, the user agent and the URI complete the picture.

  • 401 and 403 status codes concentrated on the login page indicate access attempts
  • Many 404s on different paths indicate scanning
  • An empty or generic user agent points to automation
  • The URI shows which routes are being probed
  • High volume from one IP in a short time indicates abuse or scraping

Combine fields before drawing conclusions

No single field proves abuse. The answer comes from cross-referencing. An IP that generates many 401s on /login, with a generic user agent and without loading static assets, looks every bit like automation. An IP with many requests but varied user agents, and browsing that fetches CSS, images and scripts, is usually a company's gateway, with several real users behind it.

Main fields in an access log line (ALB, simplified)
time                    2026-07-20T14:03:11Zclient_ip               203.0.113.45request                 "POST https://app.example/login HTTP/2.0"elb_status_code         401user_agent              "python-requests/2.31"target_processing_time  0.004

Abuse patterns and WAF correlation

Cross-reference edge logs with WAF logs to understand what was blocked and what got through. If the WAF blocks a pattern a lot, but something similar goes through with a success status, there is a gap in the rule that needs tuning. Unusual user agents, missing expected headers and bursts of requests from the same IP or the same range are signs of bots and scraping.

Be careful with shared IPs. Many legitimate users reach the internet through the same corporate address, so high volume from one IP is not always an attack. Before concluding it is abuse, combine other signals, such as the pattern of URIs accessed and the error rate.

Investigation queries over the logs

With the logs in an S3 bucket, Athena lets you run queries on demand, without keeping analysis infrastructure running all the time. Have a few queries ready before the incident, so you do not have to write them under pressure. The first one that usually pays off is the concentration of access-denied responses per IP on authentication endpoints.

Concentration of 401s and 403s on login, per IP (column names depend on your table)
SELECT client_ip, count(*) AS attemptsFROM alb_logsWHERE elb_status_code IN (401, 403)  AND request LIKE '%/login%'  AND time >= '2026-07-01'GROUP BY client_ipORDER BY attempts DESCLIMIT 20;

The second one reveals scanning. A single IP that generates many 404s, each on a different path, is mapping routes and files instead of browsing. Adjust the threshold (50 paths in the query below) to your traffic, because large applications also generate legitimate 404s.

Sign of scanning: many distinct paths returning 404, per IP
SELECT client_ip, count(DISTINCT request) AS paths_404FROM alb_logsWHERE elb_status_code = 404GROUP BY client_ipHAVING count(DISTINCT request) > 50ORDER BY paths_404 DESC;

Storage, partitioning and continuous detection

ALB and CloudFront logs are delivered to an S3 bucket, and the volume grows fast in busy applications. Partition by date in the key layout. That way an investigation query reads only the period of interest instead of scanning the whole history, which cuts cost and response time. Also configure a lifecycle policy that moves old history to cheaper storage and expires whatever is past the retention window.

From manual query to alert

On-demand queries are for investigating after the fact. For detection, some signals need to raise alerts on their own. One option is to send status metrics to CloudWatch and alert when there is a spike of 401s and 403s or of 5xx. Another is to schedule periodic Athena queries for the patterns you already know to look for. The idea is to shorten the time between the abuse happening and someone noticing, without depending on a chance look at the dashboard.

In an investigation, these logs rebuild an attacker's sequence of requests and show which route was probed. They complete what CloudTrail shows about identity and what VPC Flow Logs show about the network.

Practical checklist

  • Turn on ALB and CloudFront access logs
  • Send the logs to a bucket with a defined retention period
  • Check for concentrations of 401s and 403s on login endpoints
  • Detect scanning through sequences of 404s on different paths
  • Identify bots by user agent and request pattern
  • Cross-reference with WAF logs to find gaps in the rules
  • Take shared IPs into account before concluding it is abuse
  • Investigate 5xx spikes to separate operational errors from abuse
  • Have Athena investigation queries ready before the incident
  • Partition logs by date so queries run faster and cheaper
  • Use lifecycle rules to move old history to cheaper storage
  • Alert on spikes of 401, 403 and 5xx, in addition to on-demand queries
  • During an incident, correlate with identity and network logs

Best practices

  • Start with the status code, the most direct sign of abuse
  • Combine IP, user agent and URI before concluding anything
  • Compare edge logs with WAF logs to tune the rules
  • Be cautious with shared corporate IPs
  • Partition logs by date for fast queries
  • Turn known patterns into alerts
  • Prepare investigation queries before the incident

Common mistakes

Edge logs turned off
Most automated traffic and abuse goes unrecorded.
Querying the whole history without partitioning
The investigation gets slow and expensive, and the team ends up analyzing less.
Concluding abuse from the volume of one IP alone
You may end up blocking many legitimate users who go out through the same gateway.
Skipping WAF correlation
Gaps in the rules stay open, and attacks keep getting through the edge.
No log retention
After a few days, it is no longer possible to reconstruct the attack.
Looking only at 2xx and ignoring 4xx and 5xx
Signs of scanning and abuse, which concentrate precisely in the errors, go unnoticed.

Authorship and review

Cesar Gargiulo

CEO and founder of GUARDIASEC. Technical and editorial lead for the content published in this library.

Published on . Found a technical error? Write to [email protected] and we will correct it and keep a record of the change.

Frequently asked questions

Which status codes most often point to an attack?
A concentration of 401s and 403s on login endpoints suggests brute force or credential stuffing. Sequences of 404s on different paths indicate scanning of routes and files. Spikes of 5xx can be abuse or an operational problem. None of these signals settles the question alone: the answer comes from cross-referencing the status code with IP, URI and user agent.
Do edge logs replace the WAF?
No. The WAF blocks traffic, and edge logs show what happened, including what got through. Each one helps the other: the logs point out gaps in the WAF rules and let you investigate attacks that were not blocked. With both, you have active defense and the visibility to tune it.
How do I avoid wrongly concluding that an IP is malicious?
Remember that many legitimate users go out through the same corporate IP, so high volume is not always an attack. Before concluding anything, combine signals: the pattern of URIs accessed, the error rate, the user agent and behavior over time. Blocks decided only by the volume from one IP tend to hit real users.
Where are these logs stored?
Both ALB and CloudFront usually deliver access logs to an S3 bucket. From there, you define retention and use queries to analyze on demand. Since the volume can be large, keep the logs in cheap storage and, during an investigation, focus the analysis on specific time windows and patterns.
How can I query these logs without building a lot of infrastructure?
Use Athena, which queries the files directly in the S3 bucket with SQL, without loading the data anywhere else. You define a table pointing to the log path, preferably partitioned by date, and run queries on demand. It is the simplest way to investigate error concentrations per IP, 404 scanning and suspicious user agents, and you only pay for what each query reads.
How do I tell a scraper from a legitimate search engine?
Well-known search engines identify themselves through the user agent and usually respect robots.txt. An abusive scraper tends to vary its user agent (or use a generic one), ignore static assets, crawl many routes at a high rate and come from IP ranges that are unusual for your audience. Since no single signal is enough, combine the URI pattern, the request rate and the user agent before deciding to block.
Why partition logs by date?
Without partitioning, every query scans the entire history in the bucket, which gets slow and expensive as volume grows. With partitions by year, month and day, an investigation query reads only the period of interest, which reduces cost and response time. That makes it practical to analyze the logs day to day, instead of opening the history only when an investigation comes up.

When to bring in specialist help

Using edge logs to detect abuse and fine-tune the WAF is part of two GUARDIASEC services: WAF and Edge Protection, and Monitoring and Response. That is where we adjust the rules and define the web detection use cases.