How to calculate a ratio between two metrics in Dynatrace SaaS Dashboards (DQL)?

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!

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

Yes, thank you for the help, the solution u gave is a great start to have.

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