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:
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.
2. 🛠️ otel-collector-config.yaml
This config tells the OpenTelemetry Collector to receive telemetry and export metrics in Prometheus format.
-
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.
-
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.
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:
2. Access the Interfaces
-
Prometheus: http://localhost:9090
-
Grafana: http://localhost:3000
Default login:admin / admin
📡 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!