A service's logs are unstructured strings like `Order 123 failed for user 9 after 3 retries`. Searching them during incidents is painful.
BeginnerScenarioObservability & Telemetry Decisions
Answer
Situation read → Free-text logs force regex searches and make aggregation impossible. Structured logs turn logs into queryable data.
What I'd do →
- Agree a JSON log schema:
timestamp,level,service,trace_id,span_id,message, plus event fields such asorder_id,retry_count,error_type. - Switch the logger to JSON output (Logback JSON encoder,
structlog,pino,zap). - Inject
trace_idautomatically from the OpenTelemetry context. - Query by field instead of regex, for example in Loki:
{app="orders"} | json | error_type="PaymentTimeout" | retry_count >= 3 - Keep high-cardinality fields (order IDs) as log fields, not as Loki stream labels.
Why → Structured logs make "how many orders failed with PaymentTimeout in the last 10 minutes" a one-line query.
Interview tip → Mention that in Loki, labels must stay low-cardinality while JSON fields can be anything.
More on Observability & Telemetry Decisions
Your team has metrics and logs but no tracing. A request to checkout fans out to 9 services and nobody can tell where the 2 seconds go. How do you introduce tracing?IntermediateThe monthly observability bill doubled in two months and finance wants it cut by 40%. What do you do?IntermediateA developer adds `customer_id` as a label to a request counter "for better debugging". You catch it in code review. What do you say?BeginnerYou need to pick a trace sampling strategy for a service doing 20,000 requests per second.AdvancedEvery team has built their own Grafana dashboards with different panels. During incidents, nobody can find anything.BeginnerYour Prometheus is a single instance holding everything. It is at 90% memory and the team wants 13 months of retention for SLO reports.Advanced