How To Get Telemetry sensor path for show cmd on IOS XR?

When we want to collect some show information by Telemetry, we will face the 1st question that how to find the correct/resolved sensor path. The first step often traps us. Is there any good way to easily find the sensor path? The answer is “Yes”. I had summarized a way that can help you quickly find the sensor path.

Before read the article,there is a file that mapping between YANG and Sensor Path in XR, you can check by keyword(e.g fan, cpu and so on) first, if not found, then check my article.

Tue Jan 22 06:58:56.512 UTC
[xr-vm_node0_RP0_CPU0:~]$cd /pkg/telemetry/mdt/protogen

yang_to_Schema.txt has all yang path to xml schema path maps.

1. How to get the following result by Telemetry?

At first, you need to know which yang file mapping the cmd.

RP/0/RP0/CPU0:iosxrv-2#show segment-routing traffic-eng forwarding policy name test-policy detail
Fri Feb 22 05:35:23.723 UTC
Policy        Segment         Outgoing    Outgoing            Next Hop        Bytes      
Name          List            Label       Interface                           Switched   
------------- --------------- ----------- ------------------- --------------- ------------
test-policy   test-app1       16004       Gi0/0/0/1        1040        
                 Label Stack (Top -> Bottom): { 16004 }
                 Path-id: 1, Weight: 5
                 Packets Switched: 10
              test-app2       Pop         Gi0/0/0/2        1040       
                 Label Stack (Top -> Bottom): { Pop }
                 Path-id: 2, Weight: 3
                 Packets Switched: 10
   Local label: 24000
   Packets/Bytes Switched: 20/2160
   (!): FRR pure backup

2. How to get the YANG files for the show cmd?

Now our IOS XR have a new command that can easy to achieve the requirement, as follow: 

RP/0/RP0/CPU0:iosxrv-2#schema-describe show segment-routing traffic-eng forwarding policy name test-policy detail
Fri Feb 22 07:38:31.988 UTC
Action: get
Path:   RootOper.XTC.Forwarding.PolicyForwarding({'Name': 'test-policy'})


3. How to get diff version YANG files?

Based on the above command, the “XTC.Forwarding.PolicyForwarding” is what we want. We need to filter all YANG File by the keyword. “cfg” YANG relation with configuration; “oper” relation with show cmd. So we only focus “oper” YANG files.

4. How to get correct sensor path?

Based on above filter result,  check all “oper” YANG files by pyang, then find correct files, as follow:

XXXXXXXX-M-L2HE:661-yang xxxxxxxx$ pyang --format tree --tree-depth 6 Cisco-IOS-XR-infra-xtc-agent-oper@2017-09-11.yang --tree-path /xtc/forwarding

module: Cisco-IOS-XR-infra-xtc-agent-oper
  +--ro xtc
     +--ro forwarding
        +--ro policy-forwardings
           +--ro policy-forwarding* [name]
              +--ro name                      xr:Cisco-ios-xr-string
              +--ro policy-name?              string
              +--ro is-local-label-valid?     boolean
              +--ro local-label?              uint32
              +--ro are-stats-valid?          boolean
              +--ro forwarding-stats-pkts?    uint64
              +--ro forwarding-stats-bytes?   uint64
              +--ro paths* []
                 +--ro outgoing-interface?       xr:Interface-name
                 +--ro next-hop-ipv4?            Xtc-ipv4-address
                 +--ro next-hop-table-id?        uint32
                 +--ro is-protected?             boolean
                 +--ro is-pure-bkup?             boolean
                 +--ro load-metric?              uint32
                 +--ro path-id?                  uint8
                 +--ro bkup-path-id?             uint8
                 +--ro segment-list-name?        string
                 +--ro are-stats-valid?          boolean
                 +--ro forwarding-stats-pkts?    uint64
                 +--ro forwarding-stats-bytes?   uint64
                 +--ro label-stack*              uint32

5. Deploy Telemetry on XRv9k

RP/0/RP0/CPU0:iosxrv-2#sh run telemetry model-driven 
Fri Feb 22 08:05:37.116 UTC
telemetry model-driven
 destination-group spr-telemetry
  address-family ipv4 10.75.58.x port 5432
   encoding self-describing-gpb
   protocol tcp
 sensor-group sr-policy-forwarding
  sensor-path Cisco-IOS-XR-infra-xtc-agent-oper:xtc/forwarding
 subscription test
  sensor-group-id sr-policy-forwarding strict-timer
  sensor-group-id sr-policy-forwarding sample-interval 5000
  destination-id spr-telemetry

6. Deploy Telemetry Server by “pipeline”

More detail information, please check original article: Quick startup guide for Model Driven Telemetry testing

  • Clone the GIT project: “git clone”
  • Update file path “cp pipeline.conf pipeline-file.conf”, “vi pipeline-file.conf”: “file = /opt/dump-frank.txt”
  • Enable pipeline by “./bin/pipeline -log= -config=pipeline-file.conf”
[root@telemetry bigmuddy-network-telemetry-pipeline]# ./bin/pipeline -log= -config=pipeline-file.conf &
[1] 20204
[root@telemetry bigmuddy-network-telemetry-pipeline]# INFO[2019-02-22 13:31:44.592956] Conductor says hello, loading config          config=pipeline-file.conf debug=false fluentd= logfile= max"
INFO[2019-02-22 13:31:44.593665] Conductor starting up section                 name=conductor section=inspector stage="xport_output" tag=pipeline
INFO[2019-02-22 13:31:44.593700] Conductor starting up section                 name=conductor section=testbed stage="xport_input" tag=pipeline
INFO[2019-02-22 13:31:44.594042] TCP server starting                           listen=":5432" name=testbed tag=pipeline
INFO[2019-02-22 13:31:44.594082] Metamonitoring: serving pipeline metrics to prometheus  name=default resource="/metrics" server=":8989" tag=pipeline
INFO[2019-02-22 13:31:44.594133] Starting up tap                               countonly=false filename="/opt/dump-frank.txt" name=inspector streamSpec=&{2 <nil>} tag=pipeline

INFO[2019-02-22 13:32:01.417426] TCP server accepted connection                encap=st keepalive=0s local="10.75.177.x:5432" name=testbe

7. Check Telemetry status and sensor status

RP/0/RP0/CPU0:iosxrv-2#show telemetry model-driven subscription test internal 
Fri Feb 22 05:24:29.874 UTC
Subscription:  test
  State:       ACTIVE <<<
  Sensor groups:
  Id: sr-policy-forwardin
    Sample Interval:      5000 ms
    Sensor Group State:   Not Configured
  Id: sr-policy-forwarding
    Sample Interval:      0 ms
    Sensor Path:          Cisco-IOS-XR-infra-xtc-agent-oper:xtc/forwarding
    Sensor Path State:    Resolved  <<<

  Destination Groups:
  Group Id: spr-telemetry
    Destination IP:       10.75.58.x
    Destination Port:     5432
    Encoding:             self-describing-gpb
    Transport:            tcp
    State:                Active
    No TLS                
    Total bytes sent:     1028
    Total packets sent:   1
    Last Sent time:       2019-02-22 05:22:19.3327875298 +0000
  Collection Groups:
    Id: 1
    Sample Interval:      0 ms (strict-timer)
    Encoding:             self-describing-gpb
    Num of collection:    1
    Collection time:      Min:    14 ms Max:    14 ms
    Total time:           Min:    15 ms Avg:    15 ms Max:    15 ms
    Total Deferred:       2
    Total Send Errors:    0
    Total Send Drops:     0
    Total Other Errors:   0
    No data Instances:    0
    Last Collection Start:2019-02-22 05:22:19.3327860298 +0000
    Last Collection End:  2019-02-22 05:22:19.3327875298 +0000
    Sensor Path:          Cisco-IOS-XR-infra-xtc-agent-oper:xtc/forwarding

      Sysdb Path:     /oper/xtc/gl/fwd/policy/*
      Count:          1 Method: DATALIST Min: 14 ms Avg: 14 ms Max: 14 ms
      Item Count:     3 Status: Eventing Not Active
      Missed Collections:0  send bytes: 1016 packets: 1 dropped bytes: 0
                      success         errors          deferred/drops  
      Gets            0               0               
      List            0               0               
      Datalist        3               0               
      Finddata        0               0               
      GetBulk         0               0               
      Encode                          0               2               
      Send                            0               0   

RP/0/RP0/CPU0:iosxrv-2#show telemetry model-driven subscription               
Fri Feb 22 05:26:48.532 UTC
Subscription:  test                     State: ACTIVE
  Sensor groups:
  Id                               Interval(ms)        State     
  sr-policy-forwarding             5000                Resolved  

  Destination Groups:
  Id                 Encoding            Transport   State   Port    Vrf     IP            
  spr-telemetry      self-describing-gpb tcp         Active  5432            10.75.58.x   
    No TLS            

8. Check Telemetry output

[root@telemetry bigmuddy-network-telemetry-pipeline]# more /opt/dump-frank.txt 

------- 2019-02-22 13:32:36.440485402 +0800 CST -------
Summary: GPB(common) Message [10.75.177.x:47896(iosxrv-2)/Cisco-IOS-XR-infra-xtc-agent-oper:xtc/forwarding/policy-forwardings/policy-forwarding msg len: 1016]
    "Source": "10.75.177.x:47896",
    "Telemetry": {
        "node_id_str": "iosxrv-2",
        "subscription_id_str": "test",
        "encoding_path": "Cisco-IOS-XR-infra-xtc-agent-oper:xtc/forwarding/policy-forwardings/policy-forwarding",
        "collection_id": 53,
        "collection_start_time": 1550813493363,
        "msg_timestamp": 1550813493363,
        "collection_end_time": 1550813493372
    "Rows": [
            "Timestamp": 1550813493371,
            "Keys": {
                "name": "test-policy"
            "Content": {
                "are-stats-valid": "true",
                "forwarding-stats-bytes": 2160,
                "forwarding-stats-pkts": 20,
                "is-local-label-valid": "true",
                "local-label": 24000,
                "path_PIPELINE_EDIT": [
                        "are-stats-valid": "true",
                        "bkup-path-id": 0,
                        "forwarding-stats-bytes": 1040,
                        "forwarding-stats-pkts": 10,
                        "is-protected": "false",
                        "is-pure-bkup": "false",
                        "label-stack": 16004,
                        "load-metric": 5,
                        "next-hop-ipv4": "",
                        "next-hop-table-id": 3758096384,
                        "outgoing-interface": "GigabitEthernet0/0/0/1",
                        "path-id": 1,
                        "segment-list-name": "test-app1"
                        "are-stats-valid": "true",
                        "bkup-path-id": 0,
                        "forwarding-stats-bytes": 1040,
                        "forwarding-stats-pkts": 10,
                        "is-protected": "false",
                        "is-pure-bkup": "false",
                        "label-stack": 3,
                        "load-metric": 3,
                        "next-hop-ipv4": "",
                        "next-hop-table-id": 3758096384,
                        "outgoing-interface": "GigabitEthernet0/0/0/2",
                        "path-id": 2,
                        "segment-list-name": "test-app2"
                "policy-name": "test-policy"
你可以留言,或者trackback 从你的网站