Host disk usage API call

Hi, I am trying to use an API request to get a server disk usage percentage. How can I achieve this?

Hi,

You can go to data explorer and select metric you and instered (builtin:host.disk.usedPct in this case) and filter server by name.

After that, press “…” and select “Copy Request”:

And you have an example to get that data.

You need to generate a token with correct permissions in advance.

Best regards

@Itani_ML

Of course, I also recommend using API Explorer, which will allow you to easily prepare and check a query to retrieve the metric of your choice.

You can find the metrics where the @AntonPineiro pointed out.

Radek

Thanks you, it really worked. One last question, with this request, is it possible to only filter out the value?

Below is my request and I am running it from Bamboo, I only want to get the value of the disk as the output

curl -X GET “https://{environmentid}.live.dynatrace.com/api/v2/metrics/query?metricSelector=(builtin:host.disk.free:filter(and(or(in("dt.entity.host\”,entitySelector(\“type(~\“HOST~\”),entityName.equals(~\“dhdelasticls01.discsrv.co.za~\”)\”))))):splitBy():sort(value(auto,descending))):limit(100):names&from=-2h&to=now" -H “accept: application/json” -H “Authorization: Api-Token XXXX-XXXX”

Hi,

If you change visualization to “Single value”:

Notice “&resolution=Inf” is added in the end when you copy request from wizard. For example:

curl -X GET "https://{environment_id}.live.dynatrace.com/api/v2/metrics/query?metricSelector=(builtin:host.disk.usedPct:filter(and(or(in(\"dt.entity.host\",entitySelector(\"type(host),entityName.equals(~\"XXXX~\")\"))))):splitBy():sort(value(auto,descending))):names&from=-2h&to=now&resolution=Inf"  -H "accept: application/json"  -H "Authorization: Api-Token XXXX-XXXX"

Best regards