cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

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

avrildong
Helper

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-enti... ( 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)

 

 

4 REPLIES 4

AntonPineiro
DynaMight Guru
DynaMight Guru

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

❤️ Emacs ❤️ Vim ❤️ Bash ❤️ Perl

avrildong
Helper

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

❤️ Emacs ❤️ Vim ❤️ Bash ❤️ Perl

ChadTurner
DynaMight Legend
DynaMight Legend

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%2Cmanagement... \   -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%2Cmanagement... \   -H 'accept: application/json; charset=utf-8' \   -H 'Authorization: Api-Token <YOUR TOKEN>'

-Chad

Featured Posts