apache_exporter icon indicating copy to clipboard operation
apache_exporter copied to clipboard

Add header support

Open ccremer opened this issue 5 years ago • 4 comments

Hello. Thank you for this project! I wondered if you could support adding multiple headers via CLI options. e.g. apache_exporter --header "Accept: */*" --header "User-Agent: something" --scrape_uri ...

The reason behind this is that we have a modSecurity (WAF) in "Front" of the Apache server and it logs false alerts for missing Accept header. Of course you could add an accept header by default, but it's probably better to make it configurable.

What do you think?

ccremer avatar Aug 08 '19 08:08 ccremer

hi @ccremer

Maybe prometheus libraries need to be updated?

Seems there's an accept header being used for scrapes as seen here:

https://github.com/prometheus/prometheus/blob/b5c833ca2194db5581b8979048b3450cc869b88a/scrape/scrape.go#L528

Is that something you can look into?

Lusitaniae avatar Aug 17 '19 07:08 Lusitaniae

Hi

I realize that I wasn't clear enough about the headers. It's the status-page (.../server-status) from Apache that expects a header, not the exporter itself.

I guess somesomewhere in in the collect function in https://github.com/Lusitaniae/apache_exporter/blob/master/apache_exporter.go#L172 is the right place.

So it's more like the exporter should add the headers to the collection request, not prometheus

ccremer avatar Aug 19 '19 08:08 ccremer

sorry for the late response,

I think it doesn't justify allowing all kinds of dynamic headers. We can just add the Accept one for now.

Don't hesitate to make a PR, I'll try to get to it earlier!

Lusitaniae avatar Aug 23 '19 07:08 Lusitaniae

Thanks for the response. In our case, adding the Accept: */* header "statically" is sufficient, so that works for us.

Cheers

ccremer avatar Aug 23 '19 09:08 ccremer

I know you decided to not have it, but I am giving you the opportunity anyways :p I'm open to modify it

AndreasPB avatar Apr 13 '23 10:04 AndreasPB

I think this was solved by #161

AndreasPB avatar Jun 27 '23 11:06 AndreasPB

Many thanks! and sorry for the time it took

Lusitaniae avatar Jun 27 '23 12:06 Lusitaniae