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

Metrics as Variables

VictorRuiz
Contributor

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:

  • dt.host.cpu.usage
  • dt.host.memory.usage

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

2 REPLIES 2

GerardJ
Advisor

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

 

Gerard

Works 🖖,

 

  Thanks a lot

 

Victor

Featured Posts