Prompt
How do I search historical logs after an incident?
Latest observation
A good way to search historical logs after an incident is to use a structured, step-by-step approach so you can quickly narrow down what happened and avoid getting lost in noise.
1) Start with the incident timeline
Gather:
- Exact time window of the incident
- Affected service/app/host
- User/request IDs, if available
- Error messages, status codes, or symptoms
- Any deployments, config changes, restarts, or infra events around that time
If you don’t know the exact time, start broad and narrow down.
2) Search by the most specific identifiers first
Use any of these if present:
- Request ID / trace ID / correlation ID
- Username / customer ID
- Host name / pod / container
- Service name
- Transaction ID
- Error code or exception text
This is usually better than searching for generic words like “error” or “failed.”
3) Filter by time range
Limit your search to:
- A few minutes before the incident
- The incident window
- A few minutes after it
This helps you see leading indicators and follow-on effects.
4) Use log fields, not just free text
If your logging system supports it, filter on structured fields like:
service=paymentslevel=errorstatus=500trace_id=...env=prodhost=...
Structured queries are much faster and more accurate than keyword searches alone.
5) Search for patterns around the failure
Look for:
- Spikes in errors, timeouts, or retries
- Authentication/authorization failures
- Dependency issues (DB, cache, queue, third-party API)
- OOMs, crashes, restarts, or deploy-related messages
- Sudden changes in latency or response codes
6) Correlate across systems
After finding one clue, check related logs:
- Application logs
- Web/server logs
- Database logs
- Load balancer / proxy logs
- Kubernetes / orchestrator events
- Monitoring and alerting events
- Audit/config change logs
Incidents often show up first in one layer and then propagate.
7) Work backward from the symptom
If the incident was:
- HTTP 500s: search for exceptions, stack traces, dependency failures
- Slow requests: search for timeout/retry logs and resource saturation
- Missing data: search for ingestion/queue/worker errors
- Login issues: search auth logs, identity provider responses, and rate limits
8) Reduce noise with exclusions
Exclude common non-issues where possible:
- Health checks
- Known noisy endpoints
- Routine warnings unrelated to the incident
- Background jobs not relevant to the affected flow
9) Build a short incident query set
A practical set of searches often includes:
- Exact request/trace ID
- Service + time window + error level
- Exception message or error code
- Dependency-related failures
- Deployment/config changes in the same time range
10) Save what you find
Once you identify the root cause or key sequence:
- Save the query
- Note the timestamps and log excerpts
- Record the related events
- Add it to the incident report or postmortem
Example
If you’re investigating an outage at 14:32 UTC, you might search:
service=checkout AND level=error AND timestamp between 14:25 and 14:40trace_id=abc123"database timeout" AND checkoutpod=checkout-* AND ("restart" OR "OOMKilled")
If you want, I can also help you with:
- Splunk queries
- ELK/OpenSearch queries
- CloudWatch Logs Insights
- Datadog log search
- A general incident log search checklist