Sign inSign up

tdsdockerhub/docker-exporter

By tdsdockerhub

•Updated 7 months ago

Image
0

956

tdsdockerhub/docker-exporter repository overview

⁠Docker Exporter for Prometheus

This Python script (docker_exporter.py) is a simple Prometheus exporter that collects metrics from Docker containers and exposes them on an HTTP endpoint. The exported metrics cover:

  • Memory: usage, limit, and working set
  • CPU: percentage usage
  • Network: cumulative bytes received and transmitted
  • Lifecycle: restart count and OOMKilled status

Metrics are labeled with the container name and short container ID, making it easy to identify individual containers in Prometheus.

⁠How it works

  1. Connects to the Docker daemon using the docker Python SDK.
  2. Lists all containers (running or stopped) and for each:
    • Reloads its attributes
    • Gathers state information (restarts, OOM kills)
    • If running, fetches live stats for memory, CPU, and network
  3. Updates corresponding Prometheus Gauge metrics
  4. Runs an HTTP server on port 9101 for Prometheus to scrape
  5. Refreshes metrics every 5 seconds

⁠Scraping with Prometheus

Add a job to your Prometheus configuration pointing at the exporter:

scrape_configs:
  - job_name: 'docker_exporter'
    static_configs:
      - targets: ['<exporter_host>:9101']

Replace <exporter_host> with the hostname or IP where the exporter is running (e.g. localhost).

Restart Prometheus after updating its config.

Tag summary

Content type

Image

Digest

sha256:4130ba104…

Size

48.7 MB

Last updated

7 months ago

docker pull tdsdockerhub/docker-exporter