Replace snmp returned string of "" with "Unknown"

telegraf

#1

Quering a wireless controller, sometimes it doesn’t detect the device so it throws back an empty string.
Wondering if there was a way for me to replace the empty string with a value of “Unknown”

[[inputs.snmp.field]]
name = “hostname”
oid = “RFC1213-MIB::sysName.0”
is_tag = true

[[inputs.snmp.table]]
name = “mel_wifi_users”
inherit_tags = [ “hostname” ]
[[inputs.snmp.table.field]]
name = “UserName”
oid = “WLSX-USER-MIB::nUserName”
[[inputs.snmp.table.field]]
name = “DeviceType”
oid = “WLSX-USER-MIB::nUserDeviceType”
is_tag = true

Basically if name DeviceType = “” then replace with DeviceType = “Unknown”
Hope this makes sense


#2

You could probably use the regex processor to make the modification in the case it is an empty string. I think it should be possible to use the override processor if it is not set at all. Use the metric filtering parameters to select only the metrics you wish to modify in the processor.