Interview Prep/Monitoring & Observability/Logging: Loki, Fluent Bit and Elasticsearch

Promtail/Alloy logs `server returned HTTP status 400 Bad Request (400): entry with timestamp ... ignored, reason: 'entry out of order' for stream`

IntermediateTroubleshootingLogging: Loki, Fluent Bit and Elasticsearch
Answer

Likely causes → Older Loki (before 2.4) or unordered_writes: false rejects entries older than the latest one in the same stream; two agents ship the same file with the same labels; or a pipeline parses timestamps from the line that go backwards.

Diagnose →

kubectl logs -n logging ds/promtail | grep -c 'out of order'
logcli series '{app="checkout"}' --since=1h

Check whether two pods/agents produce identical label sets.

Fix → Upgrade Loki and enable limits_config.unordered_writes: true (default since 2.4), add a unique label per source (pod, instance), and drop the timestamp stage if app timestamps are unreliable.

Prevent → One writer per stream; monitor loki_discarded_samples_total{reason="out_of_order"}.

All Monitoring & Observability questions Roadmap: Logging & tracing

More on Logging: Loki, Fluent Bit and Elasticsearch