How do I make Prometheus scrape metrics with POST?

Viewed 84

I have a datasource that I can access remotely with a POST request (including an API key and user ID as data in the request).

Is there anyway to configure Prometheus to scrape this datasource? Preferably without any additional software.

1 Answers

I think not using scrape_config without a proxy (or additional software) unless the datasource is accessible using one of the service discovery targest listed in Prometheus configuration.

If you need to use a proxy, this should be straightforward.

You'd need to construct an out-of-band HTTP server defined as the proxy to accept proxied (GET) requests from Prometheus, possibly1 (!) injecting the API key and user ID, do whatever's necessary to respond to Prometheus' GET with a list of metrics in the expected exposition format returning these as the scrape response.

1 - unless you can wrangle your inputs as HTML params, or as basic_auth or authorization headers.

Related