cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

DQL to list on a dashboard only local drives disk.used.percent

mrigau
Observer

What is the best way to create a DQL code that lists the local host disk space used for Windows and Linux servers?  I need only the local physical disk, not to show the mapped network drives.  I'm using this code, and it shows local and network drives. Not sure how to filter for local drives only.  Any recommendations?  Thanks:

timeseries { Used = avg(dt.host.disk.used.percent), Disk_Used = avg(dt.host.disk.used.percent, scalar: true) }, by: { dt.entity.host, dt.entity.disk },
  filter: {
    matchesValue(entityAttr(dt.entity.host, "tags"), array($ManagementZone)) and
    in(entityAttr(dt.entity.host, "osType"), array($OS))
  }
| lookup 
[fetch dt.entity.host
      | fieldsAdd entity.name
], sourceField:dt.entity.host, lookupField:id
 
| fieldsAdd disk.name = entityName(dt.entity.disk)
| fieldsRename  Server = lookup.entity.name
    
| sort Disk_Used desc
5 REPLIES 5

marco_irmer
Champion

I don't think there is a dedicated entity attribute to distinguish between local and network drives. This means you may have to filter at the end of the query based on some sort of name pattern that would match local drives and not network drives. Is there a specific pattern in how local drives are named when compared to network drives that you could filter on?

p_devulapalli
Leader

@mrigau If your network drives have a format something like "\\NAME\SOFTWARE" you can add filter to exclude . Below is an example 

 

timeseries { avg(dt.host.disk.used.percent), value.A = avg(dt.host.disk.used.percent, scalar: true) }, by: { host.name, dt.entity.disk }, filter: { NOT matchesValue(entityAttr(dt.entity.disk, "entity.name"), "\\*") }
| fieldsAdd dt.entity.disk.name = entityName(dt.entity.disk)
Phani Devulapalli

mrigau
Observer

What about this metric?:  storage.disk.fstype
I can probably filter by the type of Linux disk to get this done.  How can I incorporate a lookup to read this disk type?

GerardJ
Mentor

Hi
You can try adding the 'filesystemType' and then filter on it :

timeseries { avg(dt.host.disk.used.percent), value.A = avg(dt.host.disk.used.percent, scalar: true) }, by: { host.name, dt.entity.disk }, filter: { NOT matchesValue(entityAttr(dt.entity.disk, "entity.name"), "\\*") }
| fieldsAdd dt.entity.disk.name = entityName(dt.entity.disk), fstype = entityAttr(dt.entity.disk, "filesystemType")

I've tried it out on my tenant, it seems to work for some OS and fs type but also got a lot of null values...

Gerard

Gerald,  thanks,  this will work for my case.  I see in my environment that the data is ok for hosts with newer Dynatrace agents, but older agents like 1.297 and below show as null.  Thanks for the recommendations.

Featured Posts