# DQL - Metric in dashboard to host

**URL:** <https://community.dynatrace.com/t/dql-metric-in-dashboard-to-host/50186>\
**Category:** DQL\
**Tags:** dql, dynatrace-managed\
**Created:** [February 10, 2025, 10:49pm UTC](https://community.dynatrace.com/t/dql-metric-in-dashboard-to-host/50186 "2025-02-10T22:49:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fast](https://avatars.discourse-cdn.com/v4/letter/f/3ec8ea/32.png) [@Fast](https://community.dynatrace.com/u/Fast)\
**Post date:** [February 10, 2025, 10:49pm UTC](https://community.dynatrace.com/t/dql-metric-in-dashboard-to-host/50186/1 "2025-02-10T22:49:54Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![p\_devulapalli](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/p_devulapalli/32/41590_2.png) [@p\_devulapalli](https://community.dynatrace.com/u/p_devulapalli)\
**Post date:** [February 11, 2025, 12:45am UTC](https://community.dynatrace.com/t/dql-metric-in-dashboard-to-host/50186/2 "2025-02-11T00:45:20Z")

</div>

[@Fast](https://community.dynatrace.com/user/86522)&nbsp;Please try similar to below

 ![p_devulapalli_0-1739234679692.png](https://global.discourse-cdn.com/dynatrace/original/3X/3/7/379a5dcdd3bbe6a91c0eeadee7479a405ac8a1df.png)

---

<div class="post-metadata">

**Author:** ![zaid-bashir](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/zaid-bashir/32/22651_2.png) [@zaid-bashir](https://community.dynatrace.com/u/zaid-bashir)\
**Post date:** [February 11, 2025, 6:37am UTC](https://community.dynatrace.com/t/dql-metric-in-dashboard-to-host/50186/3 "2025-02-11T06:37:18Z")

</div>

Hi&nbsp;[@Fast](https://community.dynatrace.com/user/86522)&nbsp;  
I am posting&nbsp; here a similar solution but by searching hostname, you can find the query below.

```markup
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

```

 ![zaidbashir_0-1739255425522.png](https://global.discourse-cdn.com/dynatrace/original/2X/e/e1f64745ac4af9f02b30e664db77310f249872ce.png)

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.

---

<div class="post-metadata">

**Author:** ![Fin\_Ubels](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/fin_ubels/32/18008_2.png) [@Fin\_Ubels](https://community.dynatrace.com/u/Fin_Ubels)\
**Post date:** [February 11, 2025, 9:12am UTC](https://community.dynatrace.com/t/dql-metric-in-dashboard-to-host/50186/4 "2025-02-11T09:12:20Z")

</div>

Just wanted to add on here another way to get entity names as a tip!

```markup
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.
