The GET metrics endpoint provides you the ability to query multiple metrics, along with partial or even full descriptors of metrics.
This example shows how to fetch the descriptors of several metrics of one parent:
builtin:host.cpu.idle
)builtin:host.cpu.load
)builtin:host.cpu.usage
)For each, we'll query the full descriptors:
We have to set the following query parameters:
builtin:host.cpu.(idle,usage,load)
displayName,description,unit,entityType,aggregationTypes,transformations,defaultAggregation,dimensionDefinitions
. Note that metricId
is omitted here, because it is always presented in the response.You can get the response in two formats:
application/json
.text/csv; header=present
. If you're not interested in the header row, use text/csv; header=absent
.To authenticate the request, set the Authorization header of the request to Api-token {your-token}
. The token must have the Read metrics (metrics.read
) permission.
Here's the Curl code of the request. Be sure to use the URL of your own environment and a real API token.
curl -L -X GET 'https://mySampleEnv.live.dynatrace.com/api/v2/metrics?fields=displayName,description,unit,entityType,aggregationTypes,transformations,defaultAggregation,dimensionDefinitions&metricSelector=builtin:host.cpu.(idle,usage,load)' \-H 'Authorization: Api-Token dt0c01.abc123.abcdefjhij1234567890' \-H 'Accept: application/json'
curl -L -X GET 'https://mySampleEnv.live.dynatrace.com/api/v2/metrics?fields=displayName,description,unit,entityType,aggregationTypes,transformations,defaultAggregation,dimensionDefinitions&metricSelector=builtin:host.cpu.(idle,usage,load)' \-H 'Authorization: Api-Token dt0c01.abc123.abcdefjhij1234567890' \-H 'Accept: text/csv; header=present'
https://mySampleEnv.live.dynatrace.com/api/v2/metrics?fields=displayName,description,unit,entityType,aggregationTypes,transformations,defaultAggregation,dimensionDefinitions&metricSelector=builtin:host.cpu.(idle,usage,load)
Both examples contains full payload, nothing is truncated.
{"totalCount": 3,"nextPageKey": null,"metrics": [{"metricId": "builtin:host.cpu.idle","displayName": "CPU idle","description": "","unit": "Percent","entityType": ["HOST"],"aggregationTypes": ["auto","avg","max","min"],"transformations": ["filter","fold","merge","names","parents"],"defaultAggregation": {"type": "avg"},"dimensionDefinitions": [{"key": "dt.entity.host","name": "Host","index": 0,"type": "ENTITY"}]},{"metricId": "builtin:host.cpu.load","displayName": "System load","description": "","unit": "Ratio","entityType": ["HOST"],"aggregationTypes": ["auto","avg","max","min"],"transformations": ["filter","fold","merge","names","parents"],"defaultAggregation": {"type": "avg"},"dimensionDefinitions": [{"key": "dt.entity.host","name": "Host","index": 0,"type": "ENTITY"}]},{"metricId": "builtin:host.cpu.usage","displayName": "CPU usage %","description": "Percentage of CPU time currently utilized.","unit": "Percent","entityType": ["HOST"],"aggregationTypes": ["auto","avg","max","min"],"transformations": ["filter","fold","merge","names","parents"],"defaultAggregation": {"type": "avg"},"dimensionDefinitions": [{"key": "dt.entity.host","name": "Host","index": 0,"type": "ENTITY"}]}]}
metricId,displayName,description,unit,entityType,aggregationTypes,transformations,defaultAggregation,dimensionDefinitionsbuiltin:host.cpu.idle,CPU idle,,Percent,[HOST],"[auto, avg, max, min]","[filter, fold, merge, names, parents]",avg,[Host:ENTITY]builtin:host.cpu.load,System load,,Ratio,[HOST],"[auto, avg, max, min]","[filter, fold, merge, names, parents]",avg,[Host:ENTITY]builtin:host.cpu.usage,CPU usage %,Percentage of CPU time currently utilized.,Percent,[HOST],"[auto, avg, max, min]","[filter, fold, merge, names, parents]",avg,[Host:ENTITY]