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

Add ability to filter printed headers in telegraf config #5585

Merged
merged 6 commits into from
Apr 26, 2019

Conversation

glinton
Copy link
Contributor

@glinton glinton commented Mar 14, 2019

Resolves #5584

This adds header-filter as an option to filter the printing of the global_tags and agent sections of the config file. By setting to "none", config headers will be skipped, allowing the creation of minimal config files.

$ telegraf \
  --output-filter none \
  --processor-filter none \
  --aggregator-filter none \
  --input-filter cpu \
  --header-filter none config

# Read metrics about cpu usage
[[inputs.cpu]]
  ## Whether to report per-cpu stats or not
  percpu = true
  ## Whether to report total system cpu stats or not
  totalcpu = true
  ## If true, collect raw CPU time metrics.
  collect_cpu_time = false
  ## If true, compute and report the sum of all non-idle CPU states.
  report_active = false

@danielnelson
Copy link
Contributor

Would it be possible to call this --section-filter and allow it to skip the plugin sections too? So if you have telegraf --section-filter agent it only prints the agent section, and if you have telegraf --section-filter input it doesn't show the 3 line comment header for the other plugin types?

@glinton
Copy link
Contributor Author

glinton commented Mar 18, 2019

That would work, though I do like the ability to remove all unneeded comments in a generated file without piping to a text processor.

@danielnelson
Copy link
Contributor

I think we should have this so that this command only prints the [agent] section, no inputs/outputs etc.

./telegraf --section-filter agent config

Also should support sections inputs, outputs, processors, outputs:

./telegraf --section-filter inputs:processors config

Only show the header for a section when the section is enabled.

@glinton
Copy link
Contributor Author

glinton commented Apr 16, 2019

Ok, now I see what you're saying. I understood the section-filter was to only control the other (currently non-configurable) sections agent, and global-tags. To just show the agent section, with changes up to now on this branch, you would need to specify:

./telegraf --section-filter agent  --input-filter none --output-filter none  --aggregator-filter none --processor-filter none config

Which is a lot of configuration. Making the change now.

cmd/telegraf/telegraf.go Outdated Show resolved Hide resolved
internal/config/config.go Outdated Show resolved Hide resolved
@danielnelson danielnelson merged commit 6436005 into master Apr 26, 2019
@danielnelson danielnelson deleted the feature/5584 branch April 26, 2019 03:34
hwaastad pushed a commit to hwaastad/telegraf that referenced this pull request Jun 13, 2019
bitcharmer pushed a commit to bitcharmer/telegraf that referenced this pull request Oct 18, 2019
athoune pushed a commit to bearstech/telegraf that referenced this pull request Apr 17, 2020
idohalevi pushed a commit to idohalevi/telegraf that referenced this pull request Sep 29, 2020
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Please change the behaviour of config generation
2 participants