A Prometheus-compatible metrics exporter that monitors container resource usage of Kubernetes workloads.
This exporter collects detailed resource usage statistics for containers by leveraging:
- cgroup v2 for container resource metrics
/proc/[pid]/smapsfor memory mapping statistics
See documentation for a full list of supported metrics. This exporter was created because other existing solutions did not provide all needed cgroup v2 and smaps metrics.
For a complete example of using the exporter in with Prometheus and Grafana, see examples/contour.
Provide configuration using a YAML file and specify it with the -config command line argument:
container-resource-exporter -config /path/to/config.yamlThe config.yaml file supports the following options:
| Field Name | Description | Default Value |
|---|---|---|
server.address |
Server listen address and port | :8080 |
paths.cgroup |
Path to cgroup v2 filesystem | /sys/fs/cgroup |
paths.proc |
Path to proc filesystem | /proc |
paths.cri_socket |
Path to CRI socket for container discovery | Auto-detected from /run/containerd/containerd.sock, /run/crio/crio.sock, or /run/cri-dockerd.sock |
scrape_interval |
Interval for collecting metrics (Go duration format) | 1s |
log_level |
Logging level (debug, info, warn, error) | info |
filters |
List of container filters to monitor | Required; at least one filter must be specified |
filters[].namespace |
Kubernetes namespace pattern (supports * wildcard) |
— |
filters[].pod |
Pod name pattern (supports * wildcard) |
— |
filters[].container |
Container name pattern (supports * wildcard) |
— |
filters[].command |
Process command pattern (supports * wildcard) 1 |
* (matches all commands) |
1 The command filter is based on the process name from /proc/[pid]/comm, which is limited to the first 15 characters of the executable name.
For a complete example, see examples/example-config.yaml.
To build the project from source, ensure you have Go installed and run:
makeA pre-built container image is available at:
ghcr.io/tsaarni/container-resource-exporter:latest
The manifests/container-resource-exporter.yaml file contains Kubernetes manifest for deploying the exporter.
Note that container-resource-exporter needs to run as root and following host paths need to be mounted into the container:
/sys/fs/cgroupfor cgroup v2 filesystem access./procfor process information filesystem.- CRI socket path e.g.,
/run/containerd/containerd.sockfor container discovery.
To deploy with provided example manifest, run:
kubectl create configmap container-resource-exporter-config --from-file=examples/example-config.yaml
kubectl apply -f manifests/container-resource-exporter.yamlPlease refer to CONTRIBUTING.md.

