14 May 2025 07:59 AM
Hi all,
I am creating a dashbord for capacity management but I would like the metric to be selectable by a variable.
I currently have several variables created that allow me to filter by host entity tags and variables that allow me to select the metric type (avg, max, min). The problem I am having is when trying to use the variables to select the metric.
I have a variable ($Metric) that contains:
I want to use that variable in a simple DQL for example:
timeseries usage = percentile(dt.host.cpu.usage, 95, rollup: avg), by:{dt.entity.host}, from: -7d | limit 2
That is:
timeseries usage = percentile($Metric, 95, rollup: avg), by:{dt.entity.host}, from: -7d | limit 2
When doing so I get an error: “The parameter has to be a metric key.” “queryString“: ‘timeseries usage = percentile(\’dt.host.cpu.usage\”, 95, rollup: \“avg”), by:{dt.e....
I understand that the problem is how to parse the value of the variable to the query, is there any way to do it?
Thanks a lot for your time
Victor
Solved! Go to Solution.
14 May 2025 08:46 AM - edited 14 May 2025 08:46 AM
Hi
You should try using the ":noquote" option for variable replacement like this :
timeseries usage = percentile($Metric:noquote, 95, rollup: avg), by:{dt.entity.host}, from: -7d | limit 2
14 May 2025 09:26 AM - edited 14 May 2025 09:27 AM
Works 🖖,
Thanks a lot
Victor