Filtering Data using XPATH
Configure MDT using the answer from the previous 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
Change the sensor-path so that only data about gi0/0/0/0.100 is exported.
Answer
telemetry model-driven
sensor-group SENSOR1
no sensor-path Cisco-IOS-XR-infra-statsd-oper:infra-statistics/interfaces/interface/latest/generic-counters
sensor-path Cisco-IOS-XR-infra-statsd-oper:infra-statistics/interfaces/interface[interface-name="GigabitEthernet0/0/0/0.100"]/latest/generic-counters
Explanation
By using XPath filtering techniques, we can limit the output of the streamed data directly at the sensor-path level. In this lab, we limit the particular interface by using the following syntax:
interface[interface-name="GigabitEthernet0/0/0/0.106"]
How did we know to use “interface-name” and not “interface” or “if-name” etc? We can check the raw output of the MDT data by using run mdt_exec -s <sensor-path>

Above, this is of course hard to read. Additionally, you cannot use pipe filters such as |include or |grep. One alternative might be to copy the output to notepad and do a search for "keys". Another idea is to use python (run python from exec mode on IOS-XR) and use pprint to pprint the output.
We can then test that our filter works by using the same command again. Notice that we now only get data about the single interface:

Now in grafana I only see data for this one interface:

Last updated