Skip to content

Correlating logs across mail, web, and database during a cPanel incident

A single-symptom incident usually has evidence in three or four logs. Lining them up by timestamp shows the chain of events the user did not see.

A cPanel incident — “the site was down for 20 minutes around lunch” — usually leaves a trail in multiple logs that look unrelated at first glance. The web server logged a spike of 503s, the database logged “too many connections”, Exim logged a queue spike, and /var/log/messages logged OOM kills. Each log alone reads like a different problem. Lined up by timestamp, they tell one story.

What’s happening

In a typical cascade, one resource exhausts and pulls down dependents. Common chain: a slow query on a busy table blocks other queries, MySQL queue fills, PHP-FPM workers hold sockets waiting for DB, FPM pm.max_children exhausts, Apache returns 503, retrying clients pile on, memory grows, OOM kicks in, MySQL or Apache gets killed, the host briefly drops, mail in flight stalls in Exim’s queue. The fix is to find the first link in the chain — not the last symptom.

How to verify

Pull the logs aligned by timestamp:

# define the incident window
START="2026-05-19 12:10"
END="2026-05-19 12:40"

# Apache access log for the spike
awk -v s="$START" -v e="$END" '$4 >= "["s && $4 <= "["e' /usr/local/apache/domlogs/<domain>
# Apache error log
awk '/'"$START"'/,/'"$END"'/' /usr/local/apache/logs/error_log
# MySQL slow + error
awk '/'"$START"'/,/'"$END"'/' /var/log/mysqld.log
mysql -e "SHOW VARIABLES LIKE 'slow_query_log_file';"
# Exim queue spike
exim -bp | head
awk '/'"$START"'/,/'"$END"'/' /var/log/exim_mainlog | wc -l
# system events
journalctl --since "$START" --until "$END"

For visualization: pipe each log through cut -c1-19 to normalize timestamps, then sort -m (or paste into a spreadsheet column-by-log) to align them.

The fix

  1. Find the first abnormal event — work backwards from the user-visible symptom. If the 503 started at 12:23, look for what changed between 12:18 and 12:23. The first bend in any chart is usually the root cause.
  2. Distinguish cause from cascade — if MySQL OOMs at 12:23, was MySQL the cause or the victim? Check /var/log/mysqld.log for query patterns before the kill. A “too many connections” message before OOM is the cascade running.
  3. Document the chain — write it as “X happened, which caused Y, which caused Z”. This is the incident timeline you share with the customer and use for the post-mortem.
  4. Fix the first link — index the slow query, raise the connection limit, kill the runaway cron, whatever the actual cause turned out to be. Resist the urge to “fix” symptoms further down the chain.
  5. Add an alert for the first link — if a slow query caused the outage, add a monitor for slow queries per minute. Catching the first link next time gives you 5 minutes instead of 25.

A cascade with no obvious starting log is almost always an external factor: a third-party service slowed down, a noisy neighbour on shared infrastructure, a DDoS or scraper. Stack Harbor builds correlation alerting under WHM server management — start a conversation when cascades recur.