fix(inputs.prometheus): Correctly handle host header (#15195)

This commit is contained in:
Joshua Powers 2024-04-19 14:10:32 -06:00 committed by GitHub
parent f5d393ca14
commit 6bb3d32da9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 1 deletions

View File

@ -437,7 +437,11 @@ func (p *Prometheus) gatherURL(u URLAndAddress, acc telegraf.Accumulator) (map[s
}
for key, value := range p.HTTPHeaders {
req.Header.Set(key, value)
if strings.EqualFold(key, "host") {
req.Host = value
} else {
req.Header.Set(key, value)
}
}
var err error