Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GNMI Plugin] Support for processing Base64 Encoded Binary Data #15046

Open
rc-networks opened this issue Mar 22, 2024 · 24 comments · May be fixed by #15201
Open

[GNMI Plugin] Support for processing Base64 Encoded Binary Data #15046

rc-networks opened this issue Mar 22, 2024 · 24 comments · May be fixed by #15201
Assignees
Labels
area/gnmi feature request Requests for new plugin and for new features to existing plugins

Comments

@rc-networks
Copy link

Use Case

Opening this Feature Request based on the discussion over #14950 .

GNMI uses YANG models to get standardized data.
Some models return data in binary format which is then encoded as Base64 following the IETF standard defined on this link, saying:

[9.8.2](https://datatracker.ietf.org/doc/html/rfc6020#section-9.8.2).  Lexical Representation

   Binary values are encoded with the base64 encoding scheme (see
   [[RFC4648], Section 4](https://datatracker.ietf.org/doc/html/rfc4648#section-4)).

Example GNMI subscription setting:

  [[inputs.gnmi.subscription]]
    name = "ps"
    origin = "openconfig"
    path = "/components/component/power-supply/state"
    subscription_mode = "sample"
    sample_interval = "60s"

CLI Logs with debug option:

2024-03-22T02:27:27Z I! Loading config: /home/dev/streaming_telemetry/telegraf.conf
2024-03-22T02:27:27Z I! Loading config: /home/dev/streaming_telemetry/telegraf.d/ios_xe.conf
2024-03-22T02:27:27Z I! Loading config: /home/dev/streaming_telemetry/telegraf.d/ios_xe_dev.conf
2024-03-22T02:27:27Z I! Loading config: /home/dev/streaming_telemetry/telegraf.d/output.conf
2024-03-22T02:27:27Z I! Loading config: /home/dev/streaming_telemetry/telegraf.d/processor.conf
2024-03-22T02:27:27Z I! Starting Telegraf 1.30.0-91ab5e95 brought to you by InfluxData the makers of InfluxDB
2024-03-22T02:27:27Z I! Available plugins: 233 inputs, 9 aggregators, 31 processors, 24 parsers, 60 outputs, 6 secret-stores
2024-03-22T02:27:27Z I! Loaded inputs: gnmi
2024-03-22T02:27:27Z I! Loaded aggregators: 
2024-03-22T02:27:27Z I! Loaded processors: converter (3x) enum parser (6x) rename (6x)
2024-03-22T02:27:27Z I! Loaded secretstores: 
2024-03-22T02:27:27Z I! Loaded outputs: file
2024-03-22T02:27:27Z I! Tags enabled: host=dev-server telemetry_source=network
2024-03-22T02:27:27Z I! [agent] Config: Interval:10s, Quiet:false, Hostname:"dev-server", Flush Interval:10s
2024-03-22T02:27:27Z D! [agent] Initializing plugins
2024-03-22T02:27:27Z D! [inputs.gnmi] Internal alias mapping: map[openconfig:/components/component/power-supply/state:ps]
2024-03-22T02:27:27Z D! [agent] Connecting outputs
2024-03-22T02:27:27Z D! [agent] Attempting connection to [outputs.file]
2024-03-22T02:27:27Z D! [agent] Successfully connected to outputs.file
2024-03-22T02:27:27Z D! [agent] Starting service inputs
2024-03-22T02:27:27Z D! [inputs.gnmi] Connection to gNMI device DEV-SW-01:50052 established
2024-03-22T02:27:37Z D! [outputs.file] Wrote batch of 2 metrics in 503.617µs
2024-03-22T02:27:37Z D! [outputs.file] Buffer fullness: 0 / 10000 metrics

Sample output:

{
    "fields": {
        "capacity": "RDLAAA==",
        "enabled": true,
        "input_current": "PvEm6Q==",
        "input_voltage": "Q1CAAA==",
        "output_current": "P5n75w==",
        "output_power": "QolAAA==",
        "output_voltage": "QmF3zw=="
    },
    "name": "app.company.network.device.ps",
    "tags": {
        "device": "DEV-SW-01",
        "host": "dev-server",
        "name": "PowerSupply1/A",
        "telemetry_source": "network"
    },
    "timestamp": 1711075500
}

For this example, we are using the Openconfig yang model openconfig-platform-psu, is returning ieeefloat32 in binary format which is then encoded into base64 as stated in the IETF standard defined on this link.
Here is a description on one of the model leafs:
image
(image taken from YANGSUITE app)

Expected behavior

The ability of GNMI plugin to decode Base64 binary string and convert that decoded data to the required format before passing it to the output plugin.

Final expected output:

{
    "fields": {
        "capacity": 715,
        "enabled": true,
        "input_current": 0.47099998593330383,
        "input_voltage": 209,
        "output_current": 1.218999981880188,
        "output_power": 68.625,
        "output_voltage": 56.367000579833984
    },
    "name": "app.company.network.device.ps",
    "tags": {
        "device": "DEV-SW-01",
        "host": "dev-server",
        "name": "PowerSupply1/A",
        "telemetry_source": "network"
    },
    "timestamp": 1711075095
}

Values are in human readable float/int format

Actual behavior

{
    "fields": {
        "capacity": "RDLAAA==",
        "enabled": true,
        "input_current": "PvEm6Q==",
        "input_voltage": "Q1CAAA==",
        "output_current": "P5n75w==",
        "output_power": "QolAAA==",
        "output_voltage": "QmF3zw=="
    },
    "name": "app.company.network.device.ps",
    "tags": {
        "device": "DEV-SW-01",
        "host": "dev-server",
        "name": "PowerSupply1/A",
        "telemetry_source": "network"
    },
    "timestamp": 1711075500
}

Values are Base64 encoded binary strings.

Additional info

No response

@rc-networks rc-networks added the feature request Requests for new plugin and for new features to existing plugins label Mar 22, 2024
@srebhan
Copy link
Contributor

srebhan commented Mar 22, 2024

@rc-networks could you please create a configuration containing

[agent]
  debug = true

[[inputs.gnmi]]
  ...
  dump_responses = true

  [[inputs.gnmi.subscription]]
    name = "ps"
    origin = "openconfig"
    path = "/components/component/power-supply/state"
    subscription_mode = "sample"
    sample_interval = "60s"

[[outputs.file]]
  files = ["stdout"]

with the adapted inputs.gnmi settings for your device. Please run Telegraf using the above configuration and check for lines containing

... D! Got update_<timestamp>: <some JSON string>

Please post a couple of those lines as I need this for adding test cases!

@srebhan srebhan self-assigned this Mar 22, 2024
@rc-networks
Copy link
Author

Sorry about that, here is the complete (redacted) config file:

[global_tags]
  telemetry_source="network"

[agent]
  interval = "10s"
  round_interval = true
  metric_batch_size = 1000
  metric_buffer_limit = 10000
  collection_jitter = "0s"
  flush_interval = "10s"
  flush_jitter = "0s"
  precision = "0s"
  hostname = ""
  omit_hostname = false
  debug = true

[[inputs.gnmi]]
  name_prefix = "app.company.network.device."
  fieldexclude = [ # REMOVING UNWANTED DATA
    "*eula*",               # SYSTEM DESCRIPTION DATA
    "current_datetime",     # SYSTEM DESCRIPTION DATA
    "discontinuity_time",   # INTERFACE_COUNTER DATA
    # "oper_status"           # INTERFACE_STATE DATA
  ]
  dump_responses = true
  username = "${DEV_USERNAME}"
  password = "${DEV_PASSWORD}"
  encoding = "json_ietf"
  redial = "10s"
  insecure_skip_verify = true
  addresses = ["DEV-SW-01:${PORT_ADDRESS}",]
  
# power-supply
  [[inputs.gnmi.subscription]]
    name = "ps"
    origin = "openconfig"
    path = "/components/component/power-supply/state"
    subscription_mode = "sample"
    sample_interval = "60s"

# POWER SUPPLY #
################
[[processors.rename]]
  namepass = ["app.company.network.device.ps"]
  [[processors.rename.replace]]
    field = "openconfig_platform_psu:input_current"
    dest = "input_current"
  [[processors.rename.replace]]
    field = "openconfig_platform_psu:input_voltage"
    dest = "input_voltage"
  [[processors.rename.replace]]
    field = "openconfig_platform_psu:output_current"
    dest = "output_current"
  [[processors.rename.replace]]
    field = "openconfig_platform_psu:output_voltage"
    dest = "output_voltage"
  [[processors.rename.replace]]
    field = "openconfig_platform_psu:output_power"
    dest = "output_power"
  [[processors.rename.replace]]
    field = "openconfig_platform_psu:enabled"
    dest = "enabled"
  [[processors.rename.replace]]
    field = "openconfig_platform_psu:capacity"
    dest = "capacity"

[[outputs.file]]
  data_format = "json"
  files = ["stdout"]

And here is the complete CLI debug output:

2024-03-23T07:14:47Z I! Loading config: /home/dev/streaming_telemetry/telegraf.conf
2024-03-23T07:14:47Z I! Loading config: /home/dev/streaming_telemetry/telegraf.d/ios_xe.conf
2024-03-23T07:14:47Z I! Loading config: /home/dev/streaming_telemetry/telegraf.d/ios_xe_dev.conf
2024-03-23T07:14:47Z I! Loading config: /home/dev/streaming_telemetry/telegraf.d/output.conf
2024-03-23T07:14:47Z I! Loading config: /home/dev/streaming_telemetry/telegraf.d/processor.conf
2024-03-23T07:14:47Z I! Starting Telegraf 1.30.0-91ab5e95 brought to you by InfluxData the makers of InfluxDB
2024-03-23T07:14:47Z I! Available plugins: 233 inputs, 9 aggregators, 31 processors, 24 parsers, 60 outputs, 6 secret-stores
2024-03-23T07:14:47Z I! Loaded inputs: gnmi
2024-03-23T07:14:47Z I! Loaded aggregators: 
2024-03-23T07:14:47Z I! Loaded processors: converter (3x) enum rename (6x)
2024-03-23T07:14:47Z I! Loaded secretstores: 
2024-03-23T07:14:47Z I! Loaded outputs: file
2024-03-23T07:14:47Z I! Tags enabled: host=dev-server telemetry_source=network
2024-03-23T07:14:47Z I! [agent] Config: Interval:10s, Quiet:false, Hostname:"dev-server", Flush Interval:10s
2024-03-23T07:14:47Z D! [agent] Initializing plugins
2024-03-23T07:14:47Z D! [inputs.gnmi] Internal alias mapping: map[openconfig:/components/component/power-supply/state:ps]
2024-03-23T07:14:47Z D! [agent] Connecting outputs
2024-03-23T07:14:47Z D! [agent] Attempting connection to [outputs.file]
2024-03-23T07:14:47Z D! [agent] Successfully connected to outputs.file
2024-03-23T07:14:47Z D! [agent] Starting service inputs
2024-03-23T07:14:47Z D! [inputs.gnmi] Connection to gNMI device DEV-SW-01:50052 established
2024-03-23T07:14:50Z D! [inputs.gnmi] Got update_1711178737105194000: {"update":{"timestamp":"1711178737105194000", "update":[{"path":{"origin":"openconfig", "elem":[{"name":"components"}, {"name":"component", "key":{"name":"PowerSupply1/A"}}, {"name":"power-supply"}, {"name":"state"}]}, "val":{"jsonIetfVal":"eyJvcGVuY29uZmlnLXBsYXRmb3JtLXBzdTplbmFibGVkIjp0cnVlLCJvcGVuY29uZmlnLXBsYXRmb3JtLXBzdTpjYXBhY2l0eSI6IlJETEFBQT09Iiwib3BlbmNvbmZpZy1wbGF0Zm9ybS1wc3U6aW5wdXQtY3VycmVudCI6IlB2RW02UT09Iiwib3BlbmNvbmZpZy1wbGF0Zm9ybS1wc3U6aW5wdXQtdm9sdGFnZSI6IlExQ0FBQT09Iiwib3BlbmNvbmZpZy1wbGF0Zm9ybS1wc3U6b3V0cHV0LWN1cnJlbnQiOiJQNW43NXc9PSIsIm9wZW5jb25maWctcGxhdGZvcm0tcHN1Om91dHB1dC12b2x0YWdlIjoiUW1GM3p3PT0iLCJvcGVuY29uZmlnLXBsYXRmb3JtLXBzdTpvdXRwdXQtcG93ZXIiOiJRb2xBQUE9PSJ9"}}, {"path":{"origin":"openconfig", "elem":[{"name":"components"}, {"name":"component", "key":{"name":"PowerSupply1/B"}}, {"name":"power-supply"}, {"name":"state"}]}, "val":{"jsonIetfVal":"eyJvcGVuY29uZmlnLXBsYXRmb3JtLXBzdTplbmFibGVkIjp0cnVlLCJvcGVuY29uZmlnLXBsYXRmb3JtLXBzdTpjYXBhY2l0eSI6IlJETEFBQT09Iiwib3BlbmNvbmZpZy1wbGF0Zm9ybS1wc3U6aW5wdXQtY3VycmVudCI6IlBzazNUQT09Iiwib3BlbmNvbmZpZy1wbGF0Zm9ybS1wc3U6aW5wdXQtdm9sdGFnZSI6IlExSEFBQT09Iiwib3BlbmNvbmZpZy1wbGF0Zm9ybS1wc3U6b3V0cHV0LWN1cnJlbnQiOiJQM0FneFE9PSIsIm9wZW5jb25maWctcGxhdGZvcm0tcHN1Om91dHB1dC12b2x0YWdlIjoiUW1GM3p3PT0iLCJvcGVuY29uZmlnLXBsYXRmb3JtLXBzdTpvdXRwdXQtcG93ZXIiOiJRaytBQUE9PSJ9"}}]}}
{"fields":{"capacity":"RDLAAA==","enabled":true,"input_current":"PvEm6Q==","input_voltage":"Q1CAAA==","output_current":"P5n75w==","output_power":"QolAAA==","output_voltage":"QmF3zw=="},"name":"app.company.network.device.ps","tags":{"device":"DEV-SW-01","host":"dev-server","name":"PowerSupply1/A","telemetry_source":"network"},"timestamp":1711178737}
{"fields":{"capacity":"RDLAAA==","enabled":true,"input_current":"Psk3TA==","input_voltage":"Q1HAAA==","output_current":"P3AgxQ==","output_power":"Qk+AAA==","output_voltage":"QmF3zw=="},"name":"app.company.network.device.ps","tags":{"device":"DEV-SW-01","host":"dev-server","name":"PowerSupply1/B","telemetry_source":"network"},"timestamp":1711178737}
2024-03-23T07:14:57Z D! [outputs.file] Wrote batch of 2 metrics in 198.136µs
2024-03-23T07:14:57Z D! [outputs.file] Buffer fullness: 0 / 10000 metrics
2024-03-23T07:15:07Z D! [outputs.file] Buffer fullness: 0 / 10000 metrics

Please let me know if you need other info

@srebhan
Copy link
Contributor

srebhan commented Mar 25, 2024

@rc-networks for my understanding, the field values are encoded as a JSON IETF field which itself is in Base64 format. When decoding for example the first data-sample we see

{
    "openconfig-platform-psu:enabled": true,
    "openconfig-platform-psu:capacity": "RDLAAA==",
    "openconfig-platform-psu:input-current": "PvEm6Q==",
    "openconfig-platform-psu:input-voltage": "Q1CAAA==",
    "openconfig-platform-psu:output-current": "P5n75w==",
    "openconfig-platform-psu:output-voltage": "QmF3zw==",
    "openconfig-platform-psu:output-power": "QolAAA=="
}

representing the fields. Now from my understanding decoding those values require the corresponding YANG model (or at least the knowledge encoded in there) as we otherwise cannot know if the field is binary or string. Even if we could guess it's binary, we cannot know how to interpret the resulting four bytes which could encode any int64, uint64, float64, string or a real sequence of bytes.
We also cannot define the type per subscription as, depending on the YANG model node, types might be mixed in there...

Is this understanding correct?

If so, would it be feasible to provide a complete YANG model hierarchy, i.e. do you usually have all required model files available locally?

@rc-networks
Copy link
Author

rc-networks commented Mar 26, 2024

You are correct, in my experience everything are sent as a string and as you said.
(Unfortunately, I cannot find any standard or reference on why everything is sent as a string. It might just be Cisco)
We cannot really now what the device is sending unless we check that specific YANG model.

That string might just be a string or a base64 encoded string of any type (i.e. float, int, binary, etc.)
The YANG models are shipped as part of the device's software,
we can only confirm what's in a given device by grabbing all the available models on that devices programmatically (i.e. via NETCONF, RESTCONF, or YANGSUITE).

As for the model references, I usually use openconfig and YangModels/yang.

I believe the best thing we can do is to be able to decode base64 to any type.

@srebhan
Copy link
Contributor

srebhan commented Mar 26, 2024

I read RFC 7951 which is used for JSON-IETF fields according to the GNMI spec and that JSON representation indeed contains data serialized to the corresponding YANG model. So for decoding we really need to read the YANG model to know how to interpret the data.

In our case, the YANG model for the PSU encodes the data as ieeefloat32 which (unfortunately) has binary as the underlying type that's why you get the base64 encoding of the float's bytes... Converting the base64 to a string will be no good as this might (or might not) mess with the actual bytes due to conversion to UTF8...

Playing around with existing libraries, I do have a PoC to get the YANG model information but there currently is no upstream way to convert the actual data. Will probably dig deeper but this might take some time...

@srebhan
Copy link
Contributor

srebhan commented Apr 22, 2024

@rc-networks please test the binary in PR #15201, available once CI finished the tests! You need to specify a directory containing the YANG-model(s) to decode the platform-psu information. I tested with the models from https://github.com/openconfig/public and successfully decoded the values.

@srebhan srebhan added the waiting for response waiting for response from contributor label Apr 25, 2024
@powersj
Copy link
Contributor

powersj commented May 2, 2024

@rc-networks,

Are you still interested in taking a look at @srebhan's PR in #15201?

Thanks!

@telegraf-tiger telegraf-tiger bot removed the waiting for response waiting for response from contributor label May 2, 2024
@powersj powersj added the waiting for response waiting for response from contributor label May 2, 2024
@rc-networks
Copy link
Author

@powersj

Yes! I'm still interested, I just got too busy with other things at the moment.
I'll make sure to test it within this week.

@telegraf-tiger telegraf-tiger bot removed the waiting for response waiting for response from contributor label May 7, 2024
@rc-networks
Copy link
Author

@srebhan I'm sorry for being late, it looks like the artifacts are no longer available for download.

$ wget https://output.circle-artifacts.com/output/job/decb5309-fe03-4426-b7f1-0d82af5795f7/artifacts/0/build/dist/telegraf-1.31.0~9f0fabe6_linux_amd64.tar.gz
--2024-05-14 08:22:16--  https://output.circle-artifacts.com/output/job/decb5309-fe03-4426-b7f1-0d82af5795f7/artifacts/0/build/dist/telegraf-1.31.0~9f0fabe6_linux_amd64.tar.gz
Resolving output.circle-artifacts.com (output.circle-artifacts.com)... 3.164.110.30, 3.164.110.74, 3.164.110.18, ...
Connecting to output.circle-artifacts.com (output.circle-artifacts.com)|3.164.110.30|:443... connected.
HTTP request sent, awaiting response... 404 Not Found
2024-05-14 08:22:16 ERROR 404: Not Found.

@srebhan
Copy link
Contributor

srebhan commented May 14, 2024

@rc-networks I pushed the code again, a binary should be available once CI finished the tests. It might take ~30min...

@rc-networks
Copy link
Author

rc-networks commented May 14, 2024

@srebhan , I tested with the problematic one that is sending binary string data openconfig-platform-psu.yang and it worked great!

I tested with another one just to be sure (openconfig-platform.yang) in this case.
GNMI config:

# temperature
  [[inputs.gnmi.subscription]]
    name = "temperature"
    origin = "openconfig"
    path = "/components/component/state/temperature"
    subscription_mode = "sample"
    sample_interval = "60s"

Some fields worked, but others are not so lucky.
it spit out:

2024-05-14T12:56:18Z D! [inputs.gnmi]  Decoding :alarm-status failed: finding alarm-status failed: getting module "" failed: no such file: .yang
2024-05-14T12:56:18Z D! [inputs.gnmi]  Decoding :alarm-threshold failed: finding alarm-threshold failed: getting module "" failed: no such file: .yang
2024-05-14T12:56:18Z D! [inputs.gnmi]  Decoding :alarm-severity failed: finding alarm-severity failed: getting module "" failed: no such file: .yang
2024-05-14T12:56:18Z D! [inputs.gnmi]  Decoding :instant failed: finding instant failed: getting module "" failed: no such file: .yang
2024-05-14T12:56:18Z D! [inputs.gnmi]  Decoding :avg failed: finding avg failed: getting module "" failed: no such file: .yang
2024-05-14T12:56:18Z D! [inputs.gnmi]  Decoding :min failed: finding min failed: getting module "" failed: no such file: .yang
2024-05-14T12:56:18Z D! [inputs.gnmi]  Decoding :max failed: finding max failed: getting module "" failed: no such file: .yang
2024-05-14T12:56:18Z D! [inputs.gnmi]  Decoding :interval failed: finding interval failed: getting module "" failed: no such file: .yang
2024-05-14T12:56:18Z D! [inputs.gnmi]  Decoding :min failed: finding min failed: getting module "" failed: no such file: .yang
2024-05-14T12:56:18Z D! [inputs.gnmi]  Decoding :max failed: finding max failed: getting module "" failed: no such file: .yang
2024-05-14T12:56:18Z D! [inputs.gnmi]  Decoding :interval failed: finding interval failed: getting module "" failed: no such file: .yang

Additional note, here is the setting for the yang directories:

  yang_model_paths = [
    "/home/dev/public/release/models/",
    "/home/dev/public/third_party/ietf/",
  ]

basically just cloned the gh repo and pointed to the yang model folders.
Did I missed anything?

@srebhan
Copy link
Contributor

srebhan commented May 14, 2024

@rc-networks could you please dump the received data so I can debug what is going on!? I need the D! [inputs.gnmi] Got update_<timestamp>: ... lines of the debug log...

@rc-networks
Copy link
Author

rc-networks commented May 15, 2024

About that, I've been running it for some time now, but I never got the any lines with D! [inputs.gnmi] Got update_

I only got these:

2024-05-15T02:19:38Z I! Loading config: /home/dev/streaming_telemetry/telegraf.conf
2024-05-15T02:19:38Z I! Loading config: /home/dev/streaming_telemetry/telegraf.d/ios_xe.conf
2024-05-15T02:19:38Z I! Loading config: /home/dev/streaming_telemetry/telegraf.d/ios_xe_dev.conf
2024-05-15T02:19:38Z I! Loading config: /home/dev/streaming_telemetry/telegraf.d/output.conf
2024-05-15T02:19:38Z I! Loading config: /home/dev/streaming_telemetry/telegraf.d/processor.conf
2024-05-15T02:19:38Z I! Starting Telegraf 1.31.0-07c97196 brought to you by InfluxData the makers of InfluxDB
2024-05-15T02:19:38Z I! Available plugins: 234 inputs, 9 aggregators, 32 processors, 25 parsers, 60 outputs, 6 secret-stores
2024-05-15T02:19:38Z I! Loaded inputs: gnmi
2024-05-15T02:19:38Z I! Loaded aggregators: 
2024-05-15T02:19:38Z I! Loaded processors: converter (3x) enum rename (6x)
2024-05-15T02:19:38Z I! Loaded secretstores: 
2024-05-15T02:19:38Z I! Loaded outputs: file
2024-05-15T02:19:38Z I! Tags enabled: host=dev-server telemetry_source=network
2024-05-15T02:19:38Z I! [agent] Config: Interval:10s, Quiet:false, Hostname:"dev-server", Flush Interval:10s
2024-05-15T02:19:38Z D! [agent] Initializing plugins
2024-05-15T02:19:38Z D! [inputs.gnmi]  Internal alias mapping: map[openconfig:/components/component/state/temperature:temperature]
2024-05-15T02:19:38Z D! [agent] Connecting outputs
2024-05-15T02:19:38Z D! [agent] Attempting connection to [outputs.file]
2024-05-15T02:19:38Z D! [agent] Successfully connected to outputs.file
2024-05-15T02:19:38Z D! [agent] Starting service inputs
2024-05-15T02:19:38Z D! [inputs.gnmi]  Connection to gNMI device DEV-SW-01:50052 established
{"fields":{"alarm_severity":"openconfig-alarm-types:MINOR","alarm_status":false,"alarm_threshold":0,"avg":24,"instant":36,"interval":"180000000000","max":36,"min":0},"name":"app.company.network.device.temperature","tags":{"device":"DEV-SW-01","host":"dev-server","name":"InletTempSensor1","telemetry_source":"network"},"timestamp":1715740323}
{"fields":{"alarm_severity":"openconfig-alarm-types:MINOR","alarm_status":false,"alarm_threshold":0,"avg":29,"instant":44,"interval":"180000000000","max":44,"min":0},"name":"app.company.network.device.temperature","tags":{"device":"DEV-SW-01","host":"dev-server","name":"OutletTempSensor1","telemetry_source":"network"},"timestamp":1715740323}
{"fields":{"alarm_severity":"openconfig-alarm-types:MINOR","alarm_status":false,"alarm_threshold":0,"avg":39,"instant":59,"interval":"180000000000","max":59,"min":0},"name":"app.company.network.device.temperature","tags":{"device":"DEV-SW-01","host":"dev-server","name":"HotSpotTempSensor1","telemetry_source":"network"},"timestamp":1715740323}
2024-05-15T02:19:48Z D! [outputs.file]  Wrote batch of 3 metrics in 161.478µs
2024-05-15T02:19:48Z D! [outputs.file]  Buffer fullness: 0 / 10000 metrics
2024-05-15T02:19:58Z D! [outputs.file]  Buffer fullness: 0 / 10000 metrics
2024-05-15T02:20:08Z D! [outputs.file]  Buffer fullness: 0 / 10000 metrics
2024-05-15T02:20:18Z D! [outputs.file]  Buffer fullness: 0 / 10000 metrics
2024-05-15T02:20:28Z D! [outputs.file]  Buffer fullness: 0 / 10000 metrics
2024-05-15T02:20:38Z D! [outputs.file]  Buffer fullness: 0 / 10000 metrics
{"fields":{"alarm_severity":"openconfig-alarm-types:MINOR","alarm_status":false,"alarm_threshold":0,"avg":24,"instant":36,"interval":"180000000000","max":36,"min":0},"name":"app.company.network.device.temperature","tags":{"device":"DEV-SW-01","host":"dev-server","name":"InletTempSensor1","telemetry_source":"network"},"timestamp":1715740383}
{"fields":{"alarm_severity":"openconfig-alarm-types:MINOR","alarm_status":false,"alarm_threshold":0,"avg":29,"instant":44,"interval":"180000000000","max":44,"min":0},"name":"app.company.network.device.temperature","tags":{"device":"DEV-SW-01","host":"dev-server","name":"OutletTempSensor1","telemetry_source":"network"},"timestamp":1715740383}
{"fields":{"alarm_severity":"openconfig-alarm-types:MINOR","alarm_status":false,"alarm_threshold":0,"avg":39,"instant":58,"interval":"180000000000","max":59,"min":0},"name":"app.company.network.device.temperature","tags":{"device":"DEV-SW-01","host":"dev-server","name":"HotSpotTempSensor1","telemetry_source":"network"},"timestamp":1715740383}
2024-05-15T02:20:48Z D! [outputs.file]  Wrote batch of 3 metrics in 173.124µs
2024-05-15T02:20:48Z D! [outputs.file]  Buffer fullness: 0 / 10000 metrics
2024-05-15T02:20:58Z D! [outputs.file]  Buffer fullness: 0 / 10000 metrics

@srebhan
Copy link
Contributor

srebhan commented May 15, 2024

@rc-networks did you set dump_responses = true? I would need some messages that cause the error...

@rc-networks
Copy link
Author

rc-networks commented May 16, 2024

I totally forgot about that dump under the gnmi plugin.
I was only looking at the debug setting on the telegraf.conf file.

Here is output of the dump

2024-05-16T05:26:25Z D! [inputs.gnmi]  Got update_1715837931766221000: {"update":{"timestamp":"1715837931766221000", "update":[{"path":{"origin":"openconfig", "elem":[{"name":"components"}, {"name":"component", "key":{"name":"InletTempSensor1"}}, {"name":"state"}, {"name":"temperature"}]}, "val":{"jsonIetfVal":"eyJpbnN0YW50IjoiMzYuMDAwMDAwIiwiYXZnIjoiMjQuMDAwMDAwIiwibWluIjoiMC4wMDAwMDAiLCJtYXgiOiIzNi4wMDAwMDAiLCJpbnRlcnZhbCI6IjE4MDAwMDAwMDAwMCIsImFsYXJtLXN0YXR1cyI6ZmFsc2UsImFsYXJtLXRocmVzaG9sZCI6MCwiYWxhcm0tc2V2ZXJpdHkiOiJvcGVuY29uZmlnLWFsYXJtLXR5cGVzOk1JTk9SIn0="}}, {"path":{"origin":"openconfig", "elem":[{"name":"components"}, {"name":"component", "key":{"name":"OutletTempSensor1"}}, {"name":"state"}, {"name":"temperature"}]}, "val":{"jsonIetfVal":"eyJpbnN0YW50IjoiNDQuMDAwMDAwIiwiYXZnIjoiMjkuMDAwMDAwIiwibWluIjoiMC4wMDAwMDAiLCJtYXgiOiI0NC4wMDAwMDAiLCJpbnRlcnZhbCI6IjE4MDAwMDAwMDAwMCIsImFsYXJtLXN0YXR1cyI6ZmFsc2UsImFsYXJtLXRocmVzaG9sZCI6MCwiYWxhcm0tc2V2ZXJpdHkiOiJvcGVuY29uZmlnLWFsYXJtLXR5cGVzOk1JTk9SIn0="}}, {"path":{"origin":"openconfig", "elem":[{"name":"components"}, {"name":"component", "key":{"name":"HotSpotTempSensor1"}}, {"name":"state"}, {"name":"temperature"}]}, "val":{"jsonIetfVal":"eyJpbnN0YW50IjoiNTguMDAwMDAwIiwiYXZnIjoiMzguMDAwMDAwIiwibWluIjoiMC4wMDAwMDAiLCJtYXgiOiI1OC4wMDAwMDAiLCJpbnRlcnZhbCI6IjE4MDAwMDAwMDAwMCIsImFsYXJtLXN0YXR1cyI6ZmFsc2UsImFsYXJtLXRocmVzaG9sZCI6MCwiYWxhcm0tc2V2ZXJpdHkiOiJvcGVuY29uZmlnLWFsYXJtLXR5cGVzOk1JTk9SIn0="}}]}}
{"fields":{"alarm_severity":"openconfig-alarm-types:MINOR","alarm_status":false,"alarm_threshold":0,"avg":24,"instant":36,"interval":"180000000000","max":36,"min":0},"name":"app.company.network.device.temperature","tags":{"device":"DEV-SW-01","host":"dev-server","name":"InletTempSensor1","telemetry_source":"network"},"timestamp":1715837931}
{"fields":{"alarm_severity":"openconfig-alarm-types:MINOR","alarm_status":false,"alarm_threshold":0,"avg":29,"instant":44,"interval":"180000000000","max":44,"min":0},"name":"app.company.network.device.temperature","tags":{"device":"DEV-SW-01","host":"dev-server","name":"OutletTempSensor1","telemetry_source":"network"},"timestamp":1715837931}
{"fields":{"alarm_severity":"openconfig-alarm-types:MINOR","alarm_status":false,"alarm_threshold":0,"avg":38,"instant":58,"interval":"180000000000","max":58,"min":0},"name":"app.company.network.device.temperature","tags":{"device":"DEV-SW-01","host":"dev-server","name":"HotSpotTempSensor1","telemetry_source":"network"},"timestamp":1715837931}
2024-05-16T05:26:34Z D! [outputs.file]  Wrote batch of 3 metrics in 167.448µs

and here is the entire log if needed:

2024-05-16T05:30:11Z I! Loading config: /home/dev/streaming_telemetry/telegraf.conf
2024-05-16T05:30:11Z I! Loading config: /home/dev/streaming_telemetry/telegraf.d/ios_xe.conf
2024-05-16T05:30:11Z I! Loading config: /home/dev/streaming_telemetry/telegraf.d/ios_xe_dev.conf
2024-05-16T05:30:11Z I! Loading config: /home/dev/streaming_telemetry/telegraf.d/output.conf
2024-05-16T05:30:11Z I! Loading config: /home/dev/streaming_telemetry/telegraf.d/processor.conf
2024-05-16T05:30:11Z I! Starting Telegraf 1.31.0-07c97196 brought to you by InfluxData the makers of InfluxDB
2024-05-16T05:30:11Z I! Available plugins: 234 inputs, 9 aggregators, 32 processors, 25 parsers, 60 outputs, 6 secret-stores
2024-05-16T05:30:11Z I! Loaded inputs: gnmi
2024-05-16T05:30:11Z I! Loaded aggregators: 
2024-05-16T05:30:11Z I! Loaded processors: converter (3x) enum rename (6x)
2024-05-16T05:30:11Z I! Loaded secretstores: 
2024-05-16T05:30:11Z I! Loaded outputs: file
2024-05-16T05:30:11Z I! Tags enabled: host=dev-server telemetry_source=network
2024-05-16T05:30:11Z I! [agent] Config: Interval:10s, Quiet:false, Hostname:"dev-server", Flush Interval:10s
2024-05-16T05:30:11Z D! [agent] Initializing plugins
2024-05-16T05:30:11Z D! [inputs.gnmi]  Internal alias mapping: map[openconfig:/components/component/state/temperature:temperature]
2024-05-16T05:30:12Z D! [agent] Connecting outputs
2024-05-16T05:30:12Z D! [agent] Attempting connection to [outputs.file]
2024-05-16T05:30:12Z D! [agent] Successfully connected to outputs.file
2024-05-16T05:30:12Z D! [agent] Starting service inputs
2024-05-16T05:30:12Z D! [inputs.gnmi]  Connection to gNMI device DEV-SW-01:50052 established
2024-05-16T05:30:12Z D! [inputs.gnmi]  Got update_1715838159171548000: {"update":{"timestamp":"1715838159171548000", "update":[{"path":{"origin":"openconfig", "elem":[{"name":"components"}, {"name":"component", "key":{"name":"InletTempSensor1"}}, {"name":"state"}, {"name":"temperature"}]}, "val":{"jsonIetfVal":"eyJpbnN0YW50IjoiMzUuMDAwMDAwIiwiYXZnIjoiMjQuMDAwMDAwIiwibWluIjoiMC4wMDAwMDAiLCJtYXgiOiIzNi4wMDAwMDAiLCJpbnRlcnZhbCI6IjE4MDAwMDAwMDAwMCIsImFsYXJtLXN0YXR1cyI6ZmFsc2UsImFsYXJtLXRocmVzaG9sZCI6MCwiYWxhcm0tc2V2ZXJpdHkiOiJvcGVuY29uZmlnLWFsYXJtLXR5cGVzOk1JTk9SIn0="}}, {"path":{"origin":"openconfig", "elem":[{"name":"components"}, {"name":"component", "key":{"name":"OutletTempSensor1"}}, {"name":"state"}, {"name":"temperature"}]}, "val":{"jsonIetfVal":"eyJpbnN0YW50IjoiNDQuMDAwMDAwIiwiYXZnIjoiMjkuMDAwMDAwIiwibWluIjoiMC4wMDAwMDAiLCJtYXgiOiI0NC4wMDAwMDAiLCJpbnRlcnZhbCI6IjE4MDAwMDAwMDAwMCIsImFsYXJtLXN0YXR1cyI6ZmFsc2UsImFsYXJtLXRocmVzaG9sZCI6MCwiYWxhcm0tc2V2ZXJpdHkiOiJvcGVuY29uZmlnLWFsYXJtLXR5cGVzOk1JTk9SIn0="}}, {"path":{"origin":"openconfig", "elem":[{"name":"components"}, {"name":"component", "key":{"name":"HotSpotTempSensor1"}}, {"name":"state"}, {"name":"temperature"}]}, "val":{"jsonIetfVal":"eyJpbnN0YW50IjoiNTguMDAwMDAwIiwiYXZnIjoiMzkuMDAwMDAwIiwibWluIjoiMC4wMDAwMDAiLCJtYXgiOiI1OS4wMDAwMDAiLCJpbnRlcnZhbCI6IjE4MDAwMDAwMDAwMCIsImFsYXJtLXN0YXR1cyI6ZmFsc2UsImFsYXJtLXRocmVzaG9sZCI6MCwiYWxhcm0tc2V2ZXJpdHkiOiJvcGVuY29uZmlnLWFsYXJtLXR5cGVzOk1JTk9SIn0="}}]}}
2024-05-16T05:30:12Z D! [inputs.gnmi]  Decoding :interval failed: finding interval failed: getting module "" failed: no such file: .yang
2024-05-16T05:30:12Z D! [inputs.gnmi]  Decoding :alarm-status failed: finding alarm-status failed: getting module "" failed: no such file: .yang
2024-05-16T05:30:12Z D! [inputs.gnmi]  Decoding :alarm-threshold failed: finding alarm-threshold failed: getting module "" failed: no such file: .yang
2024-05-16T05:30:12Z D! [inputs.gnmi]  Decoding :alarm-severity failed: finding alarm-severity failed: getting module "" failed: no such file: .yang
2024-05-16T05:30:12Z D! [inputs.gnmi]  Decoding :instant failed: finding instant failed: getting module "" failed: no such file: .yang
2024-05-16T05:30:12Z D! [inputs.gnmi]  Decoding :avg failed: finding avg failed: getting module "" failed: no such file: .yang
2024-05-16T05:30:12Z D! [inputs.gnmi]  Decoding :min failed: finding min failed: getting module "" failed: no such file: .yang
2024-05-16T05:30:12Z D! [inputs.gnmi]  Decoding :max failed: finding max failed: getting module "" failed: no such file: .yang
2024-05-16T05:30:12Z D! [inputs.gnmi]  Decoding :instant failed: finding instant failed: getting module "" failed: no such file: .yang
2024-05-16T05:30:12Z D! [inputs.gnmi]  Decoding :avg failed: finding avg failed: getting module "" failed: no such file: .yang
2024-05-16T05:30:12Z D! [inputs.gnmi]  Decoding :min failed: finding min failed: getting module "" failed: no such file: .yang
2024-05-16T05:30:12Z D! [inputs.gnmi]  Decoding :max failed: finding max failed: getting module "" failed: no such file: .yang
2024-05-16T05:30:12Z D! [inputs.gnmi]  Decoding :interval failed: finding interval failed: getting module "" failed: no such file: .yang
2024-05-16T05:30:12Z D! [inputs.gnmi]  Decoding :alarm-status failed: finding alarm-status failed: getting module "" failed: no such file: .yang
2024-05-16T05:30:12Z D! [inputs.gnmi]  Decoding :alarm-threshold failed: finding alarm-threshold failed: getting module "" failed: no such file: .yang
2024-05-16T05:30:12Z D! [inputs.gnmi]  Decoding :alarm-severity failed: finding alarm-severity failed: getting module "" failed: no such file: .yang
2024-05-16T05:30:12Z D! [inputs.gnmi]  Decoding :avg failed: finding avg failed: getting module "" failed: no such file: .yang
2024-05-16T05:30:12Z D! [inputs.gnmi]  Decoding :min failed: finding min failed: getting module "" failed: no such file: .yang
2024-05-16T05:30:12Z D! [inputs.gnmi]  Decoding :max failed: finding max failed: getting module "" failed: no such file: .yang
2024-05-16T05:30:12Z D! [inputs.gnmi]  Decoding :interval failed: finding interval failed: getting module "" failed: no such file: .yang
2024-05-16T05:30:12Z D! [inputs.gnmi]  Decoding :alarm-status failed: finding alarm-status failed: getting module "" failed: no such file: .yang
2024-05-16T05:30:12Z D! [inputs.gnmi]  Decoding :alarm-threshold failed: finding alarm-threshold failed: getting module "" failed: no such file: .yang
2024-05-16T05:30:12Z D! [inputs.gnmi]  Decoding :alarm-severity failed: finding alarm-severity failed: getting module "" failed: no such file: .yang
2024-05-16T05:30:12Z D! [inputs.gnmi]  Decoding :instant failed: finding instant failed: getting module "" failed: no such file: .yang
{"fields":{"alarm_severity":"openconfig-alarm-types:MINOR","alarm_status":false,"alarm_threshold":0,"avg":24,"instant":35,"interval":"180000000000","max":36,"min":0},"name":"app.company.network.device.temperature","tags":{"device":"DEV-SW-01","host":"dev-server","name":"InletTempSensor1","telemetry_source":"network"},"timestamp":1715838159}
{"fields":{"alarm_severity":"openconfig-alarm-types:MINOR","alarm_status":false,"alarm_threshold":0,"avg":29,"instant":44,"interval":"180000000000","max":44,"min":0},"name":"app.company.network.device.temperature","tags":{"device":"DEV-SW-01","host":"dev-server","name":"OutletTempSensor1","telemetry_source":"network"},"timestamp":1715838159}
{"fields":{"alarm_severity":"openconfig-alarm-types:MINOR","alarm_status":false,"alarm_threshold":0,"avg":39,"instant":58,"interval":"180000000000","max":59,"min":0},"name":"app.company.network.device.temperature","tags":{"device":"DEV-SW-01","host":"dev-server","name":"HotSpotTempSensor1","telemetry_source":"network"},"timestamp":1715838159}
2024-05-16T05:30:22Z D! [outputs.file]  Wrote batch of 3 metrics in 344.124µs
2024-05-16T05:30:22Z D! [outputs.file]  Buffer fullness: 0 / 10000 metrics

@srebhan
Copy link
Contributor

srebhan commented May 16, 2024

@rc-networks thanks for the data. I pushed a change to the PR, could you please test again?

@rc-networks
Copy link
Author

@srebhan
Awesome! it's working great!

Maybe I should test every openconfig yang model that I use before we close it just to be sure

@powersj
Copy link
Contributor

powersj commented May 17, 2024

Maybe I should test every openconfig yang model that I use before we close it just to be sure

Would love the extra testing! How much time would this take?

@rc-networks
Copy link
Author

@powersj
I just finished checking for standard openconfig models that I currently use.
Did not managed to test the yang models for Cisco non standard yang modules, since I'm not yet sure where to get them.

But here's my observation for the openconfig models so far:

  1. system-memory-state:
  [[inputs.gnmi.subscription]]
    name = "memory"
    origin = "openconfig"
    path = "/system/memory/state"
    subscription_mode = "sample"
    sample_interval = "5s"

output:

2024-05-17T01:28:05Z D! [inputs.gnmi]  Got update_1715910033945511000: {"update":{"timestamp":"1715910033945511000", "update":[{"path":{"origin":"openconfig", "elem":[{"name":"system"}, {"name":"memory"}, {"name":"state"}]}, "val":{"jsonIetfVal":"eyJwaHlzaWNhbCI6Ijc5MzQzNzM4ODgiLCJyZXNlcnZlZCI6IjM2MjczOTMwMjQifQ=="}}]}}
2024-05-17T01:28:10Z D! [inputs.gnmi]  Got update_1715910038944754000: {"update":{"timestamp":"1715910038944754000", "update":[{"path":{"origin":"openconfig", "elem":[{"name":"system"}, {"name":"memory"}, {"name":"state"}]}, "val":{"jsonIetfVal":"eyJwaHlzaWNhbCI6Ijc5MzQzNzM4ODgiLCJyZXNlcnZlZCI6IjM2Mjc3NTM0NzIifQ=="}}]}}
{"fields":{"physical":"7934373888","reserved":"3627393024"},"name":"app.company.network.device.memory","tags":{"device":"DEV-SW-01","host":"dev-server","telemetry_source":"network"},"timestamp":1715910033}
{"fields":{"physical":"7934373888","reserved":"3627753472"},"name":"app.company.network.device.memory","tags":{"device":"DEV-SW-01","host":"dev-server","telemetry_source":"network"},"timestamp":1715910038}
2024-05-17T01:28:15Z D! [outputs.file]  Wrote batch of 2 metrics in 102.893µs
2024-05-17T01:28:15Z D! [outputs.file]  Buffer fullness: 0 / 10000 metrics

fields are returning as stringed integers
openconfig datatype: uint64
meaning unsigned integer? but the returned output value is a string

  1. platform-component-temp-state
[[inputs.gnmi.subscription]]
name = "temperature"
origin = "openconfig"
path = "/components/component/state/temperature"
subscription_mode = "sample"
sample_interval = "60s"

output

2024-05-17T04:44:55Z D! [inputs.gnmi]  Got update_1715921843698835000: {"update":{"timestamp":"1715921843698835000", "update":[{"path":{"origin":"openconfig", "elem":[{"name":"components"}, {"name":"component", "key":{"name":"InletTempSensor1"}}, {"name":"state"}, {"name":"temperature"}]}, "val":{"jsonIetfVal":"eyJpbnN0YW50IjoiMzcuMDAwMDAwIiwiYXZnIjoiMjQuMDAwMDAwIiwibWluIjoiMC4wMDAwMDAiLCJtYXgiOiIzNy4wMDAwMDAiLCJpbnRlcnZhbCI6IjE4MDAwMDAwMDAwMCIsImFsYXJtLXN0YXR1cyI6ZmFsc2UsImFsYXJtLXRocmVzaG9sZCI6MCwiYWxhcm0tc2V2ZXJpdHkiOiJvcGVuY29uZmlnLWFsYXJtLXR5cGVzOk1JTk9SIn0="}}, {"path":{"origin":"openconfig", "elem":[{"name":"components"}, {"name":"component", "key":{"name":"OutletTempSensor1"}}, {"name":"state"}, {"name":"temperature"}]}, "val":{"jsonIetfVal":"eyJpbnN0YW50IjoiNDUuMDAwMDAwIiwiYXZnIjoiMzAuMDAwMDAwIiwibWluIjoiMC4wMDAwMDAiLCJtYXgiOiI0NS4wMDAwMDAiLCJpbnRlcnZhbCI6IjE4MDAwMDAwMDAwMCIsImFsYXJtLXN0YXR1cyI6ZmFsc2UsImFsYXJtLXRocmVzaG9sZCI6MCwiYWxhcm0tc2V2ZXJpdHkiOiJvcGVuY29uZmlnLWFsYXJtLXR5cGVzOk1JTk9SIn0="}}, {"path":{"origin":"openconfig", "elem":[{"name":"components"}, {"name":"component", "key":{"name":"HotSpotTempSensor1"}}, {"name":"state"}, {"name":"temperature"}]}, "val":{"jsonIetfVal":"eyJpbnN0YW50IjoiNjAuMDAwMDAwIiwiYXZnIjoiNDAuMDAwMDAwIiwibWluIjoiMC4wMDAwMDAiLCJtYXgiOiI2MC4wMDAwMDAiLCJpbnRlcnZhbCI6IjE4MDAwMDAwMDAwMCIsImFsYXJtLXN0YXR1cyI6ZmFsc2UsImFsYXJtLXRocmVzaG9sZCI6MCwiYWxhcm0tc2V2ZXJpdHkiOiJvcGVuY29uZmlnLWFsYXJtLXR5cGVzOk1JTk9SIn0="}}]}}
{"fields":{"alarm_severity":"openconfig-alarm-types:MINOR","alarm_status":false,"alarm_threshold":0,"avg":"24.000000","instant":"37.000000","interval":"180000000000","max":"37.000000","min":"0.000000"},"name":"app.company.network.device.temperature","tags":{"device":"DEV-SW-01","host":"dev-server","name":"InletTempSensor1","telemetry_source":"network"},"timestamp":1715921843}
{"fields":{"alarm_severity":"openconfig-alarm-types:MINOR","alarm_status":false,"alarm_threshold":0,"avg":"30.000000","instant":"45.000000","interval":"180000000000","max":"45.000000","min":"0.000000"},"name":"app.company.network.device.temperature","tags":{"device":"DEV-SW-01","host":"dev-server","name":"OutletTempSensor1","telemetry_source":"network"},"timestamp":1715921843}
{"fields":{"alarm_severity":"openconfig-alarm-types:MINOR","alarm_status":false,"alarm_threshold":0,"avg":"40.000000","instant":"60.000000","interval":"180000000000","max":"60.000000","min":"0.000000"},"name":"app.company.network.device.temperature","tags":{"device":"DEV-SW-01","host":"dev-server","name":"HotSpotTempSensor1","telemetry_source":"network"},"timestamp":1715921843}
2024-05-17T04:45:04Z D! [outputs.file]  Wrote batch of 3 metrics in 319.008µs
2024-05-17T04:45:04Z D! [outputs.file]  Buffer fullness: 0 / 10000 metrics

openconfig datatype: decimal64
outputs are in strings


The one that was initially reported (openconfig-platform-psu) was working as expected.
Which convertes the received update from encoded strings to the correct format that was intended by the yang model.

[[inputs.gnmi.subscription]]
name = "ps"
origin = "openconfig"
path = "/components/component/power-supply/state"
subscription_mode = "sample"
sample_interval = "60s"

output:

2024-05-17T04:52:43Z D! [inputs.gnmi]  Got update_1715922312005136000: {"update":{"timestamp":"1715922312005136000", "update":[{"path":{"origin":"openconfig", "elem":[{"name":"components"}, {"name":"component", "key":{"name":"PowerSupply1/A"}}, {"name":"power-supply"}, {"name":"state"}]}, "val":{"jsonIetfVal":"eyJvcGVuY29uZmlnLXBsYXRmb3JtLXBzdTplbmFibGVkIjp0cnVlLCJvcGVuY29uZmlnLXBsYXRmb3JtLXBzdTpjYXBhY2l0eSI6IlJETEFBQT09Iiwib3BlbmNvbmZpZy1wbGF0Zm9ybS1wc3U6aW5wdXQtY3VycmVudCI6IlB2RW02UT09Iiwib3BlbmNvbmZpZy1wbGF0Zm9ybS1wc3U6aW5wdXQtdm9sdGFnZSI6IlExQ0FBQT09Iiwib3BlbmNvbmZpZy1wbGF0Zm9ybS1wc3U6b3V0cHV0LWN1cnJlbnQiOiJQNkVHSlE9PSIsIm9wZW5jb25maWctcGxhdGZvcm0tcHN1Om91dHB1dC12b2x0YWdlIjoiUW1GM3p3PT0iLCJvcGVuY29uZmlnLXBsYXRmb3JtLXBzdTpvdXRwdXQtcG93ZXIiOiJRb2xBQUE9PSJ9"}}, {"path":{"origin":"openconfig", "elem":[{"name":"components"}, {"name":"component", "key":{"name":"PowerSupply1/B"}}, {"name":"power-supply"}, {"name":"state"}]}, "val":{"jsonIetfVal":"eyJvcGVuY29uZmlnLXBsYXRmb3JtLXBzdTplbmFibGVkIjp0cnVlLCJvcGVuY29uZmlnLXBsYXRmb3JtLXBzdTpjYXBhY2l0eSI6IlJETEFBQT09Iiwib3BlbmNvbmZpZy1wbGF0Zm9ybS1wc3U6aW5wdXQtY3VycmVudCI6IlBzM1M4Zz09Iiwib3BlbmNvbmZpZy1wbGF0Zm9ybS1wc3U6aW5wdXQtdm9sdGFnZSI6IlExR0FBQT09Iiwib3BlbmNvbmZpZy1wbGF0Zm9ybS1wc3U6b3V0cHV0LWN1cnJlbnQiOiJQM0FneFE9PSIsIm9wZW5jb25maWctcGxhdGZvcm0tcHN1Om91dHB1dC12b2x0YWdlIjoiUW1GM3p3PT0iLCJvcGVuY29uZmlnLXBsYXRmb3JtLXBzdTpvdXRwdXQtcG93ZXIiOiJRaytBQUE9PSJ9"}}]}}
{"fields":{"capacity":715,"enabled":true,"input_current":0.47099998593330383,"input_voltage":208.5,"output_current":1.2580000162124634,"output_power":68.625,"output_voltage":56.367000579833984},"name":"app.company.network.device.ps","tags":{"device":"DEV-SW-01","host":"dev-server","name":"PowerSupply1/A","telemetry_source":"network"},"timestamp":1715922312}
{"fields":{"capacity":715,"enabled":true,"input_current":0.4020000100135803,"input_voltage":209.5,"output_current":0.9380000233650208,"output_power":51.875,"output_voltage":56.367000579833984},"name":"app.company.network.device.ps","tags":{"device":"DEV-SW-01","host":"dev-server","name":"PowerSupply1/B","telemetry_source":"network"},"timestamp":1715922312}
2024-05-17T04:52:50Z D! [outputs.file]  Wrote batch of 2 metrics in 269.035µs
2024-05-17T04:52:50Z D! [outputs.file]  Buffer fullness: 0 / 10000 metrics

if the goal was to only fix openconfig-platform-psu datatype handling, then the goal for this change is already achieved.
but since, we are already working with the yang models directly, it would be great to fix the datatype handling for every given yang model, right?
or would it be better to open separate feature request for that?

@srebhan
Copy link
Contributor

srebhan commented May 17, 2024

@rc-networks thanks for your report and the data. Decoding the "temperature" fields is kind of another feature as here, the JSON field not explicitly states the YANG model to use (contrary to the PSU ones) but it requires to lookup the provided path in the YANG model.

Anyway, I extended the PR to handle the above case. Please note that it can only handle int8/16/32/64, uint8/16/32/64 and decimal64 base types but I guess this accounts for a large amount of practical use...

Let me know if this helps...

@rc-networks
Copy link
Author

This change helps a lot.
Thank you!

@srebhan
Copy link
Contributor

srebhan commented May 17, 2024

So you can confirm that the PR works as intended? If so, I can mark it as ready-for-review...

@rc-networks
Copy link
Author

@srebhan Yes, as far as I can see, it's working as expected.
Thanks for the good work.
I'm gonna close this request now.

@powersj
Copy link
Contributor

powersj commented May 20, 2024

Thank you very much for confirming! I'm going to reopen, just until we review and land the PR.

@powersj powersj reopened this May 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/gnmi feature request Requests for new plugin and for new features to existing plugins
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants