Multi Dimensional Dashboard Variables
Introduction: The Need for Multi-Dimensional Filtering
In the previous lesson, you created your first query variable — a host selector that filters all panels on your dashboard. This was a significant improvement over hard-coded queries because it allowed you to switch between different hosts (host-a, host-b, host-c) with a single dropdown selection. However, if you look closely at your metrics data, you'll notice that host filtering alone isn't always enough to create focused visualizations.
Consider your disk metrics table. Each host doesn't just have one disk — it has multiple mount points. host-a might have a root partition (/), a var directory (/var), and a data volume (/data). When you filter by $host, your disk usage panel shows all three mount points combined, making it difficult to focus on a specific partition. The same issue exists with network metrics: each host has multiple network interfaces like eth0 and eth1. Filtering by host alone shows traffic across all interfaces mixed together.
What you need is the ability to filter along multiple dimensions simultaneously. You want to say, "Show me disk usage for host-a's root partition," or "Show me network throughput for host-b's eth0 interface." This requires combining your existing host variable with new variables that capture these additional dimensions. In this lesson, you'll create two new variables — one for disk mount points and one for network interfaces — and learn how to use multiple variables together in your WHERE clauses.
Creating the Mount Variable
Start by creating a variable that lists all available mount points from your disk metrics. This follows the exact same pattern you used when creating the host variable in the previous lesson: you’ll write a query that returns distinct mount points, and Grafana will use those results to populate a dropdown menu.
Open your dashboard settings by clicking the gear icon in the top right, select Variables from the sidebar, and click Add variable. Configure the variable with the following settings: Name: mount, Label: Mount Point, Type: Query, Data source: Postgres Local.
Then enter this query:
This query retrieves all unique mount points from your disk metrics table. The DISTINCT keyword ensures each mount point appears only once, even though it appears in hundreds or thousands of rows across different timestamps. The AS text, mount AS value pattern should be familiar from the previous lesson — this is the format Grafana requires for query variables. The text column determines what users see in the dropdown (like /, /var, /data), and the value column determines what gets substituted into your queries when that option is selected.
The ORDER BY mount clause sorts the mount points alphabetically. This is particularly useful for mount points because the forward slash character sorts before letters, which means your root partition (/) will always appear first in the list, followed by other paths like /data and /var.





