Hi,
I am configuring the inputs.opcua_listener
plugin in bracketed group notation. When doing so it is not possible to add default tags to the top level (the connection itself). This means I have to repeat all common tags in every single group.
To solve this missing feature I want to use default processors.defaults
to set the default tags for a connection. However I need to be able to tagpass
the metric coming from a specific input where the configured default tags apply.
Is there a way to get the alias
of a plugin to be added as a tag? This would be by far the easiest to know where a metric originated from.
One way to work arround this would be to add a name_prefix
to the connection and route based on the prefix. But I don’t want this prefix to clutter my measurement names as it is only for use in telegraf. So one would have to remove the prefix somehow.
To do this I first went to the processors.strings.trim_prefix
function, but this is not dynamic enough as you would have to define each prefix you used. So regex it is…
In my case I used a prefix ending with pipe symbol so the processor looks as follows:
[[processors.regex]]
alias = "trim name prefix"
order = 1000000
log_level = "debug"
[[processors.regex.metric_rename]]
pattern = '^(.*?)\|'
Note the order number is verry high, this is the last number I defined before outputs.
But just having the input alias as a tag would simplify this whole ordeal to a simple tagexclude
.
Does anybody have better suggestions on how to do this?
I solved my problem for now, but just want to share some thoughts.