This application is a task for CNCF - Chaos Mesh: Monitoring Metrics about Chaos Mesh for Linux Foundation Mentorship Program 2021.
- Goal 1: Build web application and expose required endpoints. ✔️
- Optional Bonus 1: Publish image on Docker Hub and create Dockerfile. ✔️
- Goal 2: Provide monitoring stack of Prometheus and Grafana dashboard. ✔️
- Optional BOnus 2: Orchestrate the monitoring stack via Docker compose. ✔️
- Python
- Flask
- Prometheus
- Grafana
- Docker
- Linux
- Flask App - Main application exposing different set of metrics via JSON on several endpoints.
- Prometheus - Main querying application scraping metrics data from the app via
/metricsendpoint. - Grafana - Main application for displaying metrics data in different format via dashboards.
-
Inside the /app directory, build the docker image of mini-node-exporter app from the Dockerfile using the following command in terminal.
sudo docker build --tag mini-node-exporter-app . -
After the image is created, run the docker image and expose the application to port: 23333 of the docker container.
sudo docker run --name mini-node-exporter-app -p 23333:23333 mini-node-exporter-app -
The flask app is up & running now. Open url provided in shell: mostly
http://172.17.0.2:23333. The localhost of your linux machine defaults to this url inside the container. Open two different terminals and enter this command to setup a watch at/info/uptime&&info/loadendpoints.1. watch -n 1 "curl localhost:23333/info/uptime" 2. watch -n 1 "curl localhost:23333/info/load" -
All the endpoints exposed by the Flask application:
/metrics | /info | /info/hostname | /info/load | /info/uptime -
Browse through different endpoints of
http://172.17.0.2:23333. Hit/metricsendpoint to see all the metrics scraped by Prometheus. Among the other default metrics, you would seenode_uptime&&node_load{duration="<time>"}metrics. -
Once your flask app is up and working, cd back to project directory where
docker-compose.ymlis present. This compose file is responsible for launching Prometheus and Grafana. Run the following command to launch your dashboard.sudo docker-compose up -d -
Now your Prometheus client and Grafana are up & running and ready for use. Go to
localhost:9090to access Prometheus client & tolocalhost:3000to access your Grafana dashboard. -
Inside your Grafana window, login using
adminas username and password. Once you're in, click on themini-node-exporter-lfxdashboard to see thenode_load&&node_timemetrics in graphical format. You could also go to explore section and write different PromQL queries and visualize the results. -
Inside your Prometheus window, write
{job="mini-node-exporter"}query to see all the metrics being scraped by Prometheus. You could also perform various PromQL queries or visualize metrics in Graphs section. -
Finally, you can kill the process by running the following command.
sudo docker-compose down -v
mini-app-exporter docker image: https://dockr.ly/3zqAc5I 📌
Vedant Raghuwanshi
Contact: raghuvedant00@gmail.com