Chapter 95: Logging with Loki, Elastic Stack and CloudWatch
95.1 Logs, metrics and traces — three different questions
Story (fictional teaching scenario). At a fictional Pune bakery, Priya and Daniel from Lisbon see failed orders. A count tells them how often; a log explains one failure; a trace shows where the request travelled.
Why
Choosing the right signal stops us from searching every line when one simple measurement answers the question.
What
- A log records an event, usually with a timestamp and context.
- A metric is a numeric measurement over time, such as error count or latency.
- A trace follows one operation through related steps; a span represents one timed step within it.
- Observability means using signals to understand system behaviour, not merely storing more data.
How
-
Ask whether you need an individual event, an aggregate trend or a request path.
-
Use a metric to notice a pattern.
-
Use selected logs and traces to investigate, with permission.
Example 1: One incident, three views
- Read the command or request.
Metric: 2 failed requests out of 6
Log: request req-demo-003 returned status 500
Trace: API span -> worker span
- Read the result.
Output (illustrative; NOT executed against Loki, Elastic or CloudWatch)
The metric gives a rate; the event gives context; the trace connects steps.
- Line by line: The metric denominator matters. The log describes one invented event. The arrows describe a request path, not proof that a tracing platform was deployed. A trace ID can correlate records, but it must not be used as a secret or proof of identity.
Ravindra Bagale's Tip
More logs do not automatically mean better observability.
जास्त logs म्हणजे आपोआप चांगली observability नाही.
ज्यादा logs से अपने आप अच्छी observability नहीं मिलती.
Did you understand? Let us try it once more.