Dynatrace API to get host mapping in /metrics/query

https://xxxxxxxx.live.dynatrace.com/api/v2/metrics/query?metricSelector=builtin:host.mem.avail.pct&resolution=1h

Suppose we use above URL and get sample data

{
“totalCount”: 2,
“nextPageKey”: null,
“resolution”: “1h”,
“result”: [
{
“metricId”: “builtin:host.mem.avail.pct”,
“data”: [
{
“dimensions”: [
“HOST-ADBCDAE05CEA42B2”
],
“dimensionMap”: {
“dt.entity.host”: “HOST-ADBCDAE05CEA42B2”
},
“timestamps”: [
1652248800000
],
“values”: [
83.1603291829427
]
}
]
}
]
}

This is sample dynatrace response we get. Here we have internal Id’s for host.

Inorder to find actual host name mapping and also process mapping we can use below mentioned APIs seperately.

https://xxxxx.live.dynatrace.com/api/v1/entity/services?relativeTime=5mins 
https://xxxxx.live.dynatrace.com/api/v1/entity/infrastructure/process-groups?relativeTime=5mins 
https://xxxxx.live.dynatrace.com/api/v1/entity/infrastructure/processes?relativeTime=5mins 
https://xxxxx.live.dynatrace.com/api/v1/entity/applications/ 
https://xxxxx.live.dynatrace.com/api/v1/entity/infrastructure/hosts

Can we get all metric data along with mapping data in /metrics/query API without calling above 5 apis? If any apis like that please let us know

It sounds like you may just need to add the ‘names’ transformation to your metric query e.g.:

builtin:host.disk.usedPct:splitBy("dt.entity.disk", "dt.entity.host"):names

This includes the names that map to the ids in the dimension mapping: