Monitoring Docker using Grafana and Prometheus

Running applications in Docker is convenient, but without visibility you’re basically flying blind. Monitoring helps you understand what’s happening behind the scenes and gives you a chance to fix issues before they become critical.


🧰 Prerequisites

Here’s what you’ll need to follow along:

  • Docker & Docker Compose
  • Prometheus (metrics collection)
  • Grafana (dashboard visualization)
  • Node Exporter (system metrics)
  • cAdvisor (container metrics)

Make sure you have installed Prometheus, Grafana, and Node Exporter


1. Install the tools we need

apt install cadvisor -y

by default cAdvisor running on port 8080, which is we need this port isn’t in-use


2. Configure the target

vi /etc/prometheus/prometheus.yaml
scrape_configs:
  - job_name: "Node_Exporter"
    scrape_interval: 5s
    static_configs:
      - targets: ["192.168.211.4:9100"]
  - job_name: "Docker_Exporter"
    scrape_interval: 5s
    static_configs:
      - targets: ["192.168.211.4:8080"]

the target is server which cAdvisor has installed

restart the prometheus service:

systemctl restart prometheus

3. Ensure that the target has been detected by Prometheus

access the prometheus for check the target, go to http://192.168.211.6:9090

Gambar_Prometheus_Target


4. Configure the Grafana

  • Access grafana http://192.168.211.6:3000/ and add the prometheus datasource. Gambar Grafana Datasource

  • Then Save and Test.

  • Import or build grafana dashboards — Grafana’s community has tons of ready-to-use ones https://grafana.com/grafana/dashboards/. Gambar Grafana Dashboard


Bonus: Alerts 🚨

Grafana isn’t just about pretty graphs — you can set up alerts too. Some simple but useful rules:

  • Ping when CPU usage stays above 80% for 5 minutes.

  • Notify when free disk space drops below 15%.

(You can hook alerts to Slack, Telegram, email, or whatever you use daily.)


🧩 Wrapping Up

And that’s it — you’ve now got a working Docker monitoring stack. Prometheus grabs the data, Grafana makes it pretty, and exporters keep the flow going.


🤝 Let’s Connect

If you have suggestions, questions, or just want to say hi, I’d love to hear from you.

Feel free to reach out — I’m always happy to help fellow builders:

If you found this helpful, consider sharing it or giving it a star wherever you found it — it really helps!

Thanks for stopping by. See you in the next post! ✌️


References 📚

Here are some useful official docs and resources if you want to dive deeper: