As part of the Grafana 9.2 release, we’re making it easier to create dynamic and interactive dashboards with a new and improved Grafana Loki query variable editor.
Templating is a great option if you don’t want to deal with hard-coding certain elements in your queries, like the names of specific servers or applications. Previously, you had to remember and enter specific syntax in order to run queries on label names or values. But now you can select variables from a drop-down menu at the top of your Grafana dashboard so you can easily switch the data sources being displayed.
In this blog, we’ll show you how to use the new query variable editor so you can get your dashboards up and running quicker.
What you need to know about the Grafana Loki query variable editor
Before we get into the UI improvements, let’s go over the basic elements of the Loki query editor. Loki is an open source log aggregation system by Grafana Labs. Within Loki, you can use the query editor to write, edit, and run queries across logs or metrics.
With query variables, you can query any Loki data source for a list of labels or label values. This would then return either a list of label names, label values for a specific label, or a list of label values for a label in a specific log stream.
How to use the Loki query variable editor in Grafana
In the quick video demo below, you’ll see how we’ve made it easier to work with query variables. To select label names, go to Query type and select Label names from the drop-down menu. Choose or input a label and you’re all set. It’s that simple.
There’s supposed to be a video here, but for some reason there isn’t. Either we entered the id wrong (oops!), or Vimeo is down. If it’s the latter, we’d expect they’ll be back up and running soon. In the meantime, check out our blog!
In the previous version of the variable editor, you had to know the exact syntax to retrieve label names or label values if you wanted to add it to your query. With the new Loki query variable editor in Grafana 9.2 you don’t have to worry about that anymore. And even better, you can still use your old variables in the new editor — this feature is backwards compatible.
Learn more about the Grafana 9.2 release
Grafana 9.2 brought a wide range of improvements that help you create and share Grafana dashboards and alerts. In addition to the new Loki query variable editor, there’s also support for Google Analytics 4 properties, new ways to get support for panels, access control improvements, security fixes, and much more.
To dig into all the details, check out the complete changelog or the What’s New in Grafana 9.2 documentation.
Grafana Cloud is the easiest way to get started with metrics, logs, traces, and dashboards. We have a generous free forever tier and plans for every use case. Sign up for free now! You can also check out our free webinar, “Getting started with Grafana,” which is available on demand.