Hi,
I have fields that come in like this:
Ethernet54/goVendorInfo/vendorSn
Ethernet6/goVendorInfo/vendorDateCode
Ethernet6/goVendorInfo/vendorName
Ethernet6/goVendorInfo/vendorPn
Ethernet6/goVendorInfo/vendorRev
Ethernet6/goVendorInfo/vendorSn
Ethernet7/goVendorInfo/vendorDateCode
Ethernet7/goVendorInfo/vendorName
My goal is to try to remove “goVendorInfo” from the field name and have the fieldnames renamed to:
Ethernet54-vendorSn
Ethernet6-vendorDateCode
Ethernet6-vendorName
Ethernet6-vendorPn
Ethernet6-vendorRev
Ethernet6-vendorSn
Ethernet7-vendorDateCode
Ethernet7-vendorName
My input plugin looks like this:
[[inputs.gnmi]]
addresses = ["router1.mgt.net:50051"]
username = "$routerUser"
password = "$routerPass"
encoding = "proto"
redial = "10s"
enable_tls = true
tls_ca = "/etc/telegraf/router_ca.pem"
insecure_skip_verify = false
fieldpass = ["Ethernet*/goVendorInfo*", "Ethernet*/lastDomUpdateTime/rxPower", "Ethernet*/lastDomUpdateTime/txPower", "Ethernet*/domRegisterData/lane1TxPower", "Ethernet*/domRegisterData/lane3OpticalRxPower", "Ethernet*/domRegisterData/lane4TxPower", "Ethernet*/domRegisterData/lane2OpticalRxPower", "Ethernet*/domRegisterData/lane2TxPower", "Ethernet*/domRegisterData/lane1OpticalRxPower", "Ethernet*/domRegisterData/lane3TxPower", "Ethernet*/domRegisterData/lane4OpticalRxPower"]
[[inputs.gnmi.subscription]]
name = "na_optics"
path="/Sysdb/hardware/archer/xcvr/status/all"
subscription_mode = "sample"
origin="eos_native"
sample_interval = "10s"
suppress_redundant = false
I’m testing with [[processors.regex.fields]]
and just trying to capture the first string before the first forward slash and store it to a new field called testing, but I’m not having any luck. If I can figure out how to do this then I think I should be able to extract out the first and third strings to form the new field name.
This is what I have:
[[processors.regex]]
namepass = ["na_optics"]
[[processors.regex.fields]]
key = "Ethernet54/domRegisterData/lane4TxPower"
pattern = "^(\\w+).*"
replacement = "${1}"
result_key = "testing"
Also, can wildcards be used in the key definition? Can I use a key that looks like this key = "Ethernet*/domRegisterData/lane4TxPower"
to target all keys that begin with “Ethernet”.
Thank you,
Mo