openconfig / gnmi-gateway

A modular, distributed, and highly available service for modern network telemetry via OpenConfig and gNMI
Apache License 2.0
137 stars 32 forks source link

Cisco XR gnmi streaming telemetry error: unsupported encoding: JSON (need proto) #22

Closed lzwaan closed 3 years ago

lzwaan commented 3 years ago

Many thanks for this great opensource project! The cisco router is configured for gnmi. But i believe as soon as i use Dial in mode, the data will be encode in proto. So i have to create a custom target loader and give argument: -TargetLoaders=proto ?

When i tried with the default -TargetLoaders=json, i get: (target "Cisco XR") failed: rpc error: code = Unimplemented desc = gNMI: subscribe: unsupported encoding: JSON;

I tried another package gnmic (https://github.com/karimra/gnmic) which is working fine but is missing the distributed options via zookeeper which i like very much. But at least i know the Cisco router has good connectivity and configured correctly.

I am not that experienced in the golang language, can you please give me an hint how to get it ready for proto encoding..?

Thanks in advance, Lars

colinmcintosh commented 3 years ago

Hi! It looks like you may be hitting an error with the gNMI subscription requesting the wrong encoding from the target device. This field can be specified in the SubscribtionList in the JSON Target Loader. Could you try something similar to this example where the encoding field is set to PROTO:

$ cat targets.json
{
  "request": {
    "default": {
      "subscribe": {
        "encoding: "PROTO",
        "prefix": {
        },
        "subscription": [
          {
            "path": {
              "elem": [
                {
                  "name": "interfaces"
                }
              ]
            }
          }
        ]
      }
    }
  },
  "target": {
    ...
  }
}
colinmcintosh commented 3 years ago

Hi @lzwaan, just wanted to check and see if you needed anything else with issue. I'm going to close this issue but if you have further questions feel free to comment and this can be re-opened.