# Alert on low disk space by using both disk space % and disk space bytes

**URL:** <https://community.dynatrace.com/t/alert-on-low-disk-space-by-using-both-disk-space-and-disk-space-bytes/46689>\
**Category:** Alerting\
**Tags:** problem-detection, problem-notification, disks, anomaly-detection, problems-classic\
**Created:** [July 18, 2024, 7:27pm UTC](https://community.dynatrace.com/t/alert-on-low-disk-space-by-using-both-disk-space-and-disk-space-bytes/46689 "2024-07-18T19:27:38Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![RishiSuthar](https://avatars.discourse-cdn.com/v4/letter/r/7ba0ec/32.png) [@RishiSuthar](https://community.dynatrace.com/u/RishiSuthar)\
**Post date:** [July 18, 2024, 7:27pm UTC](https://community.dynatrace.com/t/alert-on-low-disk-space-by-using-both-disk-space-and-disk-space-bytes/46689/1 "2024-07-18T19:27:38Z")

</div>

Hi,

We are looking to monitor low disk space with the following setup:  
alert if space \<= 97% AND space \<300 gig

Is this something that can be achieved within the alerting query?

---

<div class="post-metadata">

**Author:** ![Maheedhar\_T](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/maheedhar_t/32/155_2.png) [@Maheedhar\_T](https://community.dynatrace.com/u/Maheedhar_T)\
**Post date:** [July 19, 2024, 6:19am UTC](https://community.dynatrace.com/t/alert-on-low-disk-space-by-using-both-disk-space-and-disk-space-bytes/46689/2 "2024-07-19T06:19:39Z")

</div>

You can use new “Davis Anomaly Detector” app for this.  
What you need is a query which checks both of the conditions.  
In data explorer it looks something like this

 ![Maheedhar_T_0-1721368409796.png](https://global.discourse-cdn.com/dynatrace/original/3X/6/8/68ef07bc42bfee68a0da72fde87674e31f61db6f.png)

and when you click on open with and open that with a notebook it gets converted to DQL and looks something like the below.

```markup
timeseries { free = avg(dt.host.disk.free), avail = avg(dt.host.disk.avail) }, by: { dt.entity.host }, filter: { in(dt.entity.host, classicEntitySelector("type(host),fromRelationship.isInstanceOf(type(HOST_GROUP),entityName.equals(\"XXXXXX\"))")) }
| sort arrayAvg(free) desc
| fieldsAdd entityName(dt.entity.host)
| limit 20

```

Then again when you click open with you find something like this.

 ![Maheedhar_T_1-1721368946085.png](https://global.discourse-cdn.com/dynatrace/original/2X/0/0a4061d7ba77a8b5228803221dadc3ce665345b7.png)

click on Davis anomaly detector and you will be redirected to the Anomaly detector Application where you can create the event.  
Then you can see your query in the query section of the config and in the Customise parameters section this is what you have to give.

 ![Maheedhar_T_2-1721369275744.png](https://global.discourse-cdn.com/dynatrace/original/3X/4/e/4e4582ef533f2e08d1d25d81105923d4128f61fe.png)

Here the query gives disk available % first and disk available (bytes) as second output hence we configure something like this.  
3,322,122,547,200  
Don’t get confused with so many “,” s.  
Split it as&nbsp;  
(3),(322,122,547,200) the first part is disk available is 3% and the second part is disk available is&nbsp;322,122,547,200 bytes.  
and we have set the alert to be triggered if the metric is below which means alert would be triggered if both of the conditions you mentioned above are met.

Hope this answers your query.

Regards,  
[@Maheedhar\_T](https://community.dynatrace.com/user/76275)

---

<div class="post-metadata">

**Author:** ![Maheedhar\_T](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/maheedhar_t/32/155_2.png) [@Maheedhar\_T](https://community.dynatrace.com/u/Maheedhar_T)\
**Post date:** [July 19, 2024, 6:22am UTC](https://community.dynatrace.com/t/alert-on-low-disk-space-by-using-both-disk-space-and-disk-space-bytes/46689/3 "2024-07-19T06:22:22Z")

</div>

One thing I forgot to mention is that you have to convert your&nbsp;300 gig to bytes to add it as threshold as the metric we are using above gives the disk available in bytes.

Also,  
This is the only way I see ahead as I was not able to replicate the same using classic metric events.

Hope you’re on Grail…  
Happy querying&nbsp;[@RishiSuthar](https://community.dynatrace.com/user/50148)

---

<div class="post-metadata">

**Author:** ![dlee1](https://avatars.discourse-cdn.com/v4/letter/d/dc4da7/32.png) [@dlee1](https://community.dynatrace.com/u/dlee1)\
**Post date:** [June 25, 2025, 7:56pm UTC](https://community.dynatrace.com/t/alert-on-low-disk-space-by-using-both-disk-space-and-disk-space-bytes/46689/4 "2025-06-25T19:56:28Z")

</div>

Hi,  
I tried following your solution as I am interested in a similar setup, however when I get to setting up the anomaly detector, I get the following error with my query: “The query results in multiple metrics, but anomaly detectors only support single metric.”

 ![dlee1_0-1750881339103.png](https://global.discourse-cdn.com/dynatrace/original/3X/0/4/045a96f897e16d1e5c641f9c16db015beee60df5.png)

\*I replaced the server name to “XXXXXX” in my screenshot, but when I put in an actual server name I get the error\*

Does this functionality no longer work, or am I missing something?

Thanks.

---

<div class="post-metadata">

**Author:** ![rkdy](https://avatars.discourse-cdn.com/v4/letter/r/cab0a1/32.png) [@rkdy](https://community.dynatrace.com/u/rkdy)\
**Post date:** [November 5, 2025, 2:52pm UTC](https://community.dynatrace.com/t/alert-on-low-disk-space-by-using-both-disk-space-and-disk-space-bytes/46689/5 "2025-11-05T14:52:32Z")

</div>

You could try something like this:

```python
timeseries by:{dt.entity.disk, dt.entity.host}, {used_percent = avg(dt.host.disk.used.percent), used = avg(dt.host.disk.used), avail = avg(dt.host.disk.avail)},
  filter:{matchesValue(entityAttr(type:"dt.entity.host", dt.entity.host, "hostGroupName"), "xxxxx")}
| fieldsAdd entityName(dt.entity.disk)
| fieldsAdd entityName(dt.entity.host)

| fieldsAdd free_percent = 100 - used_percent[],
            free_space_gb = avail[] / (1024*1024*1024)
| filter iAny(free_space_gb[] < 300)

| fieldsAdd alert_level = if(isNull(free_percent[]), null,
                           else:if(free_percent[] < 5, 2, 
                           else:if(free_percent[] < 10, 1, else:0)))
| filter iAny(alert_level[] > 0) 

| fields dt.entity.disk, dt.entity.host, dt.entity.disk.name, dt.entity.host.name, alert_level, timeframe, interval, used_percent, used
, avail,
         last_alert_level = arrayLast(alert_level), 
         last_used_percent_display = round(arrayLast(used_percent), decimals:2),
         last_free_space_gb = round(arrayLast(free_space_gb), decimals:2)

| fieldsAdd alert_severity = if(last_alert_level == 2, "CRITICAL",
                             else:if(last_alert_level == 1, "WARNING", 
                             else:"OK"))

| dedup dt.entity.disk

```
