cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
392
Views
2
Helpful
7
Replies

Correct yang path with gnmic

dbillon
Level 1
Level 1

Hi,

I'm trying to use gnmic to gather some QFP stats on a Cisco C83000-1N1S-6T running IOS 17.12.04

I managed to fetch simple counters like:

gnmic get --path '/interfaces/interface[name=GigabitEthernet0/0/0]/state'

But I can't figure out the right path to fetch a counter from Cisco-IOS-XE-qfp-stats.yang.

Even when I use "gnmic prompt" feature I don't get the requested values:

% gnmic prompt --file /home/user01/10-gnmic/yang/vendor/cisco/xe/17121/Cisco-IOS-XE-qfp-stats.yang --suggest-with-origin
gnmic> get --path Cisco-IOS-XE-qfp-stats:/global-drop-statistics
target "ce1" Get request failed: "1.2.3.4:50052" GetRequest failed: rpc error: code = OutOfRange desc = Unsupported Path::Origin value[ cisco-ios-xe-qfp-stats ] in Request
Error: one or more requests failed

I successfully used Yang Suite to fetch a QFP value but I can't figure out how to translate this working RPC into a correct gnmic path:

{
  "path": [
    {
      "origin": "rfc7951",
      "elem": [
        {
          "name": "Cisco-IOS-XE-qfp-stats-oper:qfp-stats-oper-data"
        },
        {
          "name": "location"
        },
        {
          "name": "datapath-qfp-stats"
        },
        {
          "name": "ipsec-input-pkts"
        }
      ]
    }
  ],
  "encoding": "JSON_IETF"
}

Any idea ?

Thanks, Damien.

1 Accepted Solution

Accepted Solutions

Hmmm interesting, try adding the rfc at the start, it’s complaining about the prefix

gnmic get --path 'rfc7951:/qfp-stats-oper-data/location/datapath-qfp-stats/ipsec-input-pkts' --encoding json_ietf

Please mark this as helpful or solution accepted to help others
Connect with me https://bigevilbeard.github.io

View solution in original post

7 Replies 7

Looks like the issue is the origin part, but gnmic is trying to use the 

Cisco-IOS-XE-qfp-stats

try gnmic get --path '/Cisco-IOS-XE-qfp-stats-oper:qfp-stats-oper-data/location/datapath-qfp-stats/ipsec-input-pkts' --encoding json_ietf

Please mark this as helpful or solution accepted to help others
Connect with me https://bigevilbeard.github.io

Hey,

Unfortunately I still get an error:

% gnmic get --path '/Cisco-IOS-XE-qfp-stats-oper:qfp-stats-oper-data/location/datapath-qfp-stats/ipsec-input-pkts' --encoding json_ietf
target "ce1" Get request failed: "1.2.3.4:50052" GetRequest failed: rpc error: code = InvalidArgument desc = Invalid element name [ Cisco-IOS-XE-qfp-stats-oper:qfp-stats-oper-data ] : unexpected prefix[ Cisco-IOS-XE-qfp-stats-oper ]
Error: one or more requests failed

I also checked that the yang model appears in the capabilities of the router:

...
  - Cisco-IOS-XE-qfp-classification-oper, Cisco Systems, Inc., 2022-11-01
  - Cisco-IOS-XE-qfp-crypto-dp-oper, Cisco Systems, Inc., 2022-11-01
  - Cisco-IOS-XE-qfp-resource-utilization-oper, Cisco Systems, Inc., 2022-11-01
  - Cisco-IOS-XE-qfp-stats-oper, Cisco Systems, Inc., 2022-11-01
...

Damien.

Hmmm interesting, try adding the rfc at the start, it’s complaining about the prefix

gnmic get --path 'rfc7951:/qfp-stats-oper-data/location/datapath-qfp-stats/ipsec-input-pkts' --encoding json_ietf

Please mark this as helpful or solution accepted to help others
Connect with me https://bigevilbeard.github.io

Yes !! it works

% gnmic get --path 'rfc7951:/qfp-stats-oper-data/location/datapath-qfp-stats/ipsec-input-pkts' --encoding json_ietf
[
  {
    "source": "ce1",
    "timestamp": 1765700017973147739,
    "time": "2025-12-14T09:13:37.973147739+01:00",
    "updates": [
      {
        "Path": "rfc7951:Cisco-IOS-XE-qfp-stats-oper:qfp-stats-oper-data/location[bay=0][chassis=-1][fru=fru-fp][node=0][slot=0]/datapath-qfp-stats/ipsec-input-pkts",
        "values": {
          "Cisco-IOS-XE-qfp-stats-oper:qfp-stats-oper-data/location/datapath-qfp-stats/ipsec-input-pkts": "18"
        }
      }
    ]
  }
]

 I'll have to understand when to add this origin depending on the namespace I use. On some docs it's said that a path without the rf7951 should work but it does not at least with this IOS release.

Thanks again, Damien.

 

NicoRomsom
Level 1
Level 1

 

Use this gnmic command without the module prefix:

 

 
gnmic get --path '/qfp-stats-oper-data/location/datapath-qfp-stats/ipsec-input-pkts' --encoding json_ietf
 

If it fails, add --origin rfc7951.

Jesus Illescas
Cisco Employee
Cisco Employee

@dbillon from a conversation with another coworker in the past, he shared the origin is client specific and that gnmic uses the <origin>:<path> format. So this is mostly a gnmic specific consideration and that's why I think docs say different things if they use another client.

if the origin is not specified it defaults to openconfig in gnmic

Hi Jesus / All,

Thanks for this update.

I would like to share another feedback regarding the use of gnmic.

My initial purpose was to subscribe to the previous parameter but it's been impossible:

% gnmic --debug sub  --output output1 --sample-interval 10s --stream-mode sample --path 'rfc7951:/qfp-stats-oper-data/location/datapath-qfp-stats/ipsec-input-pkts'

This command is accepted by gnmic but the "output" is not populated despite the fact that gnmic receives feedback from the router every 10 seconds (tshark packet dump). Nothing came out of the debug option added to the gnmic command. So I opened an Issue on gnmic github with all the details. BTW, gnmic subscriptions work perfectly with more standard counters.

So I chose Telegraf to be able to subscribe to this parameter and it works ! It share an extract of my telegraf.conf configuration file below. It shows that the path is different from the one I used with "gnmic get" command:

  ...
    origin = "rfc7951"
    path = "/Cisco-IOS-XE-qfp-stats-oper:qfp-stats-oper-data/location/datapath-qfp-stats/ipsec-input-pkts"
  ...

So I will go on now to build my full stack : Telegraf + Victoria Metrics + Grafana.

Hope this helps.

Damien.