# How to get a host ID with web request URL using the Dynatrace API?

**URL:** <https://community.dynatrace.com/t/how-to-get-a-host-id-with-web-request-url-using-the-dynatrace-api/39085>\
**Category:** Dynatrace API\
**Tags:** dynatrace-api\
**Created:** [March 30, 2023, 6:57am UTC](https://community.dynatrace.com/t/how-to-get-a-host-id-with-web-request-url-using-the-dynatrace-api/39085 "2023-03-30T06:57:34Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![guihoon\_hwang](https://avatars.discourse-cdn.com/v4/letter/g/cc9497/32.png) [@guihoon\_hwang](https://community.dynatrace.com/u/guihoon_hwang)\
**Post date:** [March 30, 2023, 6:57am UTC](https://community.dynatrace.com/t/how-to-get-a-host-id-with-web-request-url-using-the-dynatrace-api/39085/1 "2023-03-30T06:57:34Z")

</div>

Hi,

How do I get the Host Id and name of the Host where the service runs with the Url obtained from the Custom multidimensional analysis screen using the API

 ![guihoon_hwang_1-1680159359194.png](https://global.discourse-cdn.com/dynatrace/original/3X/7/4/7495aa83af866ffc8e9d557e4edba61a3334821c.png)

For example, when I got localhost:7878 like the picture above, I want to get the Id of the host where that request occurred with this.

thanks,

guihoon

---

<div class="post-metadata">

**Author:** ![Babar\_Qayyum](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/babar_qayyum/32/13620_2.png) [@Babar\_Qayyum](https://community.dynatrace.com/u/Babar_Qayyum)\
**Post date:** [March 30, 2023, 7:16am UTC](https://community.dynatrace.com/t/how-to-get-a-host-id-with-web-request-url-using-the-dynatrace-api/39085/2 "2023-03-30T07:16:56Z")

</div>

Hello&nbsp;[@guihoon\_hwang](https://community.dynatrace.com/user/61314)

Try the&nbsp;{Service:Instance} of&nbsp;Split by dimension. Once you know the instance/host then, you can click on the host in your environment. The host ID will be displayed in the URL.

Regards,

Babar

---

<div class="post-metadata">

**Author:** ![paolo\_fumanelli](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/paolo_fumanelli/32/1037_2.png) [@paolo\_fumanelli](https://community.dynatrace.com/u/paolo_fumanelli)\
**Post date:** [March 30, 2023, 7:27am UTC](https://community.dynatrace.com/t/how-to-get-a-host-id-with-web-request-url-using-the-dynatrace-api/39085/3 "2023-03-30T07:27:11Z")

</div>

Hi, as far as I know {URL: Host} is not a dimension that can be used to extract entities via API. If you at least know the service name or id that is run, you can get host id via

```auto
api/v2/entities

```

using a similar entitySelector:

type(HOST),toRelationships.runsOnHost(type(SERVICE),entityName.equals( **\<SERVICE\_NAME\>** ))

or

type(HOST),toRelationships.runsOnHost(type(SERVICE),entityId( **\<SERVICE\_ENTITY\_ID\>** ))

if you know service entity id.

---

<div class="post-metadata">

**Author:** ![guihoon\_hwang](https://avatars.discourse-cdn.com/v4/letter/g/cc9497/32.png) [@guihoon\_hwang](https://community.dynatrace.com/u/guihoon_hwang)\
**Post date:** [March 30, 2023, 8:15am UTC](https://community.dynatrace.com/t/how-to-get-a-host-id-with-web-request-url-using-the-dynatrace-api/39085/4 "2023-03-30T08:15:42Z")

</div>

Thank you for your answer.

Additionally,&nbsp;May I know how to get a service id?

---

<div class="post-metadata">

**Author:** ![guihoon\_hwang](https://avatars.discourse-cdn.com/v4/letter/g/cc9497/32.png) [@guihoon\_hwang](https://community.dynatrace.com/u/guihoon_hwang)\
**Post date:** [March 30, 2023, 8:15am UTC](https://community.dynatrace.com/t/how-to-get-a-host-id-with-web-request-url-using-the-dynatrace-api/39085/5 "2023-03-30T08:15:52Z")

</div>

Thank you for your answer.

---

<div class="post-metadata">

**Author:** ![paolo\_fumanelli](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/paolo_fumanelli/32/1037_2.png) [@paolo\_fumanelli](https://community.dynatrace.com/u/paolo_fumanelli)\
**Post date:** [March 30, 2023, 8:30am UTC](https://community.dynatrace.com/t/how-to-get-a-host-id-with-web-request-url-using-the-dynatrace-api/39085/6 "2023-03-30T08:30:08Z")

</div>

You can find service entity id by accessing service detail page, then look at URL, you’ll find SERVICE-XYZXYZXYZ.

Bye  
Paolo

---

<div class="post-metadata">

**Author:** ![guihoon\_hwang](https://avatars.discourse-cdn.com/v4/letter/g/cc9497/32.png) [@guihoon\_hwang](https://community.dynatrace.com/u/guihoon_hwang)\
**Post date:** [March 30, 2023, 8:31am UTC](https://community.dynatrace.com/t/how-to-get-a-host-id-with-web-request-url-using-the-dynatrace-api/39085/7 "2023-03-30T08:31:24Z")

</div>

Yes, but is there any way to get it through API?

thanks,

guihoon

---

<div class="post-metadata">

**Author:** ![paolo\_fumanelli](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/paolo_fumanelli/32/1037_2.png) [@paolo\_fumanelli](https://community.dynatrace.com/u/paolo_fumanelli)\
**Post date:** [March 30, 2023, 10:22am UTC](https://community.dynatrace.com/t/how-to-get-a-host-id-with-web-request-url-using-the-dynatrace-api/39085/8 "2023-03-30T10:22:11Z")

</div>

In order to retrieve service entity id via API, you should know service name and any other service tag or property that can be helpful to filter exactly the service you are looking for.

Using the same API mentioned in my comment above, you can find your service id by providing the following entity selector if you know the entire or part of the service name:

type(SERVICE),entityName.equals() or&nbsp;type(SERVICE),entityName.contains() or&nbsp;type(SERVICE),entityName.startsWith()

As said above, you can add filters by tag and other properties.

I suggest you to take a look here:

[Environment API v2 - Entity selector | Dynatrace Docs](https://www.dynatrace.com/support/help/dynatrace-api/environment-api/entity-v2/entity-selector)

bye  
Paolo

---

<div class="post-metadata">

**Author:** ![guihoon\_hwang](https://avatars.discourse-cdn.com/v4/letter/g/cc9497/32.png) [@guihoon\_hwang](https://community.dynatrace.com/u/guihoon_hwang)\
**Post date:** [March 31, 2023, 12:27am UTC](https://community.dynatrace.com/t/how-to-get-a-host-id-with-web-request-url-using-the-dynatrace-api/39085/9 "2023-03-31T00:27:40Z")

</div>

Thank you. It was very helpful.
