Search code examples
prometheusgrafanagrok

Understanding Grafana metrics variables


Provided with some prometheus series:

query_duration{datname="audit_log", group="grok-pg", instance="docker.for.mac.localhost:9144", job="grok-pg", ts="21-05-19 12:18:10.965"}   14.859
query_duration{datname="audit_log", group="grok-pg", instance="docker.for.mac.localhost:9144", job="grok-pg", ts="21-05-19 12:19:27.603"}   10.082

Grafana is able to recognise variable datname if I assign a specific value:

enter image description here

However if I treat it as a variable then it does not work:

enter image description here

What am I missing? Thank you for your attention


Solution

  • $datname is a Grafana variable whose value needs to be set by Grafana before the expression is evaluated and sent to Prometheus to get the data.

    Need to set the variable in Settings > Variables.

    enter image description here