I need to query for collected metrics in my application and the only way I found to do it is via Prometheus rest api as described here: https://prometheus.io/docs/prometheus/latest/querying/api/ Does any Spring or java api for fetching metrics from Prometheus exist, so that I wouldn't have to implement it from scratch?
Asked
Active
Viewed 2,859 times
10
-
1Have a look at https://github.com/anhdat/prometheus4j – Edgar Domingues Jul 17 '20 at 06:14
-
You could also connect Grafana to prometheus – Radu Sebastian LAZIN Nov 07 '21 at 04:09
1 Answers
0
If you want to collect metrics from your spring application using Prometheus, this is what you have to do:
In your application's pom.xml add this dependency:
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
<version>1.7.0</version>
</dependency>
In application.properties you need to add:
management.endpoints.web.exposure.include=*
management.endpoint.health.show-details=always
And this should be all, now when you start your Spring application you can check the collected metrics at /actuator/prometheus, you'll have all the metrics grouped here.
Good luck!

Anghel Ionut
- 61
- 5