telegraf icon indicating copy to clipboard operation
telegraf copied to clipboard

Add Headers map to inputs.prometheus

Open rnsc opened this issue 4 years ago • 6 comments

Feature Request

I'd be interested in having the possibility to add specific headers to the GET request done by the inputs.prometheus plugin.

Proposal:

As it was mentioned here, maybe we can just add the same headers map[string]string that exists for other inputs plugin like httpjson.

We would then have:

[[inputs.prometheus]]
  urls = ["http://localhost:9100/metrics"]
  [inputs.prometheus.headers]
    X-Auth-Token = "123"
    Another-Header = "MyCustomerHeader"

Use case:

I have a use case where the application requires a specific header to be set.

I'm willing to help with the PR if needed, but I'm opening this feature request first to see if it's accepted or not.

rnsc avatar Aug 31 '20 07:08 rnsc

I already created the changes in a personal fork: https://github.com/rnsc/telegraf/commits/feature/inputs-prometheus-headers

rnsc avatar Aug 31 '20 17:08 rnsc

I would be interested in this functionality too.

As an example, an application like PowerDNS's DNSDist has a web server that exposes its metrics in prometheus format (see here), however, this requires that the X-API-Key header is set to authorise the request (see here)

Adding this functionality would allow me to query DNSDist directly for its prometheus metrics

00Asgaroth00 avatar Sep 21 '20 20:09 00Asgaroth00

Hello,

Can this be looked at? Thanks,

rnsc avatar Oct 12 '20 09:10 rnsc

Hello @ssoroka @sjwang90 ,

Can you have a look at this Feature request and the PR I made? Do you think it can be merged? Or is it not a desired feature?

Thanks,

rnsc avatar Nov 03 '20 09:11 rnsc

Agree, this is something we need as well. The endpoint we use exposes Prometheus metrics but needs a specific HTTP authentication header which bearer_token_string does not support.

vjanssens avatar Jan 12 '22 13:01 vjanssens

@rnsc there is a http_headers option in the prometheus input, is this what you are looking for?

srebhan avatar Apr 26 '24 08:04 srebhan

Hello! I am closing this issue due to inactivity. I hope you were able to resolve your problem, if not please try posting this question in our Community Slack or Community Forums or provide additional details in this issue and reqeust that it be re-opened. Thank you!

telegraf-tiger[bot] avatar May 10 '24 18:05 telegraf-tiger[bot]