Sample Data:
You can see the interfaces sensor is reporting metrics about the interfaces as well as optic metrics. I want to store any field that has the word “optics” in it and save it to a new measurement called “optics”
interfaces,device=device1.mgt.net,host=telegraf-agent,interface-name=et-0/0/31 in-octets=3684801013572901i,out-pkts=433625371i,in-pkts=3384240329403i,in-unicast-pkts=116402503i,out-multicast-pkts=433625371i,high-speed=100000i,parent-ae-name="ae15",carrier-transitions=1i,out-octets=53655804358i,in-multicast-pkts=3384123926900i 1670338427875000000
interfaces,device=device1.mgt.net,host=telegraf-agent,interface-name=ae2 last-change=1664204707593168000i,admin-status="UP",oper-status="UP",mtu=9100i,type="ieee8023adLag",description="device description",enabled=true 1670338427955943620
interfaces,device=device1.mgt.net,host=telegraf-agent,interface-name=ae2 mac-address="aa:18:22:f2:cc:33",port-speed="SPEED_400GB" 1670338427957359779
interfaces,device=device2.mgt.net,host=telegraf-agent,interface-name=xe-0/0/0 optics/module_temp=39.89799880981445,optics/module_temp_high_alarm_threshold=75i,optics/module_temp_low_alarm_threshold=-5i,optics/module_temp_high_warning_threshold=70i,optics/module_temp_low_warning_threshold=0i,optics/laser_output_power_high_alarm_threshold_dbm=6,optics/laser_output_power_low_alarm_threshold_dbm=-5,optics/laser_output_power_high_warning_threshold_dbm=3,optics/laser_output_power_low_warning_threshold_dbm=-1,optics/laser_rx_power_high_alarm_threshold_dbm=-3,optics/laser_rx_power_low_alarm_threshold_dbm=-30.969999313354492,optics/laser_rx_power_high_warning_threshold_dbm=-7,optics/laser_rx_power_low_warning_threshold_dbm=-26.989999771118164,optics/laser_bias_current_high_alarm_threshold=75,optics/laser_bias_current_low_alarm_threshold=25,optics/laser_bias_current_high_warning_threshold=70,optics/laser_bias_current_low_warning_threshold=30 1670338428026000000
interfaces,device=device2.mgt.net,host=telegraf-agent,interface-name=xe-0/0/0,lane_number=0 optics/lanediags/lane/lane_laser_output_power_dbm=0.29383736848831177,optics/lanediags/lane/lane_laser_receiver_power_dbm=-9.100947380065918,optics/lanediags/lane/lane_laser_bias_current=50,optics/lanediags/lane/lane_laser_output_power_high_alarm=false,optics/lanediags/lane/lane_laser_output_power_low_alarm=false,optics/lanediags/lane/lane_laser_output_power_high_warning=false,optics/lanediags/lane/lane_laser_output_power_low_warning=false,optics/lanediags/lane/lane_laser_receiver_power_high_alarm=false,optics/lanediags/lane/lane_laser_receiver_power_low_alarm=false,optics/lanediags/lane/lane_laser_receiver_power_high_warning=false,optics/lanediags/lane/lane_laser_receiver_power_low_warning=false,optics/lanediags/lane/lane_laser_bias_current_high_alarm=false,optics/lanediags/lane/lane_laser_bias_current_low_alarm=false,optics/lanediags/lane/lane_laser_bias_current_high_warning=false,optics/lanediags/lane/lane_laser_bias_current_low_warning=false 1670338428026000000
interfaces,device=device2.mgt.net,host=telegraf-agent,interface-name=xe-0/0/1 optics/module_temp=42.30799865722656,optics/module_temp_high_alarm_threshold=90i,optics/module_temp_low_alarm_threshold=-45i,optics/module_temp_high_warning_threshold=85i,optics/module_temp_low_warning_threshold=-40i,optics/laser_output_power_high_alarm_threshold_dbm=6,optics/laser_output_power_low_alarm_threshold_dbm=-5,optics/laser_output_power_high_warning_threshold_dbm=3,optics/laser_output_power_low_warning_threshold_dbm=-1,optics/laser_rx_power_high_alarm_threshold_dbm=-3,optics/laser_rx_power_low_alarm_threshold_dbm=-30.969999313354492,optics/laser_rx_power_high_warning_threshold_dbm=-7,optics/laser_rx_power_low_warning_threshold_dbm=-26.989999771118164,optics/laser_bias_current_high_alarm_threshold=75,optics/laser_bias_current_low_alarm_threshold=25,optics/laser_bias_current_high_warning_threshold=70,optics/laser_bias_current_low_warning_threshold=30 1670338428026000000
Would like the above data to look like this:
interfaces,device=device1.mgt.net,host=telegraf-agent,interface-name=et-0/0/31 in-octets=3684801013572901i,out-pkts=433625371i,in-pkts=3384240329403i,in-unicast-pkts=116402503i,out-multicast-pkts=433625371i,high-speed=100000i,parent-ae-name="ae15",carrier-transitions=1i,out-octets=53655804358i,in-multicast-pkts=3384123926900i 1670338427875000000
interfaces,device=device1.mgt.net,host=telegraf-agent,interface-name=ae2 last-change=1664204707593168000i,admin-status="UP",oper-status="UP",mtu=9100i,type="ieee8023adLag",description="device description",enabled=true 1670338427955943620
interfaces,device=device1.mgt.net,host=telegraf-agent,interface-name=ae2 mac-address="aa:18:22:f2:cc:33",port-speed="SPEED_400GB" 1670338427957359779
optics,device=device2.mgt.net,host=telegraf-agent,interface-name=xe-0/0/0 optics/module_temp=39.89799880981445,optics/module_temp_high_alarm_threshold=75i,optics/module_temp_low_alarm_threshold=-5i,optics/module_temp_high_warning_threshold=70i,optics/module_temp_low_warning_threshold=0i,optics/laser_output_power_high_alarm_threshold_dbm=6,optics/laser_output_power_low_alarm_threshold_dbm=-5,optics/laser_output_power_high_warning_threshold_dbm=3,optics/laser_output_power_low_warning_threshold_dbm=-1,optics/laser_rx_power_high_alarm_threshold_dbm=-3,optics/laser_rx_power_low_alarm_threshold_dbm=-30.969999313354492,optics/laser_rx_power_high_warning_threshold_dbm=-7,optics/laser_rx_power_low_warning_threshold_dbm=-26.989999771118164,optics/laser_bias_current_high_alarm_threshold=75,optics/laser_bias_current_low_alarm_threshold=25,optics/laser_bias_current_high_warning_threshold=70,optics/laser_bias_current_low_warning_threshold=30 1670338428026000000
optics,device=device2.mgt.net,host=telegraf-agent,interface-name=xe-0/0/0,lane_number=0 optics/lanediags/lane/lane_laser_output_power_dbm=0.29383736848831177,optics/lanediags/lane/lane_laser_receiver_power_dbm=-9.100947380065918,optics/lanediags/lane/lane_laser_bias_current=50,optics/lanediags/lane/lane_laser_output_power_high_alarm=false,optics/lanediags/lane/lane_laser_output_power_low_alarm=false,optics/lanediags/lane/lane_laser_output_power_high_warning=false,optics/lanediags/lane/lane_laser_output_power_low_warning=false,optics/lanediags/lane/lane_laser_receiver_power_high_alarm=false,optics/lanediags/lane/lane_laser_receiver_power_low_alarm=false,optics/lanediags/lane/lane_laser_receiver_power_high_warning=false,optics/lanediags/lane/lane_laser_receiver_power_low_warning=false,optics/lanediags/lane/lane_laser_bias_current_high_alarm=false,optics/lanediags/lane/lane_laser_bias_current_low_alarm=false,optics/lanediags/lane/lane_laser_bias_current_high_warning=false,optics/lanediags/lane/lane_laser_bias_current_low_warning=false 1670338428026000000
optics,device=device2.mgt.net,host=telegraf-agent,interface-name=xe-0/0/1 optics/module_temp=42.30799865722656,optics/module_temp_high_alarm_threshold=90i,optics/module_temp_low_alarm_threshold=-45i,optics/module_temp_high_warning_threshold=85i,optics/module_temp_low_warning_threshold=-40i,optics/laser_output_power_high_alarm_threshold_dbm=6,optics/laser_output_power_low_alarm_threshold_dbm=-5,optics/laser_output_power_high_warning_threshold_dbm=3,optics/laser_output_power_low_warning_threshold_dbm=-1,optics/laser_rx_power_high_alarm_threshold_dbm=-3,optics/laser_rx_power_low_alarm_threshold_dbm=-30.969999313354492,optics/laser_rx_power_high_warning_threshold_dbm=-7,optics/laser_rx_power_low_warning_threshold_dbm=-26.989999771118164,optics/laser_bias_current_high_alarm_threshold=75,optics/laser_bias_current_low_alarm_threshold=25,optics/laser_bias_current_high_warning_threshold=70,optics/laser_bias_current_low_warning_threshold=30 1670338428026000000