# Process Memory /CPU usage per host and Service

**URL:** <https://community.dynatrace.com/t/process-memory-cpu-usage-per-host-and-service/49471>\
**Category:** DQL\
**Tags:** dql, dashboards, timeseries\
**Created:** [December 22, 2024, 2:43pm UTC](https://community.dynatrace.com/t/process-memory-cpu-usage-per-host-and-service/49471 "2024-12-22T14:43:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![eranma](https://avatars.discourse-cdn.com/v4/letter/e/ea5d25/32.png) [@eranma](https://community.dynatrace.com/u/eranma)\
**Post date:** [December 22, 2024, 2:43pm UTC](https://community.dynatrace.com/t/process-memory-cpu-usage-per-host-and-service/49471/1 "2024-12-22T14:43:22Z")

</div>

I’m trying to create a timeseries tile that presents a&nbsp;Process Memory /CPU usage per host, and filter it according to a variable called “ServiceId”. for example :

I use a variable called “ServiceID” and i choose “Service-123”. I want to receive a tile for the CPU and another one for memory usage of the Service’s process, spited by the hosts it is running on.&nbsp; so if it runs on server A and Server B i&nbsp; will get a tile with 2 graphs showing the memory&nbsp; usage of the service’s process (same for CPU).

i tried to create several DQL for that but couldn’t get to a correct one. i’ll be glad for advise and code examples.

Thanks!

---

<div class="post-metadata">

**Author:** ![sia\_h](https://avatars.discourse-cdn.com/v4/letter/s/f14d63/32.png) [@sia\_h](https://community.dynatrace.com/u/sia_h)\
**Post date:** [December 23, 2024, 7:37am UTC](https://community.dynatrace.com/t/process-memory-cpu-usage-per-host-and-service/49471/2 "2024-12-23T07:37:01Z")

</div>

Try this:

```markup
timeseries avg(dt.process.cpu.usage), by: { dt.entity.process_group_instance, dt.entity.process_group, dt.entity.host }
| fieldsAdd dt.entity.process_group_instance.name = entityName(dt.entity.process_group_instance)
| fieldsAdd dt.entity.process_group.name = entityName(dt.entity.process_group)
| fieldsAdd dt.entity.host.name = entityName(dt.entity.host)
| fieldsAdd value.A = arrayAvg(`avg(dt.process.cpu.usage)`)
| lookup [ fetch dt.entity.service
| fields entity.name, id, runs_on
| fieldsFlatten runs_on
], sourceField:dt.entity.process_group, lookupField:runs_on.dt.entity.process_group
| filter lookup.entity.name == $Service

```

Variable Service

```markup
fetch dt.entity.service
| fields entity.name

```

 ![Dashboards-Demo-Live-guu84124-Dynatrace.png](https://global.discourse-cdn.com/dynatrace/original/3X/0/1/0182b0301f37ca539288fd0f342231f6c3785da6.jpeg)

---

<div class="post-metadata">

**Author:** ![eranma](https://avatars.discourse-cdn.com/v4/letter/e/ea5d25/32.png) [@eranma](https://community.dynatrace.com/u/eranma)\
**Post date:** [December 23, 2024, 1:11pm UTC](https://community.dynatrace.com/t/process-memory-cpu-usage-per-host-and-service/49471/3 "2024-12-23T13:11:24Z")

</div>

Thanks that helps!

Any chance to get the legend as the process name and the host name? currently it’s the process name and the host id

---

<div class="post-metadata">

**Author:** ![sia\_h](https://avatars.discourse-cdn.com/v4/letter/s/f14d63/32.png) [@sia\_h](https://community.dynatrace.com/u/sia_h)\
**Post date:** [December 23, 2024, 1:34pm UTC](https://community.dynatrace.com/t/process-memory-cpu-usage-per-host-and-service/49471/4 "2024-12-23T13:34:59Z")

</div>

You can update that in the Legend and tooltip section under Visual:

 ![Dashboards-Demo-Live-guu84124-Dynatrace.png](https://global.discourse-cdn.com/dynatrace/original/3X/7/0/701cbf30ac3a2d33e061068789545f9c488d7119.png)
