# Dashboard Configure Variables

## Table of Contents

- [Configure Template Variables](https://docs.kloudfuse.com/platform/latest/dashboards/usage/action-menu-configurable-variables/#configure-template-variables)
  - [Create a Template Variable](https://docs.kloudfuse.com/platform/latest/dashboards/usage/action-menu-configurable-variables/#create-a-template-variable)
  - [General Settings](https://docs.kloudfuse.com/platform/latest/dashboards/usage/action-menu-configurable-variables/#general-settings)
  - [Query Options](https://docs.kloudfuse.com/platform/latest/dashboards/usage/action-menu-configurable-variables/#query-options)
  - [Filter values](https://docs.kloudfuse.com/platform/latest/dashboards/usage/action-menu-configurable-variables/#filter-values)
  - [Use Regex](https://docs.kloudfuse.com/platform/latest/dashboards/usage/action-menu-configurable-variables/#use-regex)
  - [Sort and Selection Options](https://docs.kloudfuse.com/platform/latest/dashboards/usage/action-menu-configurable-variables/#sort-and-selection-options)
  - [Preview and Save](https://docs.kloudfuse.com/platform/latest/dashboards/usage/action-menu-configurable-variables/#preview-and-save)
- [Use a Textbox Variable](https://docs.kloudfuse.com/platform/latest/dashboards/usage/action-menu-configurable-variables/#use-a-textbox-variable)
  - [General Settings](https://docs.kloudfuse.com/platform/latest/dashboards/usage/action-menu-configurable-variables/#general-settings-2)
  - [Text Options](https://docs.kloudfuse.com/platform/latest/dashboards/usage/action-menu-configurable-variables/#text-options)
  - [Use Cases](https://docs.kloudfuse.com/platform/latest/dashboards/usage/action-menu-configurable-variables/#use-cases)
- [Use a Custom Variable](https://docs.kloudfuse.com/platform/latest/dashboards/usage/action-menu-configurable-variables/#use-a-custom-variable)
  - [General Settings](https://docs.kloudfuse.com/platform/latest/dashboards/usage/action-menu-configurable-variables/#general-settings-3)
  - [Custom Options](https://docs.kloudfuse.com/platform/latest/dashboards/usage/action-menu-configurable-variables/#custom-options)
  - [Selection Options](https://docs.kloudfuse.com/platform/latest/dashboards/usage/action-menu-configurable-variables/#selection-options)
  - [Preview and Save](https://docs.kloudfuse.com/platform/latest/dashboards/usage/action-menu-configurable-variables/#preview-and-save-2)

Dashboard variables act as placeholders in panel queries. They allow dashboards to adapt based on user selections—such as cluster, namespace, environment, or service—without changing the underlying queries.

Variables improve reusability by letting you:

- Switch between environments without duplicating dashboards.
- Filter data across all panels with a single selection.
- Provide drop-downs, text inputs, or pre-defined options to dashboard viewers.

You can configure several types of template variables:

## Configure Template Variables

Template variables let you dynamically filter dashboards using runtime values from your telemetry data, such as namespace, cluster, pod, or service.

### Create a Template Variable

1. In the dashboard, open the **Actions** menu.
2. Select **Configure variables**.
3. Click **Add Variable**.

### General Settings

- **Name** — Internal reference used in queries (e.g., `$namespace`)
- **Label** — Optional UI label (e.g., **Namespace**)
- **Description** — Optional help text visible in the dropdown
- **Variable type** — Select from:
  - `Query` (default): populate values dynamically from the backend

### Query Options

- **Stream type** — Choose `Metrics`, `Logs`, or other supported types
- **Query type** — Select how to extract values:
  - `Label values` — populate from label keys
  - `Series` — match full series names
- **Label** — Choose a label such as `service_namespace` or `cluster`
- **Metric** — Optional, limit values to a specific metric

### Filter values

Use filters to narrow results:

- Combine filters using **key**, **operator**, and **value**
- Click `+` to add multiple filter conditions

### Use Regex

Use regex to extract or format display values.

Example:

```
/.+(?<text>.*):(?<value>.*)/
```

This lets you split a label or metric into display name and internal value.

### Sort and Selection Options

- **Sort** — Choose how to order values (e.g., by value or name)
- **Multi-value** — Allow selecting more than one value
- **Allow custom values** — Allow users to enter custom values
- **Include all options** — Add an **All** selection to apply to every possible value

### Preview and Save

1. Click **Run query** to test the variable setup.
2. Use the preview at the bottom to confirm expected values.
3. Click **Save** or **Go back to list** to apply the configuration.

|     |     |
| --- | --- |
|  | Once configured, you can use the variable in any panel query using `$variableName`. |

## Use a Textbox Variable

Use a `Textbox` variable to let users input freeform text at runtime, such as a dynamic filter value or manual override.

### General Settings

Same fields as other variable types:
- **Name** — Internal reference (e.g., `$env`)
- **Label** — Display name shown in the dashboard
- **Description** — Optional help text

### Text Options

- **Default value** — Optional preset value (e.g., `prod`, `us-east-1`, `*`)

### Use Cases

Textbox variables are useful when:

- You want to test specific values without listing all possibilities
- You use regex or wildcards in metric filters
- You want maximum input flexibility

|     |     |
| --- | --- |
|  | Textbox values must match the expected query format in your panels. |

## Use a Custom Variable

Set the variable type to `Custom` for a static list of manually defined values.

### General Settings

Same as query variables:
- **Name** — Internal reference (e.g., `$threshold`)
- **Label** — Optional display name
- **Description** — Optional help text

### Custom Options

Define custom values in the textbox using comma-separated format.

You can specify:
- Simple values: `20`, `30`
- Key-value format: `key1: value1`, `key2: value2`
- Escaped characters: `escaped\,value`

|     |     |
| --- | --- |
|  | Escape commas (`\,`) if they’re part of the value. |

### Selection Options

- **Multi-value** — Enable selection of multiple static values
- **Allow custom values** — Let users add entries at runtime
- **Include all options** — Adds an `All` option

### Preview and Save

1. Verify values using the **Preview values** section.
2. Click **Go back to list** to save and return to the variable list.
