A resource-friendly, highly efficient, and minimal Prometheus exporter to track Memory, CPU, Disk and Network I/O usage of Docker containers along with their lifecycle (uptime).
see a sample of the metrics page in here.
- Port 8000 must be open (default port)
- Docker & Docker Compose should be installed (optional)
- The presence of Git and Python3.10
- clone and enter the repository using the following commands:
git clone https://github.com/Shayan-Ghani/Container-exporter.git
cd Container-Exporter
- Deploy the docker-compose file that suits you the best for instance :
# Make the file executable
chmod +x ./start.sh
# With docker compose v1
docker-compose -f container-exporter.yml up -d
# Or using v2
docker compose -f container-exporter.yml up -d
# build from base with Dockerfile
docker-compose -f container-exporter-local.yml up --build -d
alternatively, run docker-compose -f container-exporter-local.yml up --build -d
to build from Dockerfile
# No need if done already
chmod +x ./start.sh
# Set up virtualenv
python3 -m venv venv
source venv/bin/activate
pip install -U pip
# Install the required python packages
pip install -r requirements.txt
# start the initializer script.
./start.sh &
You can use nohup as well :
nohup ./start.sh -out ./nohup.out
# to stop cxp without docker use this command
kill -9 <PID>
Replace <PID>
with the pid of ./start.sh script.
./start.sh <your custome port> &
# or
CONTAINER_EXPORTER_PORT=<your custom port> docker-compose -f container-exporter.yml up -d
Change <your custom port>
with a port of your choice and make sure you change the port mapping in docker-compose accordingly.
- Edit your
prometheus.yml
file and add the address of container-exporter in scrape_configs:
- Reload or restart your Prometheus server and reach out to
http://127.0.0.1:8000/metrics
Check out dashboards directory for Json files. including CPU & Memory usage + containers status (uptime).
Change Your Prometheus data source uid
with the uid of Prometheus data source uid. you can find it this way:
-
Reach out to Grafana then enter
Home > Administration > Data sources
then click on your Prometheus data source. -
the characters after
datasources/edit/
are your uid. (e.g datasources/edit/c8e586ac-4262-4aad5-a103-1240ss826424) -
alternatively, use
dashboard-gen.sh
script to change the dashboards' uid by providing the uid as the first argument of the script. do the following steps:
cd scripts && bash dashboard-gen.sh <your uid>
-
replace
<your uid>
with your Prometheus datasource uid. -
now head to Grafana dashboards and hit
new > import
then copy the dashboard Json file and paste it intoImport via panel json
-
hit the
load
button and Done!
- Disk I/O usage
- Network I/O Usage
- Add metrics in units of byte
- Check and Unregister stat metrics for containers that are not running
- Design grafana dashboards and share them on grafana cloud
- Design and develop a static website to showcase Documentation, new features, etc.
Welcome to CXP! This project is currently in an experimental yet stable version, and we encourage contributions to enhance its functionality, optimize code, and add new features
Feel free to contribute in any wacacy you can. If you come across a bug or have a suggestion, please don't hesitate to file an issue. Your input is valuable and helps us improve CXP for everyone; Therefore, add any desired function or feature to TO DO section. We appreciate your contribution to making CXP even better! If you have any questions or need assistance, feel free to reach out. Thank you!
- If you want to add metrics to cxp, make sure the naming convention is conformed to. (
container_metric_name
)