We intend to get checklist of hosts with their CPU% and MEM% used info, which should return result to be consistent with dynatrace console > hosts page. We tried api/v1/oneagents and api/v1/entity/infrastructure/hosts, we are unable to find those info CPU% and MEM% and NetworkTraffic.
The above call uses curl arguments and the following metric selector with a names transformation to add the hostname:
builtin:host.(cpu,mem).usage:names
Finally, the “accept” header is set to text/csv to output the metric data in CSV format. The data is returned with all the cpu metrics followed by all the memory metrics. A simple sort in Excel can put them in hostname order.
I like this solution of csv (bundle builtin:host.(cpu,mem).usage:names) and definitely keep as future reference. This case I use json output. I am able to use your approach to get below:
Result from /api/v2/metrics/query?metricSelector=builtin%3Ahost.%28cpu%2Cmem%29.usage%3Anames&resolution=10m&from=-5m&to=now:
Q1. If feasible, any straight curl way to only pick last data-point-value? we intend to only grab latest/now data-point binding CPU, MEM%, total MEM, disk latency and network traffic value, which is same as last 30mins default timeframe shown in console > hosts page.
Q2. From “console > hosts page”: there is extra "total MEM " + “Disk latency” + “Network traffic”, which metrics is for “Disk latency”?
i.e. please also help to review below use case and confirm "total MEM " + “Network traffic” metrics are correct.
HostName1,
“Memory usage” = 4.46 % of 31.2 GiB (4.46% grabbed from above your providing builtin:host.mem.usage, 31.2GiB total MEM from “builtin:host.mem.total”), “Disk latency”=725 µs (? which one?), “Network traffic”=“14.7 kbit/s”(from “builtin:host.net.nic.traffic”)
I am able to use your approach to grab those 4 metrics by hostname, via 3 separate API calls, is it feasible to make all 3 into 1 convenient API call? if feasible, what could be the syntax?
Q1) There is a last transformation which returns the last data point of the timeframe searched. I wouldn’t suggest using it with a timeframe consisting of “now” because often times the current minute is null until the metric value is received.
Q2) Disk latency is the disk read and write time metrics:
builtin:host.disk.readTime
builtin:host.disk.writeTime
Q3) You can use commas to separate multiple metrics in a single query