API call for OneAgent using tags

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”

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)

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’

thank you so much

Hi @huzoor

  1. you can create access token with “oneAgents.read”, “DataExport” scopes either or both would be fine.
  2. If you have access to environment Api v1 > oneagent on a host > Get.
  3. unlock the key > try it now > execute.

Regards,