I would like to push metrics, e.g. processing time of an HTTP request or current heap size, to Prometheus through a Pushgateway in a Spring Boot application.
I'm struggling because there are many documents, either from Spring Metrics or Prometheus but neither of them address my specific problem.
The easiest way would be to use the @Timed
annotation on a RestController class, as described here: http://projects.spring.io/spring-metrics/
However, I don't see, where I could configure an URL for the pushgateway and ask myself if the @Timed
annotation just exports metrics to the /prometheus
endpoint where they should be pulled from.
The Prometheus guides, however, tell me to use a simpleclient_pushgateway
library: https://github.com/prometheus/client_java#exporting-to-a-pushgateway
Lastly, there's another simpleclient called simpleclient_spring_boot
, which would be the third way to integrate Prometheus into Spring Boot.
Could you please tell me, how I can accomplish
A) pushing metrics from preferrably an annotation based approach for HTTP requests
B) some approach for JVM metrics every x seconds
C) to a configurable (in the application.yml
file) pushgateway
Thank you very much