# Hostname for Process restart event

**URL:** <https://community.dynatrace.com/t/hostname-for-process-restart-event/42971>\
**Category:** DQL\
**Tags:** dql\
**Created:** [December 1, 2023, 9:05am UTC](https://community.dynatrace.com/t/hostname-for-process-restart-event/42971 "2023-12-01T09:05:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![janne\_olkoniemi](https://avatars.discourse-cdn.com/v4/letter/j/8e8cbc/32.png) [@janne\_olkoniemi](https://community.dynatrace.com/u/janne_olkoniemi)\
**Post date:** [December 1, 2023, 9:05am UTC](https://community.dynatrace.com/t/hostname-for-process-restart-event/42971/1 "2023-12-01T09:05:45Z")

</div>

Hello,

I’m relativity new with DQL and taking my first baby steps with it currently and trying to figure out how to utilize it.  
One us case I have currently is to list certain process restarts for table and facing some challenges how to include the hostname on my query where the restart has happened?

I would be greatly appreciated if someone could help me on this since since not sure which way I should approach this challenge.

```auto
fetch events
| fieldsAdd dt.entity.host.name, dt.entity.process_group_instance.name, displayName, timestamp
| filter event.group_label == "Process restart" and dt.entity.process_group_instance.name == "WebSphere Liberty runtime"
| fields dt.entity.process_group_instance.name, timestamp, dt.entity.host.name
| sort timestamp desc
| limit 10

```

---

<div class="post-metadata">

**Author:** ![sinisa\_zubic](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/sinisa_zubic/32/32498_2.png) [@sinisa\_zubic](https://community.dynatrace.com/u/sinisa_zubic)\
**Post date:** [December 5, 2023, 8:25am UTC](https://community.dynatrace.com/t/hostname-for-process-restart-event/42971/2 "2023-12-05T08:25:37Z")

</div>

Hi&nbsp;[@janne\_olkoniemi](https://community.dynatrace.com/user/23527)

Are you looking for this query?

```markup
fetch events
| filter event.kind == "DAVIS_EVENT" and event.type == "PROCESS_RESTART"
| lookup [
  fetch dt.entity.process_group_instance
  | fieldsAdd host = belongs_to[dt.entity.host]
  | fieldsAdd host.name = lookup([fetch dt.entity.host | fields id, entity.name, osArchitecture], sourceField:host, lookupField:id)[entity.name]
], sourceField:dt.entity.process_group_instance, lookupField:id,fields: { host.name }
| fields timestamp, dt.entity.process_group_instance.name,host.name

```

Best,  
Sini

---

<div class="post-metadata">

**Author:** ![janne\_olkoniemi](https://avatars.discourse-cdn.com/v4/letter/j/8e8cbc/32.png) [@janne\_olkoniemi](https://community.dynatrace.com/u/janne_olkoniemi)\
**Post date:** [December 12, 2023, 2:09pm UTC](https://community.dynatrace.com/t/hostname-for-process-restart-event/42971/3 "2023-12-12T14:09:55Z")

</div>

Hi&nbsp;[@sinisa\_zubic](https://community.dynatrace.com/user/38283),

Thanks for your suggestion and I was taking few days off from my work so took some time to answer .

The query itself seems to work but it just takes a quite a lot of time on our environment and if I try to pull data from the past 7 days it shoots the following error after a while.

_The lookup command’s subquery read too much data. Please continue to filter the lookup table or narrow the query time range._

But thanks for pointing it out how to utilize the lookup and now just need to find some way to make the query more lightweight.

---

<div class="post-metadata">

**Author:** ![sinisa\_zubic](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/sinisa_zubic/32/32498_2.png) [@sinisa\_zubic](https://community.dynatrace.com/u/sinisa_zubic)\
**Post date:** [December 14, 2023, 12:08pm UTC](https://community.dynatrace.com/t/hostname-for-process-restart-event/42971/4 "2023-12-14T12:08:24Z")

</div>

I have tried to optimize the query and instead of lookup and I am using now join and append. Can you try this query out?

```markup
fetch events, scanLimitGBytes:-1
| fieldsAdd dt.system.bucket
| filter event.kind == "DAVIS_EVENT" and event.type == "PROCESS_RESTART"
| fieldsAdd dt.entity.process_group_instance = arrayFirst(affected_entity_ids)
| JOIN [
  fetch dt.entity.process_group_instance
  | fields dt.entity.host = belongs_to[dt.entity.host], dt.entity.process_group_instance = id
  | append[
    fetch dt.entity.host
    | fields dt.entity.host = id, hostname = entity.name
  ]
  | summarize {hostname = takeAny(hostname), dt.entity.process_group_instance = takeAny(dt.entity.process_group_instance)}, by:{dt.entity.host}
], on:{dt.entity.process_group_instance}, 
  fields:{
    hostname
  }
| fields timestamp, dt.entity.process_group_instance.name,hostname

```
