-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Inputs.prometheus] Double Accept header using http_headers
#12906
Comments
Tweaking the Prometheus plugin to use Would that cause issues with existing use of diff --git a/plugins/inputs/prometheus/prometheus.go b/plugins/inputs/prometheus/prometheus.go
index 03c0b3811..ebb01b0c2 100644
--- a/plugins/inputs/prometheus/prometheus.go
+++ b/plugins/inputs/prometheus/prometheus.go
@@ -364,7 +364,7 @@ func (p *Prometheus) gatherURL(u URLAndAddress, acc telegraf.Accumulator) error
if p.HTTPHeaders != nil {
for key, value := range p.HTTPHeaders {
- req.Header.Add(key, value)
+ req.Header.Set(key, value)
}
} Headers with above change:
|
yeah looks like add appends to a header while set would overwrite. I would expect if a user is setting a value, to overwrite anything else. Can you try the PR artifacts found in #12907 in 20-30mins to confirm the change? |
Tested the Linux artifacts in #12907 and they fix the issue with Authentik. The Accept header is overwritten as proposed |
It is OK for |
Agreed, then is there a better way to resolve this issue for the user? If a user is explicit about what they want to accept, it seems wise to follow through and only accept that. We seem to have a mix of set and add throughout telegraf as it is today. |
This particular problem can probably be resolved with:
if server is standard compliant. as for general set vs add I think |
Relevant telegraf.conf
Logs from Telegraf
System info
Telegraf 1.26.0 (git: HEAD@064650c8) in Docker 20.10.21
Docker
No response
Steps to reproduce
Expected behavior
Authentik metrics are read (using Prometheus interface)
Actual behavior
Looks a lot like issue #12749
Additional info
The configured HTTP Accept Header seems to be added instead of replacing the original. Authentik probably only uses the first.
Headers in the request
Tcpdump
The text was updated successfully, but these errors were encountered: