# Create Metric for DQL Query

**URL:** <https://community.dynatrace.com/t/create-metric-for-dql-query/50553>\
**Category:** Open Q&A\
**Tags:** dql, dynatrace-managed, metric-events\
**Created:** [March 5, 2025, 7:02am UTC](https://community.dynatrace.com/t/create-metric-for-dql-query/50553 "2025-03-05T07:02:23Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vikas\_g1997](https://avatars.discourse-cdn.com/v4/letter/v/b3f665/32.png) [@Vikas\_g1997](https://community.dynatrace.com/u/Vikas_g1997)\
**Post date:** [March 5, 2025, 7:02am UTC](https://community.dynatrace.com/t/create-metric-for-dql-query/50553/1 "2025-03-05T07:02:23Z")

</div>

Hi Team,  
We are looking to create a metric and configure an alert based on the count of logs generated from a specific source. The goal is to trigger an alert if the count value exceeds 500 or 1000.Could anyone suggest how we can set up this metric and configure the alert accordingly? Your assistance would be greatly appreciated.

| filter log.source ==“/home/wtrovruns/bb/log/bb-ovo.log”  
| summarize eventcount= count()

---

<div class="post-metadata">

**Author:** ![moin\_DT1](https://avatars.discourse-cdn.com/v4/letter/m/c67d28/32.png) [@moin\_DT1](https://community.dynatrace.com/u/moin_DT1)\
**Post date:** [March 5, 2025, 5:11pm UTC](https://community.dynatrace.com/t/create-metric-for-dql-query/50553/2 "2025-03-05T17:11:14Z")

</div>

Hi&nbsp;[@Vikas\_g1997](https://community.dynatrace.com/user/57336)&nbsp;  
Try using Davis Anomaly Detector.

And there you have to use query with makeTimeseries command. And put 500 or 1000 in the threshold value.

 ![moin_DT1_0-1741194586250.png](https://global.discourse-cdn.com/dynatrace/original/2X/5/5067ad5bae92d7305df9424b036f6db2d33b69c2.png)

I never created a Metric event like this, but try creating yourself.

Regards,

Moin

---

<div class="post-metadata">

**Author:** ![marco\_irmer](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/marco_irmer/32/3038_2.png) [@marco\_irmer](https://community.dynatrace.com/u/marco_irmer)\
**Post date:** [March 6, 2025, 8:23pm UTC](https://community.dynatrace.com/t/create-metric-for-dql-query/50553/3 "2025-03-06T20:23:08Z")

</div>

I believe the most straight-forward way to accomplish this would be to create a log metric to count these log entries. During the configuration, you will be asked to provide filter criteria which will ensure that only the relevant log entries are counted. Once the metric is created you will gain the ability to report and alert on the data just as you would with any other metric.

References:

1. [Log metrics — Dynatrace Docs](https://docs.dynatrace.com/docs/analyze-explore-automate/logs/lma-analysis/lma-log-metrics)
2. [Log processing with OpenPipeline — Dynatrace Docs](https://docs.dynatrace.com/docs/analyze-explore-automate/logs/lma-openpipeline)

---

<div class="post-metadata">

**Author:** ![moin\_DT1](https://avatars.discourse-cdn.com/v4/letter/m/c67d28/32.png) [@moin\_DT1](https://community.dynatrace.com/u/moin_DT1)\
**Post date:** [March 7, 2025, 12:32pm UTC](https://community.dynatrace.com/t/create-metric-for-dql-query/50553/4 "2025-03-07T12:32:30Z")

</div>

[@marco\_irmer](https://community.dynatrace.com/user/19769)&nbsp;Yes exactly, but i think he would like know, if using DQL its possible to create metric events?

---

<div class="post-metadata">

**Author:** ![rguaram](https://avatars.discourse-cdn.com/v4/letter/r/54ee81/32.png) [@rguaram](https://community.dynatrace.com/u/rguaram)\
**Post date:** [March 7, 2025, 4:59pm UTC](https://community.dynatrace.com/t/create-metric-for-dql-query/50553/5 "2025-03-07T16:59:28Z")

</div>

```auto
Hello, how are you? I have achieved it with metric extraction

```

 ![rguaram_0-1741366562531.png](https://global.discourse-cdn.com/dynatrace/original/3X/f/3/f33f16cbaf3dfb8b99210abc4584ca4ce4e44469.png)

 ![rguaram_1-1741366671205.png](https://global.discourse-cdn.com/dynatrace/original/3X/9/0/9077ab22aa33cc93b3823f433d719054a1dcd50e.png)

```auto
or also with workflow if the query is very complex

```

 ![rguaram_2-1741366753386.png](https://global.discourse-cdn.com/dynatrace/original/2X/f/fdee8b603a01fc254b9801218055588603e908c1.png)

---

<div class="post-metadata">

**Author:** ![StrangerThing](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/strangerthing/32/12182_2.png) [@StrangerThing](https://community.dynatrace.com/u/StrangerThing)\
**Post date:** [March 7, 2025, 6:44pm UTC](https://community.dynatrace.com/t/create-metric-for-dql-query/50553/6 "2025-03-07T18:44:58Z")

</div>

This is the way if you want to use DQL

---

<div class="post-metadata">

**Author:** ![marco\_irmer](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/marco_irmer/32/3038_2.png) [@marco\_irmer](https://community.dynatrace.com/u/marco_irmer)\
**Post date:** [March 7, 2025, 6:56pm UTC](https://community.dynatrace.com/t/create-metric-for-dql-query/50553/7 "2025-03-07T18:56:01Z")

</div>

DQL & Davis Anomaly detector can also be used on a log metric. The main difference in using a log metric lies in the fact that the logs do not need to be queried continuously, thus reducing query expenses. The other difference is that the log metric will benefit from the longer default data retention vs logs.

---

<div class="post-metadata">

**Author:** ![StrangerThing](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/strangerthing/32/12182_2.png) [@StrangerThing](https://community.dynatrace.com/u/StrangerThing)\
**Post date:** [March 7, 2025, 7:03pm UTC](https://community.dynatrace.com/t/create-metric-for-dql-query/50553/8 "2025-03-07T19:03:30Z")

</div>

I agree and this is what I do in practice and would recommend to keep query costs down. He was just asking about creating the metric event with DQL
