This is a simple python app to a coding challenge. The aim of this coding challenge is to write a small Prometheus Exporter app that returns metric values for the count of Docker images pulls in a DockerHub organization and is running in a Kubernetes cluster.
-
Make sure you have
Python 3.12.0
or later -
Set following env variables-
Variable Name Default Value DOCKERHUB_ORGANIZATION
camunda
POLLING_SECONDS
600
METRICS_PORT
2113
-
Run
pip install -r requirements.txt
to setup dependencies -
Run
python src/main.py
-
Navigate to http://localhost:2113/metrics in your browser
- Run
make build
to build docker image namedlocal.registry/camunda-app:1.0.0
- Run the image with
docker run -it -p 2113:2113 local.registry/camunda-app:1.0.0
P8s-exporter is a minimal webserver which expose user-defined metrics to HTTP endpoint. This webserver running a forever loop which makes GET requests to DockerHub url. Required fields (image_name, image_pull_count) are extracted from json response and published as P8s Gauge.