Prompt
How do I search application logs by request ID during an outage?
Latest observation
During an outage, the fastest way to search logs by request ID is to use the request ID as a correlation key across all log sources and services.
1) Find the request ID
You usually get it from:
- an error response header/body
- load balancer / API gateway logs
- APM/tracing tools
- customer support tickets or client-side logs
Examples: request_id, trace_id, correlation_id, x-request-id
2) Search your logs directly
Use your log system’s query language:
Plain text / grep
grep "abc123" application.log
Across rotated logs:
zgrep "abc123" /var/log/app/*.log.gz
Recursive search:
grep -R "abc123" /var/log/app/
Cloud log tools
- CloudWatch Logs Insights
fields @timestamp, @message
| filter @message like /abc123/
| sort @timestamp desc
| limit 100
- Elasticsearch / Kibana
request_id:"abc123"
- Splunk
request_id="abc123"
- Datadog
@request_id:abc123
3) Search across services, not just one app
During outages, one request often spans:
- API gateway / ingress
- frontend/backend app
- downstream services
- worker queues
- database proxy
- cache layer
Search by the same ID in each service’s logs. If you have distributed tracing, search the trace ID too.
4) Use a wider time window
If timestamps are uncertain:
- start from the error time
- search ±5–15 minutes
- widen if retries or async jobs are involved
5) Look for these patterns
When you find the request ID, inspect:
- first occurrence: where the request entered
- last occurrence: where it failed or timed out
- errors/exceptions around it
- retries, circuit breaker events, timeout messages
- latency spikes or upstream failures
6) If the ID isn’t indexed
Try variations:
- different field names:
request_id,req_id,traceId - quoted/unquoted forms
- uppercase/lowercase
- hyphenated vs. compact format
If logs are structured JSON, search the field directly instead of raw text.
7) Best practice for future outages
Make sure every log line includes:
- request ID / trace ID
- timestamp in UTC
- service name
- environment
- severity
- user/session ID if appropriate
And propagate the same request ID through all services.
If you tell me what logging system you use (CloudWatch, Splunk, ELK, Datadog, Kubernetes, etc.), I can give you the exact query and command.