29 Mar 2023
11:57 PM
- last edited on
30 Mar 2023
04:42 AM
by
Ana_Kuzmenchuk
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.
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
Thank you for your answer.
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.
Thank you for your answer.
Additionally, May I know how to get a service id?
You can find service entity id by accessing service detail page, then look at URL, you'll find SERVICE-XYZXYZXYZ.
Bye
Paolo
Yes, but is there any way to get it through API?
thanks,
guihoon
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
Thank you. It was very helpful.