Skip to content
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

fix(outputs.influxdb*): Support setting Host header #14481

Merged

Conversation

slai
Copy link
Contributor

@slai slai commented Dec 19, 2023

Summary

The outputs.influxdb and outputs.influxdb_v2 plugins currently do not support setting the Host header in the http_headers config parameter. If set, it is silently dropped by Go's HTTP client.

The Go HTTP client requires the Host header to be set on the http.Request struct instead. This is already done in other plugins, e.g. inputs.http, outputs.http and secretstores.http.

for k, v := range h.Headers {
if strings.EqualFold(k, "host") {
request.Host = v
} else {
request.Header.Add(k, v)
}
}

This PR updates the outputs.influxdb and outputs.influxdb_v2 plugins to bring it inline with the other plugins, i.e. allow setting the Host header using the http_headers config parameter.

Checklist

  • No AI generated code was used in this PR

Related issues

resolves #14482

The outputs.influxdb and outputs.influxdb_v2 plugins currently do not
support setting the Host header in the `http_headers` config parameter.
If set, it is silently dropped by Go's HTTP client.

The Go HTTP client requires the Host header to be set on the
http.Request struct instead. This is already done in other plugins, e.g.
inputs.http, outputs.http and secretstores.http.

This PR updates the outputs.influxdb and outputs.influxdb_v2 plugins to
bring it inline with the other plugins, i.e. allow setting the Host
header using the `http_headers` config parameter.
@telegraf-tiger telegraf-tiger bot added feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin plugin/output 1. Request for new output plugins 2. Issues/PRs that are related to out plugins labels Dec 19, 2023
@powersj
Copy link
Contributor

powersj commented Dec 19, 2023

Hi,

Can you please file an issue and detail why a user would want to set the headers please?

Thanks

edit: if you could just file an issue so we have something to track this with, I would appreciate it.

@slai
Copy link
Contributor Author

slai commented Dec 19, 2023

@powersj thanks for looking at this so quickly! I've filed #14482 to describe the use case.

@powersj powersj changed the title feat(outputs.influxdb*): support setting Host header fix(outputs.influxdb*): Support setting Host header Dec 19, 2023
Copy link
Contributor

@powersj powersj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for taking the time to put this up!

@powersj powersj merged commit 08fd16f into influxdata:master Dec 19, 2023
23 of 24 checks passed
@github-actions github-actions bot added this to the v1.30.0 milestone Dec 19, 2023
@slai slai deleted the outputs_influxdb_support_host_header branch December 22, 2023 22:11
powersj pushed a commit that referenced this pull request Jan 8, 2024
@powersj powersj modified the milestones: v1.30.0, v1.29.2 Jan 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin plugin/output 1. Request for new output plugins 2. Issues/PRs that are related to out plugins
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[outputs.influxdb_v2] Allow setting Host HTTP header
2 participants