How do I fetch the list of monitored hosts?

A call to the /infrastructure/hosts endpoint returns a list of currently monitored hosts along with their attributes and relationships.

Hosts endpoint

https://{id}.live.dynatrace.com/api/v1/entity/infrastructure/hosts

HTTP GET parameters

The endpoint allows the following parameters to be sent as HTTP GET requests:

  1. tag (optional) Filters the resulting set of hosts by the given tag. Use multiple tag parameters to combine multiple tag filters using the logical operator AND. In case of key-value tags, such as imported AWS or CloudFoundry tags use following format: [context]key:value. An example for a complex tag could be: [AWS]Category:Demo.
  2. startTimestamp and endTimestamp (optional) Filters the resulting set of hosts by the last seen timestamp. The timestamp values must be in UTC milliseconds and the query is restricted to a maximum period of 3 days.

Result

  • fromRelationships: Outgoing connections from the host to other entities.
  • toRelationships: Incoming connections to the host.
  • tags: Returns the list of tags that have been defined for the host. This list contains all user-defined labels as well as all tags imported from third-party systems, such as AWS.
  • osType: Shows the operating system type of the host, such as Linux or Windows.
  • osVersion: Shows the operating system version of the host, such as Ubuntu 14.04.4 LTS, Trusty Tahr (kernel 4.2.0-41-generic), or Windows 10.

The following code block shows an example result:

[  
  {  
    entityId:"HOST-D70EC6885E79D6C4",
    displayName:"gdn-rx-ub12-ci04v (maintained by PHP agent team)",
    customizedName:"gdn-rx-ub12-ci04v (maintained by PHP agent team)",
    tags:[  
      {  
        context:"USER",
        key:"opsTeamBoston"
      }
    ],
    fromRelationships:{  
      isNetworkClientOfHost:[  
        "HOST-D70EC6885E79D6C4"
      ]
    },
    toRelationships:{  
      isNetworkClientOfHost:[  
        "HOST-D70EC6885E79D6C4"
      ]
    },
    osType:"LINUX",
    osArchitecture:"X86",
    osVersion:"Ubuntu 12.04.5 LTS, Precise Pangolin (kernel 3.13.0-39-generic)",
    hypervisorType:"VMWARE",
    ipAddresses:[  
      "172.18.147.13"
    ]
  }
]