✦ For everyone, free.

Practical knowledge for real and everyday life

Home

9.3.5.4 Observability Compose Profiles

A focused guide to Observability Compose Profiles, connecting core concepts with practical Docker and container operations.

Observability Compose profiles group together services that provide monitoring, logging aggregation, and tracing capabilities — tools like Prometheus, Grafana, or a log aggregator — tagged with a profile so this additional infrastructure can be optionally included when deeper observability into an application's behavior is specifically needed.

Tagging Observability Infrastructure

An observability-oriented profile groups together the supporting tools needed to monitor and inspect an application's behavior in detail.

services:
  api:
    build: .
  prometheus:
    image: prom/prometheus
    profiles:
      - observability
    ports:
      - "9090:9090"
  grafana:
    image: grafana/grafana
    profiles:
      - observability
    ports:
      - "3001:3000"

These monitoring tools only start when the observability profile is explicitly activated, alongside the application's core services.

Activating Observability When Investigating an Issue

A developer wanting deeper insight into an application's behavior — investigating a performance issue, for instance — activates this profile to bring up the relevant monitoring tools alongside what's already running.

docker compose --profile observability up -d
Why Observability Tools Are Often Better as Optional

Running a full monitoring stack alongside an application adds meaningful resource overhead and complexity that isn't always necessary for ordinary day-to-day development — keeping these tools optional, available on demand, avoids this overhead when deeper observability isn't currently needed.

docker compose up -d

This default startup excludes the observability stack entirely, keeping resource usage and complexity to a minimum for typical development work.

Configuring the Application to Expose Metrics for These Tools

For the observability profile's tools to be genuinely useful, the application itself typically needs to expose metrics or logs in a format these tools can consume.

services:
  api:
    environment:
      - METRICS_ENABLED=true
Why Observability Compose Profiles Matter

Making monitoring and observability infrastructure available as an optional, on-demand profile provides valuable diagnostic capability exactly when it's needed, without imposing its overhead and complexity on every ordinary development session.