12 Jul 2025 07:33 AM
Hi,
I'm new to Dynatrace and DQL, and I’d appreciate some advice. I'd like to calculate a ratio between two metrics (avg(read_time) / avg(write_time)) and display it as a single value in the Dynatrace SaaS Dashboards App.
Is this possible, and what’s the correct way to do it?
Thanks in advance!
Solved! Go to Solution.
12 Jul 2025 08:59 PM
Hi Irdina,
Please try this DQL and see if this is what you are trying to achieve:
This is a time series showing the ratio of average disk write time to average disk read time over time, with the intermediate metrics removed for clarity.
timeseries { write_time = avg(dt.host.disk.write_time), read_time = avg(dt.host.disk.read_time) }
| fieldsAdd expression = write_time[] / read_time[]
| fieldsRemove write_time, read_time
14 Jul 2025 04:45 AM
Yes, thank you for the help, the solution u gave is a great start to have.
14 Jul 2025 04:47 AM
Current update:
__________________________
timeseries {
write_time = avg(dt.host.disk.write_time),
read_time = avg(dt.host.disk.read_time)
}
| fieldsAdd wt = arrayAvg(write_time), rt = arrayAvg(read_time)
| fieldsAdd ratio = concat(tostring(toLong(wt)), ":", tostring(toLong(rt)))
| fieldsKeep ratio
_____________________
I extended the logic to convert the metric outputs into scalar values suitable for a single value tile. I also included a string-based ratio format