# Metric anomaly detection for a range of values in the logs

**URL:** <https://community.dynatrace.com/t/metric-anomaly-detection-for-a-range-of-values-in-the-logs/47284>\
**Category:** DQL\
**Tags:** dql, dynatrace-managed, anomaly-detection, logs\
**Created:** [August 23, 2024, 11:51am UTC](https://community.dynatrace.com/t/metric-anomaly-detection-for-a-range-of-values-in-the-logs/47284 "2024-08-23T11:51:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![davidrb](https://avatars.discourse-cdn.com/v4/letter/d/8baadc/32.png) [@davidrb](https://community.dynatrace.com/u/davidrb)\
**Post date:** [August 23, 2024, 11:51am UTC](https://community.dynatrace.com/t/metric-anomaly-detection-for-a-range-of-values-in-the-logs/47284/1 "2024-08-23T11:51:08Z")

</div>

Attempting to create an Anomaly detection metric event based on a specific range of data from logs.&nbsp;I can find this data from the logs with this DQL query:

```markup
fetch logs
| filter matchesValue(k8s.namespace.name, "app-namespace") and toLong(application-event-id) >= 100 and toLong(application-event-id) <= 1000
| sort timestamp desc

```

I am creating a Log Metric, that will be used by a Anomaly detection metric event, but the Matcher doesn’t allow the range selection: toLong(application-event-id) \>= 100 and toLong(application-event-id) \<= 1000. I am using this instead:

```markup
matchesValue(k8s.namespace.name, "app-namespace") and not isNull("application-event-id")

```

Then using an Anomaly detection metric event to raise a Problem if a certain threshold of 100-1000 application-event-

id are raised in the logs.

I can filter for a specific application-event-id, but how can I do this for the range of application-event-id in the logs (100 to 1000)

```markup
log.application_event_ids:filter(eq("application-eventid-id",100))

```

---

<div class="post-metadata">

**Author:** ![DavidBruendl](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/davidbruendl/32/5695_2.png) [@DavidBruendl](https://community.dynatrace.com/u/DavidBruendl)\
**Post date:** [November 21, 2024, 10:20am UTC](https://community.dynatrace.com/t/metric-anomaly-detection-for-a-range-of-values-in-the-logs/47284/2 "2024-11-21T10:20:56Z")

</div>

Hi&nbsp;[@davidrb](https://community.dynatrace.com/user/79773)&nbsp;,

you can use your log query add |makeTimeseries and place it in the Davis Anomaly Detector

```markup
fetch logs
| filter matchesValue(k8s.namespace.name, "app-namespace") and toLong(application-event-id) >= 100 and toLong(application-event-id) <= 1000
| makeTimeseries count()

```

Please give a try, thank you 🙂

best greetings

David
