# DQL query on disk free space

**URL:** <https://community.dynatrace.com/t/dql-query-on-disk-free-space/50251>\
**Category:** DQL\
**Tags:** dql\
**Created:** [February 13, 2025, 1:15pm UTC](https://community.dynatrace.com/t/dql-query-on-disk-free-space/50251 "2025-02-13T13:15:15Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![akashsaini](https://avatars.discourse-cdn.com/v4/letter/a/a9a28c/32.png) [@akashsaini](https://community.dynatrace.com/u/akashsaini)\
**Post date:** [February 13, 2025, 1:15pm UTC](https://community.dynatrace.com/t/dql-query-on-disk-free-space/50251/1 "2025-02-13T13:15:15Z")

</div>

Hi Team,

We require DQL query on disk free space with OS type.

Information require through dql query --

disk free space for /opt/ directory  
os type-like Linux ubuntu , AIX

Thanks in advance !

---

<div class="post-metadata">

**Author:** ![gbaudart](https://avatars.discourse-cdn.com/v4/letter/g/e47c2d/32.png) [@gbaudart](https://community.dynatrace.com/u/gbaudart)\
**Post date:** [February 13, 2025, 3:59pm UTC](https://community.dynatrace.com/t/dql-query-on-disk-free-space/50251/2 "2025-02-13T15:59:54Z")

</div>

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

You can try this query :

```markup
timeseries avg(dt.host.disk.free), by: { dt.entity.host, dt.entity.disk }
| fieldsAdd dt.entity.host.name = entityName(dt.entity.host)
| fieldsAdd dt.entity.disk.name = entityName(dt.entity.disk)
| lookup [fetch dt.entity.host
  | fieldsAdd osType2=osType], sourceField:dt.entity.host, lookupField:id, fields:{osType2}
| fieldsAdd DiskFree = arrayAvg(`avg(dt.host.disk.free)`)
| fieldsKeep dt.entity.host.name,dt.entity.disk.name, osType2, DiskFree

```

Let me know if it works

---

<div class="post-metadata">

**Author:** ![akashsaini](https://avatars.discourse-cdn.com/v4/letter/a/a9a28c/32.png) [@akashsaini](https://community.dynatrace.com/u/akashsaini)\
**Post date:** [February 17, 2025, 8:38am UTC](https://community.dynatrace.com/t/dql-query-on-disk-free-space/50251/3 "2025-02-17T08:38:15Z")

</div>

Thanks Gbaudart,

query perfectly working.

Please confirm the disk free space in GB ?

---

<div class="post-metadata">

**Author:** ![gbaudart](https://avatars.discourse-cdn.com/v4/letter/g/e47c2d/32.png) [@gbaudart](https://community.dynatrace.com/u/gbaudart)\
**Post date:** [February 17, 2025, 8:15pm UTC](https://community.dynatrace.com/t/dql-query-on-disk-free-space/50251/4 "2025-02-17T20:15:20Z")

</div>

Hi&nbsp;[@akashsaini](https://community.dynatrace.com/user/77906),  
Normally, the unit will match the magnitude of your result. You can change the unit in the query display options.

---

<div class="post-metadata">

**Author:** ![manog1978](https://avatars.discourse-cdn.com/v4/letter/m/7cd45c/32.png) [@manog1978](https://community.dynatrace.com/u/manog1978)\
**Post date:** [April 7, 2025, 10:09am UTC](https://community.dynatrace.com/t/dql-query-on-disk-free-space/50251/5 "2025-04-07T10:09:07Z")

</div>

I am creating a Dashboad to pull the disk usage for windows and Linux Servers, for example in windows server (C. D. e) and Linux Server ,(/tmp, /root) can you please advise. should i use Query based or Metric based.

---

<div class="post-metadata">

**Author:** ![manog1978](https://avatars.discourse-cdn.com/v4/letter/m/7cd45c/32.png) [@manog1978](https://community.dynatrace.com/u/manog1978)\
**Post date:** [April 7, 2025, 10:56am UTC](https://community.dynatrace.com/t/dql-query-on-disk-free-space/50251/6 "2025-04-07T10:56:40Z")

</div>

the following query works for percentage based, i would like to get the GB how much used and how much free.

timeseries avg(dt.host.disk.free), by: { dt.entity.host, dt.entity.disk }  
| fieldsAdd dt.entity.host.name = entityName(dt.entity.host)  
| fieldsAdd dt.entity.disk.name = entityName(dt.entity.disk)  
| lookup [fetch dt.entity.host  
| fieldsAdd osType2=osType], sourceField:dt.entity.host, lookupField:id, fields:{osType2}  
| fieldsAdd DiskFree = arrayAvg(`avg(dt.host.disk.free)`)  
| fieldsAdd DiskUsage = 100 - DiskFree  
| fieldsKeep dt.entity.host.name, dt.entity.disk.name, osType2, DiskFree, DiskUsage

| sort DiskUsage asc

---

<div class="post-metadata">

**Author:** ![alagurajpl](https://avatars.discourse-cdn.com/v4/letter/a/c68b51/32.png) [@alagurajpl](https://community.dynatrace.com/u/alagurajpl)\
**Post date:** [April 28, 2026, 7:10am UTC](https://community.dynatrace.com/t/dql-query-on-disk-free-space/50251/7 "2026-04-28T07:10:02Z")

</div>

Hi&nbsp;[@manog1978](https://community.dynatrace.com/user/77777)

You can use this query for available space in value.

_timeseries max(dt.host.disk.avail), by: { dt.entity.host, dt.entity.disk }__| fieldsAdd dt.entity.host.name = entityName(dt.entity.host)__| fieldsAdd dt.entity.disk.name = entityName(dt.entity.disk)__| lookup [fetch dt.entity.host__| fieldsAdd osType2=osType], sourceField:dt.entity.host, lookupField:id, fields:{osType2}__| fieldsAdd DiskFree = arrayAvg(`max(dt.host.disk.avail)`)__| fieldsKeep dt.entity.host.name,dt.entity.disk.name, osType2, DiskFree_
