Rename multiple fields via Telegraf processor

Hello,

I’m using telegraf as a receiver for Cisco Telemetry data, the metrics I get back are all working fine, but I would like to trim the “phy_info/phy_details/” in front of the fields.

At the moment I’m using the “rename processor”:

[[processors.rename.replace]]
    field = "phy_info/phy_details/dig_opt_mon_alarm_thresholds/transceiver_voltage_warning_high"
    dest = "dig_opt_mon_alarm_thresholds/transceiver_voltage_warning_high"
[[processors.rename.replace]]
    field = "phy_info/phy_details/dig_opt_mon_alarm_thresholds/transceiver_voltage_warning_low"
    dest = "dig_opt_mon_alarm_thresholds/transceiver_voltage_warning_low"
[[processors.rename.replace]]
    field = "phy_info/phy_details/dig_opt_mon_alarm_thresholds/transceiver_voltage_alarm_low"
    dest = "dig_opt_mon_alarm_thresholds/transceiver_voltage_alarm_low"
.
.
.

Is there a better way to do this?
I’ll be getting more Telemetry data and adding a rename processor for every field seems like its not the best way.

Thanks in advance !

_

Example Data for the Telemetry:

media-if,host=ti-p-telinput3,interface-name=MgmtEth0/RSP1/CPU0/1,path=Cisco-IOS-XR-drivers-media-eth-oper:ethernet-interface/interfaces/interface,source=NAME,subscription=media,tag_kafkatopic=telemetry_influx layer1_info/autoneg/mask=0i,oper_state_up=0i,phy_info/media_type="ethernet-1000base-thd",phy_info/phy_details/vendor_serial_number="",layer1_info/current_alarms/squelch_alarm="alarm-not-supported",layer1_info/ipg="standard",layer1_info/duplex="half-duplex",layer1_info/current_alarms/loss_of_synchronization_data_alarm="alarm-not-supported",mac_info/burned_in_mac_address="xxxx.xxxx.xxxx",phy_info/phy_details/vendor_part_number="",layer1_info/led_state="led-off",layer1_info/autoneg/config_override=0i,layer1_info/current_alarms/sd_ber_alarm="alarm-not-supported",layer1_info/opd_monitoring/settings/received_optical_power_degrade_threshold_set=0i,layer1_info/link_state="phy-not-present",layer1_info/previous_alarms/pcs_loss_of_block_lock_alarm="alarm-not-supported",layer1_info/opd_monitoring/settings/received_optical_power_degrade_threshold=51i,admin_state="disabled",phy_info/phy_details/lane_field_validity/wavelength_valid=0i,phy_info/phy_details/lane_field_validity/receive_power_valid=0i,layer1_info/speed="ten-mbps",layer1_info/previous_alarms/local_fault_alarm="alarm-not-supported",mac_info/mru=1510i,phy_info/phy_details/lane_field_validity/transmit_power_valid=0i,phy_info/phy_details/optics_type="",layer1_info/opd_monitoring/supported=1i,phy_info/phy_details/vendor="",phy_info/phy_details/revision_number="",layer1_info/current_alarms/hi_ber_alarm="alarm-not-supported",layer1_info/previous_alarms/sf_ber_alarm="alarm-not-supported",layer1_info/previous_alarms/hi_ber_alarm="alarm-not-supported",layer1_info/previous_alarms/squelch_alarm="alarm-not-supported",layer1_info/current_alarms/pcs_loss_of_block_lock_alarm="alarm-not-supported",layer1_info/previous_alarms/rx_opd_alarm="alarm-not-supported",mac_info/mtu=1510i,phy_info/loopback="no-loopback",layer1_info/current_alarms/received_loss_of_signal_alarm="alarm-not-supported",phy_info/phy_present="phy-not-present",layer1_info/current_alarms/local_fault_alarm="alarm-not-supported",mac_info/multicast_mac_filters/multicast_promiscuous=0i,layer1_info/autoneg/speed="one-gbps",mac_info/operational_mac_address/value="78ba.f977.fb01",layer1_info/flowcontrol="no-flowcontrol",layer1_info/previous_alarms/sd_ber_alarm="alarm-not-supported",layer1_info/previous_alarms/loss_of_synchronization_data_alarm="alarm-not-supported",phy_info/phy_details/lane_field_validity/laser_bias_valid=0i,layer1_info/current_alarms/sf_ber_alarm="alarm-not-supported",layer1_info/current_alarms/rx_opd_alarm="alarm-not-supported",layer1_info/current_alarms/remote_fault_alarm="alarm-not-supported",layer1_info/previous_alarms/received_loss_of_signal_alarm="alarm-not-supported",layer1_info/autoneg/autoneg_enabled=1i,layer1_info/autoneg/flowcontrol="no-flowcontrol",layer1_info/autoneg/fec="not-configured",layer1_info/autoneg/duplex="full-duplex",layer1_info/previous_alarms/remote_fault_alarm="alarm-not-supported" 1571047263986000000

Right now this is the only way to handle the renames, but this is definitely something we know is painful. Keep an eye on issue 5159 for updates, it is about renaming measurements but we would definitely want any fix to also support tags and fields.

Thanks for the answer.
I’ll keep an eye on that issue.