How do logs, metrics, and traces work together in observability?
Show the answer
The three pillars of observability serve complementary roles:
Metrics: numeric measurements aggregated over time (counters, gauges, histograms). Efficient for alerting and dashboards. Example: request rate, CPU utilization, error rate. Tools: Prometheus, CloudWatch, Datadog.
Logs: timestamped, structured or unstructured text records of discrete events. Rich in context for debugging a specific error. Tools: Loki, Elasticsearch (ELK), CloudWatch Logs.
Traces: end-to-end records of a request as it flows through multiple services. Each trace is composed of spans; each span records the operation, duration, and parent-child relationships. Tools: Jaeger, Zipkin, AWS X-Ray, Tempo.
How they work together:
A Prometheus alert fires on high error rate (metric).
You drill into Grafana → link to Loki logs for that time window → find a specific error log with a trace ID.
You open Tempo with that trace ID to see which microservice in the chain is slow or failing.
OpenTelemetry provides a unified SDK/collector to instrument all three signals and ship them to any backend.
You've been asked to move from centralized logging to a service-mesh-based observability model. What are your tradeoffs?
Show the answer
Centralized logging (current):
Simple mental model: all logs flow to one place (ELK, Loki).
Application teams own what they log.
Easy to query across services.
High cardinality logs can be expensive to store.
Service-mesh-based observability (Istio/Linkerd):
Pros: automatic L7 metrics (request rate, error rate, latency) per service pair without code changes; automatic mTLS; distributed tracing headers injected by Envoy sidecar; consistent golden signals for all services.
Cons: sidecar overhead (CPU/memory per pod); control plane complexity; traces only cover inter-service calls (not internal app behavior); application-level business logic still needs custom logging; observability blind spots for non-HTTP protocols.
My recommendation: complement, not replace. Use the service mesh for infrastructure-level telemetry (L7 metrics, traces, mTLS audit) and keep centralized logging for application-level events and business logic. Use the OpenTelemetry Collector as the unifying agent.
How do you set up custom metrics for Kubernetes pods?
Show the answer
Instrument the application: expose a /metrics endpoint in Prometheus format (using the Prometheus client library for your language).
Configure Prometheus scraping: add a ServiceMonitor (if using the Prometheus Operator) or add a scrape config in prometheus.yml: