๐Ÿš€ Container Exporter (CXP)

A resource-friendly, highly efficient Prometheus exporter for monitoring Docker containers' Memory, CPU, Disk, and Network I/O usage โ€” with uptime tracking.

when a container is not running due to whatever reason cxp removes all its stats metrics (cpu, memory, etc.) (if CONTAINER_EXPORTER_CLEAR_METRICS=True otherwise they are set to 0 to retain time series data.) but keeps its status ( running/not-running/(restarting/unhealthy) ) to facilitate alerting in case something goes wrong with that contaier.

Check out a sample of the metrics output here to see how it works.

๐Ÿ“š Table of Contents

  1. DEV STACK
  2. DEMO
  3. Deployment Guide
  4. Config and Settings
  5. Grafana Dashboards
  6. Alerting

๐Ÿ› ๏ธ DEV STACK

๐ŸŽฅ DEMO

CXP Demo GIF

Config and Settings

Uvicorn

the following settings can be set via exporting environment variables and are applied to start.sh entrypoint.

App Settings

the following settings can be set via exporting environment variables or a .env file.

๐Ÿ“‹ Deployment Guide

Before You Start

โš™๏ธ Deploy with GitHub Actions

How Workflows Work

Double check the required variables and secrets to prevent any unexpected failures.

With Docker Compose

git clone https://github.com/Shayan-Ghani/Container-exporter.git
cd Container-Exporter
chmod +x ./start.sh
docker-compose -f container-exporter.yml up -d

Without Docker

python3 -m venv venv
source venv/bin/activate
pip install -U pip
pip install -r requirements.txt
./start.sh &

Add CXP to Prometheus

Modify your prometheus.yml scrape configs and point to localhost:8000/metrics.

Scrape config example

๐Ÿ“Š Grafana Dashboards

Import dashboards from the ./dashboards directory and use dashboard-gen.sh to auto-replace datasource UIDs.

Alerting Rules

A page of sample Prometheus rules can be accessed here . setting alerts on cxp_container_status is one of the main points users prefer CXP overcAdvisor.