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 - failed to parse JSON value #15975

Open
rmcleitao opened this issue Oct 3, 2024 · 1 comment
Open

gNMI - failed to parse JSON value #15975

rmcleitao opened this issue Oct 3, 2024 · 1 comment
Assignees
Labels
bug unexpected problem or unintended behavior

Comments

@rmcleitao
Copy link

rmcleitao commented Oct 3, 2024

Relevant telegraf.conf

[[inputs.gnmi.subscription]]
name = "cisco_gnmi_client"
origin = "rfc7951"
path = "/Cisco-IOS-XE-wireless-client-oper:client-oper-data/common-oper-data"
subscription_mode = "sample"
sample_interval = "120s"

[[inputs.gnmi.tag_subscription]]
name = "descr"
origin = "rfc7951"
path = "/Cisco-IOS-XE-wireless-client-oper:client-oper-data/common-oper-data/ap-name"
subscription_mode = "sample"
sample_interval = "120s"
match = "elements"
elements = ["common-oper-data"]

[[inputs.gnmi.tag_subscription]]
name = "descr"
origin = "rfc7951"
path = "/Cisco-IOS-XE-wireless-client-oper:client-oper-data/common-oper-data/username"
subscription_mode = "sample"
sample_interval = "120s"
match = "elements"
elements = ["common-oper-data"]

[[inputs.gnmi.subscription]]
name = "cisco_gnmi_client"
origin = "rfc7951"
path = "/Cisco-IOS-XE-wireless-client-oper:client-oper-data/common-oper-data/co-state"
subscription_mode = "sample"
sample_interval = "120s"

Logs from Telegraf

2024-10-03T07:33:52Z E! [inputs.gnmi] Processing update path:{origin:"rfc7951"  elem:{name:"Cisco-IOS-XE-wireless-client-oper:client-oper-data"}  elem:{name:"common-oper-data"  key:{key:"client-mac"  value:"30:03:c8:b7:00:00"}}  elem:{name:"username"}}  val:{json_ietf_val:"\"MCH\\mabconline\""} failed: failed to parse JSON value: invalid character 'm' in string escape code
(...)
2024-10-03T07:51:52Z E! [inputs.gnmi] Processing update path:{origin:"rfc7951"  elem:{name:"Cisco-IOS-XE-wireless-client-oper:client-oper-data"}  elem:{name:"common-oper-data"  key:{key:"client-mac"  value:"16:8a:62:88:00:00"}}  elem:{name:"username"}}  val:{json_ietf_val:"\"mch\\salesx\""} failed: failed to parse JSON value: invalid character 's' in string escape code

System info

From Telegraf 1.26.3 up to Telegraf 1.32.0

Docker

No response

Steps to reproduce

  1. Make a gNMI request where the response tag has "\" in the value

Expected behavior

Tags should get the correct value:
username= "MCH\mabconline"
username = "mch\salesx"

Actual behavior

Tags get the correct value:
username= None
username = None

Additional info

Using Cisco YANG Suite it returns correctly:

Request:

{
  "path": [
    {
      "origin": "rfc7951",
      "elem": [
        {
          "name": "Cisco-IOS-XE-wireless-client-oper:client-oper-data"
        },
        {
          "name": "common-oper-data",
          "key": {
            "client-mac": ""
          }
        },
        {
          "name": "ap-name"
        }
      ]
    },
    {
      "origin": "rfc7951",
      "elem": [
        {
          "name": "Cisco-IOS-XE-wireless-client-oper:client-oper-data"
        },
        {
          "name": "common-oper-data",
          "key": {
            "client-mac": ""
          }
        },
        {
          "name": "username"
        }
      ]
    }
  ],
  "encoding": "JSON_IETF"
}

Response:

val {
  json_ietf_val: "{"client-mac":"30:03:c8:b7:00:00","ap-name":"0298-X-AP000","ms-ap-slot-id":1,"ms-radio-type":"client-dot11ax-5ghz-prot","wlan-id":1,"client-type":"dot11-client-normal","co-state":"client-status-run","aaa-override-passphrase":false,"is-tvi-enabled":false,"wlan-policy":{"current-switching-mode":"local","wlan-switching-mode":"local","central-authentication":"client-authentication-type-central","central-dhcp":false,"central-assoc-enable":false,"vlan-central-switching":false,"is-fabric-client":false,"is-guest-fabric-client":false,"upn-bit-flag":[null]},"username":"MCH\\mabconline","guest-lan-client-info":{"wired-vlan":0,"phy-ifid":0,"idle-time-seconds":0},"method-id":"dot1x-auth-id","l3-vlan-override-received":false,"upn-id":0,"is-locally-administered-mac":false,"idle-timeout":0,"idle-timestamp":"1970-01-01T00:00:00+00:00"}"
}
@rmcleitao rmcleitao added the bug unexpected problem or unintended behavior label Oct 3, 2024
@srebhan
Copy link
Member

srebhan commented Oct 8, 2024

Next steps: reproduce locally.

@srebhan srebhan self-assigned this Oct 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

2 participants