10

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?

dev123
  • 477
  • 8
  • 20

1 Answers1

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!