telegraf
telegraf copied to clipboard
[gGNMI] incorrect metric processing
Relevant telegraf.conf
[[inputs.gnmi]]
addresses = ["gnmi_dut:xxx"]
## define credentials
username = "xxxxx"
password = "xxxxx"
encoding = "proto"
tagexclude = ["path"]
max_msg_size = "4MB"
dump_responses = true
[inputs.gnmi.tags]
test_tag = "test"
[[inputs.gnmi.subscription]]
name = "cisco_xr_stats_qos_in"
origin = "Cisco-IOS-XR-qos-ma-oper"
path = "qos/interface-table/interface/input/service-policy-names/service-policy-instance/statistics"
subscription_mode = "sample"
sample_interval = "10s"
suppress_redundant = false
[[inputs.gnmi.subscription]]
name = "cisco_xr_stats_qos_out"
origin = "Cisco-IOS-XR-qos-ma-oper"
path = "qos/interface-table/interface/output/service-policy-names/service-policy-instance/statistics"
subscription_mode = "sample"
sample_interval = "10s"
suppress_redundant = false
Logs from Telegraf
no error messages. metric dump attached in comment below
System info
Telegraf 1.30.3, Ubuntu 22.04.3 LTS (latest updates)
Docker
No response
Steps to reproduce
simple starlark script:
[[processors.starlark]]
order = 200
namepass = ["cisco_xr_stats_qos_in", "cisco_xr_stats_qos_out"]
script="/etc/telegraf/starlark/cisco_xr_embedded_tag.star"
source = '''
load("logging.star", "log")
def apply(metric):
log.warn("!!!!!>>>>>> start processing new metric!")
log.warn("!!!!!>>>>>> metric len: {}".format(str(len(metric.fields.keys()))))
for path, value in metric.fields.items():
log.warn("!!!!!>>>>>>metric name: {}, path:{}, value: {}".format(metric.name, str(path), str(value)))
log.warn("!!!!!>>>>>> start processing tags")
for k, value in metric.tags.items():
log.warn("!!!!!>>>>>>metric name: {}, path:{}, value: {}".format(metric.name, str(k), str(value)))
'''
Expected behavior
starlark script should iterate over all elements in array - dump contains 901 element.
In [21]: len(d['update']['update'])
Out[21]: 901
Actual behavior
starlark iterates over last elements of array:
2024-08-29T12:35:45Z W! [processors.starlark] !!!!!>>>>>> start processing new metric!
2024-08-29T12:35:45Z W! [processors.starlark] !!!!!>>>>>> metric len: 37
2024-08-29T12:35:45Z W! [processors.starlark] !!!!!>>>>>>metric name: cisco_xr_stats_qos_out, path:policy_name, value: EXTERNAL-EGRESS-QUEUING
2024-08-29T12:35:45Z W! [processors.starlark] !!!!!>>>>>>metric name: cisco_xr_stats_qos_out, path:state, value: active
2024-08-29T12:35:45Z W! [processors.starlark] !!!!!>>>>>>metric name: cisco_xr_stats_qos_out, path:class_stats/counter_validity_bitmask, value: 7864320
2024-08-29T12:35:45Z W! [processors.starlark] !!!!!>>>>>>metric name: cisco_xr_stats_qos_out, path:class_stats/class_name, value: class-default
2024-08-29T12:35:45Z W! [processors.starlark] !!!!!>>>>>>metric name: cisco_xr_stats_qos_out, path:class_stats/cac_state, value: unknown
2024-08-29T12:35:45Z W! [processors.starlark] !!!!!>>>>>>metric name: cisco_xr_stats_qos_out, path:class_stats/general_stats/transmit_packets, value: 1212927705
2024-08-29T12:35:45Z W! [processors.starlark] !!!!!>>>>>>metric name: cisco_xr_stats_qos_out, path:class_stats/general_stats/transmit_bytes, value: 211143580313
2024-08-29T12:35:45Z W! [processors.starlark] !!!!!>>>>>>metric name: cisco_xr_stats_qos_out, path:class_stats/general_stats/total_drop_packets, value: 3662217
2024-08-29T12:35:45Z W! [processors.starlark] !!!!!>>>>>>metric name: cisco_xr_stats_qos_out, path:class_stats/general_stats/total_drop_bytes, value: 369239845
2024-08-29T12:35:45Z W! [processors.starlark] !!!!!>>>>>>metric name: cisco_xr_stats_qos_out, path:class_stats/general_stats/total_drop_rate, value: 0
2024-08-29T12:35:45Z W! [processors.starlark] !!!!!>>>>>>metric name: cisco_xr_stats_qos_out, path:class_stats/general_stats/match_data_rate, value: 66
2024-08-29T12:35:45Z W! [processors.starlark] !!!!!>>>>>>metric name: cisco_xr_stats_qos_out, path:class_stats/general_stats/total_transmit_rate, value: 66
2024-08-29T12:35:45Z W! [processors.starlark] !!!!!>>>>>>metric name: cisco_xr_stats_qos_out, path:class_stats/general_stats/pre_policy_matched_packets, value: 1216589922
2024-08-29T12:35:45Z W! [processors.starlark] !!!!!>>>>>>metric name: cisco_xr_stats_qos_out, path:class_stats/general_stats/pre_policy_matched_bytes, value: 211512820158
2024-08-29T12:35:45Z W! [processors.starlark] !!!!!>>>>>>metric name: cisco_xr_stats_qos_out, path:class_stats/queue_stats_array/queue_id, value: 0
2024-08-29T12:35:45Z W! [processors.starlark] !!!!!>>>>>>metric name: cisco_xr_stats_qos_out, path:class_stats/queue_stats_array/tail_drop_packets, value: 3662217
2024-08-29T12:35:45Z W! [processors.starlark] !!!!!>>>>>>metric name: cisco_xr_stats_qos_out, path:class_stats/queue_stats_array/tail_drop_bytes, value: 369239845
2024-08-29T12:35:45Z W! [processors.starlark] !!!!!>>>>>>metric name: cisco_xr_stats_qos_out, path:class_stats/queue_stats_array/queue_instance_length/value, value: 0
2024-08-29T12:35:45Z W! [processors.starlark] !!!!!>>>>>>metric name: cisco_xr_stats_qos_out, path:class_stats/queue_stats_array/queue_instance_length/unit, value: policy-param-unit-ms
2024-08-29T12:35:45Z W! [processors.starlark] !!!!!>>>>>>metric name: cisco_xr_stats_qos_out, path:class_stats/queue_stats_array/queue_average_length/value, value: 0
2024-08-29T12:35:45Z W! [processors.starlark] !!!!!>>>>>>metric name: cisco_xr_stats_qos_out, path:class_stats/queue_stats_array/queue_average_length/unit, value: policy-param-unit-ms
2024-08-29T12:35:45Z W! [processors.starlark] !!!!!>>>>>>metric name: cisco_xr_stats_qos_out, path:class_stats/queue_stats_array/queue_max_length/value, value: 0
2024-08-29T12:35:45Z W! [processors.starlark] !!!!!>>>>>>metric name: cisco_xr_stats_qos_out, path:class_stats/queue_stats_array/queue_max_length/unit, value: policy-param-unit-ms
2024-08-29T12:35:45Z W! [processors.starlark] !!!!!>>>>>>metric name: cisco_xr_stats_qos_out, path:class_stats/queue_stats_array/queue_drop_threshold, value: 122368
2024-08-29T12:35:45Z W! [processors.starlark] !!!!!>>>>>>metric name: cisco_xr_stats_qos_out, path:class_stats/queue_stats_array/forced_wred_stats_display, value: False
2024-08-29T12:35:45Z W! [processors.starlark] !!!!!>>>>>>metric name: cisco_xr_stats_qos_out, path:class_stats/queue_stats_array/random_drop_packets, value: 0
2024-08-29T12:35:45Z W! [processors.starlark] !!!!!>>>>>>metric name: cisco_xr_stats_qos_out, path:class_stats/queue_stats_array/random_drop_bytes, value: 0
2024-08-29T12:35:45Z W! [processors.starlark] !!!!!>>>>>>metric name: cisco_xr_stats_qos_out, path:class_stats/queue_stats_array/max_threshold_packets, value: 0
2024-08-29T12:35:45Z W! [processors.starlark] !!!!!>>>>>>metric name: cisco_xr_stats_qos_out, path:class_stats/queue_stats_array/max_threshold_bytes, value: 0
2024-08-29T12:35:45Z W! [processors.starlark] !!!!!>>>>>>metric name: cisco_xr_stats_qos_out, path:class_stats/queue_stats_array/conform_packets, value: 0
2024-08-29T12:35:45Z W! [processors.starlark] !!!!!>>>>>>metric name: cisco_xr_stats_qos_out, path:class_stats/queue_stats_array/conform_bytes, value: 0
2024-08-29T12:35:45Z W! [processors.starlark] !!!!!>>>>>>metric name: cisco_xr_stats_qos_out, path:class_stats/queue_stats_array/exceed_packets, value: 0
2024-08-29T12:35:45Z W! [processors.starlark] !!!!!>>>>>>metric name: cisco_xr_stats_qos_out, path:class_stats/queue_stats_array/exceed_bytes, value: 0
2024-08-29T12:35:45Z W! [processors.starlark] !!!!!>>>>>>metric name: cisco_xr_stats_qos_out, path:class_stats/queue_stats_array/conform_rate, value: 0
2024-08-29T12:35:45Z W! [processors.starlark] !!!!!>>>>>>metric name: cisco_xr_stats_qos_out, path:class_stats/queue_stats_array/exceed_rate, value: 0
2024-08-29T12:35:45Z W! [processors.starlark] !!!!!>>>>>>metric name: cisco_xr_stats_qos_out, path:satid, value: 0
2024-08-29T12:35:45Z W! [processors.starlark] !!!!!>>>>>>metric name: cisco_xr_stats_qos_out, path:policy_timestamp, value: 1724934940835
2024-08-29T12:35:45Z W! [processors.starlark] !!!!!>>>>>> start processing tags
2024-08-29T12:35:45Z W! [processors.starlark] !!!!!>>>>>>metric name: cisco_xr_stats_qos_out, path:interface_name, value: Bundle-Ether70
2024-08-29T12:35:45Z W! [processors.starlark] !!!!!>>>>>>metric name: cisco_xr_stats_qos_out, path:service_policy_name, value: EXTERNAL-EGRESS-QUEUING
2024-08-29T12:35:45Z W! [processors.starlark] !!!!!>>>>>>metric name: cisco_xr_stats_qos_out, path:source, value: xxxxxxxxx
Additional info
No response