Hi,
My optic sensor data coming from a network device looks like this:
"fields": {
"Ethernet13/laneStats/0/rxPowerHiAlarm/changes": 0,
"Ethernet13/laneStats/0/rxPowerHiAlarm/current_value": 0,
"Ethernet13/laneStats/0/rxPowerHiAlarm/lastChange": 0,
"Ethernet13/laneStats/0/rxPowerHiWarn/changes": 0,
"Ethernet13/laneStats/0/rxPowerHiWarn/current_value": 0,
"Ethernet13/laneStats/0/rxPowerHiWarn/lastChange": 0,
"Ethernet13/laneStats/0/rxPowerLoAlarm/changes": 0,
"Ethernet13/laneStats/0/rxPowerLoAlarm/current_value": 0,
"Ethernet13/laneStats/0/rxPowerLoAlarm/lastChange": 0,
"Ethernet13/laneStats/0/rxPowerLoWarn/changes": 0,
"Ethernet13/laneStats/0/rxPowerLoWarn/current_value": 0,
"Ethernet13/laneStats/0/rxPowerLoWarn/lastChange": 0,
"Ethernet13/laneStats/0/txPowerHiAlarm/changes": 0,
"Ethernet13/laneStats/0/txPowerHiAlarm/current_value": 0,
"Ethernet13/laneStats/0/txPowerHiAlarm/lastChange": 0,
"Ethernet13/laneStats/0/txPowerHiWarn/changes": 0,
"Ethernet13/laneStats/0/txPowerHiWarn/current_value": 0,
"Ethernet13/laneStats/0/txPowerHiWarn/lastChange": 0,
"Ethernet13/laneStats/0/txPowerLoAlarm/changes": 0,
"Ethernet13/laneStats/0/txPowerLoAlarm/current_value": 0,
"Ethernet13/laneStats/0/txPowerLoAlarm/lastChange": 0,
"Ethernet13/laneStats/0/txPowerLoWarn/changes": 0,
"Ethernet13/laneStats/0/txPowerLoWarn/current_value": 0,
"Ethernet13/laneStats/0/txPowerLoWarn/lastChange": 0
}
To make this data useable I want to remove the first part of the field name (Ethernet13) and store it as a separate tag. Currently, the interface name doesn’t come in as a tag.
I would like the fields to be stored like this:
"fields": {
"/laneStats/0/rxPowerHiAlarm/changes": 0,
"/laneStats/0/rxPowerHiAlarm/current_value": 0,
"/laneStats/0/rxPowerHiAlarm/lastChange": 0,
"/laneStats/0/rxPowerHiWarn/changes": 0,
"/laneStats/0/rxPowerHiWarn/current_value": 0,
"/laneStats/0/rxPowerHiWarn/lastChange": 0,
"/laneStats/0/rxPowerLoAlarm/changes": 0,
"/laneStats/0/rxPowerLoAlarm/current_value": 0,
"/laneStats/0/rxPowerLoAlarm/lastChange": 0,
"/laneStats/0/rxPowerLoWarn/changes": 0,
"/laneStats/0/rxPowerLoWarn/current_value": 0,
"/laneStats/0/rxPowerLoWarn/lastChange": 0,
"/laneStats/0/txPowerHiAlarm/changes": 0,
"/laneStats/0/txPowerHiAlarm/current_value": 0,
"/laneStats/0/txPowerHiAlarm/lastChange": 0,
"/laneStats/0/txPowerHiWarn/changes": 0,
"/laneStats/0/txPowerHiWarn/current_value": 0,
"/laneStats/0/txPowerHiWarn/lastChange": 0,
"/laneStats/0/txPowerLoAlarm/changes": 0,
"/laneStats/0/txPowerLoAlarm/current_value": 0,
"/laneStats/0/txPowerLoAlarm/lastChange": 0,
"/laneStats/0/txPowerLoWarn/changes": 0,
"/laneStats/0/txPowerLoWarn/current_value": 0,
"/laneStats/0/txPowerLoWarn/lastChange": 0
}
and the tags to be stored like this:
"tags": {
"host": "69c9bbdbf5-clnkc-telegraf-agent",
"source": "nep6aara101.mgt.net",
"interface-name": "Ethernet13"
}
I tried using the [[processors.regex]] plugin but I don’t think this is possible since I don’t see a way to store the result from the pattern match as a tag. I can’t change the way the data is coming from the device, so any suggestions or ideas would be greatly appreciated. Thank you!