-
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
Add Tags Processor #3773
Add Tags Processor #3773
Conversation
Metrics created by different input plugins can have tags attached to provide additional information. Those tags may either be configured in the global_tags section in the telegraf.conf file or may be provided by the respective plugin. Telegraf provides a filtering mechanism with the *taginclude* property to only include certain tags. However, this mechanism will also drop all tags, that are not explicitly listed. This applies to the plugin specific tags as well as the global tags. In order to always provide global tags, this processor adds all configured tags after the tag filtering was applied. Therefore all those tags will always be present. This is useful in the case, were only some tags provided by an input plugin are needed, but it is not exactly known, which other tags may be attached by the input plugin. Using this processor provides the ability to use *taginclude* for the wanted tags from the input plugin while still retaining global tags. It eases the configuration as the global tags do not need to be repeated in every *taginclude*. This implementation will add the configured tags to all metrics, no filtering is supported. When adding the tags, values of tags with the same key will be overwritten by the processor. Signed-off-by: Karsten Schnitter <[email protected]>
I'm considering #3362 as an alternative way to do this, what do you think of it? |
The problem I tried to solve was not of conflicting tags but incomplete information when creating a configuration by merging parts from different sources. I have the situation, where I provide a basic configuration including the output plugin. The user then can configure plugins (input, processors, aggregators) specific to the use case. There is a policy what tags need to be present in each metric to ensure correct attribution to the emitting system. Therefore I would need a mechanism to ensure precedence of globally configured tags over tags configured in the plugin configuration. As far as I understand, #3362 still allows the plugin to suppress global tags by the tags subtable. |
That makes sense, perhaps we should aim to make this work on more than just tags, the modifications that are available on all inputs and aggregators are:
It could look very similar to an input plugin, tricky part is coming up with a good name: # Apply standard modifications to matched metrics
[[processors.standard]]
name_override = "baz"
[processors.standard.tags]
foo = "bar" |
Including name_override, name_prefix and name_suffix seems very reasonable. Naming indeed is hard. To me standard suggests slightly, that the plugin is always needed. Maybe policy is more suitable:
I will start on implementing name_override, name_prefix and name_suffix. |
Provide general modification of measurement names as available on inputs and aggregators: - name_override - name_prefix - name_suffix
Since the processor should provide the common interface of inputs and aggregators the tags map is renamed accordingly.
I have implemented name_override, name_prefix and name_suffix. All that is missing is the name of the plugin. We discussed the names standard or policy. @danielnelson, do you have some suggestion on that? |
After some discussion here, I think we should go with |
Thanks for the input. I will change the name and alter the README.md accordingly. |
Merged for 1.6, thanks! |
This plugin can perform the standard metric modifications using override semantics.
Metrics created by different input plugins can have tags attached to provide
additional information. Those tags may either be configured in the global_tags
section in the telegraf.conf file or may be provided by the respective plugin.
Telegraf provides a filtering mechanism with the taginclude property to only
include certain tags. However, this mechanism will also drop all tags, that are
not explicitly listed. This applies to the plugin specific tags as well as the
global tags.
In order to always provide global tags, this processor adds all configured tags
after the tag filtering was applied. Therefore all those tags will always be
present. This is useful in the case, were only some tags provided by an input
plugin are needed, but it is not exactly known, which other tags may be attached
by the input plugin. Using this processor provides the ability to use
taginclude for the wanted tags from the input plugin while still retaining
global tags. It eases the configuration as the global tags do not need to be
repeated in every taginclude.
This implementation will add the configured tags to all metrics, no filtering is
supported. When adding the tags, values of tags with the same key will be
overwritten by the processor.
Required for all PRs: