Skip to content

Commit 40272af

Browse files
committed
change custom metrics to counters + monitor async task executor
1 parent b9cb186 commit 40272af

5 files changed

Lines changed: 516 additions & 209 deletions

File tree

other/monitoring/README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,26 @@ Grafana can be accessed on port `3000`.
3939
* add prometheus data source: *Configuration* > *Add data source* > *Prometheus*, and set URL=`http://prometheus:9090`
4040
* add an open-source Spring Boot dashboard: *"+"* > *Import*: https://grafana.com/grafana/dashboards/10280
4141
* add the custom BBData dashboard using the same import wizard and load (or copy-paste) the JSON file `bbdata-dashboard-grafana.json`
42+
43+
### Tips
44+
45+
For all metrics of type *summary* (such as `http_server_requests_seconds_*`), we have three sub counters at our disposal:
46+
* `_count`: the total number of records
47+
For http requests, this means the total number of requests made to each endpoints;
48+
* `_sum`: the sum of all the records made during a time window.
49+
For http requests, it means the total duration of every request for each endpoint;
50+
51+
We can work with those summaries in Prometheus/Graffana using common approaches:
52+
53+
* Average latency: `rate(timer_sum[10s])/rate(timer_count[10s])`
54+
* Throughput (requests per second): `rate(timer_count[10s])`
55+
* Count `increase(timer_count)`
56+
57+
For http_server_requests, we also have a `_max`: (gauge, optional) the maximum request during a time window.
58+
The value resets to 0 when a new time window starts.
59+
60+
## Resources
61+
62+
* [SpringDoc: Prometheus](https://docs.spring.io/spring-metrics/docs/current/public/prometheus)
63+
* [How does a Prometheus Counter work?](https://www.robustperception.io/how-does-a-prometheus-counter-work)
64+
* [Spring Boot default metrics](https://tomgregory.com/spring-boot-default-metrics/)

0 commit comments

Comments
 (0)