Skip to main content

Prometheus Docker Exporter

Exports stats from Docker API (/containers/<id>/stat endpoint).

Metrics are collected on each request, everything in single thread. Fetching stats from Docker API for lots of containers on a small machine could take few seconds, but this implementation will not use host CPU excessively (looking at you, cAdvisor!).

Supported metrics

  • cpu
  • block i/o (cgroups v2)
  • memory
  • network

Usage

usage: glorpen-docker-exporter [-h] [-a ADDR] [-p PORT] [--sysfs SYSFS]

options:
  -h, --help            show this help message and exit
  -a ADDR, --addr ADDR  address to lsiten on, defaults to 0.0.0.0
  -p PORT, --port PORT  port to listen on, defaults to 8080
  --sysfs SYSFS, -s SYSFS
                        path to sysfs to use, defaults to /sys

Access to /sys is needed for resolving block device names (/sys/dev/block).

Exporter needs r/w access to Docker socket (eg. /run/docker.sock).

Supported Docker envs:

  • DOCKER_HOST: The URL to the Docker host.
  • DOCKER_TLS_VERIFY: Verify the host against a CA certificate.
  • DOCKER_CERT_PATH: A path to a directory containing TLS certificates to use when connecting to the Docker host.

Docker

docker run -v /sys:/sys:ro -v /run/docker.sock:/run/docker.sock:rw glorpen/prometheus-docker-exporter:1.0.0

Pypi

pip install glorpen-docker-exporter
python -m glorpen-docker-exporter

Example Prometheus queries

CPU usage per container (as in docker stat command):

delta(container_cpu_seconds_total[2m]) / delta(container_cpu_system_seconds_total[2m]) * avg_over_time(container_cpu_online[2m])

Container HDD reads and writes:

rate(container_blkio_reads_bytes_total[2m]) > 0
rate(container_blkio_writes_bytes_total[2m]) > 0

Metadata

Release files for glorpen-docker-exporter 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for glorpen-docker-exporter 1.0.0
File Interpreter ABI Platform
glorpen_docker_exporter-1.0.0-py3-none-any.whl Python 3 none any Details

Release files / glorpen_docker_exporter-1.0.0-py3-none-any.whl

Download URL glorpen_docker_exporter-1.0.0-py3-none-any.whl
Size 21.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6ff751ae7d6554c27a56033442318acd8616996091e63fd2bb0cbd28189ea529
BLAKE2b-256 checksum
How to use checksums
b03c2f7211619732e7521e467083924004681d2105a845ee436fd550a816c1da
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.1 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.9

Release history Release notifications | RSS feed

This release

1.0.0 This release

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page