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(inputs.prometheus): Remove duplicate response_timeout option #15078

Merged
merged 2 commits into from
Apr 9, 2024

Conversation

powersj
Copy link
Contributor

@powersj powersj commented Mar 28, 2024

Summary

In #14153, the HTTP client config struct gained a response timeout config option with TOML tags. This meant that there were two defined for both Prometheus plugin and the HTTP client config struct.

This removes the one in the Prometheus plugin, which allows users to correctly load previously existing plugins. However, the response_timeout option will now set the HTTP Client config's ResponseHeaderTimeout, which is the time spent reading the headers of the response. While timeout will set the Timeout, which sets the timeout for the entire connection.

This would also get rid of the deprecation warning. Because this now sets a different value and there is no deprecation warning, I'm not sure this is the right thing to do, but it does allow a user to correctly load a config. The other option may be not to import HTTPClientConfig and have that locally?

Checklist

  • No AI generated code was used in this PR

Related issues

fixes: #15076

In influxdata#14153, the HTTP client config struct gained a response timeout
config option with TOML tags. This meant that there were two defined for
both Prometheus plugin and the HTTP client config struct. This removes
the one in Prometheus, which was used to set the one in the HTTP client
anyway.

fixes: influxdata#15076
@telegraf-tiger telegraf-tiger bot added area/prometheus fix pr to fix corresponding bug plugin/input 1. Request for new input plugins 2. Issues/PRs that are related to input plugins labels Mar 28, 2024
@powersj powersj self-assigned this Mar 29, 2024
@powersj
Copy link
Contributor Author

powersj commented Apr 4, 2024

Example output when set:

❯ ./telegraf --config config.toml --once
2024-04-04T20:11:07Z I! Loading config: config.toml
2024-04-04T20:11:07Z I! Starting Telegraf 1.31.0-19728c5b brought to you by InfluxData the makers of InfluxDB
2024-04-04T20:11:07Z I! Available plugins: 233 inputs, 9 aggregators, 31 processors, 24 parsers, 60 outputs, 6 secret-stores
2024-04-04T20:11:07Z I! Loaded inputs: prometheus
2024-04-04T20:11:07Z I! Loaded aggregators: 
2024-04-04T20:11:07Z I! Loaded processors: 
2024-04-04T20:11:07Z I! Loaded secretstores: 
2024-04-04T20:11:07Z I! Loaded outputs: file
2024-04-04T20:11:07Z I! Tags enabled: 
2024-04-04T20:11:07Z D! [agent] Initializing plugins
2024-04-04T20:11:07Z I! [inputs.prometheus] Using the label selector:  and field selector: 
2024-04-04T20:11:07Z W! [inputs.prometheus] Config option response_timeout was set to non-zero value. This option's behavior was changed in Telegraf 1.30.2 and now controls the HTTP client's header timeout, and not the Prometheus timeout. Users can ignore this warning if that was the intention. Otherwise, please use the timeout config option for the Prometheus timeout.
2024-04-04T20:11:07Z D! [agent] Connecting outputs
2024-04-04T20:11:07Z D! [agent] Attempting connection to [outputs.file]
2024-04-04T20:11:07Z D! [agent] Successfully connected to outputs.file
2024-04-04T20:11:07Z D! [agent] Starting service inputs
2024-04-04T20:11:07Z D! [agent] Stopping service inputs
2024-04-04T20:11:07Z D! [agent] Input channel closed
2024-04-04T20:11:07Z I! [agent] Hang on, flushing any cached metrics before shutdown
2024-04-04T20:11:07Z D! [outputs.file] Buffer fullness: 0 / 10000 metrics
2024-04-04T20:11:07Z I! [agent] Stopping running outputs
2024-04-04T20:11:07Z D! [agent] Stopped Successfully

With no value set or zero value:

❯ ./telegraf --config config.toml --once
2024-04-04T20:11:51Z I! Loading config: config.toml
2024-04-04T20:11:51Z I! Starting Telegraf 1.31.0-19728c5b brought to you by InfluxData the makers of InfluxDB
2024-04-04T20:11:51Z I! Available plugins: 233 inputs, 9 aggregators, 31 processors, 24 parsers, 60 outputs, 6 secret-stores
2024-04-04T20:11:51Z I! Loaded inputs: prometheus
2024-04-04T20:11:51Z I! Loaded aggregators: 
2024-04-04T20:11:51Z I! Loaded processors: 
2024-04-04T20:11:51Z I! Loaded secretstores: 
2024-04-04T20:11:51Z I! Loaded outputs: file
2024-04-04T20:11:51Z I! Tags enabled: 
2024-04-04T20:11:51Z D! [agent] Initializing plugins
2024-04-04T20:11:51Z I! [inputs.prometheus] Using the label selector:  and field selector: 
2024-04-04T20:11:51Z D! [agent] Connecting outputs
2024-04-04T20:11:51Z D! [agent] Attempting connection to [outputs.file]
2024-04-04T20:11:51Z D! [agent] Successfully connected to outputs.file
2024-04-04T20:11:51Z D! [agent] Starting service inputs
2024-04-04T20:11:51Z D! [agent] Stopping service inputs
2024-04-04T20:11:51Z D! [agent] Input channel closed
2024-04-04T20:11:51Z I! [agent] Hang on, flushing any cached metrics before shutdown
2024-04-04T20:11:51Z D! [outputs.file] Buffer fullness: 0 / 10000 metrics
2024-04-04T20:11:51Z I! [agent] Stopping running outputs
2024-04-04T20:11:51Z D! [agent] Stopped Successfully

@powersj powersj added the ready for final review This pull request has been reviewed and/or tested by multiple users and is ready for a final review. label Apr 4, 2024
@powersj powersj assigned srebhan and DStrand1 and unassigned powersj Apr 4, 2024
@telegraf-tiger
Copy link
Contributor

telegraf-tiger bot commented Apr 4, 2024

@srebhan srebhan removed their assignment Apr 8, 2024
@DStrand1 DStrand1 merged commit 47e28d0 into influxdata:master Apr 9, 2024
26 checks passed
@github-actions github-actions bot added this to the v1.30.2 milestone Apr 9, 2024
powersj added a commit that referenced this pull request Apr 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/prometheus fix pr to fix corresponding bug plugin/input 1. Request for new input plugins 2. Issues/PRs that are related to input plugins ready for final review This pull request has been reviewed and/or tested by multiple users and is ready for a final review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

response_timeout deprecated option for Prometheus input still broken
3 participants