cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Function replace by variable (dropdown selection)

wbolten
Frequent Guest

Hi,

I have a panel with the below timeseries command and it is working. However they would like to be able to change from avg to max, or other ones for that matter and without the need to change the DQL everytime in the panel. 

I am doing a similar thing with dropdown values on the dashboard for the threshold of the disk usage. Doing the same for the avg to change it to max is not working. 

Possible options are: min, max, avg

 

timeseries diskusage = avg(dt.host.disk.used.percent), by:{dt.entity.host,dt.entity.disk}, interval:1d

Any suggestions? 

@marina_pollehn 

 

4 REPLIES 4

krzysztof_hoja
Dynatrace Pro
Dynatrace Pro

Variable value is a quoted string, so it is not possible to use it as a command or function in the query, but you can check such query:

timeseries {
avg_diskusage = avg(dt.host.disk.used.percent), 
min_diskusage = avg(dt.host.disk.used.percent), 
max_diskusage = avg(dt.host.disk.used.percent) },
by:{dt.entity.host,dt.entity.disk}, interval:1d
| fields diskusage=coalesce( 
    if($function=="max", max_diskusage),
    if($function=="min", min_diskusage),
    avg_diskusage ), interval, timeframe, dt.entity.host, dt.entity.disk

together with this definition of variable:

krzysztof_hoja_0-1713904731815.png

 

Kris

 

Hero! Works for me 🙂 Made a small correction to the operators.

timeseries {
avg_diskusage = avg(dt.host.disk.used.percent),
min_diskusage = min(dt.host.disk.used.percent),
max_diskusage = max(dt.host.disk.used.percent) },

Thank you so much!!!!

A Dynatrace Professional nerd working for Conclusion Xforce

Thx for correction. "ctrl-c" + "ctrl-v" 😉

Kris

Hi @krzysztof_hoja 

This is an excellent work around and exactly what we needed. @marina_pollehn already adjusted the panel on our side and it is working as expected. 

Thank you. 

Featured Posts