30 Mar 2023 07:57 AM - last edited on 20 Aug 2024 03:03 PM by Michal_Gebacki
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
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
Solved! Go to Solution.
30 Mar 2023 08:16 AM - edited 30 Mar 2023 08:34 AM
Hello @guihoon_hwang
Try the {Service:Instance} of 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
30 Mar 2023 09:15 AM
Thank you for your answer.
30 Mar 2023 08:27 AM
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
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.
30 Mar 2023 09:15 AM
Thank you for your answer.
Additionally, May I know how to get a service id?
30 Mar 2023 09:30 AM
You can find service entity id by accessing service detail page, then look at URL, you'll find SERVICE-XYZXYZXYZ.
Bye
Paolo
30 Mar 2023 09:31 AM
Yes, but is there any way to get it through API?
thanks,
guihoon
30 Mar 2023 11:22 AM
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 type(SERVICE),entityName.contains() or 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
bye
Paolo
31 Mar 2023 01:27 AM
Thank you. It was very helpful.