DEX is a lightweight Prometheus exporter that monitors Docker containers and exports their metrics. It's designed to run as a Docker container and supports all architectures.
- Lightweight and efficient
- Supports all architectures
- Real-time container metrics monitoring
- Easy integration with Prometheus and Grafana
- No configuration required for basic usage
| Metric Name | Type | Description | Labels |
|---|---|---|---|
| dex_block_io_read_bytes_total | Counter | Total number of bytes read from block devices | container_name |
| dex_block_io_write_bytes_total | Counter | Total number of bytes written to block devices | container_name |
| dex_container_exited | Gauge | 1 if container has exited, 0 otherwise | container_name |
| dex_container_restarting | Gauge | 1 if container is restarting, 0 otherwise | container_name |
| dex_container_restarts_total | Counter | Total number of container restarts | container_name |
| dex_container_running | Gauge | 1 if container is running, 0 otherwise | container_name |
| dex_cpu_utilization_percent | Gauge | Current CPU utilization percentage | container_name |
| dex_cpu_utilization_seconds_total | Counter | Cumulative CPU time consumed | container_name |
| dex_memory_total_bytes | Gauge | Total memory limit in bytes | container_name |
| dex_memory_usage_bytes | Counter | Current memory usage in bytes | container_name |
| dex_memory_utilization_percent | Gauge | Current memory utilization percentage | container_name |
| dex_network_rx_bytes_total | Counter | Total bytes received over network | container_name |
| dex_network_tx_bytes_total | Counter | Total bytes transmitted over network | container_name |
| dex_pids_current | Counter | Current number of processes in the container | container_name |
- Docker installed and running
- Prometheus server (for metrics collection)
- Grafana (optional, for visualization)
| Environment Variable | Description | Default |
|---|---|---|
DEX_PORT |
The port the exporter will listen on. | 8080 |
DEX_LABELS |
Comma-separated list of additional labels to export. | "" |
You can add extra labels to all metrics using the DEX_LABELS environment variable. This can be useful for adding more context to your metrics, such as the image name or command.
Available Labels:
imageimage_idcommandcreated
Example:
export DEX_LABELS="image,command"This will add the image and command labels to all exported metrics.
Warning
NOTE! High Cardinality Ahead!
Each unique combination of key-value label pairs represents a new time series in Prometheus. Using labels with high cardinality (many different values), such as image_id or created, can dramatically increase the amount of data stored and impact Prometheus' performance.
For more information, please see the Prometheus documentation on labels.
Start docker container with following docker-compose.yml:
version: '2.1'
services:
dex:
image: spx01/dex
container_name: dex
volumes:
- /var/run/docker.sock:/var/run/docker.sock
ports:
- 8386:8080
restart: alwaysAs an alternative to Docker, you can build and run DEX from source:
# Clone the repository
git clone https://github.com/spx01/dex.git
cd dex
# Build the binary
go build -o dex .
# Run the exporter
./dex$ curl localhost:8386/metricsExample output:
# HELP dex_container_running 1 if docker container is running, 0 otherwise
# TYPE dex_container_running gauge
dex_container_running{container_name="dex"} 1
# HELP dex_cpu_utilization_percent CPU utilization in percent
# TYPE dex_cpu_utilization_percent gauge
dex_cpu_utilization_percent{container_name="dex"} 0.036
...
Contributions are welcome! Please feel free to submit a pull request.
Example grafana7 dashboard definition as JSON
.
Another dashboard for Grafana 8 (thanks @scMarkus !!!) as JSON

Modification (thanks @GitSchorsch) with additional job filter as JSON