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.
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.004Abuse 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.
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.
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.