Chapter 95: Logging with Loki, Elastic Stack and CloudWatch
95.14 Correlation, duplicates and event identity
Story (fictional teaching scenario). At a fictional Nagpur team, Arjun and Amira from Rabat see one line twice after a collector restart. They distinguish duplicate delivery from two genuine attempts.
Why
Counting every delivered row as a unique business event can inflate error rates.
What
- At-least-once delivery can deliver an event more than once.
- A duplicate is a repeated representation of the same intended event.
- Deduplication removes repeats according to an explicit identity rule.
- An event ID identifies one event; a request/correlation ID can cover many different events.
- A retry attempt may be a genuine new event even when its request ID is unchanged.
How
-
Check collector checkpoints and delivery acknowledgement behaviour.
-
Use a well-defined event identity when exact counts matter.
-
Do not deduplicate every record sharing a request ID.
-
Document whether an error chart counts events, requests or attempts.
Example 1: Two cases with one request ID
- Read the command or request.
req-demo-003: attempt 1 failed
req-demo-003: attempt 2 succeeded
req-demo-003: attempt 1 failed delivered again
- Read the result.
Output (illustrative; NOT executed against Loki, Elastic or CloudWatch)
Two actual attempts, three deliveries; blindly keeping one request row loses information.
- Line by line: The first two are different events. The third repeats the first in this story. The Python lab later uses a simplified timestamp/request/status tuple only for its fixture. That tuple is NOT a universal event-identity guarantee.
Ravindra Bagale's Tip
A request ID is not automatically a unique event ID.
Request ID म्हणजे आपोआप unique event ID नाही.
Request ID अपने आप unique event ID नहीं है.
Did you understand? Let us try it once more.