Metrics vs Logs
Compare numerical time-series telemetry with detailed event records for monitoring and troubleshooting.
Observability
Metrics
Metrics are numerical values collected over time, such as CPU usage, request count, latency, or error rate. They are optimized for dashboards, alerting, and trend analysis.
Observability
Logs
Logs are detailed event records produced by systems and applications. They capture contextual information about specific events, errors, requests, and internal behavior.
Key Differences
Metrics are compact numerical measurements over time, while logs are detailed event-by-event records.
Metrics are efficient for alerting and dashboards, while logs are better for debugging and understanding event context.
Metrics answer high-level questions such as load, latency, and error rate, while logs answer detailed questions about what happened and why.
Metrics are cheaper and lighter to store at scale, while logs usually consume more storage and indexing cost.
Metrics are ideal for trends and thresholds, while logs are ideal for root-cause investigation.
Most mature observability systems use both because they answer different levels of questions.
When to Use
When to use Metrics
Use metrics for dashboards, alerting, trend analysis, service health indicators, and any situation where fast, aggregated time-series data is most useful.
When to use Logs
Use logs when you need detailed event context, request information, stack traces, debugging data, or evidence of exactly what happened at a specific moment.
Tradeoffs
Metrics are fast, scalable, and efficient, but less detailed.
Logs provide much richer detail, but are heavier to store and harder to analyze at scale without strong tooling.
Metrics tell you something is wrong quickly, while logs help explain why it happened.
Common Mistakes
Trying to replace logs entirely with metrics.
Storing excessive log volume when metrics would answer the main operational question.
Expecting metrics alone to explain complex failures without supporting logs.
Interview Tip
The classic answer is: metrics tell you that something is wrong, logs help you understand why.