30 Jul 2021 12:43 PM - last edited on 19 Nov 2021 11:16 AM by MaciejNeumann
Hello Everyone,
I am new to Dynatrace and its APIs, I am trying to get average CPU usage for last 5 mins for all HOSTs.
Here is my API call :
https://{your-domain}/e/{your-environment-id}/api/v2/metrics/query?metricSelector=builtin:host.cpu.u...
This gives me : CPU Usage like below.
CPU Usage per minute for last 5 minutes per host.
metricId,dt.entity.host,time,value
builtin:host.cpu.usage,HOST1,2021-07-30 11:23:00,1.8231608072916667
builtin:host.cpu.usage,HOST1,2021-07-30 11:24:00,2.5442708333333335
builtin:host.cpu.usage,HOST1,2021-07-30 11:25:00,2.3963826497395835
..
builtin:host.cpu.usage,HOST2,2021-07-30 11:23:00,2.1693929036458335
builtin:host.cpu.usage,HOST2,2021-07-30 11:24:00,
builtin:host.cpu.usage,HOST2,2021-07-30 11:25:00,0.35211181640625
What I want is :
I am looking for one value per most which is average CPU usage for that host for last 5 minute like below.
metricId,dt.entity.host,time,value
builtin:host.cpu.usage,HOST1,2021-07-30 11:xx:00,1.8231608072916667
builtin:host.cpu.usage,HOST2,2021-07-30 11:xx:00,2.5442708333333335
builtin:host.cpu.usage,HOST3,2021-07-30 11:xx:00,2.3963826497395835
How can I transform the API to get such results? I read about metric transformation, didn't follow it well.
Thank You.
Solved! Go to Solution.
30 Jul 2021 01:05 PM
Hello @Aniket ,
I believe you want to use the fold transformation for that. It will aggregate the data points into one for each dimension.
https://your-domain/e/your-environment-id/api/v2/metrics/query?metricSelector=builtin:host.cpu.usage:fold&resolution=1m&from=now-5m&entitySelector=type("HOST")
Julius
30 Jul 2021 03:48 PM
Thanks @Julius_Loman 😊