# Finding the correct YANG model

Configure MDT using the solution from the first lab, if it is not already configured.

```
#XR1
telemetry model-driven
 destination-group TIG
  address-family ipv4 10.100.100.1 port 57500
   encoding self-describing-gpb
   protocol grpc no-tls
  !
 !
 sensor-group SENSOR1
  sensor-path Cisco-IOS-XR-infra-statsd-oper:infra-statistics/interfaces/interface/latest/generic-counters
 !
 subscription SUB1
  sensor-group-id SENSOR1 sample-interval 5000
  destination-id TIG
```

Add an additional sensor-path which exports the number of routes in the RIB from ISIS 1.

## Answer <a href="#id-0185a7ed-ffd1-4976-8798-09d5fd079d8a" id="id-0185a7ed-ffd1-4976-8798-09d5fd079d8a"></a>

```
telemetry model-driven
 sensor-group SENSOR1
  sensor-path Cisco-IOS-XR-ip-rib-ipv4-oper:rib/vrfs/vrf[vrf-name="default"]/afs/af[af-name="IPv4"]/safs/saf[saf-name="Unicast"]/ip-rib-route-table-names/ip-rib-route-table-name[route-table-name="default"]/protocol/isis/as[as='1']/information
```

## Explanation <a href="#ca04e9da-b5b4-4b61-b5d5-6d4aa5cd2a78" id="ca04e9da-b5b4-4b61-b5d5-6d4aa5cd2a78"></a>

This is quite tricky. First, I found a YANG model for the IPv4 RIB using the following tool:

```
yang-describe operational show route
```

This gave me:

```
Cisco-IOS-XR-ip-rib-ipv4-oper:rib/vrfs/vrf/afs/af/safs/saf/ip-rib-route-table-names/ip-rib-route-table-name/routes/route
```

From here, I found the following tutorial on xrdocs, which I based the path on: <https://xrdocs.io/telemetry/tutorials/2016-12-23-streaming-bgp-route-and-neighbor-counts-with-mdt/>

I found that I needed to specify the vrf, af-name, saf-name, route-table-name, and ISIS AS.

We can actually get the first four keys from the path that was given from the first **yang-describe** command.

<div align="left"><figure><img src="https://3072390383-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkUz2C3GqnZcWhoVL6jfk%2Fuploads%2FwQPcJsXsyrIhxpPsiX1f%2Fimage.png?alt=media&#x26;token=51021fe3-7469-4b0b-bdc1-9f31f2a56a34" alt=""><figcaption></figcaption></figure></div>

From here, knowing that there is a /protocol/ path might be difficult. I would not have found that unless I found the xrdocs page.

Use the following Grafana query:

```
from(bucket: "telemetry")
  |> range(start: v.timeRangeStart, stop:v.timeRangeStop)
  |> filter(fn: (r) =>
    r._measurement == "Cisco-IOS-XR-ip-rib-ipv4-oper:rib/vrfs/vrf/afs/af/safs/saf/ip-rib-route-table-names/ip-rib-route-table-name/protocol/isis/as/information" and
    r._field == "active_routes_count"
  )
```

I shutdown XR2’s loopback1 and brought it back up to test that the data stream works. The counter goes from 3, to 2, and back to 3.

<div align="left"><figure><img src="https://3072390383-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkUz2C3GqnZcWhoVL6jfk%2Fuploads%2FoIrZbo9S9IR30wZow9yt%2Fimage.png?alt=media&#x26;token=aac94a12-59c0-40ab-b774-a995589efc8f" alt=""><figcaption></figcaption></figure></div>
