🧭 Observability Made Easy: OpenTelemetry + Prometheus + Grafana in Docker

🧭 Observability Made Easy: OpenTelemetry + Prometheus + Grafana in Docker

Observability is essential for understanding the health and performance of modern applications. With tools like OpenTelemetry, Prometheus, and Grafana, you can collect, store, and visualize metrics with ease. In this blog post, I’ll show you how to set up a fully functional observability stack using Docker.

You’ll learn how to:

  • Collect telemetry data with the OpenTelemetry Collector

  • Export metrics in Prometheus format

  • Visualize data in Grafana, automatically provisioned with Prometheus as the data source

Let’s dive in. 🐳


🗂️ Project Structure

First, create a directory with the following structure:

arduino
my-otel-grafana-setup/
├── docker-compose.yml
├── otel-collector-config.yaml
├── prometheus.yml
└── grafana/
└── provisioning/
└── datasources/
└── datasource.yml

Each file plays a role in defining, configuring, and connecting the services.


1. 🚢 docker-compose.yml

This file defines and runs our services: the OpenTelemetry Collector, Prometheus, and Grafana.

yaml
version: '3.8' services: otel-collector: image: otel/opentelemetry-collector-contrib:latest volumes: - ./otel-collector-config.yaml:/etc/otelcol-contrib/config.yaml ports: - "1888:1888" - "8888:8888" - "8889:8889" - "13133:13133" - "4317:4317" - "4318:4318" - "55679:55679" prometheus: image: prom/prometheus:latest volumes: - ./prometheus.yml:/etc/prometheus/prometheus.yml ports: - "9090:9090" grafana: image: grafana/grafana:latest volumes: - ./grafana/provisioning:/etc/grafana/provisioning environment: - GF_SECURITY_ADMIN_PASSWORD=admin ports: - "3000:3000"

2. 🛠️ otel-collector-config.yaml

This config tells the OpenTelemetry Collector to receive telemetry and export metrics in Prometheus format.

yaml
receivers: otlp: protocols: grpc: http: exporters: prometheus: endpoint: "0.0.0.0:8888" service: pipelines: metrics: receivers: [otlp] exporters: [prometheus]
  • Receives OTLP metrics via gRPC and HTTP

  • Exports them for Prometheus on port 8888


3. 📊 prometheus.yml

Prometheus is configured to scrape the metrics from the collector.

yaml
global: scrape_interval: 15s scrape_configs: - job_name: 'otel-collector' static_configs: - targets: ['otel-collector:8888']
  • Scrapes every 15 seconds

  • Uses Docker Compose’s internal networking to reach otel-collector:8888


4. 📈 grafana/provisioning/datasources/datasource.yml

Automatically provisions Prometheus as Grafana’s data source on startup.

yaml
apiVersion: 1 datasources: - name: Prometheus type: prometheus access: proxy url: http://prometheus:9090 isDefault: true editable: false

No manual setup in the UI needed—just open Grafana and start building dashboards.


🚀 Getting Started

1. Start Everything

Navigate to your project folder and run:

bash
docker-compose up -d

2. Access the Interfaces


📡 Sending Metrics

To see real data in Grafana, send telemetry to the OTLP Collector via:

  • http://localhost:4318/v1/metrics (HTTP)

  • grpc://localhost:4317 (gRPC)

You can use:

  • Your own instrumented app

  • Tools like otel-cli

  • Sample exporters in OpenTelemetry SDKs


🖥️ Build Dashboards in Grafana

Once the data is flowing, head to Dashboards > New and start visualizing:

  • Request rate

  • Error counts

  • Custom metrics

  • Anything your app emits!


✅ Conclusion

You now have a full observability pipeline:

  • OpenTelemetry Collector gathers data

  • Prometheus scrapes and stores it

  • Grafana displays beautiful dashboards

This setup is perfect for local testing, demos, or as a foundation for production monitoring. Just plug in your app and start exploring your telemetry!


💡 Pro Tip:

Extend this stack with:

  • Logs and traces

  • Alerting via Prometheus Alertmanager

  • Grafana dashboards as code

If you found this helpful or have questions, feel free to reach out or leave a comment!

Back to blog
  • ChatGPT Uncovered Podcast

    ChatGPT Uncovered Podcast

    Pedro Martins

    ChatGPT Uncovered Podcast ChatGPT Uncovered Podcast Exploring the Frontiers of AI Conversational Models Episode 1: Understanding ChatGPT Published on: May 15, 2023 Your browser does not support the audio element....

    ChatGPT Uncovered Podcast

    Pedro Martins

    ChatGPT Uncovered Podcast ChatGPT Uncovered Podcast Exploring the Frontiers of AI Conversational Models Episode 1: Understanding ChatGPT Published on: May 15, 2023 Your browser does not support the audio element....

  • Power Apps In-Depth Podcast

    Power Apps In-Depth Podcast

    Pedro Martins

    Power Apps In-Depth Podcast Power Apps In-Depth Podcast Exploring the Capabilities of Microsoft Power Apps Episode 1: Introduction to Power Apps Published on: April 20, 2023 Your browser does not...

    Power Apps In-Depth Podcast

    Pedro Martins

    Power Apps In-Depth Podcast Power Apps In-Depth Podcast Exploring the Capabilities of Microsoft Power Apps Episode 1: Introduction to Power Apps Published on: April 20, 2023 Your browser does not...

  • Exploring Power Pages Podcast

    Exploring Power Pages Podcast

    Pedro Martins

    Exploring Power Pages Podcast Exploring Power Pages Podcast Delving into the World of Microsoft Power Pages Episode 1: Getting Started with Power Pages Published on: March 10, 2023 Your browser...

    Exploring Power Pages Podcast

    Pedro Martins

    Exploring Power Pages Podcast Exploring Power Pages Podcast Delving into the World of Microsoft Power Pages Episode 1: Getting Started with Power Pages Published on: March 10, 2023 Your browser...

1 of 3