# 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="/files/WabfQQBI3oAmjQEBSI4S" 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="/files/Er4d0hEj2Cy47KNbXHqp" alt=""><figcaption></figcaption></figure></div>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://ccie-sp.gitbook.io/ccie-spv5.1-labs/labs/mdt/finding-the-correct-yang-model.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
