Skip to content

fborello-lambda/prometheus_grafana

Repository files navigation

Prometheus & Grafana 🦀

Why?

The idea behind this project is to learn about Grafana and Prometheus. It can be used as a template too.

How?

  • A docker-compose is used to bundle all the needed components:
    • PORT 3000 → API written in rust
    • PORT 3001 → Grafana
      • usr: admin
      • pwd: admin
    • PORT 9090 → Prometheus

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:

Grafana Image

What?

The key about this project is the monitoring folder.

  • grafana_povisioning → The docker-compose.yaml file mounts this folder
    • It has configuration files:
      • dashboard.yaml
      • datasource.yaml
      • Note: The datasource.yaml has a uid that is then used in dashboard.json. I've tried to export the dashboard as proposed by the following URL, but it didn't work.
  • prometheus.yaml → Scrapping interval and URL to scrap, prometheus scrapes the URL/metrics endpoint.

Resources

About

Prometheus & Grafana HandsOn with Rust

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published