# Alerting for SQL queries

**URL:** <https://community.dynatrace.com/t/alerting-for-sql-queries/37045>\
**Category:** Alerting\
**Tags:** sql, problems-classic\
**Created:** [October 27, 2022, 6:43am UTC](https://community.dynatrace.com/t/alerting-for-sql-queries/37045 "2022-10-27T06:43:10Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![KVZ](https://avatars.discourse-cdn.com/v4/letter/k/3ec8ea/32.png) [@KVZ](https://community.dynatrace.com/u/KVZ)\
**Post date:** [October 27, 2022, 6:43am UTC](https://community.dynatrace.com/t/alerting-for-sql-queries/37045/1 "2022-10-27T06:43:10Z")

</div>

Is there a way to create alerts for SQL statement that run longer than 1 min for example, in a specific application?

---

<div class="post-metadata">

**Author:** ![MateuszKacprzak](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/mateuszkacprzak/32/5197_2.png) [@MateuszKacprzak](https://community.dynatrace.com/u/MateuszKacprzak)\
**Post date:** [October 27, 2022, 8:30am UTC](https://community.dynatrace.com/t/alerting-for-sql-queries/37045/2 "2022-10-27T08:30:57Z")

</div>

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

It is possible to customize the alerting of a particular database.&nbsp;On the database section you need to go to a database that you are interested in and go to it’s settings (click on three dots). Then you will be able to adjust the alerting.&nbsp;You can define a threshold of the response time alerting.&nbsp;It’s a bit limited, but you can define that if N % of queries take more than a minute then Dynatrace will report about this situation.

Best Regards,

Mateusz

---

<div class="post-metadata">

**Author:** ![mizso74](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/mizso74/32/41729_2.png) [@mizso74](https://community.dynatrace.com/u/mizso74)\
**Post date:** [October 27, 2022, 10:14am UTC](https://community.dynatrace.com/t/alerting-for-sql-queries/37045/3 "2022-10-27T10:14:59Z")

</div>

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

I would do the following.

Create a multidimension analysis view about the slow database statements (\>1s) and a mteric about it:

In one of my environment there are many statements above 1 sec…

 ![Mizs_0-1666864472551.png](https://global.discourse-cdn.com/dynatrace/original/3X/9/5/9529e2142fdbfdf460d748d4bff844827cd7c04d.png)

At least one metric point should be generated in order to be able to browse it in the metrics or data explorer (after than you can create dashboard or a custom alert): dimension would be your database statements. In the example I focus only to the top ten (Limit =10). Slow database statement metric is the new metric which one created from the MDA.

 ![Mizs_1-1666864781991.png](https://global.discourse-cdn.com/dynatrace/original/2X/d/d37955e2e445669b3b25b25bda4c6a5046830aa1.png)

At anomaly detection you can use the build or code mode version of the new metric. eg in this case code mode filtered for a specific DB service (from the Database menu).

 ![Mizs_2-1666865084712.png](https://global.discourse-cdn.com/dynatrace/original/2X/9/9a3f6cb4185e3af3a320c6d52c2f09efaffb71c5.png)

At anomaly detection rule:

 ![Mizs_3-1666865206619.png](https://global.discourse-cdn.com/dynatrace/original/3X/a/e/ae3d3b2cef30e0a3f5d9ab100b9fa5b3243a00d7.png)

Here is the preview for a static threshold (1 occurance within a predefined time frame) and an expected red line for the problem (and finally an alert):

 ![Mizs_4-1666865361443.png](https://global.discourse-cdn.com/dynatrace/original/2X/2/2ded2e11bc0a612c2f73d0a8631f80d152caf5a5.png)

If you had an alert you would only check the data explorer (or the created dashboard about it) or the saved multidimension view.

I hope it helps. Have a nice day.

Best regards,

Mizső

---

<div class="post-metadata">

**Author:** ![DebrajG](https://avatars.discourse-cdn.com/v4/letter/d/b3f665/32.png) [@DebrajG](https://community.dynatrace.com/u/DebrajG)\
**Post date:** [August 24, 2023, 2:25pm UTC](https://community.dynatrace.com/t/alerting-for-sql-queries/37045/4 "2023-08-24T14:25:24Z")

</div>

Dear Team,

We are working on&nbsp; a similar scenario and wanted to send notification which crosses 1 min threshold value. However we cannot navigate to anomaly detection rule. Can you please help us in identifying the section where we can find this option.

Regards,

Debraj

---

<div class="post-metadata">

**Author:** ![mizso74](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/mizso74/32/41729_2.png) [@mizso74](https://community.dynatrace.com/u/mizso74)\
**Post date:** [August 24, 2023, 2:55pm UTC](https://community.dynatrace.com/t/alerting-for-sql-queries/37045/5 "2023-08-24T14:55:50Z")

</div>

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

You can create a metric event here:

 ![Mizs_0-1692888884860.png](https://global.discourse-cdn.com/dynatrace/original/3X/2/c/2c99c523d483e35edcf61b088a844988fcad1d94.png)

It will open a problem then you can create an alerting profile and problem notification integration in the settings.

I hope it helps.

Best regards,

Mizső
