# Create Alerts for Multiple Location Failures Using DQL

**URL:** <https://community.dynatrace.com/t/create-alerts-for-multiple-location-failures-using-dql/48768>\
**Category:** DQL\
**Tags:** dql\
**Created:** [November 6, 2024, 4:07pm UTC](https://community.dynatrace.com/t/create-alerts-for-multiple-location-failures-using-dql/48768 "2024-11-06T16:07:42Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![sivart\_89](https://avatars.discourse-cdn.com/v4/letter/s/848f3c/32.png) [@sivart\_89](https://community.dynatrace.com/u/sivart_89)\
**Post date:** [November 6, 2024, 4:07pm UTC](https://community.dynatrace.com/t/create-alerts-for-multiple-location-failures-using-dql/48768/1 "2024-11-06T16:07:42Z")

</div>

I’m trying to essentially duplicate this type of alerting but with a custom alert in the Davis anomaly detection app. What I’m struggling most with is the ‘3 times consecutively’ part. The synthetic I am working with runs every 5 minutes, any ideas of a DQL that would work for this? I have some simple code below, it just needs to be improved upon.

 ![sivart_89_0-1730908684096.png](https://global.discourse-cdn.com/dynatrace/original/3X/7/3/73412912fbaad7dc2cb96afaa0dc68206b9643c0.png)

timeseries synthetics\_v = avg(dt.synthetic.browser.availability), by: {dt.entity.synthetic\_test, dt.entity.synthetic\_location}, interval: 5m  
| fieldsAdd syntheticName = entityName(dt.entity.synthetic\_test)  
| fieldsAdd locationName = entityName(dt.entity.synthetic\_location)  
| filter contains(syntheticName, “\<synthetic name\>”)

---

<div class="post-metadata">

**Author:** ![p\_devulapalli](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/p_devulapalli/32/41590_2.png) [@p\_devulapalli](https://community.dynatrace.com/u/p_devulapalli)\
**Post date:** [November 8, 2024, 12:05am UTC](https://community.dynatrace.com/t/create-alerts-for-multiple-location-failures-using-dql/48768/2 "2024-11-08T00:05:17Z")

</div>

[@sivart\_89](https://community.dynatrace.com/user/17361)&nbsp;- I think you can achieve it by using violating samples and sliding window in advanced properties of anomaly detector app

> **[Anomaly detection configuration](https://docs.dynatrace.com/docs/dynatrace-intelligence/anomaly-detection/anomaly-detection-configuration)**
>
> How to set up an alert for missing measurements.

 ![p_devulapalli_0-1731024096217.png](https://global.discourse-cdn.com/dynatrace/original/2X/b/bd81859d8bb41b818002c5b8782c276fe99aa623.png)

---

<div class="post-metadata">

**Author:** ![sivart\_89](https://avatars.discourse-cdn.com/v4/letter/s/848f3c/32.png) [@sivart\_89](https://community.dynatrace.com/u/sivart_89)\
**Post date:** [November 11, 2024, 3:39pm UTC](https://community.dynatrace.com/t/create-alerts-for-multiple-location-failures-using-dql/48768/3 "2024-11-11T15:39:23Z")

</div>

If I set it up this way then an alert will get created when a single location fails 3 times within a 5 minute window. There’s 2 things I see wrong with this. First, I need it to alert when there are 3 consecutive failures and second, I only need an alert if 2 locations fail 3 times consecutive, I don’t want an alert if just 1 single location is failing.

---

<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 18, 2025, 12:56pm UTC](https://community.dynatrace.com/t/create-alerts-for-multiple-location-failures-using-dql/48768/4 "2025-12-18T12:56:31Z")

</div>

Hey&nbsp;[@sivart\_89](https://community.dynatrace.com/user/17361)&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.

---

<div class="post-metadata">

**Author:** ![t\_pawlak](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/t_pawlak/32/14991_2.png) [@t\_pawlak](https://community.dynatrace.com/u/t_pawlak)\
**Post date:** [December 18, 2025, 2:01pm UTC](https://community.dynatrace.com/t/create-alerts-for-multiple-location-failures-using-dql/48768/5 "2025-12-18T14:01:49Z")

</div>

Hi,  
What you’re missing is that “3 consecutive failures” can’t be reliably expressed with violating samples or sliding windows alone, especially when you also need multi-location logic.

So, I think i find other solution, something like workaround. A practical way to model consecutive failures in DQL is to treat them as continuous failure over the evaluation window.  
For a browser synthetic running every 5 minutes,  
3 consecutive runs = 15 minutes of continuous failure.

You can express this in DQL by checking that all samples in the window failed, and then counting how many locations meet that condition.

Example DQL:

```markup
timeseries avail = avg(dt.synthetic.browser.availability),
by:{dt.entity.synthetic_test, dt.entity.synthetic_location},
interval:5m
| fieldsAdd syntheticName = entityName(dt.entity.synthetic_test)
| fieldsAdd locationName = entityName(dt.entity.synthetic_location)
| filter syntheticName == "<synthetic name>"
| fieldsAdd
    samples = arraySize(avail),
    maxAvail = arrayMax(avail)
| filter samples >= 3
| filter maxAvail < 1
| summarize
    failing_locations = count(),
    by:{dt.entity.synthetic_test}
| filter failing_locations >= 2

```

arrayMax(avail) \< 1 guarantees there was no successful execution in the window → truly consecutive failures

samples \>= 3 ensures at least 3 runs were evaluated

failing\_locations \>= 2 enforces the multi-location condition

In Davis Anomaly Detection, configure:

Evaluation window: 15 minutes

Evaluation frequency: 5 minutes

Trigger condition: Result exists

No sliding window / violating samples needed

Try this and give me feedback. I test it, but I don’t have test with 3 failures.
