elastic / examples

Home for Elasticsearch examples available to everyone. It's a great way to get started.
Apache License 2.0
2.63k stars 1.24k forks source link

[Enhancement request] example for elastic SCRAPPING SpringBoot Actuator /prometheus endpoint #418

Open patpatpat123 opened 1 year ago

patpatpat123 commented 1 year ago

Hello Elastic team,

This is my first post in this repo. First of all, I would like to say big thanks for putting those examples together. They are very clear and helpful.

For me in particular, I learned a lot with this example: https://github.com/elastic/examples/blob/master/scraping-prometheus-k8s-with-metricbeat/metricbeat-prometheus-auto-discover.yaml

I would like to reach out with a small enhancement request please: SpringBoot with the latest micrometer combined with SpringBoot actuator offers a very nice /prometheus endpoint. The information provided by this endpoint are very useful and appreciated by the community.

Here is the official doc: https://docs.spring.io/spring-boot/docs/2.5.6/reference/html/actuator.html#actuator.metrics.export.prometheus

Here is a small example of the very clear metrics as http response:

# HELP http_server_requests_active_seconds_max  
# TYPE http_server_requests_active_seconds_max gauge
http_server_requests_active_seconds_max{exception="none",method="GET",outcome="SUCCESS",status="200",uri="UNKNOWN",} 0.4322848
# HELP http_server_requests_active_seconds  
# TYPE http_server_requests_active_seconds summary
http_server_requests_active_seconds_active_count{exception="none",method="GET",outcome="SUCCESS",status="200",uri="UNKNOWN",} 1.0
http_server_requests_active_seconds_duration_sum{exception="none",method="GET",outcome="SUCCESS",status="200",uri="UNKNOWN",} 0.4322638

Some prometheus scrappers can SCRAP this endpoint and forward the metrics onto prometheus server, following a very nice "poll the metrics" instead of having the app proactively send the metrics.

However, this requires relying on some prometheus scrappers, as well as a prometheus server.

Our team enjoy and heavily use Elastic Stack.

Would it be possible to have an example where the Elastic Stack scrap this /prometheus endpoint, get the metrics (fingers crossed they are compatible with Elastc) and send them to Elastic please?

This would be a great example and a great addition.

Thank you for your time