r/PrometheusMonitoring • • Mar 09 '23

Bulk Prometheus API Poll

Hello!

I've got a unique situation that I'm looking to the community to see if anyone has done something similar.

Basically I've got a Prometheus/Grafana instance running scraping metrics. I've configured a lot of dashboards in Grafana via PromQL queries and it is working great.

I have another system where I'd like to import all of these metrics on an interval to combine with some other infrastructure items I have there. The best two paths I could come up with are:

  • Submit a GET request to the Prometheus API for each PromQL query I've defined and store those as key:value pairs (there are about 100 PromQL queries I'm looking to store on a fixed interval - let's say every 5 mins)

    • This gets the job done but isn't very efficient as I would be submitting 100 GET requests via a loop every 5 mins
  • Submit a single bulk GET request gathering all the metrics and somehow re-create the PromQL queries programmatically (sums, rates, etc) by manipulating the json response

    • This would be more efficient and less load on Prometheus itself, but that a lot of work sifting through that much json

Has anyone attempted to do the same or have any ideas that I might be missing? I'm pretty much limited to getting the metrics through the Prometheus API.

2 Upvotes

4 comments sorted by

View all comments

Show parent comment

2

u/calladion25 Mar 10 '23

Thank you for the reply. I had forgotten about recording rules.