19 Sep 2024 07:02 PM - last edited on 24 Sep 2024 12:30 PM by Michal_Gebacki
Hi,
Can someone give me the api call to get the hosts associated with App ID, below is the output .. can someone get me the appropriate api call
"entityId": "HOST-xxx",
"displayName": "Ahghj.ally.corp",
"tags": [
{
"context": "CONTEXTLESS",
"key": "AppID",
"value": "104378"
Solved! Go to Solution.
19 Sep 2024 07:11 PM
Try this:
GitHub - dynatrace-oss/api-client-python: Dynatrace API Python client
from dynatrace import Dynatrace
from dynatrace import TOO_MANY_REQUESTS_WAIT
from dynatrace.environment_v2.tokens_api import SCOPE_METRICS_READ, SCOPE_METRICS_INGEST
from dynatrace.configuration_v1.credential_vault import PublicCertificateCredentials
from dynatrace.environment_v2.settings import SettingsObject, SettingsObjectCreate
from datetime import datetime, timedelta
# Create a Dynatrace client
dt = Dynatrace("environment_url", "api_token")
# Get all hosts and some properties
for entity in dt.entities.list('type("HOST"),tag("AppID:104378")'):
print(entity.entity_id, entity.display_name, entity.properties)
19 Sep 2024 07:16 PM
or this:
curl -X 'GET' \ 'https:/URL/e/ENV_ID/api/v2/entities?entitySelector=type%28%22HOST%22%29%2Ctag%28%22AppID%3A104378%22%29' \ -H 'accept: application/json; charset=utf-8' \ -H 'Authorization: Api-Token TOKEN'
19 Sep 2024 07:26 PM
thank you so much
25 Sep 2024 03:06 PM
Hi @huzoor
Regards,