Your app writes free-text logs like `User 42 paid 19.99 in 340ms`. Why push for structured logging, and how?
BeginnerScenarioLogging Pipelines
Answer
Situation read → Free text forces regex parsing that breaks every time a developer edits a message. Queries become fragile.
What I'd do →
- Agree a JSON log schema:
ts,level,msg,service,trace_id,span_id, plus event-specific fields. - Switch to a structured logger (zap/slog in Go, structlog in Python, pino in Node, Logback JSON encoder in Java).
- Inject
trace_idautomatically from the OpenTelemetry context. - Parse once in the shipper (
jsonstage) and query fields directly.
{"ts":"2026-03-02T10:15:01Z","level":"info","msg":"payment completed","user_id":42,"amount":19.99,"duration_ms":340,"trace_id":"4bf92f3577b34da6"}
Why → Fields are stable contracts; message text is not.
Interview tip → Mention that user_id belongs in the log body, never as a Loki label.
More on Logging Pipelines
Developers SSH into servers and `grep` log files to debug. You are asked to centralise logging. Where do you start?BeginnerLoki ingestion is failing with `stream limit exceeded` and the ingester memory is exploding. What happened?IntermediateFluent Bit pods on busy nodes are dropping logs during traffic spikes. How do you make the pipeline lossless?IntermediateThe Elasticsearch cluster for logs goes red every Monday after the weekend batch jobs. How do you stabilise it?AdvancedFinance says the log bill doubled in a quarter. How do you cut it without losing debugging ability?IntermediateA Java stack trace shows up in Kibana as 40 separate log events. How do you fix it?Beginner