Skip to main content
DevSecOps

Observability for Microservices: Logs, Metrics, and Traces Done Right

Mohakdeep Singh|May 28, 2025|9 min read
Observability for Microservices: Logs, Metrics, and Traces Done Right

The Observability Challenge

Monolithic applications were relatively simple to debug: one process, one log file, one set of metrics. Microservices shatter this simplicity. A single user request might traverse 10 services, 3 databases, and 2 message queues before returning a response.

When something breaks -- and it will -- you need to answer "what happened and why" in minutes, not hours. That requires observability: the ability to understand a system's internal state from its external outputs.

The Three Pillars

Logs: What Happened

Logs record discrete events: errors, state changes, and significant actions.

Structured logging is mandatory. Plain text logs are nearly useless at scale. Every log entry should be a structured JSON object with consistent fields: - timestamp (ISO 8601) - level (debug, info, warn, error) - service name - trace ID and span ID (for correlation) - message - relevant context (user ID, request ID, resource identifiers)

Log aggregation: Ship logs from all services to a centralized platform: - ELK Stack (Elasticsearch, Logstash, Kibana): Self-hosted, powerful but operationally heavy - Grafana Loki: Lightweight, cost-effective, excellent for Kubernetes environments - Cloud-native: AWS CloudWatch Logs, Azure Monitor, GCP Cloud Logging

Metrics: How Is It Performing

Metrics are numerical measurements collected at regular intervals.

The RED Method for Services: - Rate: Requests per second - Errors: Error rate as a percentage of total requests - Duration: Latency distribution (P50, P95, P99)

The USE Method for Infrastructure: - Utilization: CPU, memory, disk, network usage - Saturation: Queue depths, thread pool usage, connection pool exhaustion - Errors: Hardware errors, OOM kills, disk failures

Metrics stack: - Prometheus: Industry standard for metrics collection in Kubernetes environments - Grafana: Visualization and dashboarding - Alertmanager: Alert routing and deduplication

Alerting best practices: - Alert on symptoms (high error rate, high latency), not causes (high CPU) - Use multi-window, multi-burn-rate alerts to reduce false positives - Every alert should have a runbook link describing what to do - Page only for customer-impacting issues; use tickets for everything else

Traces: Why Did It Break

Distributed tracing follows a request across service boundaries, showing you the complete journey and where time is spent.

How it works: 1. The first service creates a trace ID and span 2. Each subsequent service creates a child span, inheriting the trace ID 3. Spans record timing, service name, operation, and status 4. The complete trace is assembled from all spans sharing the same trace ID

Tracing tools: - Jaeger: Open-source, CNCF project, excellent for Kubernetes - Tempo (Grafana): Cost-effective trace storage, integrates with Grafana - Cloud-native: AWS X-Ray, Azure Application Insights, GCP Cloud Trace

Putting It All Together

Correlation Is Key

The real power of observability comes from correlating across pillars: - Click on a trace to see the logs from every service involved - Click on an error log to see the trace that produced it - View metrics dashboards filtered by a specific trace attribute

This requires consistent context propagation: every log, metric label, and trace span should share common identifiers (trace ID, service name, environment).

OpenTelemetry

OpenTelemetry (OTel) is the emerging standard for instrumentation: - Single SDK that produces logs, metrics, and traces - Vendor-neutral -- switch backends without changing application code - Auto-instrumentation for popular frameworks (Express, Spring, Django, Flask) - CNCF project with broad industry support

We strongly recommend standardizing on OpenTelemetry for all new services.

Service Level Objectives (SLOs)

Define SLOs for your critical services: - Availability: 99.9% of requests return non-error responses - Latency: 95% of requests complete within 200ms - Correctness: 99.99% of transactions are processed accurately

Use error budgets to balance reliability with feature velocity. When the error budget is exhausted, prioritize reliability work over new features.

Getting Started

  1. Week 1: Adopt structured logging across all services, ship to a centralized platform
  2. Week 2: Deploy Prometheus and Grafana, instrument RED metrics for top 5 services
  3. Week 3: Add distributed tracing with OpenTelemetry, connect to Jaeger or Tempo
  4. Week 4: Build dashboards correlating all three pillars, define SLOs for critical services

Observability Anti-Patterns to Avoid

Even well-intentioned teams fall into traps that undermine their observability investment:

Logging everything: High-cardinality logging creates noise, increases storage costs, and makes it harder to find signal. Log meaningful events, not routine operations. A database query succeeding is not log-worthy; a query taking 10x longer than usual is.

Dashboard overload: Fifty dashboards that nobody looks at are worse than five that teams actively use. Build dashboards around specific user journeys and SLOs. Every panel should answer a question that someone actually asks during incidents.

Alert fatigue: If your on-call engineers ignore 80% of alerts, your alerting system is broken. Audit every alert quarterly -- if nobody acted on it in 90 days, delete it or reclassify it as a non-paging notification.

Siloed tooling: When the infrastructure team uses Datadog, the application team uses New Relic, and the security team uses Splunk, cross-cutting investigations become painful. Standardize on a unified stack or ensure clean integration between tools.

Missing context propagation: If your logs and traces do not share a common trace ID, you lose the ability to correlate across pillars. This is the single most valuable investment you can make -- propagate context everywhere, including message queues and async workflows.

Observability in Kubernetes Environments

Kubernetes adds both complexity and opportunity to observability. The ephemeral nature of pods means traditional host-based monitoring breaks down, but the Kubernetes API provides rich metadata for correlation.

Kubernetes-native observability essentials:

  • kube-state-metrics: Exposes cluster state as Prometheus metrics -- pod status, deployment replicas, resource requests versus actual usage
  • Node exporter: Hardware and OS metrics from each node
  • cAdvisor: Container-level resource usage metrics, built into kubelet
  • Kubernetes events: Record scheduling decisions, restarts, and failures -- ship these to your log aggregation platform

Pod-level instrumentation:

Every pod should expose a /metrics endpoint in Prometheus format. Use the resource request data to correlate performance metrics with resource allocation. This integration between observability and cost optimization is where FinOps meets SRE.

Service mesh observability: If you run Istio, Linkerd, or a similar service mesh, you get automatic L7 metrics (request rate, error rate, latency) for every service-to-service call without any code changes. This is invaluable for quickly identifying which service in a chain is degrading.

Building an Observability Maturity Roadmap

Organizations rarely go from zero to full observability overnight. Here is a practical maturity model:

Level 1 -- Reactive: Centralized logging exists but teams mostly grep through logs after incidents. Basic uptime monitoring is in place. This is where most organizations start.

Level 2 -- Proactive: Prometheus and Grafana are deployed. RED/USE metrics are collected for critical services. Alerting is configured but alert fatigue is common. Some distributed tracing exists but coverage is spotty.

Level 3 -- Integrated: OpenTelemetry is standardized. Logs, metrics, and traces are correlated via shared context. SLOs are defined for top 10 services. Error budgets influence sprint planning. Alert quality is high with low false-positive rates.

Level 4 -- Predictive: Machine learning identifies anomalies before they become incidents. Automated remediation handles common failure modes. Observability data feeds into AI-powered analysis for both reliability and cost optimization. Teams spend less time firefighting and more time building.

Target Level 2 within the first quarter, Level 3 within six months, and Level 4 within a year. The ROI from reduced mean time to resolution (MTTR) alone typically justifies the investment by Level 2.

Cost-Effective Observability Architecture

A common objection to comprehensive observability is cost. Storing logs, metrics, and traces at scale can become expensive quickly. Here are strategies to keep costs manageable without sacrificing visibility:

Sampling for traces: You do not need to store every single trace. Implement head-based sampling (decide at the start of a request) at 10-20% for healthy services. Use tail-based sampling (decide after the request completes) to capture 100% of errors, slow requests, and requests matching specific criteria. This typically reduces trace storage by 80% while preserving all the interesting data.

Log tiering: Not all logs need the same retention. Keep error and warning logs for 90 days, info logs for 30 days, and debug logs for 7 days. Use cheaper storage tiers for older logs. Most log platforms support automated retention policies that make this effortless to manage.

Metric cardinality control: High-cardinality labels (like user ID or request ID) on metrics can explode storage costs. Reserve high-cardinality identifiers for logs and traces. Metrics should use bounded labels: service name, HTTP method, status code range, and environment. Monitor your metric cardinality and set alerts when new high-cardinality series appear.

Open-source stack advantages: A self-hosted stack of Prometheus, Grafana, Loki, and Tempo on Kubernetes can cost 60-70% less than equivalent SaaS solutions. The trade-off is operational overhead, but for organizations with strong platform engineering teams, this is often the better economic choice. Consider a managed Grafana Cloud plan for smaller teams that lack the capacity to operate the stack themselves.

Budget allocation guideline: Plan for observability infrastructure costs of 3-5% of your total cloud spend. This typically delivers 10x ROI through faster incident resolution, reduced over-provisioning, and better capacity planning. Organizations that invest in observability early save significantly on incident response costs and avoid the expensive firefighting cycles that plague under-instrumented systems.

At Optivulnix, observability is a cornerstone of our DevSecOps practice. We help teams build observable systems that reduce mean time to detection and resolution. Contact us for a free observability maturity assessment.

Mohakdeep Singh

Mohakdeep Singh

Principal Consultant

Specializes in AI/ML Engineering, Cloud-Native Architecture, and Intelligent Automation. Designs and builds production-grade AI systems including retrieval-augmented generation (RAG) pipelines, conversational agents, and document intelligence platforms that transform how enterprises access and act on information.

Meet Our Team ->

Stay Updated

Get the latest cloud optimization insights delivered to your inbox.

Ready to Transform Your Cloud Infrastructure?

Let our team show you where your cloud spend is going -- and how to fix it. AI-powered optimization across AWS, Azure, GCP, and OCI.

Schedule Your Free Consultation