API > How to get DISKID and DISK NAME and associated HOST?

Goal: Find out the API way to get host-name, host-id, disk-name, disk-id.

Use case sample:

  • HostABC HOST-DAFC097F97F00205
  • DISK-BE465B9E78ADD276  > Unable to find both: the DISK-ID associated HOST-ID?  and its exact DISK-NAME such as /home, /infra, etc?

Question: which API or multi-APIs can help to get above 4 infos (host-name, host-id, disk-name, disk-id)?

FYI Reference: https://community.dynatrace.com/t5/Dynatrace-API/Correlating-multiple-disk-entities-within-host-entity-using/td-p/123501 ( but 1) we do not think that API is correct one, plus 2)  that URL also has similar concern of how to find DISK-name and associate host via disk-id)

Hi,

I would use Monitored entities API - GET an entity . It return host id, host display name and disks ids.

"entityId": "HOST-06F288EE2A930951",
"displayName": "my host",
"toRelationships": {
    "isDiskOf": [
      {
        "id": "DISK-0393340DCA3853B0",
        "type": "DISK"
      }
    ]
  }

You can use same API to get disk display name.

Best regards

Thanks!

So in total - 2 run of same API but with diff entities -

  • Step1: api/v2/entities?pageSize=1000&entitySelector=type(“HOST”)&fields=lastSeenTms,properties,tags,managementZones,toRelationships  to get list of hosts, hostname, hostid and associated diskids
  • Step2: loop step1 diskid then use api/v2/entities/{disk-id} (e.g. api/v2/entities/DISK-BE465B9E78ADD276) to get diskname

Hi,

Yes.

Best regards

Here is the Curl Commands for each layer:

To get the Disks on a host:
curl -X ‘GET’ \   'https://<YOUR ID>.live.dynatrace.com/api/v2/entities/HOST-<ID>?fields=properties%2Ctags%2CmanagementZones%2CtoRelationships’ \   -H ‘accept: application/json; charset=utf-8’ \   -H ‘Authorization: Api-Token <YOUR TOKEN>’

To Get the True Disk name from the Disk IDs:

curl -X ‘GET’ \   'https://<YOUR ID>.live.dynatrace.com/api/v2/entities/DISK-<ID>?fields=properties%2Ctags%2CmanagementZones%2CtoRelationships’ \   -H ‘accept: application/json; charset=utf-8’ \   -H ‘Authorization: Api-Token <YOUR TOKEN>’