# Davis alert for interface count changes per device (7-day comparison)

**URL:** <https://community.dynatrace.com/t/davis-alert-for-interface-count-changes-per-device-7-day-comparison/53864>\
**Category:** DQL\
**Tags:** dql, dynatrace-managed, davis, notebooks\
**Created:** [October 27, 2025, 8:53am UTC](https://community.dynatrace.com/t/davis-alert-for-interface-count-changes-per-device-7-day-comparison/53864 "2025-10-27T08:53:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![RaidanAlmaqtari](https://avatars.discourse-cdn.com/v4/letter/r/da6949/32.png) [@RaidanAlmaqtari](https://community.dynatrace.com/u/RaidanAlmaqtari)\
**Post date:** [October 27, 2025, 8:53am UTC](https://community.dynatrace.com/t/davis-alert-for-interface-count-changes-per-device-7-day-comparison/53864/1 "2025-10-27T08:53:41Z")

</div>

Hi everyone,  
I’d like to create a Davis anomaly detection (DQL event) that triggers when the number of interfaces (ports) on a network device changes between two time periods (e.g., previous 7 days vs current 7 days).

My initial attempts used a traffic/discards metric and rolling sums, but that’s not ideal when I only need to know how many interfaces exist (or report data) in each period. I think the right approach is to count distinct interfaces per device per period and compare.

Does the DQL below look correct? Is there a simpler/better way?

Goal

Count distinct interfaces per device for last week and this week

Join the two results

Calculate the difference

Trigger a Davis event if the count changed (non-zero difference)

Thanks

timeseries sum(`com.dynatrace.extension.palo-alto.generic.if.in.discards.count`, default: 0),  
by: { `dt.entity.network:interface`, `dt.entity.network:device` },  
from: now() - 14d, to: now() -7d, interval: 1m  
| fieldsAdd prev\_roll = arrayMovingSum(`sum(\`com.dynatrace.extension.palo-alto.generic.if.in.discards.count\`, default:0)`, windowsize: 60)  
| fieldsAdd aligned\_key = toTimestamp(toLong(timeframe[start]) + 604800000.0)  
// | fieldsKeep `dt.entity.network:interface`, `dt.entity.network:device`, aligned\_key, prev\_roll

| join [  
timeseries sum(`com.dynatrace.extension.palo-alto.generic.if.in.discards.count`, default: 0),  
by: { `dt.entity.network:interface`, `dt.entity.network:device` },  
from: now() - 7d, to: now(), interval: 1m  
| fieldsAdd curr\_roll = arrayMovingSum(`sum(\`com.dynatrace.extension.palo-alto.generic.if.in.discards.count\`, default:0)`, windowsize: 60)

| fieldsAdd aligned\_key = timeframe[start]  
| fieldsKeep `dt.entity.network:interface`, `dt.entity.network:device`, aligned\_key, curr\_roll  
], on: { `dt.entity.network:interface`, `dt.entity.network:device`,aligned\_key}

---

<div class="post-metadata">

**Author:** ![izabelarokita](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/izabelarokita/32/41812_2.png) [@izabelarokita](https://community.dynatrace.com/u/izabelarokita)\
**Post date:** [December 17, 2025, 10:04am UTC](https://community.dynatrace.com/t/davis-alert-for-interface-count-changes-per-device-7-day-comparison/53864/2 "2025-12-17T10:04:29Z")

</div>

Hey&nbsp;[@RaidanAlmaqtari](https://community.dynatrace.com/user/95545)&nbsp;,  
I just wanted to check in and see if you still need help with this. If so, I’d be happy to look into it for you!&nbsp;:blush:  
Please let me know what works best for you.
