Open greenfox878 opened 2 weeks ago
There is something strange with the GNMI message as the same path is sent multiple times with different values! Check for example class-stats/class-name
which appears 8 times with different values... As the path makes up for the field names those 8 entries collide and will make up one field in the end. That's why you don't get the expected number of fields.
How would you interpret the data?
Yes, I noticed it. Looks like it's a "feature" of Cisco's native YANG model. Device returns unkeyed list like: [ class_name: tc-1, drops: xxx, ... class_name: tc-2, drops: xxx, .... ] I'm going to create multiple metrics from this list with starlark script
The problem is that you cannot get the fields as they override each other... All fields are collected into a metric if the metric name and tags are identical currently. We could add a "workaround" flag say output_metric_per_field
and then avoid grouping the fields into a single metric...
It would be great to have such an option i.e. disable grouping fields and let the user do whatever it needs with Starlark. I think it's more flexible than handling broken vendor models in go code. I can add example starlark script for this particular case.
Do you think "one metric per update-path/field" would be OK?
I mean, introduce an option i.e "disable_grouping_fields"
[[inputs.gnmi.subscription]]
....
disable_grouping_fields = true
If the user sets the option it should consider using Starlark to process the metric. In general, logic should be next - if the option is true, pass metric "as is" to the Processor block without field grouping, if no processor logic is applied to metric - create metric per field or drop metric (last is better IMO).
We cannot pass the metric as-is because the field names collide! There are two options to solve this, simply output one metric per "field" (aka update path) or to append suffixes to the field names like _1
, _2
etc.
The former is easy as we just need to skip the grouping step but there is no way to know which metrics belong together after we output them as they are all named the same. So your only bet is to use the metric order for grouping in starlark.
The latter is more difficult on the gnmi-plugin side as we need to figure out if the group already contains a field, so we probably need to adapt the metrics-grouper... However, this format is much simpler to process in starlark as all fields belonging together will have the same suffix...
I need your opinion to judge which way to go. :-)
Thank you for the detailed explanation! I vote for appending suffixes (_1, _2, etc) to the field names because it gives more predictable output.
Relevant telegraf.conf
Logs from Telegraf
System info
Telegraf 1.30.3, Ubuntu 22.04.3 LTS (latest updates)
Docker
No response
Steps to reproduce
simple starlark script:
Expected behavior
starlark script should iterate over all elements in array - dump contains 901 element.
Actual behavior
starlark iterates over last elements of array:
Additional info
No response