# Anomaly detection with timeframe

**URL:** <https://community.dynatrace.com/t/anomaly-detection-with-timeframe/45778>\
**Category:** Alerting\
**Tags:** dynatrace-managed, timeselector, filter, anomaly-detection\
**Created:** [May 27, 2024, 2:34pm UTC](https://community.dynatrace.com/t/anomaly-detection-with-timeframe/45778 "2024-05-27T14:34:07Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![audiokarate](https://avatars.discourse-cdn.com/v4/letter/a/e47c2d/32.png) [@audiokarate](https://community.dynatrace.com/u/audiokarate)\
**Post date:** [May 27, 2024, 2:34pm UTC](https://community.dynatrace.com/t/anomaly-detection-with-timeframe/45778/1 "2024-05-27T14:34:07Z")

</div>

Hi, im new to dynatrace and Im having trouble creating an anomaly detection that will verify the increase of a metric for a period of 24h.

Here is the query im running in the data explorer page.

 ![audiokarate_0-1716820056612.png](https://global.discourse-cdn.com/dynatrace/original/2X/c/c0c979669a9e277c6a1f5ab402b2d515ba93f6aa.png)

However when I create my anomaly detection it doesnt include the 24 hours filter… Do i need to modify my query to add a timeframe if so how can i do this?

---

<div class="post-metadata">

**Author:** ![PacoPorro](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/pacoporro/32/36087_2.png) [@PacoPorro](https://community.dynatrace.com/u/PacoPorro)\
**Post date:** [May 27, 2024, 2:45pm UTC](https://community.dynatrace.com/t/anomaly-detection-with-timeframe/45778/2 "2024-05-27T14:45:51Z")

</div>

Maybe you are looking for this the&nbsp;[Metrics API - Metric selector — Dynatrace Docs](https://docs.dynatrace.com/docs/shortlink/api-metrics-v2-selector#timeshift) ?

---

<div class="post-metadata">

**Author:** ![audiokarate](https://avatars.discourse-cdn.com/v4/letter/a/e47c2d/32.png) [@audiokarate](https://community.dynatrace.com/u/audiokarate)\
**Post date:** [May 27, 2024, 5:00pm UTC](https://community.dynatrace.com/t/anomaly-detection-with-timeframe/45778/3 "2024-05-27T17:00:22Z")

</div>

i tried that before opening the ticket and its not giving me the result i need

i need to be alerted if my metric does not increase by at least 1 in the last 24 hours…

see screenshot below

 ![audiokarate_1-1716829190316.png](https://global.discourse-cdn.com/dynatrace/original/3X/3/2/324e667101d198e5ed307a3e829dc05ffdbee66d.png)

---

<div class="post-metadata">

**Author:** ![PacoPorro](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/pacoporro/32/36087_2.png) [@PacoPorro](https://community.dynatrace.com/u/PacoPorro)\
**Post date:** [May 28, 2024, 6:43am UTC](https://community.dynatrace.com/t/anomaly-detection-with-timeframe/45778/4 "2024-05-28T06:43:33Z")

</div>

Try to do a calculation

(your metrics with timeshift) - (metric without timeshift)

 ![PacoPorro_0-1716878602631.png](https://global.discourse-cdn.com/dynatrace/original/2X/8/8e53a1c730347dc56fc61bf9d6c43896c83511e2.png)

---

<div class="post-metadata">

**Author:** ![audiokarate](https://avatars.discourse-cdn.com/v4/letter/a/e47c2d/32.png) [@audiokarate](https://community.dynatrace.com/u/audiokarate)\
**Post date:** [May 28, 2024, 5:45pm UTC](https://community.dynatrace.com/t/anomaly-detection-with-timeframe/45778/5 "2024-05-28T17:45:13Z")

</div>

![audiokarate_0-1716915989724.png](https://global.discourse-cdn.com/dynatrace/original/3X/c/e/ceed09ce7ac820a680457bae95ae6592f2d8785a.png)

im having the same problem

 ![audiokarate_1-1716918283003.png](https://global.discourse-cdn.com/dynatrace/original/2X/1/172a9e6f8ca1b6dd24d5dfbd62b75489c947db0d.png)

---

<div class="post-metadata">

**Author:** ![PacoPorro](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/pacoporro/32/36087_2.png) [@PacoPorro](https://community.dynatrace.com/u/PacoPorro)\
**Post date:** [May 29, 2024, 2:39pm UTC](https://community.dynatrace.com/t/anomaly-detection-with-timeframe/45778/6 "2024-05-29T14:39:43Z")

</div>

So, livraison and observability-cac ran 163 successful backup in the last 24h, and also 163 in the interval from -42h to -18h.&nbsp;  
Looks like the expected behaviour is to have the same number of backups in the last 24h than in previous period.

---

<div class="post-metadata">

**Author:** ![audiokarate](https://avatars.discourse-cdn.com/v4/letter/a/e47c2d/32.png) [@audiokarate](https://community.dynatrace.com/u/audiokarate)\
**Post date:** [May 29, 2024, 4:55pm UTC](https://community.dynatrace.com/t/anomaly-detection-with-timeframe/45778/7 "2024-05-29T16:55:55Z")

</div>

actually we run only 4 backups a day (every 6h) and i have to make sure that there was atleast one sucessful backup in the last 24h.

I have no idea where this 163 value is coming from.

We are in the process of doing the migration of our monitoring from prometheus to dynatrace. If i compare the exact same metric in dynatrace and in in prometheus im getting different results (see both graphs below)

 ![audiokarate_0-1717001692438.png](https://global.discourse-cdn.com/dynatrace/original/2X/9/9b57802d21e1f095a4e378e3583833af89137ae6.png)

 ![audiokarate_1-1717001710526.png](https://global.discourse-cdn.com/dynatrace/original/3X/6/4/64de6bbc63d19254dc899cbc36136c8fc178f822.png)

---

<div class="post-metadata">

**Author:** ![PacoPorro](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/pacoporro/32/36087_2.png) [@PacoPorro](https://community.dynatrace.com/u/PacoPorro)\
**Post date:** [May 31, 2024, 11:29am UTC](https://community.dynatrace.com/t/anomaly-detection-with-timeframe/45778/8 "2024-05-31T11:29:40Z")

</div>

It looks like you are using fold operator.
