Search code examples
prometheusgrafana

Use Grafana variable as input parameter for prometheus function


I am trying to create a panel that shows the n'th percentile request time using the Prometheus function histogram_quantile(). I have a text box variable on the Grafana dashboard that the user will enter a floating point value in. I want to use this variable as the input to histogram_quantile

My current query is

histogram_quantile($quantile, 
   sum(rate( request_duration_seconds_bucket[2m])) by (le))

However I get an error" : "1:20: parse error: unexpected character: '$'"

Is it possible to use a grafana variable as input for a prometheus function?


Solution

  • Yes, it is possible to use dashboard variable as input for a prometheus function.

    You have some error in your case. Blind guess: you have a typo in the variable name, so it is not interpreted - use query inspector to verify that variable was replaced with the correct value.

    Try also to save dashboard and then refresh dashboard with browser refresh (F5).