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

Retrieve all host group names in the environment via APIs

davide_piras
Visitor

I need to use some Dynatrace APIs to retrieve a list of all host groups names configured in our environment,

 

i do not have host group ids and i do not want to retrieve a single host or host group, simply a full list of ALL  distinct host groups names, and their ids in case host groups also have IDs.

 

what is the easiest set of APIs to use to retrieve this list?

 

Thanks,

Davide

 

2 REPLIES 2

ChadTurner
DynaMight Guru
DynaMight Guru

You can do this via the API: 

ChadTurner_0-1623264260159.png

I recommend saving the API Json then importing it to excel where you then can remove unwanted data: 

ChadTurner_1-1623264476719.png

 

-Chad

ct_27
DynaMight Helper
DynaMight Helper

I have an equally good solution.   Someone had created an amazing set of powershell scripts to also extract administrative type data out of DT.  The Git Repo is here:  https://github.com/mzball-dt/dynatrace-pwsh

 

Note: Each script has a helpful header that tells you what permissions the token requires, the parameters you can pass in, and some example runs

 

First create a token with the proper access to run the script. You'll need it in Step 5

 

Steps for DT SaaS. If you use Managed then follow the instruction in the Git repo.

1) downloaded and extract the zip

2) Open a powershell prompt (e.g. C:\dynatrace-pwsh-master)

3) navigate to the directory you extracted the code into

4) Enter (replace xxxxx with your SaaS tenant id)

 $env:dtenv='https://xxxxxxxxx.live.dynatrace.com';

5) Enter 

$env:dttoken='dt0c01.XXXXXXXXXXX';

6) Enter this command and enter 'Y'. This changes the execution policy so that you can run third-party scripts.

Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass;   

 

7) Run any of the scripts you like.

 

Here are example commands I use frequently to get the data

C:\dynatrace-pwsh-master\get-tenantHostGroupDetail.ps1 -token dt0c01.xxxxxx -dtenv https://xxxxx.live.dynatrace.com  -outfile hostgroup_06092021.csv

C:\dynatrace-pwsh-master\get-tenantHostGroupDetail.ps1 | format-table

C:\dynatrace-pwsh-master\get-tenantHostGroupDetail.ps1 -token dt0c01.xxxxxxxx -dtenv https://xxxxxxx.live.dynatrace.com  -summary