The idea behind this project is to learn about Grafana
and Prometheus
. It can be used as a template too.
- A
docker-compose
is used to bundle all the needed components:- PORT
3000
→ API written in rust - PORT
3001
→ Grafana- usr:
admin
- pwd:
admin
- usr:
- PORT
9090
→ Prometheus
- PORT
Using make
, the containers are started, and the entire setup is initiated.
To test the dashboard, you can open Grafana in your preferred web browser with: http://localhost:3001/login. Login with the credentials (admin
/admin
), go to the Dashboards
section and open the Transactions DEMO
dashboard.
The panels will be blank. To populate them with data, we can send some information to the API:
watch -n 1 'curl -s -X POST http://localhost:3000/transact -H "Content-Type: application/json" -d '\''{"operation": "reada", "id": 4, "value": 100.50}'\'
We will be sending a POST request every second. The dashboard on the left should always show an increasing value, while the dashboard on the right should reach a value of 1, indicating 1 TPS.
The following image shows a possible output:
The key about this project is the monitoring
folder.
grafana_povisioning
→ Thedocker-compose.yaml
file mounts this folder- It has configuration files:
dashboard.yaml
datasource.yaml
- Note: The
datasource.yaml
has auid
that is then used indashboard.json
. I've tried to export the dashboard as proposed by the following URL, but it didn't work.
- It has configuration files:
prometheus.yaml
→ Scrapping interval and URL to scrap, prometheus scrapes the URL/metrics endpoint.
- Telegraf vs. Prometheus: Choosing the Right Metrics Collection Tool - NashTech Insights
- How to Managed Grafana Dashboard in Multiple Environments — and find UID Harmony | by Hélia Barroso | Medium
- Visualizing Rust App Metrics using Prometheus & Grafana | Step by Step Guide - YouTube
- Quick start to instrumenting a Rust web app with Prometheus - YouTube