#prometheus #exporter-prometheus #docker #metrics

app docker-prometheus-exporter

Exports basic metrics from Docker for scraping by Prometheus

1 stable release

Uses new Rust 2024

new 1.0.0 Apr 14, 2025

#3 in #exporter-prometheus

MIT/Apache

28KB
374 lines

Docker Prometheus Exporter

Exports basic metrics from Docker to the defined endpoint with path / or /metrics for scraping by Prometheus.

V1 Breaking Changes

  • 254a698 - Removes DOCKER_HOST environment variable. Now connects via Unix Socket or Windows Pipe
  • f7652c7 - Default behaviour for container_health metric now only reports the health status on containers with the following label docker-prometheus-exporter.metric.container_health.enabled. This behaviour can be configured with the CONTAINER_HEALTH_FILTER_LABEL environment variable
  • 608a1eb - Default listen address changed to 127.0.0.1

Available Metrics

Metric Name Description Units/Values Labels
docker_up Reports the state of Docker 0 - Offline
1 - Online
N/A
container_health Reports the health state of a Docker container 0 - Unknown
1 - Stopped
2 - Alive, no healthcheck
3 - Unhealthy
4 - Healthy
id - Container ID
name - Container Name

Environment Variables

Name Description Default
RUST_LOG Sets logging verbosity, see documentation info
LISTEN_ADDR Metrics endpoint listen address 127.0.0.1
LISTEN_PORT Metrics endpoint listen port 9000
CLIENT_IP_SOURCE Sets the Client IP source for logging, see documentation for valid values ConnectInfo
CONTAINER_HEALTH_FILTER_LABEL Whether the container_health metric should only report containers which have the docker-prometheus-exporter.metric.container_health.enabled=true label true

Example Docker Compose

services:
  docker-prometheus-exporter:
    container_name: docker-prometheus-exporter
    image: calum4/docker-prometheus-exporter:1
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    environment:
      - RUST_LOG=info,docker_prometheus_exporter=info
      - LISTEN_ADDR=0.0.0.0
    expose:
      - "9000:9000"
    ports:
      - "127.0.0.1:9000:9000"
    labels:
      "docker-prometheus-exporter.metric.container_health.enabled": true
    restart: unless-stopped

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

See CONTRIBUTING.md.

Dependencies

~19–31MB
~449K SLoC