I’m collecting some stats using Telegraf via SNMP.
I wasn’t able to get the data points in Grafana so had a look at Influx and can see the following. Is the issue that the stored value is “-67 dBm” and if so, how do I remove the “dBm” part from being stored?
select RSSI, value from 3GTable
name: 3GTable
time RSSI value
You should be able to clean this up using the regex followed by the converter processors. Use the namepass option on both processors to select only the 3GTable measurement and also remember to define the order of the processors.
If i use the telegraf --test --debug would I expect to see just the value in the output i.e. -67 instead of -67 dBM or does this happen after collection?
At present it still shows -67 dBm, but i’m not sure if that’s to be expected?
This is expected, currently the --test function only runs the inputs, and skips the processors, aggregators, and outputs. For end to end testing I usually swap out my real output for a file output.
Hi have a similar problem, but am not sure if the regex processor behaves correctly or my approach is not correct.
I want to create tags for IPv4 or IPv6 log entries (I use tail plugin with grok parsing), but don’t want to keep the real IPs.
What I do is:
[[processors.regex]]
#process all access_log measurements
namepass = "*access_lo*"
order = 1
## Tag and field conversions defined in a separate sub-tables
[[processors.regex.tags]]
## Tag to change
key = "client_ip"
## Regular expression to match on a tag value
pattern = "^([0-1]?[0-9]{1,2}|2[0-4][0-9]|25[0-5])[.]"
## Pattern for constructing a new value (${1} represents first subgroup)
replacement = "ipv4"
So I just want to have only ipv4 (or ipv6) in the tag client_ip. But the output for client_ip is e.g.:
ipv456.174.137
So without specifing it, it outputs “ipv4${1}” isn’t it ? Is this intended behavior or a bug ? How can I achieve my goal ?
After some testing it seems that the plugin outputs the unmatched part of the tag value at the end of the replacement string, what makes no sense to me. But if I build some pattern with non-capturing groups for the whole value then it is not happening. Maybe the clue is to have a full pattern that matches everything not parts of the value. This works for me:
[[processors.regex]] #process all access_log measurements
namepass = [“access_log”]
order = 1
[[processors.regex.tags]]
## Tag to change
key = “client_ip”
## Regular expression to match on a tag value
pattern = “^(?:^\d+[.])(?:.*)$”
## Pattern for constructing a new value (${1} represents first subgroup)
replacement = “ipv4”
[[processors.regex]] #process all access_log measurements
namepass = [“access_log”]
order = 2
[[processors.regex.tags]]
## Tag to change
key = “client_ip”
## Regular expression to match on a tag value
pattern = “^(?:[0-9A-Fa-f]{1,4}:)(?:.*)$”
## Pattern for constructing a new value (${1} represents first subgroup)
replacement = “ipv6”
This will allow you to convert a tag to a field type, during conversion the string tag is reinterpreted as the target type. If you have a tag that is answer=42 you could convert it to an integer field, but if the tag is host=example.org you can only convert it to a string field without error.