Possible to have an int as a template variable

Hello all. I am wondering if what I am trying to achieve is even possible. What I want to do is, in a way, have a global constant variable. The variable is an integer, which equals 432000. What I want to be able to do is use this variable across my dashboard, so when I build queries I can use this constant to limit my data.

Here is a graphical representation of what I want to do.


What I want to do:

Is something like this even possible to do? Thanks for all of those who reply in advance.

Should work fine. Grafana will always store the variable value as a string, but that value will just get placed in your query - without quotation marks, unless you add them - so setting it to a valid integer (e.g. $var = “432000” or $var = “10”) should get you the result you’re after.

Where would I go about specifying that $var = “432000” ?

Check out https://grafana.com/docs/reference/templating/. If you for example set the variable type to be “Text box” you should get a box where you can enter the value.

Use ${var:raw} instead of just $var

1 Like