Whether you are just starting your observability journey or already are an expert, our courses will help advance your knowledge and practical skills.
Expert insight, best practices and information on everything related to Observability issues, trends and solutions.
Explore our guides on a broad range of observability related topics.
A variable is like a placeholder for a value used in queries. Once set up in Custom Dashboards, your dashboard panel’s queries will update to show data for that value.
Variables make dashboards more interactive and dynamic. Instead of putting specific names for servers, applications, or sensors in your queries, you can use variables instead. Once set up, you can easily switch between different data views. This means that if you have very complex, high-cardinality metrics, you can add variables to zoom in on specific values you care about, across widgets for all data types and regardless of the variable source type.
Choose from any of the following variable types:
Variable type | Description |
---|---|
Static-value variable | Manually define a fixed list of variable values, such as a number or a string of numbers separated by a comma. For example, if you have country names that never change, you might want to create them as a static-value variable rather than a data source variable. |
Query variable | Variable values are retrieved from a data source query using logs, metrics, or spans. For example, a query variable can generate a list of server names, sensor IDs, or data centers, dynamically updating the values by fetching options via a data source query. Query variables prove beneficial when managing multiple data source instances, especially across diverse environments. |
Navigate to Dashboards > Custom Dashboards.
In a new or existing dashboard, click the Manage Variable icon { } in the upper left-hand corner of your dashboard. Then click + Variable.
Define the following fields for all variable types:
Select a variable type.
Text entered in this field determines how the variable name will appear in your query, e.g, {{podvalues}}. No capitals or spaces are allowed.
[Optional] Text entered in this field will appear in the top bar selection as part of the drop-down, e.g., “My Pods”.
Once you have defined your variable, you may choose from these selection options:
When both options are selected, all variable options are selected by default, and one or more may be deselected. Opting out of both options will allow you to select one variable value at a time.
STEP 1. Select static-values
as variable type.
STEP 2. Define the general options.
STEP 3. Enter the variable values manually, separated by a comma. For example: 2024, 2025, 2026, 2027
.
STEP 4. Click SAVE.
STEP 1. Select query
as variable type.
STEP 2. Define the general options.
STEP 3. For query options:
logs
as your source.values
as your variable type.STEP 4. Click SAVE.
STEP 1. Select query
as variable type.
STEP 2. Define the general options.
STEP 3. For query options:
spans
as your source.values
as your variable type.STEP 4. Click SAVE.
STEP 1. Select query
as variable type.
STEP 2. Select general options.
STEP 3. For query options:
metrics
as your source.metric names
as your variable type.^kube(.*)
will produce all metric names that begin with kube.STEP 5. Click SAVE.
STEP 1. Select query
as variable type.
STEP 2. Select variable and display name.
STEP 3. For query options:
metrics
as your source.metric labels
as your variable type. Choose the label for which you want the values displayed.^kube(.*)
will produce all metric names that begin with kube.STEP 5. Click SAVE.
STEP 1. Select query
as variable type.
STEP 2. Define the general options.
STEP 3. For query options:
metrics
as your source.label values
as your variable type.cluster
the labels for a specific metric, you may choose to filter the labels by cluster
. Select a value that is {{podvalue}} or the hardcoded name of your cluster.STEP 5. Click SAVE.
Easily view and manage the variables from the Custom Dashboards upper toolbar.
To edit or delete a variable, select the variable display name to be rerouted to the variable setup. To delete, click on the trash icon.
Query with Lucene, PromQL, or DataPrime.
Use {{ variable_name }}
in the widget’s query language.
The PromQL query sum(kube_pod_owner{pod=~"{{pod}}"})
is used to aggregate metrics related to Kubernetes pods. {pod=~"{{pod}}"}
is a label selector that filters the kube_pod_owner metric for the specific pod whose name matches the variable’s value. The {{pod}} placeholder is a template variable, which replaces the actual pod name when the query is executed.
You may use predefined variables in your PromQL query.
Variable | Description | Example |
---|---|---|
${__range} | This variable represents the duration of the dashboard time range. It is rendered as an interval string supported by PromQL. e.g., If one selects a time range from 13.00 to 14.30, then ${__range} variable will be rendered as 90m. | 1d, 5m |
${__range_s} | Rendered as the number of seconds in the selected time frame | 60s, 180s |
${__range_ms} | Rendered as the number of milliseconds in the selected time frame | 60ms, 180ms |
For example, you could use the __range
variable in sum_over_time
:
sum_over_time(kube_pod_owner[${__range}])
For example, use product_id:{{pid}}
where pid
is the actual variable name (not the display name).
For example,
source logs | filter {{severity}}.arrayContains($m.severity)
source logs | filter arrayContains({{severity}}, $m.severity)
{{severity}}
is a logs-based variable created using the severity metadata field.
Check out this instructional video to jump-start your variable setup.
Need help?
Our world-class customer success team is available 24/7 to walk you through your setup and answer any questions that may come up.
Feel free to contact us via our in-app chat or by emailing [email protected].