Ensure one last Prometheus scrape before graceful shutdown

Viewed 135

I have a spring-boot application (with default Tomcat server) producing metrics for Prometheus using micrometer. The application is configured with graceful shutdown.

When shutting down I want to make sure Prometheus scrapes one last time to get the final metrics but since the server stops accepting new requests Prometheus scrape request won't be handled.

I've looked at Prometheus PushGateway which allows me to explicitly push the metrics to Prometheus although I wanted to avoid it and was looking for some solution from Spring end. Is there anyway I can avoid blocking Prometheus scrape requests upon graceful shutdown? Probably overriding some shutdown event handler...

0 Answers
Related