10 Feb 2025 10:49 PM
Hi there.
I am new in DQL, and I need help to have and view metrics (CPU usage by host / Memory usage by host) in the dashboard, those hosts have an specific tag.
Therefore, I have been trying to get the metrics since days ago; however, I have not been able to do it. I was wondering if you know how to segment this by the tag and bring the metric.
I was checking many cases in Dynatrace Community and I tried those queries, and the queries work, but they mix the host.
Grateful if anyone can help on the this issue.
Thanks!
11 Feb 2025 06:37 AM
Hi @Fast
I am posting here a similar solution but by searching hostname, you can find the query below.
timeseries {avgCpu = avg(dt.host.cpu.usage),avgMem = avg(dt.host.memory.usage)}, by:{dt.entity.host}, interval:30m
| fieldsRename id = dt.entity.host
| join [fetch dt.entity.host | fieldsAdd entity.name],on: {id}
| filter right.entity.name == $Search_Host
But You have to first create a variable for Search_Host which will take your hostname and checks the hostname that is equal to resulted hostname and filters the result. You can also use contains() here to get the results matching with Search_Host Variable.
You can modify the above query to get remaining metrics and add other variables to furthur extend the query.
If you need furthur help in this, reply.
11 Feb 2025 09:12 AM
Just wanted to add on here another way to get entity names as a tip!
timeseries {avgCpu = avg(dt.host.cpu.usage),avgMem = avg(dt.host.memory.usage)}, by:{dt.entity.host}, interval:30m
| fieldsAdd entity.name = entityName(dt.entity.host)
| filter entity.name == $Search_Host
You can also use the entityAttr() to get a specific attribute removing the need to write out and do a full join/lookup and then cleanup any of the stuff that comes with that.