My Spring-Boot application simply has a counter metric. I just don't know how to send this information to Prometheus. I am using Maven (build tool) and Spring Boot (Java).
Start your application, and send an HTTP get request to http://localhost:8080/actuator/prometheus . You will see all of the metrics being exposed. If you don't see your custom metric, make sure that you have triggered the code to be executed. The metric won't appear until the timer has recorded at least once.
The first part of monitoring Spring Boot applications is choosing a metrics database. By default, Spring Boot will configure a Micrometer metrics registry in every application. This default implementation collects a pre-defined set of application metrics such as memory and CPU usage, HTTP requests, and a few others.
Prometheus, like Graphite, is a time-series storage engine.
Grafana can then query Prometheus to generate graphics and alerts.
https://prometheus.io/docs/introduction/faq/
As the documentation cites, Prometheus, unlike other metrics storage systems, uses a (debatable) "pull" model.
This means that there is a (stand-alone) Prometheus server that must be downloaded/installed. This server then periodically makes HTTP GET requests (pull) to a list of application servers - such as a Java SpringBoot server to fetch (in-memory) stored metrics.
Ref: https://prometheus.io/docs/introduction/faq/#why-do-you-pull-rather-than-push?
Thus the (Spring Boot) application must expose a metrics end-point that the Prometheus server can pull from (default is /metrics).
Ref: https://github.com/prometheus/client_java
Thus there is much documentation available on Google but that is the (arguably convoluted) topology - along with arguments from the SoundCloud and Prometheus folks as to why a "pull" model is preferred over "push" as every other metrics framework employs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With