# Event-Driven MDT

Configure MDT as follows:

```
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[interface-name="GigabitEthernet0/0/0/0.100"]/latest/generic-counters
 !
 subscription SUB1
  destination-id TIG
```



Use event-driven MDT so that data is only sent to the collector upon a change.



Use the following query in Grafana:

```
from(bucket: "telemetry")
  |> range(start: v.timeRangeStart, stop:v.timeRangeStop)
  |> filter(fn: (r) =>
    r._measurement == "Cisco-IOS-XR-infra-statsd-oper:infra-statistics/interfaces/interface/latest/generic-counters" and
    r._field == "bytes_sent"
  )
```











































## Answer <a href="#dcd0069e-d154-481e-87c6-47eff44d1923" id="dcd0069e-d154-481e-87c6-47eff44d1923"></a>

```
telemetry model-driven
 include select-leaves-on-events
 !
 subscription SUB1
  sensor-group-id SENSOR1 sample-interval 0
```



## Explanation <a href="#id-95125e34-e39e-426e-92b5-0d06e8552658" id="id-95125e34-e39e-426e-92b5-0d06e8552658"></a>

Event-driven telemetry can be more optimal than timer-based MDT. With event-drive telemetry, data is only sent to the collector upon a change.



There seems to be a limited number of sensor-paths that can use event-driven telemetry. For example, I first tried to do this with the previous ISIS RIB path, but it didn’t work. I found this slide which appears to indicate that it only works for certain paths.

<figure><img src="https://3072390383-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkUz2C3GqnZcWhoVL6jfk%2Fuploads%2FUfDB9eVwuLVuKXNuIsy9%2Fimage.png?alt=media&#x26;token=24389cc2-765f-43cd-866f-3f8223a6b8c4" alt=""><figcaption></figcaption></figure>



To configure event-driven telemetry, you simply set the sample-interval to 0.

```
telemetry model-driven
 subscription SUB1
  sensor-group-id SENSOR1 sample-interval 0
```



We also have the below optional knob:

```
telemetry model-driven
 include select-leaves-on-events
```



This appears to mean that only when the configured leaves in the sensor path have a change (i.e. Gi0/0/0/0.100), the data will stream. Not when _any_ leaf in the path has a change.



The documentation also now differentiates between timer-based and event-based streaming by calling timer-based streaming “candence-driven telemetry.”



Note that I was not able to get this to work reliably. Perhaps it is a limitation with XRv9K and XRd. I only got one data point when I committed the config, and nothing else. Later I added the “include” knob and got another data point, but again nothing else after that.
