Docker Container Status as Prometheus Exporter Metrics
Reading time: 2 – 2 minutesTracking Docker container status in real time is a common challenge in DevOps. Popular tools like cAdvisor and the default Docker exporter for Prometheus often lack direct metrics for container states, meaning key insights—such as the number of containers that are running, stopped, or inactive—require complex workarounds. This limitation can complicate monitoring and lead to unreliable data.
Before creating docker_container_exporter, I relied on complex Prometheus queries to retrieve container statuses. This often involved calculations based on the last time a container was seen as active, but this approach had a major flaw: if the query time range didn’t match the last activity timestamp precisely, the data could be inaccurate or incomplete. Monitoring container states shouldn’t be this difficult.
With docker_container_exporter, this problem is solved. My tool captures real-time Docker container statuses, providing data on the number of running, stopped, and other container states, all in a Prometheus-compatible format. You can collect these metrics through a standard Prometheus polling process, or use agents like Grafana Alloy to push the data to Prometheus storage or compatible DB servers like Grafana Mimir or Thanos.
You can find my project in this GitHub repository: docker_container_exporter
In the README file, you’ll find details on how to use it, as well as instructions for integrating it with Grafana Alloy.
Tot posant-me al dia dels tropocientosmil feeds que tenia atrassats d’aquests dies de massa feina m’he trobat, no em feu dir on, un site molt útil. Ens permet supervisar des de tot el món quina és la visibilitat dels nostres sites i/o serveis. Ens fa informes tan en format de text, com gràfics. Realment si teniu aquesta necessitat ús el recomano moltíssim ja que sobretot de cara a informar a clients de forma certificiada quina és la vostre disponibilitat, latència, etc. crec que és molt útil. A més també pot generar alarmes per falles de servei.