

# Dashboards in Grafana version 12
<a name="v12-dashboards"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 12.x**.  
For Grafana workspaces that support Grafana version 10.x, see [Working in Grafana version 10](using-grafana-v10.md).  
For Grafana workspaces that support Grafana version 9.x, see [Working in Grafana version 9](using-grafana-v9.md).  
For Grafana workspaces that support Grafana version 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

 A dashboard is a set of one or more [panels](v12-panels.md) organized and arranged into one or more rows. Grafana ships with a variety of panels making it easy to construct the right queries, and customize the visualization so that you can create the perfect dashboard for your need. Each panel can interact with data from any configured [Connect to data sources](AMG-data-sources.md). 

The dashboard rendering engine is built on the Scenes framework, providing improved performance, better template variable support, and more flexible layouts.

 Dashboard snapshots are static. Queries and expressions cannot be re-executed from snapshots. As a result, if you update any variables in your query or expression, it will not change your dashboard data. 

**Topics**
+ [Using dashboards](v12-dash-using-dashboards.md)
+ [Building dashboards](v12-dash-building-dashboards.md)
+ [Managing dashboards](v12-dash-managing-dashboards.md)
+ [Managing playlists](v12-dash-managing-playlists.md)
+ [Sharing dashboards and panels](v12-dash-sharing.md)
+ [Variables](v12-dash-variables.md)
+ [Assessing dashboard usage](v12-dash-assess-dashboard-usage.md)
+ [Troubleshoot dashboards](v12-dash-troubleshoot.md)
+ [Searching Dashboards in Grafana version 12](v12-search.md)

# Using dashboards
<a name="v12-dash-using-dashboards"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 12.x**.  
For Grafana workspaces that support Grafana version 10.x, see [Working in Grafana version 10](using-grafana-v10.md).  
For Grafana workspaces that support Grafana version 9.x, see [Working in Grafana version 9](using-grafana-v9.md).  
For Grafana workspaces that support Grafana version 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

This topic provides an overview of dashboard features and shortcuts, and describes how to use dashboard search.

## Features
<a name="v12-dash-features"></a>

You can use dashboards to customize the presentation of your data. The following image shows the dashboard interface in the Amazon Managed Grafana workspace.

![\[An image showing the interface for dashboards in an Amazon Managed Grafana workspace, with highlights for the buttons for different features.\]](http://docs.aws.amazon.com/grafana/latest/userguide/images/AMG-dashboard-overview-v10.png)



|  Feature  |  Description  | 
| --- | --- | 
| **1. Home** | Select the Grafana home icon to be redirected to the home page configured in the Grafana instance. | 
| **2. Title** | When you select the dashboard title, you can search for dashboards contained in the current folder. | 
| **3. Sharing a dashboard** | Use this option to share the current dashboard by link or snapshot. You can also export the dashboard definition from the share modal. | 
| **4. Adding a new panel** | Use this option to add a panel, dashboard row, or library panel to the current dashboard. | 
| **5. Save dashboard** | Choose the Save icon to save changes to your dashboard. | 
| **6. Dashboard insights** | Choose to view analytics about your dashboard, including information about users, activity, and query counts. For more information, see [Assessing dashboard usage](v12-dash-assess-dashboard-usage.md). | 
| **7. Dashboard settings** | Use this option to change the dashboard name, folder, or tags and manage variables and annotation queries. For more information about dashboard settings, see [Modifying dashboard settings](v12-dash-modify-settings.md). | 
| **8. Time picker dropdown** |  Use to select relative time range options and set custom absolute time ranges. You can change the **Timezone** and **fiscal year** settings from the time range controls by clicking the **Change time settings** button. Time settings are saved on a per-dashboard basis.  | 
| **9. Zoom out time range** |  Use to zoom out the time range. For more information about how to use time range controls, see [Setting dashboard time range](#v12-dash-setting-dashboard-time-range).  | 
| **10. Refresh dashboard** | Select to immediately trigger queries and refresh dashboard data. | 
| **11. Refresh dashboard time interval** | Select a dashboard auto refresh time interval. | 
| **12. View mode**  | Select to display the dashboard on a large screen such as a TV or a kiosk. View mode hides irrelevant information such as navigation menus.  | 
| **13. Dashboard panel** |  The primary building block of a dashboard is the panel. To add a new panel, dashboard row, or library panel, select **Add panel**. [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/grafana/latest/userguide/v12-dash-using-dashboards.html)  | 
| **14. Graph legend** | Change series colors, y-axis, and series visibility directly from the legend. | 
| **15. Dashboard row** | A dashboard row is a logical divider within a dashboard that groups panels together. [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/grafana/latest/userguide/v12-dash-using-dashboards.html)  | 

## Keyboard shortcuts
<a name="v12-dash-keyboard-shortcuts"></a>

Grafana has a number of keyboard shortcuts available. To display all keyboard shortcuts available to you, press **?** or **h** on your keyboard.
+ `Ctrl+S` saves the current dashboard. 
+ `f` opens the dashboard finder/search. 
+  `d+k` toggles kiosk mode (hides the menu). 
+ `d+e` expands all rows. 
+ `d+s` opens dashboard settings. 
+ `Ctrl+K` opens the command palette.
+ `Esc` exits panel when in fullscreen view or edit mode. Also returns you to the dashboard from the dashboard settings.

**Focused panel**

To use shortcuts targeting a specific panel, hover over a panel with your pointer.
+ `e` toggles panel edit view 
+ `v` toggles panel fullscreen view 
+ `ps` opens panel share feature 
+ `pd` duplicates panel 
+ `pr` removes panel 
+ `pl` toggles panel legend 

## Setting dashboard time range
<a name="v12-dash-setting-dashboard-time-range"></a>

Grafana provides several ways to manage the time ranges of the data being visualized, for dashboard, panels and also for alerting.

This section describes supported time units and relative ranges, the common time controls, dashboard-wide time settings, and panel-specific time settings.

**Time units and relative ranges**

Grafana supports the following time units: `s (seconds)`, `m (minutes)`, `h (hours)`, `d (days)`, `w (weeks)`, `M (months)`, `Q (quarters)`, and `y (years)`. 

The minus operator enables you to step back in time, relative to the current date and time, or `now`. If you want to display the full period of the unit (day, week, or month), append `/<time unit>` to the end. To view fiscal periods, use `fQ (fiscal quarter)` and `fy (fiscal year)` time units.

The plus operator enables you to step forward in time, relative to now. For example, you can use this feature to look at predicted data in the future.

The following table provides example relative ranges.


| Example relative range | From | To | 
| --- | --- | --- | 
| Last 5 minutes |  `now-5m`  |  `now`  | 
| The day so far |  `now/d`  |  `now`  | 
| This week |  `now/w`  |  `now/w`  | 
| This week so far |  `now/w`  |  `now`  | 
| This month |  `now/M`  |  `now/M`  | 
| This month so far |  `now/M`  |  `now`  | 
| Previous Month |  `now-1M/M`  |  `now-1M/M`  | 
| This year so far |  `now/Y`  |  `now`  | 
| This Year |  `now/Y`  |  `now/Y`  | 
| Previous fiscal year |  `now-1y/fy`  |  `now-1y/fy`  | 

**Note**  
 Grafana Alerting does not support the following syntaxes:  
`now+n` for future timestamps.
`now-1n/n` for *start of n until end of n*, because this is an absolute timestamp.

**Common time range controls**

The dashboard and panel time controls have a common user interface. The following describes common time range controls.
+ Current time range, also called the *time picker*, shows the time range currently displayed in the dashboard or panel you are viewing. Hover your cursor over the field to see the exact time stamps in the range and their source (such as the local browser time). Click the *current time range* to change it. You can change the current time using a *relative time range*, such as the last 15 minutes, or an absolute time range, such as `2020-05-14 00:00:00` to `2020-05-15 23:59:59`.
+ The **relative time range** can be selected from the **Relative time ranges** list. You can filter the list using the input field at the top. Some examples of time ranges include *Last 30 minutes*, *Last 12 hours*, *Last 7 days*, *Last 2 years*, *Yesterday*, *Day before yesterday*, *This day last week*, *Today so far*, *This week so far*, and *This month so far*.
+ **Absolute time range** can be set in two ways: Typing exact time values or relative time values into the **From** and **To** fields and clicking **Apply time range**, or clicking a date or date range from the calendar displayed when you click the **From** or **To** field. To apply your selections, click **Apply time range**. You can also choose from a list of recently used absolute time ranges.
+ **Semi-relative time range** can be selected in the absolute time range settings. For example, to show activity since a specific date, you can choose an absolute time for the start time, and a relative time (such as `now`) for the end time.

  Using a semi-relative time range, as time progresses, your dashboard will automatically and progressively zoom out to show more history and fewer details. At the same rate, as high data resolution decreases, historical trends over the entire time period will become more clear.
**Note**  
Alerting does not support semi-relative time ranges.
+ **Zoom out** by selecting the zoom out icon (or by using Cmd\$1Z or Ctrl\$1Z as a keyboard shortcut). This increases the view, showing a larger time range in the dashboard or panel visualization.
+ **Zoom in** by selecting a time range you want to view on the graph in the visualization.
**Note**  
Zooming in is only applicable to graph visualizations. 

**Refresh dashboards**

Click the **Refresh dashboard** icon to immediately run every query on the dashboard and refresh the visualizations. Grafana cancels any pending requests when you trigger a refresh.

By default, Grafana does not automatically refresh the dashboard. Queries run on their own schedule according to the panel settings. However, if you want to regularly refresh the dashboard, then click the down arrow next to the **Refresh dashboard** icon and then select a refresh interval.

**Control the time range using a URL**

You can control the time range of a dashboard by providing the following query parameters in the dashboard URL.
+ `from` defines the lower limit of the time range, specified in ms epoch, or [relative time](#v12-dash-setting-dashboard-time-range).
+ `to` defines the upper limit of the time range, specified in ms epoch, or relative time.
+ `time` and `time.window` defines a time range from `time-time.window/2` to `time+time.window/2`. Both parameters should be specified in ms. For example `?time=1500000000000&time.window=10000` results in 10s time range from 1499999995000 to 1500000005000.

# Building dashboards
<a name="v12-dash-building-dashboards"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 12.x**.  
For Grafana workspaces that support Grafana version 10.x, see [Working in Grafana version 10](using-grafana-v10.md).  
For Grafana workspaces that support Grafana version 9.x, see [Working in Grafana version 9](using-grafana-v9.md).  
For Grafana workspaces that support Grafana version 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

After you create a Grafana workspace and sign in, you can create dashboards and modify settings to suit your needs. A dashboard is made up of [panels with visualizations](v12-panels-viz.md). Each panel has a query associated with it, to pull data from one of your [Connect to data sources](AMG-data-sources.md).

You can create more interactive and dynamic dashboards by adding and using [variables](v12-dash-variables.md). Instead of hard-coding the server, application, or other names in your metric queries, you can use variables in their place.

**Topics**
+ [Creating dashboards](v12-dash-creating.md)
+ [Importing dashboards](v12-dash-importing.md)
+ [Exporting dashboards](v12-dash-exporting.md)
+ [Modifying dashboard settings](v12-dash-modify-settings.md)
+ [Dashboard URL variables](v12-dash-dashboard-url-variables.md)
+ [Managing library panels](v12-dash-manage-library-panels.md)
+ [Managing dashboard version history](v12-dash-manage-version-history.md)
+ [Managing dashboard links](v12-dash-manage-dashboard-links.md)
+ [Annotate visualizations](v12-dash-annotations.md)
+ [Dashboard JSON model](v12-dash-dashboard-json-model.md)
+ [Best practices for dashboards](v12-dash-bestpractices.md)

# Creating dashboards
<a name="v12-dash-creating"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 12.x**.  
For Grafana workspaces that support Grafana version 10.x, see [Working in Grafana version 10](using-grafana-v10.md).  
For Grafana workspaces that support Grafana version 9.x, see [Working in Grafana version 9](using-grafana-v9.md).  
For Grafana workspaces that support Grafana version 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

**Creating a dashboard **

Dashboards and panels allow you to show your data in visual form using Grafana. Each panel needs at least one query to display a visualization. Before you get started, complete the following prerequisites.
+ Ensure that you have the proper permissions. For more information about permissions, see [Users, teams, and permissions](Grafana-administration-authorization.md).
+ Identify the dashboard to which you want to add the panel.
+ Understand the query language of the target data source.
+ Ensure that data source for which you are writing a query has been added. For more information, see [Connect to data sources](AMG-data-sources.md).

 To create a dashboard:

1. Sign into Grafana, and select **Dashboards** from the left menu.

1. Select **New**, then **New dashboard**.

1. On the empty dashboard, select **\$1 Add visualization**. This opens the new visualization dialog box.

1. Select a data source. You can choose an existing data source, one of Grafana's built in data sources for testing, or choose **Configure a new data source** to set up a new one (only users with Admin permissions can configure new data sources).

   The **Edit panel** view opens, with your data source selected. You can change the data source for the panel later, using the **Query** tab of the panel editor, if needed.

1. Write or construct a query in the query language of your data source. Choose the refresh dashboard icon to perform a query on the data source, seeing the results as you go.

1. In the **Visualization** list, select a visualization type. Grafana displays a preview of your query results with the visualization applied. For more information, see [Visualizations options](v12-panels-viz.md).

1. Under **Panel options**, you can enter a title and description for your panel. 

1. Most visualizations need some adjustment before they display the exact information that you need. You can adjust panel settings in the following ways.
   + [Configure value mappings](v12-panels-configure-value-mappings.md)
   + [Visualization-specific options](v12-panels-viz.md)
   + [Override field values](v12-panels-configure-overrides.md)
   + [Configure thresholds](v12-panels-configure-thresholds.md)
   + [Configure standard options](v12-panels-configure-standard-options.md)

1. When you've finished configuring your panel, choose **Save** to save the dashboard.

   Alternatively, select **Apply** to see changes without leaving the panel editor.

1. Add a note to describe the visualization (or describe your changes) and then click **Save** in the upper-right corner of the page.
**Note**  
Notes are helpful if you need to revert the dashboard to a previous version.

1. Choose **Save**.

1. Optionally, you can add more panels to the dashboard by choosing **Add** in the dashboard header, and selecting **Visualization** from the drop-down.

**Copying an existing dashboard**

You can quickly copy an existing dashboard, to jumpstart creating a new one.

**To copy an existing dashboard**

1. Select **Dashboards** from the left menu.

1. Choose the dashboard you want to copy, to open it.

1. Select **Settings** (gear icon) in the top right of the dashboard.

1. Select **Save as**in the top right corner of the dashboard.

1. (Optional) Specify the name, folder, description, and whether or not to copy the original dashboard tags for the copied dashboard.

1. Select **Save**.

**Configuring repeating rows**

You can configure Grafana to dynamically add panels or rows to a dashboard based on the value of a variable. Variables dynamically change your queries across all rows in a dashboard. For more information about repeating panels, see [Configure repeating panels]().

You can also repeat rows if you have variables set with `Multi-value` or `Include all values` selected.

Before you get started, ensure that the query includes a multi-value variable, then you should complete the following steps.

**To configure repeating rows**

1. Select **Dashboards** from the left menu, then choose the dashboard you want to modify.

1. At the top of the dashboard, select **Add**, and then select **Row** from the drop down.

   If the dashboard is empty, you can alternately select the **\$1 Add row** button in the middle of the dashboard.

1. Hover over the row title and select the **Settings** (gear) icon that appears.

1. On the **Row Options** dialog box, add a title and select the variable for which you want to add repeating rows.
**Note**  
 To provide context to dashboard users, add the variable to the row title. 

1. Select **Update**.

**Repeating rows and the Dashboard special data source**

If a row includes panels using the special [Dashboard](AMG-data-sources.md#AMG-data-sources-special) data source—the data source that uses a result set from another panel in the smae dashboard—then corresponding panels in repeated rows will reference the panel in the original row, not the ones in the repeated rows.

For example, in a dashboard:
+ `Row 1` includes `Panel 1A` and `Panel 1B`.
+ `Panel 1B` uses the results from `Panel 1A` by using the `Dashboard` data source.
+ Repeating `Row 2` includes `Panel 2A` and `Panel 2B`.
+ `Panel 2B` references `Panel 1A`, not `Panel 2A`.

**To move a panel**

1. Open the dashboard.

1. Select the panel title and drag the panel to the new location. You can place a panel on a dashboard in any location.

**To resize a panel**

1. Open the dashboard.

1. To adjust the size of the panel, drag the lower-right corner of the panel. You can size a dashboard panel to suits your needs.

# Importing dashboards
<a name="v12-dash-importing"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 12.x**.  
For Grafana workspaces that support Grafana version 10.x, see [Working in Grafana version 10](using-grafana-v10.md).  
For Grafana workspaces that support Grafana version 9.x, see [Working in Grafana version 9](using-grafana-v9.md).  
For Grafana workspaces that support Grafana version 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

You can import preconfigured dashboards into your Amazon Managed Grafana workspace.

**To import a dashboard**

1. Sign into your Amazon Managed Grafana workspace.

1. Select **Dashboards** from the left menu.

1. Select **New** and choose **Import** in the drop down menu.

1. Next you need to choose the dashboard JSON definition to import. You have three choices for how to import JSON:
   + Upload a file containing dashboard JSON.
   + Directly copy JSON text into the text area.
   + Paste a Grafana Labs dashboard URL or ID into the field. For more information on grafana.com dashboard URLs, see the next section.
   + (Optional) Change any dashboard details that you wish to change.
   + Select a data source, if required.
   + Choose **Import**.
   + Save the dashboard.

## Finding dashboards on grafana.com
<a name="v12-dash-import-from-grafana"></a>

The [Dashboards](https://grafana.com/grafana/dashboards/) page on grafana.com provides you with dashboards for common server applications. Browse a library of official and community-built dashboards and import them to quickly get up and running.

**Note**  
To import dashboards from grafana.com, your Amazon Managed Grafana workspace must have access to the internet.

# Exporting dashboards
<a name="v12-dash-exporting"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 12.x**.  
For Grafana workspaces that support Grafana version 10.x, see [Working in Grafana version 10](using-grafana-v10.md).  
For Grafana workspaces that support Grafana version 9.x, see [Working in Grafana version 9](using-grafana-v9.md).  
For Grafana workspaces that support Grafana version 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

You can use the Grafana UI or the HTTP API to export dashboards.

The dashboard export action creates a Grafana JSON file that contains everything you need, including layout, variables, styles, data sources, queries, and so on, so that you can later import the dashboard.

**Making a dashboard portable**

If you want to export a dashboard for others to use, you can add template variables for things like a metric prefix (use a constant variable) and server name.

A template variable of the type `Constant` will automatically be hidden in the dashboard, and will also be added as a required input when the dashboard is imported.

**To export a dashboard**

1. Open the dashboard that you want to export.

1. Select the share icon.

1. Choose **Export**.

1. Choose **Save to file.**

**Note**  
Grafana downloads a JSON file to your local machine. 

# Modifying dashboard settings
<a name="v12-dash-modify-settings"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 12.x**.  
For Grafana workspaces that support Grafana version 10.x, see [Working in Grafana version 10](using-grafana-v10.md).  
For Grafana workspaces that support Grafana version 9.x, see [Working in Grafana version 9](using-grafana-v9.md).  
For Grafana workspaces that support Grafana version 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

The dashboard settings page enables you to:
+ Edit general dashboard properties, including time settings.
+ Add annotation queries.
+ Add dashboard variables.
+ Add links.
+ View the dashboard JSON model

**To access the dashboard setting page**

1. Open a dashboard in edit mode.

1. Click **Dashboard settings** (gear icon) located at the top of the page.

**Modifying dashboard time settings**

Adjust dashboard time settings when you want to change the dashboard timezone, the local browser time, and specify auto-refresh time intervals.

**To modify dashboard time settings**

1. On the **Dashboard** settings page, select **General**.

1. Navigate to the **Time Options** section.

1. Specify time settings according to the following descriptions.

1. 
   + **Timezone** – Specify the local time zone of the service or system that you are monitoring. This can be helpful when monitoring a system or service that operates across several time zones.
     + **Default** – Grafana uses the default selected time zone for the user profile, team, or organization. If no time zone is specified for the user profile, a team the user is a member of, or the organization, then Grafana uses the local browser time.
     + **Local browser time** – The time zone configured for the viewing user browser is used. This is usually the same time zone as set on the computer.
     + Use standard [ISO 8601 time zones](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones), including UTC.
   + **Auto-refresh** – Customize the options displayed for relative time and the auto-refresh options. Entries are comma separated and accept any valid time unit.
   + **Now delay** – Override the `now` time by entering a time delay. Use this option to accommodate known delays in data aggregation to avoid null values.
   + **Hide time picker** – Selecting this option if you do not want the dashboard to display the time picker.

**Note**  
To have time controls, your data must include a time column. See the documentation for your specific [data source](AMG-data-sources.md) for more information about including a time column.

**Adding an annotation query**

An annotation query is a query that queries for events. These events can be visualized in graphs across the dashboard as vertical lines along with a small icon you can hover over to see the event information.

**To add an annotation query**

1. On the **Dashboard settings** page, select **Annotations**.

1. Select **Add annotation query**. 

1. Enter a name and select a data source.

1. Complete the rest of the form to build a query and annotation.

The query editor UI changes based on the data source that you select. see the [Data source](AMG-data-sources.md) documentation for details on how to construct a query. Or, for data source plugins that you install from the [Find plugins with the plugin catalog](grafana-plugins.md#plugin-catalog), you can use the [documentation on the Grafana Labs website](https://grafana.com/docs/grafana/v10.3/datasources/).

**Adding a variable**

Variables enable you to create more interactive and dynamic dashboards. Instead of hard-coding things like server, application, and sensor names in your metric queries, you can use variables in their place. Variables are displayed as dropdown lists at the top of the dashboard. These dropdowns make it easy to change the data being displayed in your dashboard.

For more information about variables, see [Variables](v12-dash-variables.md).

**To add a variable**

1. On the **Dashboard settings** page, click **Variable** in the left side section menu and then the **Add variable** button.

1. In the **General** section, add the name of the variable. This is the name that you will later use in queries.

1. Select a variable **Type**.
**Note**  
The variable type that you select impacts which fields that you populate on the page.

1. Define the variable and click **Update**.

**Adding a link**

Dashboard links enable you to place links to other dashboards and websites directly below the dashboard header. Links provide for easy navigation to other, related dashboards and content. 

**To add a link**

1. On the **Dashboard settings** page, choose **Links** from the left side section menu and then the **Add link** button.

1. Enter a title and in the **Type** field, select **Dashboard** or **Link**.

1. To add a dashboard link, add an optional tag, select any of the dashboard link Options, and click **Apply**.
**Note**  
Using tags creates a dynamic dropdown of dashboards that all have a specific tag.

1. To add a web link, add a URL and tooltip text that appears when the user hovers over the link, select an icon that appears next to the link, and select any of the dashboard link options. 

**View dashboard JSON model **

A dashboard in Grafana is represented by a JSON object, which stores the metadata of a dashboard. Dashboard metadata includes dashboard properties, metadata from panels, template variables, panel queries, and so on. The JSON metadata defines the dashboard.

To view a dashboard JSON model, on the **Dashboard settings** page, click **JSON**.

For more information about the JSON fields, see [JSON fields](v12-dash-dashboard-json-model.md).

# Dashboard URL variables
<a name="v12-dash-dashboard-url-variables"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 12.x**.  
For Grafana workspaces that support Grafana version 10.x, see [Working in Grafana version 10](using-grafana-v10.md).  
For Grafana workspaces that support Grafana version 9.x, see [Working in Grafana version 9](using-grafana-v9.md).  
For Grafana workspaces that support Grafana version 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

Grafana can apply variable values passed as query parameters in dashboard URLs. For more information, see [Manage dashboard links](v12-dash-manage-dashboard-links.md) and [Templates and variables](v12-dash-variables.md).

**Passing variables as query parameters**

Grafana interprets query string parameters prefixed with `var-` as variables in the given dashboard.

For example, in this URL: 

```
https://${your-domain}/path/to/your/dashboard?var-example=value
```

The query parameter `var-example=value` represents the dashboard variable example with a value of `value`.

**Passing multiple values for a variable**

To pass multiple values, repeat the variable parameter once for each value.

```
https://${your-domain}/path/to/your/dashboard?var-example=value1&var-example=value2
```

Grafana interprets `var-example=value1&var-example=value2` as the dashboard variable example with two values: `value1` and `value2`.

**Adding variables to dashboard links**

Grafana can add variables to dashboard links when you generate them from a dashboard’s settings. For more information and steps to add variables, see [Manage dashboard links](v12-dash-manage-dashboard-links.md).

**Passing ad hoc filters**

Ad hoc filters apply key or value filters to all metric queries that use a specified data source. For more information, see [Ad hoc filters](v12-dash-variable-add.md#v12-dash-variable-add-adhoc).

To pass an ad hoc filter as a query parameter, use the variable syntax to pass the ad hoc filter variable, and also provide the key, the operator as the value, and the value as a pipe-separated list.

For example, in this URL:

`https://${your-domain}/path/to/your/dashboard?var-adhoc=example_key|=|example_value` 

The query parameter `var-adhoc=key|=|value` applies the ad hoc filter configured as the adhoc dashboard variable using the `example_key` key, the `=` operator, and the `example_value` value.

**Note**  
When sharing URLs with ad hoc filters, remember to encode the URL. In the above example, replace the pipes (`|`) with `%7C` and the equality operator (`=`) with `%3D`.

**Controlling time range using the URL**

To set a dashboard’s time range, use the `from`, `to`, `time`, and `time.window` query parameters. Because these are not variables, they do not require the `var-` prefix.

# Managing library panels
<a name="v12-dash-manage-library-panels"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 12.x**.  
For Grafana workspaces that support Grafana version 10.x, see [Working in Grafana version 10](using-grafana-v10.md).  
For Grafana workspaces that support Grafana version 9.x, see [Working in Grafana version 9](using-grafana-v9.md).  
For Grafana workspaces that support Grafana version 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

A library panel is a reusable panel that you can use in any dashboard. When you change a library panel, the change propagates to all instances of where the panel is used. Library panels streamline reuse of panels across multiple dashboards.

You can save a library panel in a folder alongside saved dashboards.

**Creating a library panel**

When you create a library panel, the panel on the source dashboard is converted to a library panel as well. You need to save the original dashboard after a panel is converted.

**To create a library panel**

1. Open the panel you want to convert to a library panel in edit mode.

1. In the panel display options, click the down arrow option to start changes to the visualization.

1. Select **Library panels**, and then **\$1 Create library panel**. This opens the create dialog.

1. In **Library panel name**, enter the name you want for the panel.

1. In **Save in folder**, select the folder to save the library panel.

1. Select **Create library panel** to save your changes to the library.

1. Save the dashboard.

After a library panel is created, you can modify the panel using any dashboard on which it appears. After you save the changes, all instances of the library panel reflect these modifications.

You can also create a library panel directly from the edit menu of any panel, by selecting **More...** then **Create library panel**.

**Adding a library panel to a dashboard**

Add a Grafana library panel to a dashboard when you want to provide visualizations to other dashboard users.

**To add a library panel to a dashboard**

1. Select **Dashboards** on the left menu.

1. Select **New**, and then choose **New dashboard** from the drop down.

1. On the empty dashboard, select **\$1 Import library panel**. You will see a list of your library panels.

1. Filter the list or search to find the panel you want to add.

1. Click a panel to add it to the dashboard.

**Unlinking a library panel**

Unlink a library panel when you want to make a change to the panel and not affect other instances of the library panel.

**To unlink a library panel**

1. Select **Dashboards** on the left menu.

1. Select **Library panels**.

1. Select a library panel that is being used in different dashboards.

1. Select the panel that you want to unlink.

1. Select the panel title (or hover the pointer anywhere over the panel), to display the actions menu on the top right corner of the panel.

1. Select **Edit**. The panel will open in edit mode.

1. Select **Unlink** on the top right corner of the page.

1. Choose **Yes, unlink**.

**Viewing a list of library panels**

You can view a list of available library panels and search for a library panel.

**To view a list of library panels**

1. Select **Dashboards** on the left menu.

1. Select **Library panels**. You can see a list of previously defined library panels.

1. Search for a specific library panel if you know its name. You can also filter the panels by folder or type.

**Deleting a library panel**

Delete a library panel when you no longer need it.

**To delete a library panel**

1. Select **Dashboards** on the left menu.

1. Select **Library panels**.

1. Select the delete icon next to the library panel name for the panel you wish to delete.

# Managing dashboard version history
<a name="v12-dash-manage-version-history"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 12.x**.  
For Grafana workspaces that support Grafana version 10.x, see [Working in Grafana version 10](using-grafana-v10.md).  
For Grafana workspaces that support Grafana version 9.x, see [Working in Grafana version 9](using-grafana-v9.md).  
For Grafana workspaces that support Grafana version 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

Whenever you save a version of your dashboard, a copy of that version is saved so that previous versions of your dashboard are not lost. A list of these versions is available by entering the dashboard settings and then selecting **Versions** in the left side menu.

**Note**  
The most recent 20 versions of a dashboard are saved.

The dashboard version history feature lets you compare and restore to previously saved dashboard versions.

**Comparing two dashboard versions**

To compare two dashboard versions, select the two versions from the list that you wish to compare. Click **Compare versions** to view the diff between the two versions. This brings up the version diff view. By default, you’ll see a textual summary of the changes.

If you want to view the diff of the raw JSON that represents your dashboard, you can do that by clicking the **View JSON Diff** button at the bottom.

**Restoring to a previously saved dashboard version**

If you need to restore to a previously saved dashboard version, you can either select the **Restore** button on the right of a row in the dashboard version list, or select the **Restore to version *<x>*** button in the diff view. Selecting either of these will prompt you to confirm the restoration.

After restoring to a previous version, a new version will be created containing the same exact data as the previous version, only with a different version number. This is indicated in the **Notes column** for the row in the new dashboard version. This ensures your previous dashboard versions are not affected by the change.

# Managing dashboard links
<a name="v12-dash-manage-dashboard-links"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 12.x**.  
For Grafana workspaces that support Grafana version 10.x, see [Working in Grafana version 10](using-grafana-v10.md).  
For Grafana workspaces that support Grafana version 9.x, see [Working in Grafana version 9](using-grafana-v9.md).  
For Grafana workspaces that support Grafana version 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

You can use links to navigate between commonly used dashboards or to connect others to your visualizations. Links let you create shortcuts to other dashboards, panels, and even external websites.

Grafana supports dashboard links, panel links, and data links. Dashboard links are displayed at the top of the dashboard. Panel links are accessible by clicking an icon on the top left corner of the panel.

**Choosing which link to use**

Start by figuring out how you’re currently navigating between dashboards. If you’re often jumping between a set of dashboards and struggling to find the same context in each, links can help optimize your workflow.

The next step is to figure out which link type is right for your workflow. Even though all the link types in Grafana are used to create shortcuts to other dashboards or external websites, they work in different contexts.
+ If the link relates to most if not all of the panels in the dashboard, use dashboard links.
+ If you want to drill down into specific panels, use panel links.
+ If you want to link to an external site, you can use either a dashboard link or a panel link.
+ If you want to drill down into a specific series, or even a single measurement, use data links.

**Controlling the time range using a URL**

To control the time range of a panel or dashboard, you can provide query parameters in the dashboard URL:
+ `from` defines lower limit of the time range, specified in ms epoch.
+ `to` defines upper limit of the time range, specified in ms epoch.
+ `time` and `time.window` defines a time range from `time-time.window/2` to `time+time.window/2`. Both params should be specified in ms. For example `?time=1500000000000&time.window=10000` will result in 10s time range from 1499999995000 to 1500000005000.

**Dashboard links**

When you create a dashboard link, you can include the time range and current template variables to directly jump to the same context in another dashboard. This way, you don’t have to worry whether the person you send the link to is looking at the right data. For other types of links, see [Data link variables]().

Dashboard links can also be used as shortcuts to external systems, such as submitting a GitHub issue with the current dashboard name.

After adding a dashboard link, it will show up in the upper-right corner of your dashboard.

**Adding links to dashboards**

Add links to other dashboards at the top of your current dashboard.

**To add a link to a dashboard**

1. While viewing the dashboard you want to link, click the gear at the top of the screen to open **Dashboard settings**.

1. Select **Links** and then **Add Dashboard Link** or **New**.

1. In **Type**, select **dashboards**.

1. Select link options from the following.
   + **With tags** – Enter tags to limit the linked dashboards to only the ones with the tags you enter. Otherwise, Grafana includes links to all other dashboards.
   + **As dropdown** – If you are linking to many dashboards, By default, Grafana displays them all side-by-side across the top of your dashboard. Selecting this option and adding an optional title, will display the links in a dropdown.
   + **Time range** – Select this option to include the dashboard time range in the link. When the user clicks the link, the linked dashboard will open with the indicated time range already set.
   + **Variable values** – Select this option to include template variables currently used as query parameters in the link. When the user clicks the link, any matching templates in the linked dashboard are set to the values from the link. For more information, see [Dashboard URL variables](v12-dash-dashboard-url-variables.md).
   + **Open in new tab** – Select this option if you want the dashboard link to open in a new tab or window.

1. Click **Add**.

**Adding a URL link to a dashboard**

Add a link to a URL at the top of your current dashboard. You can link to any available URL, including dashboards, panels, or external sites. You can even control the time range to ensure the user is zoomed in on the right data in Grafana.

**To add a URL link to a dashboard**

1. While viewing the dashboard you want to link, select the gear at the top of the screen to open **Dashboard settings**.

1. Select **Links** and then **Add Dashboard Link** or **New**.

1. In **Type**, select **Link**.

1. Select link options from the following.
   + **URL** – Enter the URL you want to link to. Depending on the target, you might want to include field values.
   + **Title** – Enter the title you want the link to display.
   + **Tooltip** – Enter the tooltip you want the link to display.
   + **Icon** – Choose the icon that you want displayed with the link.
   + **Time range** – Select this option to include the dashboard time range in the link. When the user clicks the link, the linked dashboard will open with the indicated time range set.
     + `from` – Defines lower limit of the time range, specified in ms epoch.
     + `to` – Defines upper limit of the time range, specified in ms epoch.
     + `time` and `time.window` – Define a time range from `time-time.window/2` to `time+time.window/2`. Both params should be specified in ms. For example `?time=1500000000000&time.window=10000` will result in 10s time range from 1499999995000 to 1500000005000.
   + **Variable values** – Select this option to include template variables currently used as query parameters in the link. When the user clicks the link, any matching templates in the linked dashboard are set to the values from the link.

     The variable format is as follows:

     ```
     https://${you-domain}/path/to/your/dashboard?var-${template-varable1}=value1&var-{template-variable2}=value2
     ```
   + **Open in a new tab** – Select this option if you want the dashboard link to open in a new tab or window

1. Select **Add**.

**Updating a dashboard link**

To change or update an existing dashboard link, follow this procedure.

**To update a dashboard link**

1. In **Dashboard settings,** on the **Links** tab, select the existing link that you want to edit.

1. Change the settings and then choose **Update**.

**Duplicating a dashboard link**

To duplicate an existing dashboard link, select the duplicate icon next to the existing link that you want to duplicate.

**Deleting a dashboard link**

To delete an existing dashboard link, select the trash icon next to the link that you want to delete.

**Panel links**

Each panel can have its own set of links that are shown in the upper left corner of the panel. You can link to any available URL, including dashboards, panels, or external sites. You can even control the time range to ensure the user is zoomed in on the right data in Grafana.

To see available panel links, select the icon to the right of the panel title.
+ **Adding a panel link**: Each panel can have its own set of links that are shown in the upper left corner of the panel. You can link to any available URL, including dashboards, panels, or external sites. You can even control the time range to ensure the user is zoomed in on the right data in Grafana. Click the icon on the top left corner of a panel to see available panel links.

  1. Hover your cursor over the panel to which you want to add a link.

  1. Select the menu, and choose **Edit**, or you can use the keyboard shortcut, `e`.

  1. Expand the **Panel options** section, and scroll down to **Panel links**.

  1. Select **Add link**.

  1. Enter a **Title**. This is a human-readable label for the link that will be displayed in the UI.

  1. Enter the **URL** you want to link to. Press `Ctrl+Space` (or `Cmd+Space`) and select the URL field to see available variables. By adding template variables to your panel link, the link sends the user to the right context, with the relevant variables already set.

     You can also use time variables.
     + `from` defines the lower limit of the time range, specified in ms epoch.
     + `to` defines the upper limit of the time range, specified in ms epoch.
     + `time` and `time.window` defines a time range from `time-time.window/2` to `time+time.window/2`. Both parameters should be specified in ms. For example `?time=1500000000000&time.window=10000` results in 10s time range from 1499999995000 to 1500000005000.
+ **Updating a panel link**

  1. Select a panel (or place the cursor over the panel) to display an actions menu at the top right of the panel.

  1. From the menu, select the **Edit**.

     You can also use the keyboard shortcut, `e`.

  1. Expand the **Panel options** section, and scroll down to **Panel links**.

  1. Find the link that you want to change, and select the **Edit** (pencil) icon next to it.

  1. Make any necessary changes.

  1. Select **Save** to save changes and close the window.

  1. Save changes to your dashboard by selecting **Save** in the upper right.
+ **Deleting a panel link**

  1. Select a panel (or place the cursor over the panel) to display an actions menu at the top right of the panel.

  1. From the menu, select the **Edit**.

     You can also use the keyboard shortcut, `e`.

  1. Expand the **Panel options** section, and scroll down to **Panel links**.

  1. Find the link that you want to delete, and select the **X** icon next to it.

  1. Select **Save** in the upper right to save your changes to the dashboard.

# Annotate visualizations
<a name="v12-dash-annotations"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 12.x**.  
For Grafana workspaces that support Grafana version 10.x, see [Working in Grafana version 10](using-grafana-v10.md).  
For Grafana workspaces that support Grafana version 9.x, see [Working in Grafana version 9](using-grafana-v9.md).  
For Grafana workspaces that support Grafana version 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

Annotations provide a way to mark points on a visualization with rich events. They are visualized as vertical lines and icons on all graph panels. When you hover over an annotation, you can get event description and event tags. The text field can include links to other systems with more detail.

Annotations support Cron syntax for time regions, providing more precise control over time-based annotations.

You can annotate visualizations in three ways:
+ Directly in the panel, using the [built-in annotations query](#v12-dash-built-in-query).
+ Using the Grafana HTTP API.
+ Configuring annotation queries in the dashboard settings.

In the first two cases, you’re creating new annotations, while in the last you’re querying existing annotations from data sources. The built-in annotation query also supports this.

This section explains the first and third options; for information about using the Grafana HTTP API, refer to [Annotations API](v12-Grafana-API-Annotations.md).

Annotations are supported for the following visualization types:
+ Time series 
+ State timeline
+ Candlestick

## Create annotations in panels
<a name="v12-dash-create-annotations-in-panels"></a>

Grafana comes with the ability to add annotation events directly from a panel using the [built-in annotations query](#v12-dash-built-in-query) that exists on all dashboards. Annotations that you create this way are stored in Grafana.

To add annotations directly in the panel:
+ The dashboard must already be saved.
+ The built-in query must be enabled.

**To add an annotation**

1. In the dashboard select the panel to which you’re adding the annotation. A context menu will appear. 

1. In the context menu, select **Add annotation**.

1. (Optional) Add an annotation description and tags.

1. Select **Save**.

Alternatively, to add an annotation, press `Ctrl` (or `Cmd`) while selecting the panel, and the **Add annotation** popover will appear.

**Region annotations**

You can also create annotations that cover a region, or period of time in a visualization.

**To add a region annotation**

1. In the dashboard press `Ctrl` (or `Cmd`) while selecting an area of the panel.

1.  Add an annotation description and tags (optional). 

1.  Click **Save**. 

**To edit an annotation**

1. In the dashboard, hover over an annotation indicator on a panel.

1. Select the **Edit** (pencil) icon in the annotation tooltip.

1. Modify the description and/or tags.

1. Select **Save**.

**To delete an annotation**

1. In the dashboard, hover over an annotation indicator on a panel.

1. Select the **Delete** (trash) icon in the annotation tooltip.

## Fetch annotations through dashboard settings
<a name="v12-dash-fetch-annotations"></a>

In the dashboard settings, under **Annotations**, you can add new queries to fetch annotations using any data source, including the built-in data annotation data source. Annotation queries return events that can be visualized as event markers in graphs across the dashboard. 

**To add a new annotation query**

1. Select the **Settings** (gear) icon in the dashboard header to open the settings menu.

1. Select **Annotations**.

1. Click **Add annotation query**.

1. Enter a name for the annotation query.

   This name is given to the toggle (checkbox) that will allow you to enable showing annotation events from this query. 

1. Select the data source for the annotations.

   You can also choose **Open advanced data source picker** to see more options, including adding a new data source (available for Admins only).

1. If you don’t want to use the annotation query right away, clear the **Enabled** checkbox.

1. If you don’t want the annotation query toggle to be displayed in the dashboard, select the **Hidden** checkbox.

1. Select a color for the event markers.

1. In the **Show in** drop-down, choose one of the following options:
   + **All panels** – The annotations are displayed on all panels that support annotations.
   + **Selected panels** – The annotations are displayed on all the panels you select.
   + **All panels except** – The annotations are displayed on all panels except the ones you select.

1. Configure the query.

   The annotation query options are different for each data source. For information about annotations in a specific data source, see [Connect to data sources](AMG-data-sources.md).

## Built-in query
<a name="v12-dash-built-in-query"></a>

After you add an annotation, they will still be visible. This is due to the built-in annotation query that exists on all dashboards. This annotation query will fetch all annotation events that originate from the current dashboard, which are stored in Grafana, and show them on the panel where they were created. This includes alert state history annotations.

By default, the built-in annotation query uses the `Grafana` special data source, and manual annotations are only supported using this data source. You can use another data source in the built-in annotation query, but you’ll only be able to create automated annotations using the query editor for that data source.

To add annotations directly to the dashboard, this query must be enabled.

**To confirm the built-in query is enabled**

1. Select the dashboard **settings** (gear) icon in the dashboard header to open the dashboard settings menu.

1. Select **Annotations**. 

1. Find the **Annotations & Alerts (Built-in)** query.

   If it shows **Disabled** before the name of the query, then you’ll need to select the query name to open it and update the setting.

**To stop annotations from being fetched and drawn**

1. Select the dashboard **settings** (gear) icon in the dashboard header to open the dashboard settings menu.

1. Select **Annotations**. 

1. Select the **Annotations & Alerts (Built-in)** query.

1. Select the **Enabled** toggle to turn it off.

When you copy a dashboard using the **Save As** feature it will get a new dashboard id, so annotations created on the source dashboard will no longer be visible on the copy. You can still show them if you add a new **Annotation Query** and filter by tags. However, this only works if the annotations on the source dashboard had tags to filter by.

**Filtering queries by tag**

You can create new queries to fetch annotations from the built-in annotation query using the `Grafana` data source by setting **Filter by** to `Tags`.

For example, create an annotation query name `outages` and specify a tag `outage`. This query will show all annotations (from any dashboard or via API) with the `outage` tag. If multiple tags are defined in an annotation query, then Grafana will only show annotations matching all the tags. To modify the behavior, enable **Match any**, and Grafana will show annotations that contain any one of the tags you provided.

 You can also use template variables in the tag query. This means if you have a dashboard showing stats for different services and a template variable that dictates which services to show, you can use the same template variable in your annotation query to only show annotations for those services. 

# Dashboard JSON model
<a name="v12-dash-dashboard-json-model"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 12.x**.  
For Grafana workspaces that support Grafana version 10.x, see [Working in Grafana version 10](using-grafana-v10.md).  
For Grafana workspaces that support Grafana version 9.x, see [Working in Grafana version 9](using-grafana-v9.md).  
For Grafana workspaces that support Grafana version 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

A dashboard in Grafana is represented by a JSON object, which stores metadata of its dashboard. Dashboard metadata includes dashboard properties, metadata from panels, template variables, and panel queries.

**To view the JSON of a dashboard**

1. Navigate to a dashboard.

1. In the top navigation menu, select the **Dashboard settings** (gear) icon.

1. Select **JSON Model**.

## JSON fields
<a name="v12-dash-json-fields"></a>

When a user creates a new dashboard, a new dashboard JSON object is initialized with the following fields.

**Note**  
In the following JSON, id is shown as null, which is the default value assigned to it until a dashboard is saved. After a dashboard is saved, an integer value is assigned to the `id` field.

```
{
  "id": null,
  "uid": "cLV5GDCkz",
  "title": "New dashboard",
  "tags": [],
  "timezone": "browser",
  "editable": true,
  "graphTooltip": 1,
  "panels": [],
  "time": {
    "from": "now-6h",
    "to": "now"
  },
  "timepicker": {
    "time_options": [],
    "refresh_intervals": []
  },
  "templating": {
    "list": []
  },
  "annotations": {
    "list": []
  },
  "refresh": "5s",
  "schemaVersion": 17,
  "version": 0,
  "links": []
}
```

The following describes each field in the dashboard JSON.


| Name | Usage | 
| --- | --- | 
| `id` | unique numeric identifier for the dashboard (generated by the db) | 
| `uid` | unique dashboard identifier that can be generated by anyone. string (8-40) | 
| `title` | current title of dashboard | 
| `tags` | tags associated with dashboard, an array of strings | 
| `style` | theme of dashboard, such as `dark` or `light` | 
| `timezone` | timezone of dashboard, such as `utc` or `browser` | 
| `editable` | whether a dashboard is editable or not | 
| `graphTooltip` | 0 for no shared crosshair or tooltip (default), 1 for shared crosshair, 2 for shared crosshair and shared tooltip | 
| `time` | time range for dashboard, such as `last 6 hours` or `last 7 days` | 
| `timepicker` | timepicker metadata, see [timepicker section](#v12-dash-json-panels) for details | 
| `templating` | templating metadata, see [templating section](#v12-dash-json-panels) for details | 
| `annotations` | annotations metadata, see [annotations](v12-dash-annotations.md) for how to add them | 
| `refresh` | auto-refresh interval | 
| `schemaVersion` | version of the JSON schema (integer), incremented each time a Grafana update brings changes to this schema | 
| `version` | version of the dashboard (integer), incremented each time the dashboard is updated | 
| `panels` | panels array (see the next section for detail) | 

## Panels
<a name="v12-dash-json-panels"></a>

Panels are the building blocks of a dashboard. It consists of data source queries, type of graphs, aliases, and more. Panel JSON consists of an array of JSON objects, each representing a different panel. Most of the fields are common for all panels but some fields depend on the panel type. The following is an example of panel JSON of a text panel.

```
"panels": [
  {
    "type": "text",
    "title": "Panel Title",
    "gridPos": {
      "x": 0,
      "y": 0,
      "w": 12,
      "h": 9
    },
    "id": 4,
    "mode": "markdown",
    "content": "# title"
  }
```

**Panel size and position**

The gridPos property describes the panel size and position in grid coordinates.
+ `w` – 1 to 24 (the width of the dashboard is divided into 24 columns)
+ `h` – In grid height units, each represents 30 pixels.
+ `x` – The x position, in the same unit as `w`.
+ `y` – The y position, in the same unit as `h`.

The grid has a negative gravity that moves up panels if there is empty space above a panel.

**Timepicker**

```
"timepicker": {
    "collapse": false,
    "enable": true,
    "notice": false,
    "now": true,
    "refresh_intervals": [
      "5s",
      "10s",
      "30s",
      "1m",
      "5m",
      "15m",
      "30m",
      "1h",
      "2h",
      "1d"
    ],
    "status": "Stable",
    "type": "timepicker"
  }
```

**Templating **

The `templating` field contains an array of template variables with their saved values along with some other metadata.

```
"templating": {
    "enable": true,
    "list": [
       {
        "allFormat": "wildcard",
        "current":  {
          "tags": [],
          "text": "prod",
          "value": "prod"
        },
        "datasource": null,
        "includeAll": true,
        "name": "env",
        "options": [
           {
            "selected": false,
            "text": "All",
            "value": "*"
          },
           {
            "selected": false,
            "text": "stage",
            "value": "stage"
          },
           {
            "selected": false,
            "text": "test",
            "value": "test"
          }
        ],
        "query": "tag_values(cpu.utilization.average,env)",
        "refresh": false,
        "type": "query"
      },
       {
        "allFormat": "wildcard",
        "current":  {
          "text": "apache",
          "value": "apache"
        },
        "datasource": null,
        "includeAll": false,
        "multi": false,
        "multiFormat": "glob",
        "name": "app",
        "options": [
           {
            "selected": true,
            "text": "tomcat",
            "value": "tomcat"
          },
           {
            "selected": false,
            "text": "cassandra",
            "value": "cassandra"
          }
        ],
        "query": "tag_values(cpu.utilization.average,app)",
        "refresh": false,
        "regex": "",
        "type": "query"
      }
    ]
  }
```

The following table describes the usage of the templating fields.


| Name | Usage | 
| --- | --- | 
|  `enable`  |  whether templating is enabled or not  | 
|  `list`  |  an array of objects each representing one template variable  | 
|  `allFormat`  |  format to use while fetching all values from data source, including `wildcard`, `glob`, `regex`, `pipe`.  | 
|  `current`  |  shows current selected variable text/value on the dashboard  | 
|  `datasource`  |  shows data source for the variables  | 
|  `includeAll`  |  whether all value option is available or not  | 
|  `multi`  |  whether multiple values can be selected or not from variable value list  | 
|  `multiFormat`  |  format to use while fetching timeseries from data source  | 
|  `name`  |  name of variable  | 
|  `options`  |  array of variable text/value pairs available for selection on dashboard  | 
|  `query`  |  data source query used to fetch values for a variable  | 
|  `refresh`  |  configures when to refresh a variable  | 
|  `regex`  |  extracts part of a series name or metric node segment  | 
|  `type`  |  type of variable, `custom`, `query`, or `interval`  | 

# Best practices for dashboards
<a name="v12-dash-bestpractices"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 12.x**.  
For Grafana workspaces that support Grafana version 10.x, see [Working in Grafana version 10](using-grafana-v10.md).  
For Grafana workspaces that support Grafana version 9.x, see [Working in Grafana version 9](using-grafana-v9.md).  
For Grafana workspaces that support Grafana version 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

This section provides information about best practices for Grafana administrators and users about how to build and maintain Grafana dashboards.

For information about the different kinds of dashboards you can create, refer to the [Grafana dashboards: A complete guide to all the different types you can build](https://grafana.com/blog/2022/06/06/grafana-dashboards-a-complete-guide-to-all-the-different-types-you-can-build/?pg=webinar-getting-started-with-grafana-dashboard-design-amer&plcmt=related-content-1) blog post on the Grafana Labs website.

**Note**  
This section can help you create a strategy for your monitoring and dashboard maintenance. You know your systems best, and should use this section to guide your understanding. Ultimately, it is your responsibility to create the best strategy for your system.

## Common observability strategies
<a name="v12-dash-common-observability-strategies"></a>

When you have a lot to monitor, like a server farm, you need a strategy to decide what is important enough to monitor. This page describes several common methods for choosing what to monitor.

A logical strategy allows you to make uniform dashboards and scale your observability platform more easily.

**Guidelines for strategies**
+ The USE method tells you how happy your machines are, the RED method tells you how happy your users are.
+ USE reports on causes of issues.
+ RED reports on user experience and is more likely to report symptoms of problems.
+ Monitoring both is important to understanding your system. As a best practice, alert on symptoms rather than causes. Typically, alerting is configured on RED dashboards.

**USE method**

USE stands for:
+ **Utilization** – Percent time the resource is busy, such as node CPU usage.
+ **Saturation** – Amount of work a resource has to do, often queue length or node load.
+ **Errors** – Count of error events.

This method is best for hardware resources in infrastructure, such as CPU, memory, and network devices. For more information, see Brendan Gregg's blog post [The USE Method](http://www.brendangregg.com/usemethod.html).

**RED method**

RED stands for:
+ **Rate** – Requests per second
+ **Errors** – Number of requests that are failing.
+ **Duration** – Amount of time these requests take, distribution of latency measurements.

This method is most applicable to services, especially a microservices environment. For each of your services, instrument the code to expose these metrics for each component. RED dashboards are good for alerting and SLAs. A well-designed RED dashboard is a proxy for user experience.

For more information, see Tom Wilkie’s blog post [The RED method: How to instrument your services](https://grafana.com/blog/2018/08/02/the-red-method-how-to-instrument-your-services).

**The Four Golden Signals**

According to the [Google SRE handbook](https://landing.google.com/sre/sre-book/chapters/monitoring-distributed-systems/#xref_monitoring_golden-signals), if you can only measure four metrics of your user-facing system, focus on these four.

This method is similar to the RED method, but it includes saturation.
+ **Latency** – Time taken to serve a request.
+ **Traffic** – How much demand is placed on your system.
+ **Errors** – Rate of requests that are failing.
+ **Saturation** – How "full" your system is,

## Dashboard management maturity model
<a name="v12-dash-management-maturity-model"></a>

*Dashboard management maturity* refers to how well-designed and efficient your dashboard ecosystem is. We recommend periodically reviewing your dashboard setup to gauge where you are and how you can improve.

Broadly speaking, dashboard maturity can be defined as low, medium, or high. 

 Much of the content for this topic was taken from the KubeCon 2019 talk [Fool-Proof Kubernetes Dashboards for Sleep-Deprived Oncalls](https://www.youtube.com/watch?v=YE2aQFiMGfY). 

**Low – default state**

At this stage, you have no coherent dashboard management strategy. Almost everyone starts here.

How can you tell you are here?
+ Everyone can modify your dashboards.
+ Lots of copied dashboards, little to no dashboard reuse.
+ One-off dashboards that hang around forever.
+ No version control (dashboard JSON in version control).
+ Lots of browsing for dashboards, searching for the right dashboard. This means lots of wasted time trying to find the dashboard you need.
+ Not having any alerts to direct you to the right dashboard.

**Medium – methodical dashboards**

At this stage, you are starting to manage your dashboard use with methodical dashboards. You might have laid out a strategy, but there are some things you could improve.

 How can you tell you are here? 
+ Prevent sprawl by using template variables. For example, you don’t need a separate dashboard for each node, you can use query variables. Even better, you can make the data source a template variable too, so you can reuse the same dashboard across different clusters and monitoring backends.

  Refer to the list of examples in [Variables](v12-dash-variables.md), for ideas.
+ Methodical dashboards according to an [observability strategy](#v12-dash-common-observability-strategies).
+ Hierarchical dashboards with drill-downs to the next level.
+ Dashboard design reflects service hierarchies. For example, you could use the RED method with one row per service. The row order could reflect the data flow, as you scroll down the dashboard.
+ Compare like to like: split service dashboards when the magnitude differs. Make sure aggregated metrics don’t drown out important information.
+ Expressive charts with meaningful use of color and normalizing axes where you can.
  + Example of meaningful color: Blue means it’s good, red means it’s bad. [Thresholds](v12-panels-configure-thresholds.md) can help with that.
  + Example of normalizing axes: When comparing CPU usage, measure by percentage rather than raw number, because machines can have a different number of cores. Normalizing CPU usage by the number of cores reduces cognitive load because the viewer can trust that at 100% all cores are being used, without having to know the number of CPUs.
+ Directed browsing cuts down on guessing.
  + Template variables make it harder to browse randomly or aimlessly.
  + Most dashboards should be linked to by alerts.
  + Browsing is directed with links. For more information, see [Managing dashboard links](v12-dash-manage-dashboard-links.md).
+  Version-controlled dashboard JSON. 

**High – optimized use**

At this stage, you have optimized your dashboard management use with a consistent and thoughtful strategy. It requires maintenance, but the results are worth it.
+ Actively reducing sprawl.
  + Regularly review existing dashboards to make sure they are still relevant.
  + Only approved dashboards added to master dashboard list.
  + Tracking dashboard use. You can take advantage of [Usage insights](v12-dash-assess-dashboard-usage.md).
+ Consistency by design.
+ Use scripting libraries to generate dashboards, ensure consistency in pattern and style.
  + grafonnet (Jsonnet)
  + grafanalib (Python)
+ No editing in the browser. Dashboard viewers change views with variables.
+ Browsing for dashboards is the exception, not the rule.
+ Perform experimentation and testing in a separate Grafana instance dedicated to that purpose, not your production instance. When a dashboard in the test environment is proven useful, then add that dashboard to your main Grafana instance.

## Best practices for creating dashboards
<a name="v12-dash-best-practices-for-creating-dashboards"></a>

This section outlines some best practices to follow when creating Grafana dashboards.

**Before you begin**

 Here are some principles to consider before you create a dashboard. 

**A dashboard should tell a story or answer a question**

What story are you trying to tell with your dashboard? Try to create a logical progression of data, such as large to small or general to specific. What is the goal for this dashboard? (Hint: If the dashboard doesn’t have a goal, then ask yourself if you really need the dashboard.)

Keep your graphs simple and focused on answering the question that you are asking. For example, if your question is "which servers are in trouble?", then maybe you don’t need to show all the server data. Just show data for the ones in trouble.

**Dashboards should reduce cognitive load, not add to it**

*Cognitive load* is basically how hard you need to think about something in order to figure it out. Make your dashboard easy to interpret. Other users and future you (when you’re trying to figure out what broke at 2AM) will appreciate it.

 Ask yourself: 
+ Can I tell what exactly each graph represents? Is it obvious, or do I have to think about it?
+ If I show this to someone else, how long will it take them to figure it out? Will they get lost?

**Have a monitoring strategy**

It’s easy to make new dashboards. It’s harder to optimize dashboard creation and adhere to a plan, but it’s worth it. This strategy should govern both your overall dashboard scheme and enforce consistency in individual dashboard design.

Refer to [Common observability strategies](#v12-dash-common-observability-strategies) and [Dashboard management maturity levels](#v12-dash-management-maturity-model) for more information.

**Write it down**

Once you have a strategy or design guidelines, write them down to help maintain consistency over time.

**Best practices to follow**
+ When creating a new dashboard, make sure it has a meaningful name.
  + If you are creating a dashboard to play or experiment, then put the word `TEST` or `TMP` in the name.
  + Consider including your name or initials in the dashboard name or as a tag so that people know who owns the dashboard.
  + Remove temporary experiment dashboards when you are done with them.
+ If you create many related dashboards, think about how to cross-reference them for easy navigation. For more information, see [Best practices for managing dashboards](#v12-dash-best-practices-for-managing-dashboards), later in this section.
+ Grafana retrieves data from a data source. A basic understanding of [Connect to data sources](AMG-data-sources.md) in general, and your specific data sources is important.
+ Avoid unnecessary dashboard refreshing to reduce the load on the network or backend. For example, if your data changes every hour, then you don’t need to set the dashboard refresh rate to 30 seconds.
+ Use the left and right Y-axes when displaying time series with different units or ranges.
+ Add documentation to dashboards and panels.
  + To add documentation to a dashboard, add a [Text panel visualization](v12-panels-text.md) to the dashboard. Record things like the purpose of the dashboard, useful resource links, and any instructions users might need to interact with the dashboard.
  + To add documentation to a panel, edit the panel settings and add a description. Any text you add will appear if you hover your cursor over the small `i` in the top left corner of the panel.
+ Reuse your dashboards and enforce consistency by using [templates and variables](v12-dash-variables.md).
+ Be careful with stacking graph data. The visualizations can be misleading, and hide important data. We recommend turning it off in most cases.

## Best practices for managing dashboards
<a name="v12-dash-best-practices-for-managing-dashboards"></a>

 This page outlines some best practices to follow when managing Grafana dashboards. 

**Before you begin**

Here are some principles to consider before you start managing dashboards.

**Strategic observability**

There are several [common observability strategies](#v12-dash-common-observability-strategies). You should research them and decide whether one of them works for you or if you want to come up with your own. Either way, have a plan, write it down, and stick to it.

Adapt your strategy to changing needs as necessary.

**Maturity level**

What is your dashboard maturity level? Analyze your current dashboard setup and compare it to the [Dashboard management maturity model](#v12-dash-management-maturity-model). Understanding where you are can help you decide how to get to where you want to be.

**Best practices to follow**
+ Avoid dashboard sprawl, meaning the uncontrolled growth of dashboards. Dashboard sprawl negatively affects time to find the right dashboard. Duplicating dashboards and changing "one thing" (worse: keeping original tags) is the easiest kind of sprawl.
  + Periodically review the dashboards and remove unnecessary ones.
  + If you create a temporary dashboard, perhaps to test something, prefix the name with `TEST:`. Delete the dashboard when you are finished.
+ Copying dashboards with no significant changes is not a good idea.
  + You miss out on updates to the original dashboard, such as documentation changes, bug fixes, or additions to metrics.
  + In many cases copies are being made to simply customize the view by setting template parameters. This should instead be done by maintaining a link to the master dashboard and customizing the view with [URL parameters](v12-panels-configure-data-links.md#v12-panels-data-link-variables).
+ When you must copy a dashboard, clearly rename it and *do not* copy the dashboard tags. Tags are important metadata for dashboards that are used during search. Copying tags can result in false matches.
+ Maintain a dashboard of dashboards or cross-reference dashboards. This can be done in several ways: 
  + Create dashboard links, panel, or data links. Links can go to other dashboards or to external systems. For more information, refer to [Manage dashboard links](v12-dash-manage-dashboard-links.md).
  +  Add a [Dashboard list panel](v12-panels-dashboard-list.md). You can then customize what you see by doing tag or folder searches.
  + Add a [Text panel](v12-panels-dashboard-list.md) and use markdown to customize the display. 

# Managing dashboards
<a name="v12-dash-managing-dashboards"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 12.x**.  
For Grafana workspaces that support Grafana version 10.x, see [Working in Grafana version 10](using-grafana-v10.md).  
For Grafana workspaces that support Grafana version 9.x, see [Working in Grafana version 9](using-grafana-v9.md).  
For Grafana workspaces that support Grafana version 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

On the **Dashboards** page of your workspace (available by selecting **Dashboards** from the left menu), you can perform dashboard management tasks, including organizing your dashboards into folders.

For more information about creating dashboards, see [Building dashboards](v12-dash-building-dashboards.md).

## Browse dashboards
<a name="v12-dash-browse-dashboards"></a>

On the **Dashboards** page, you can browse and manage folders and dashboards. This includes options to:
+ Create folders and dashboards.
+ Move dashboards between folders.
+ Delete multiple dashboards and folders.
+ Navigate to a folder.
+ Manage folder permissions. For more information, see [Dashboard and folder permissions](dashboard-and-folder-permissions.md).

## Creating dashboard folders
<a name="v12-dash-create-dashboard-folder"></a>

Folders help you organize and group dashboards, which is useful when you have many dashboards or multiple teams using the same Grafana instance. Subfolders allow you to create a nested hierarchy in your dashboard organization.

**Prerequisites**

Ensure that you have Grafana Admin permissions. For more information about dashboard permissions, see [Dashboard and folder permissions](dashboard-and-folder-permissions.md).

**To create a dashboard folder**

1. Sign in to Grafana. 

1. On the left menu, select **Dashboards**.

1. On the **Dashboards** page, select **New** then choose **New folder** in the drop down.

1. Enter a unique name and click **Create**.

**Note**  
When you save a dashboard, you can either select a folder for the dashboard to be saved in or create a new folder.

**To edit the name of a folder**

1. Select **Dashboards**in the left menu.

1. Select the folder to rename

1. Select the **Edit title** (pencil) icon in the header and update the name of the folder.

   The new folder name is automatically saved.

**Folder permissions**

You can assign permissions to a folder. Dashboard in the folder inherit any permissions that you've assigned to the folder. You can assign permissions to organization roles, teams, and users.

**To modify permissions for a folder**

1. Select **Dashboards** from the left menu.

1. Select the folder in the list.

1. On the folder's details page, select **Folder actions** and select **Manage permissions** in the drop down list.

1. Update the permissions as desired.

Changes are saved automatically.

# Managing playlists
<a name="v12-dash-managing-playlists"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 12.x**.  
For Grafana workspaces that support Grafana version 10.x, see [Working in Grafana version 10](using-grafana-v10.md).  
For Grafana workspaces that support Grafana version 9.x, see [Working in Grafana version 9](using-grafana-v9.md).  
For Grafana workspaces that support Grafana version 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

A *playlist* is a list of dashboards that are displayed in a sequence. You might use a playlist to build situational awareness or to present your metrics to your team or visitors. Grafana automatically scales dashboards to any resolution, which makes them perfect for large screens. You can access the playlist feature from Grafana’s side menu in the **Dashboards** submenu.

## Accessing, sharing, and controlling a playlist
<a name="v12-dash-access-share-control-playlist"></a>

Use the information in this section to access existing playlists. Start and control the display of a playlist using one of the five available modes.

**To access a playlist**

1. Select **Playlists** from the left menu.

1. Choose a playlist from the list of existing playlists.

**Starting a playlist**

You can start a playlist in five different view modes. View mode determines how the menus and navigation bar appear on the dashboards.

By default, each dashboard is displayed for the amount of time entered in the **Interval** field, which you set when you create or edit a playlist. After you start a playlist, you can control it with the navigation bar at the top of the page.

**To start a playlist**

1. Access the playlist page to see a list of existing playlists.

1. Find the playlist that you want to start, then click **Start playlist**.

   The start playlist dialog box will open.

1. Select one of the five playlist modes available based on the information in the following table.

1. Click **Start <playlist name>**.

The playlist displays each dashboard for the time specified in the `Interval` field, set when creating or editing a playlist. After a playlist starts, you can control it using the navigation bar at the top of your screen.


| Mode | Description | 
| --- | --- | 
| Normal mode |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/grafana/latest/userguide/v12-dash-managing-playlists.html)  | 
| TV mode |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/grafana/latest/userguide/v12-dash-managing-playlists.html)  | 
| TV mode (with auto fit panels) |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/grafana/latest/userguide/v12-dash-managing-playlists.html)  | 
| Kiosk mode |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/grafana/latest/userguide/v12-dash-managing-playlists.html)  | 
| Kiosk mode (with auto fit panels) |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/grafana/latest/userguide/v12-dash-managing-playlists.html)  | 

**Controlling a playlist**

You can control a playlist in **Normal** or **TV** mode after it has started, using the navigation bar at the top of your screen. Press the `Esc` key in your keyboard to stop the playlist.


| Button | Action | 
| --- | --- | 
| Next (double-right arrow) | Advances to the next dashboard. | 
| Back (left arrow) | Returns to the previous dashboard. | 
| Stop (square) | Ends the playlist, and exits to the current dashboard. | 
| Cycle view mode (monitor icon) | Rotates the display of the dashboards in different view modes. | 
| Time range | Displays data within a time range. It can be set to display the last 5 minutes up to 5 years ago, or a custom time range, using the down arrow. | 
| Refresh (circle arrow) | Reloads the dashboard, to display the current data. It can be set to reload automatically every 5 seconds to 1 day, using the dropdown arrow. | 

## Creating a playlist
<a name="v12-dash-create-playlist"></a>

You can create a playlist to present dashboards in a sequence with a set order and time interval between dashboards.

**To create a playlist**

1. Select **Dashboards** from the left menu.

1. Select **Playlists** on the playlist page.

1. Select **New playlist**.

1. Enter a descriptive name in the **Name** text box.

1. Enter a time interval in the **Interval** text box. The dashboards you add are listed in a sequential order.

1. In **Dashboards**, add existing dashboards to the playlist using the **Add by title** and **Add by tag** dropdown options.

1. Optionally:
   + Search for a dashboard by its name, a regular expression, or a tag.
   + Filter your results by starred status or tags.
   + Rearrange the order of the dashboards you have added using the up and down arrow icon.
   + Remove a dashboard from the playlist by clicking the **x** icon beside the dashboard.

1. Select **Save** to save your changes.

## Saving a playlist
<a name="v12-dash-save-playlist"></a>

You can save a playlist and add it to your **Playlists** page, where you can start it.

**Important**  
Ensure all the dashboards that you want to appear in your playlist are added when creating or editing the playlist before saving it.

**To save a playlist**

1. Select **Dashboards** in the left menu.

1. Select **Playlists** to view the playlists available to you.

1. Choose the playlist of your choice.

1. Edit the playlist.

1. Check that the playlist has a **Name**, **Interval**, and at least one **Dashboard** added to it.

1. Select **Save** to save your changes.

## Editing or deleting a playlist
<a name="v12-dash-edit-delete-playlist"></a>

You can edit a playlist by updating its name, interval time, and by adding, removing, and rearranging the order of dashboards, or you can delete the playlist.

**To edit a playlist**

1. Select **Edit playlist** on the playlist page.

1. Update the name and time interval, then add or remove dashboards from the playlist using instructions in Create a playlist, above.

1. Select **Save** to save your changes.

**To delete a playlist**

1. Select **Playlists**.

1. Select **Remove** next to the playlist you want to delete.

**To rearrange dashboard order in a playlist**

1. Next to the dashboard you want to move, click the up or down arrow.

1. Select **Save** to save your changes.

**To remove a dashboard**

1. Select **Remove** to remove a dashboard from the playlist.

1. Select **Save** to save your changes.

## Sharing a playlist in view mode
<a name="v12-dash-share-playlist-view-mode"></a>

You can share a playlist by copying the link address on the view mode you prefer, and pasting the URL to your destination.

**To share a playlist in view mode**

1. From the **Dashboards** left side menu, choose **Playlists**.

1. Select **Start playlist** next to the playlist you want to share.

1. In the dropdown, right click the view mode you prefer.

1. Select **Copy Link Address** to copy the URL to your clipboard.

1. Paste the URL to your destination.

# Sharing dashboards and panels
<a name="v12-dash-sharing"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 12.x**.  
For Grafana workspaces that support Grafana version 10.x, see [Working in Grafana version 10](using-grafana-v10.md).  
For Grafana workspaces that support Grafana version 9.x, see [Working in Grafana version 9](using-grafana-v9.md).  
For Grafana workspaces that support Grafana version 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

Grafana enables you to share dashboards and panels with other users within an organization and in certain situations, publicly on the Web. You can share using:
+ A direct link
+ A snapshot
+ An export link (for dashboards only)

You must have an authorized viewer permission to see an image rendered by a direct link.

When you share a panel or dashboard as a snapshot, a snapshot (which is a panel or dashboard at the moment you take the snapshot) is publicly available on the web. Anyone with a link to it can access it. Because snapshots do not require any authorization to view, Grafana removes information related to the account it came from, as well as any sensitive data from the snapshot.

## Sharing a dashboard
<a name="v12-dash-share-dashboard"></a>

You can share a dashboard as a direct link or as a snapshot. You can also export a dashboard. The sharing workflow includes customizable shareable panel images and a streamlined interface.

**Note**  
If you change a dashboard, ensure that you save the changes before sharing.

**To Share a dashboard**

1. Select **Dashboards** from the left menu in your workspace.

1. Choose the dashboard you want to share.

1. Select the share icon at the top of the screen.

   The share dialog box opens and shows the **Link** tab.

**Sharing a direct link**

The **Link** tab shows the current time range, template variables, and the default theme. You can also share a shortened URL.

**To share a directly link**

1. Select **Copy**. This action copies the default or the shortened URL to the clipboard.

1. Send the copied URL to a Grafana user with authorization to view the link.

**Publishing a snapshot**

A dashboard snapshot shares an interactive dashboard publicly. Grafana strips sensitive data such as queries (metric, template, and annotation) and panel links, leaving only the visible metric data and series names embedded in the dashboard. Dashboard snapshots can be accessed by anyone with the link.

You can publish snapshots to your local instance.

**To publish a snapshot**

1. Select the **Snapshot** tab.

1. Select the **Local Snapshot**.

1. Grafana generates a link of the snapshot. Copy the snapshot link, and share it either within your organization or publicly on the web.

**Exporting a dashboard**

Grafana dashboards can easily be exported and imported. For more information, see the import and export sections in [Building dashboards](v12-dash-building-dashboards.md).

## Sharing a panel
<a name="v12-dash-share-panel"></a>

You can share a panel as a direct link, or as a snapshot. You can also create library panels using the **Share** option on any panel.

**To share a panel**

1. Select the panel title of the panel you want to share. The panel menu opens.

1. Select **Share**. The share dialog box will open and show the **Link** tab.

**Using a direct link**

The **Link** tab shows the current time range, template variables, and the default theme. You can optionally enable a shortened URL to share.

**To use a direct link**

1. Select **Copy** to copy the default or the shortened URL to the clipboard. 

1. Send the copied URL to a Grafana user with authorization to view the link.

**Publishing a snapshot of a panel**

A panel snapshot is a share of an interactive panel publicly. Grafana strips sensitive data leaving only the visible metric data and series names embedded in the dashboard. Panel snapshots can be accessed by anyone with the link.

You can publish snapshots to your local instance.

**To publish a snapshot of a panel**

1. In the **Share Panel** dialog box, select the **Snapshot** tab.

1. Select **Local Snapshot**. Grafana generates the link of the snapshot.

1. Copy the snapshot link, and share it either within your organization or publicly on the web.

If you created a snapshot by mistake, click **Delete snapshot** to remove the snapshot from your Grafana instance.

**Creating a library panel**

To create a library panel from the **Share Panel** dialog box.

**To create a library panel**

1. Select **Library panel**.

1. In **Library panel name**, enter the name.

1. In **Save in folder**, select the folder in which to save the library panel. By default, the root folder is selected.

1. Select **Create library panel** to save your changes.

1. Save the dashboard.

# Variables
<a name="v12-dash-variables"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 12.x**.  
For Grafana workspaces that support Grafana version 10.x, see [Working in Grafana version 10](using-grafana-v10.md).  
For Grafana workspaces that support Grafana version 9.x, see [Working in Grafana version 9](using-grafana-v9.md).  
For Grafana workspaces that support Grafana version 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

A variable is a placeholder for a value. You can use variables in metric queries and in panel titles. So when you change the value, using the dropdown at the top of the dashboard, your panel’s metric queries will change to reflect the new value.

Variables allow you to create more interactive and dynamic dashboards. Instead of hard-coding things like server, application, and sensor names in your metric queries, you can use variables in their place. Variables are displayed as dropdown lists at the top of the dashboard. These dropdowns make it easy to change the data being displayed in your dashboard.

These can be especially useful for administrators who want to allow Grafana viewers to quickly adjust visualizations but do not want to give them full editing permissions. Grafana Viewers can use variables.

Variables and templates also allow you to single-source dashboards. If you have multiple identical data sources or servers, you can make one dashboard and use variables to change what you are viewing. This simplifies maintenance and upkeep enormously.

**Templates**

A template is any query that contains a variable. For example, if you were administering a dashboard to monitor several servers, you could make a dashboard for each server, or you could create one dashboard and use panels with template queries, such as the following.

```
wmi_system_threads{instance=~"$server"}
```

Variable values are always synced to the URL using the syntax var-<varname>=value.

**Examples**

Variables are listed in dropdown lists across the top of the screen. Select different variables to see how the visualizations change.

To see variable settings, navigate to **Dashboard Settings > Variables**. Click a variable in the list to see its settings.

Variables can be used in titles, descriptions, text panels, and queries. Queries with text that starts with `$` are templates. Not all panels will have template queries.

**Variable best practices**
+ Variable dropdown lists are displayed in the order they are listed in the variable list in **Dashboard settings**.
+ Put the variables that you will change often at the top, so they will be shown first (far left on the dashboard).
+ Variables preselect the topmost value in the dropdown list by default. If you want to choose an empty value instead, change the variable settings, as follows:

  1. Select the **Include All Option** checkbox.

  1. In the **Custom all value** field, enter the value `+`.

**Topics**
+ [Add and manage variables](v12-dash-variable-add.md)
+ [Inspect Variables](v12-dash-variable-add-inspect.md)
+ [Variable syntax](v12-dash-variable-syntax.md)

# Add and manage variables
<a name="v12-dash-variable-add"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 12.x**.  
For Grafana workspaces that support Grafana version 10.x, see [Working in Grafana version 10](using-grafana-v10.md).  
For Grafana workspaces that support Grafana version 9.x, see [Working in Grafana version 9](using-grafana-v9.md).  
For Grafana workspaces that support Grafana version 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

The following table lists the types of variables in Grafana.


| Variable type | Description | 
| --- | --- | 
| Query | Query-generated list of values such as metric names, server names, sensor IDs, data centers, and so on. Query variables also support static options, giving you more control over variable values without requiring a data source query. | 
| Custom | Define the variable options manually using a comma-separated list. | 
| Text box | Display a free text input field with an optional default value. | 
| Constant | Define a hidden constant. | 
| Data source | Quickly change the data source for an entire dashboard. | 
| Interval | Interval variables represent time spans. | 
| Ad hoc filters | Key-value filters that are automatically added to all metric queries for a data source. Ad hoc filters provide improved support across data sources for dynamically filtering dashboard data. | 
| Switch | Quickly toggle between values in queries, simplifying dashboard interactions. | 
| Global variables | Built-in variables that can be used in expressions in the query editor. | 
| Chained variables | Variable queries can contain other variables. | 

**Topics**
+ [Entering General options](#v12-dash-variable-options)
+ [Adding a query variable](#v12-dash-variable-add-query)
+ [Adding a custom variable](#v12-dash-variable-add-custom)
+ [Adding a text box variable](#v12-dash-variable-add-text)
+ [Adding a constant variable](#v12-dash-variable-add-constant)
+ [Adding a data source variable](#v12-dash-variable-add-datasource)
+ [Adding an interval variable](#v12-dash-variable-add-internal)
+ [Adding ad hoc filters](#v12-dash-variable-add-adhoc)
+ [Configure variable selection options](#v12-dash-variable-add-selection)
+ [Global variables](#v12-dash-variable-add-global)
+ [Chained variables](#v12-dash-variable-add-chained)
+ [Manage variables](#v12-dash-variable-add-manage)
+ [Filter variables with regex](#v12-dash-variable-add-filter)

## Entering General options
<a name="v12-dash-variable-options"></a>

You must enter general options for any type of variable that you create.

**To enter general options**

1. Navigate to the dashboard you want to make a variable for and select the **Dashboard settings** (gear) icon at the top of the page.

1. On the **Variables** tab, select **New variable**.

1. Enter a **Name** for the variable.

1. In the **Type** list, select **Query**.

1. (Optional) In **Label**, enter the display name of the variable dropdown.

   If you don’t enter a display name, then the dropdown label is the variable name.

1. Choose a **Hide** option:
   + **No selection (blank)** – The variable dropdown displays the variable **Name** or **Label** value.
   + **Label** – The variable dropdown only displays the selected variable value and a down arrow.
   + **Variable** – No variable dropdown is displayed on the dashboard.

## Adding a query variable
<a name="v12-dash-variable-add-query"></a>

Query variables enable you to write a data source query that can return a list of metric names, tag values, or keys. For example, a query variable might return a list of server names, sensor IDs, or data centers. The variable values change as they dynamically fetch options with a data source query.

Query variables are generally only supported for strings. If your query returns numbers or any other data type, you might need to convert them to strings in order to use them as variables. For the Azure data source, for example, you can use the [tostring](https://docs.microsoft.com/en-us/azure/data-explorer/kusto/query/tostringfunction) function for this purpose.

Query expressions can contain references to other variables and in effect create linked variables. Grafana detects this and automatically refreshes a variable when one of its linked variables change.

**Note**  
Query expressions are different for each data source. For more information, refer to the documentation for your [data source](AMG-data-sources.md).

**To add a query variable**

1. Enter general options, as above.

1. In the **Data source** list, select the target data source for the query.

1. In the **Refresh** list, select when the variable should update options.
   + **On Dashboard Load** – Queries the data source every time the dashboard loads. This slows down dashboard loading, because the variable query needs to be completed before dashboard can be initialized.
   + **On Time Range Change** – Queries the data source when the dashboard time range changes. Only use this option if your variable options query contains a time range filter or is dependent on the dashboard time range.

1. In the **Query** field, enter a query.
   + The query field varies according to your data source. Some data sources have custom query editors.
   + The query must return values named `__text` and `__value`. For example, in SQL, you can use a query such as `SELECT hostname AS __text, id AS __value from MyTable`. Queries for other languages will vary depending on syntax.
   + If you need more room in a single input field query editor, then hover your cursor over the lines in the lower right corner of the field and drag downward to expand.

1. (Optional) In the **Regex** field, type a regex expression to filter or capture specific parts of the names returned by your data source query. To see examples, refer to [Filter variables with regex](#v12-dash-variable-add-filter).

1. In the **Sort** list, select the sort order for values to be displayed in the dropdown list. The default option, **Disabled**, means that the order of options returned by your data source query will be used.

1. (Optional) Enter [Selection Options](#v12-dash-variable-add-selection).

1. In **Preview of values**, Grafana displays a list of the current variable values. Review them to ensure they match what you expect.

1. Select **Add** to add the variable to the dashboard.

## Adding a custom variable
<a name="v12-dash-variable-add-custom"></a>

Use a *custom* variable for a value that does not change, such as a number or a string.

For example, if you have server names or Region names that never change, then you might want to create them as custom variables rather than query variables. Because they do not change, you might use them in [chained variables](#v12-dash-variable-add-chained) rather than other query variables. That would reduce the number of queries Grafana must send when chained variables are updated.

**To add a custom variable**

1. Enter general options, as above.

1. In the **Values separated by comma** list, enter the values for this variable in a comma-separated list. You can include numbers, strings, or key-value pairs separated by a space and a colon. For example, `key1 : value1,key2 : value2`.

1. (Optional) Enter [Selection Options](#v12-dash-variable-add-selection).

1. In **Preview of values**, Grafana displays a list of the current variable values. Review them to ensure they match what you expect.

1. Select **Add** to add the variable to the dashboard.

## Adding a text box variable
<a name="v12-dash-variable-add-text"></a>

*Text box* variables display a free text input field with an optional default value. This is the most flexible variable, because you can enter any value. Use this type of variable if you have metrics with high cardinality or if you want to update multiple panels in a dashboard at the same time.

**To add a text box variable**

1. Enter general options, as above.

1. (Optional) In the **Default value** field, select the default value for the variable. If you do not enter anything in this field, then Grafana displays an empty text box for users to type text into.

1. In **Preview of values**, Grafana displays a list of the current variable values. Review them to ensure they match what you expect.

1. Select **Add** to add the variable to the dashboard.

## Adding a constant variable
<a name="v12-dash-variable-add-constant"></a>

*Constant* variables enable you to define a hidden constant. This is useful for metric path prefixes for dashboards you want to share. When you export a dashboard, constant variables are converted to import options.

Constant variables are *not* flexible. Each constant variable only holds one value, and it cannot be updated unless you update the variable settings.

Constant variables are useful when you have complex values that you need to include in queries but don’t want to retype in every query. For example, if you had a server path called `i-0b6a61efe2ab843gg`, then you could replace it with a variable called `$path_gg`.

**To add a constant variable**

1. Enter general options, as above.

1. In the **Value** field, enter the variable value. You can enter letters, numbers, and symbols. You can even use wildcards if you use [raw format](v12-dash-variable-syntax.md#v12-dash-variable-syntax-raw).

1. In **Preview of values**, Grafana displays a list of the current variable values. Review them to ensure they match what you expect.

1. Select **Add** to add the variable to the dashboard.

## Adding a data source variable
<a name="v12-dash-variable-add-datasource"></a>

*Data source* variables enable you to quickly change the data source for an entire dashboard. They are useful if you have multiple instances of a data source, perhaps in different environments.

**To add a data source variable**

1. Enter general options, as above.

1. In the **Type** list, select the target data source for the variable.

   You can also choose **Open advanced data source picker** to see more options, including adding a data source (Admins only). For more information, see [Connect to data sources](AMG-data-sources.md).

1. (Optional) In **Instance name filter**, enter a regex filter for which data source instances to choose from in the variable value dropdown list. Leave this field empty to display all instances.

1. (Optional) Enter [Selection Options](#v12-dash-variable-add-selection).

1. In **Preview of values**, Grafana displays a list of the current variable values. Review them to ensure they match what you expect.

1. Select **Add** to add the variable to the dashboard.

## Adding an interval variable
<a name="v12-dash-variable-add-internal"></a>

Use an *interval* variable to represents time spans such as `1m`,`1h`, or `1d`. You can think of them as a dashboard-wide *group by time* command. Interval variables change how the data is grouped in the visualization. You can also use the Auto Option to return a set number of data points per time span.

You can use an interval variable as a parameter to group by time (for InfluxDB), date histogram interval (for Elasticsearch), or as a summarize function parameter (for Graphite).

**To add an interval variable**

1. Enter general options, as above.

1. In the **Values** field, enter the time range intervals that you want to appear in the variable dropdown list. The following time units are supported: `s (seconds)`, `m (minutes)`, `h (hours)`, `d (days)`, `w (weeks)`, `M (months)`, and `y (years)`. You can also accept or edit the default values: `1m,10m,30m,1h,6h,12h,1d,7d,14d,30d`.

1. (Optional) Turn on the **Auto Option** if you want to add the `auto` option to the list. This option allows you to specify how many times the current time range should be divided to calculate the current `auto` time span. If you turn it on, then two more options appear:
   + **Step count** – Select the number of times the current time range will be divided to calculate the value, similar to the **Max data points** query option. For example, if the current visible time range is 30 minutes, then the `auto` interval groups the data into 30 one-minute increments. The default value is 30 steps.
   + **Min Interval** – The minimum threshold below which the step count intervals will not divide the time. To continue the 30 minute example, if the minimum interval is set to 2m, then Grafana would group the data into 15 two-minute increments.

1. In **Preview of values**, Grafana displays a list of the current variable values. Review them to ensure they match what you expect.

1. Select **Add** to add the variable to the dashboard.

**Interval variable examples**

The following example shows a template variable `myinterval` in a Graphite function:

```
summarize($myinterval, sum, false)
```

## Adding ad hoc filters
<a name="v12-dash-variable-add-adhoc"></a>

*Ad hoc filters* enable you to add key-value filters that are automatically added to all metric queries that use the specified data source. Unlike other variables, you do not use ad hoc filters in queries. Instead, you use ad hoc filters to write filters for existing queries.

**Note**  
Ad hoc filter variables only work with Prometheus, Loki, InfluxDB, and Elasticsearch data sources.

1. Enter general options, as above.

1. In the **Data source** list, select the target data source.

   You can also choose **Open advanced data source picker** to see more options, including adding a data source (Admins only). For more information, see [Connect to data sources](AMG-data-sources.md).

1. Select **Add** to add the variable to the dashboard.

**Create ad hoc filters**

Ad hoc filters are one of the most complex and flexible variable options available. Instead of a regular list of variable options, this variable allows you to build a dashboard-wide ad hoc query. Filters you apply in this manner are applied to all panels on the dashboard.

## Configure variable selection options
<a name="v12-dash-variable-add-selection"></a>

*Selection Options* are a feature you can use to manage variable option selections. All selection options are optional, and they are off by default.

### Multi-value variables
<a name="v12-dash-variable-add-selection-multi"></a>

Interpolating a variable with multiple values selected is tricky as it is not straight forward how to format the multiple values into a string that is valid in the given context where the variable is used. Grafana tries to solve this by allowing each data source plugin to inform the templating interpolation engine what format to use for multiple values.

**Note**  
The **Custom all value** option on the variable must be blank for Grafana to format all values into a single string. If it is left blank, then Grafana concatenates (adds together) all the values in the query. For example, `value1,value2,value3`. If a custom `all` value is used, then instead the value will be `*` or `all`.

**Multi-value variables with a Graphite data source**

Graphite uses glob expressions. A variable with multiple values is, in this case, be interpolated as `{host1,host2,host3}` if the current variable value iss *host1*, *host2*, and *host3*.

**Multi-value variables with a Prometheus or InfluxDB datasource**

InfluxDB and Prometheus use regex expressions, so the same variable is interpolated as `(host1|host2|host3)`. Every value is also regex escaped. If it were not, a value with a regex control character would break the regex expression.

**Multi-value variables with an Elastic data source**

Elasticsearch uses lucene query syntax, so the same variable is formatted as `("host1" OR "host2" OR "host3")`. In this case, every value is escaped so that the value only contains lucene control words and quotation marks.

**Troubleshoot multi-value variables**

Automatic escaping and formatting can cause problems and it can be tricky to grasp the logic behind it. Especially for InfluxDB and Prometheus where the use of regex syntax requires that the variable is used in regex operator context.

If you do not want Grafana to do this automatic regex escaping and formatting, then you must do one of the following:
+ Turn off the **Multi-value** or **Include All option** options.
+ Use the [raw format](v12-dash-variable-syntax.md#v12-dash-variable-syntax-raw).

### Include All option
<a name="v12-dash-variable-add-multi-all"></a>

Grafana adds an `All` option to the variable dropdown list. If a user selects this option, then all variable options are selected.

### Custom all value
<a name="v12-dash-variable-add-multi-custom"></a>

This option is only visible if the **Include All option** is selected.

Enter regex, globs, or lucene syntax in the **Custom all value** field to define the value of the `All` option.

By default the `All` value includes all options in a combined expression. This can become very long and can have performance problems. Sometimes it can be better to specify a custom all value, like a wildcard regex.

To have custom regex, globs, or lucene syntax in the **Custom all value** option, it is never escaped so you will have to think about what is a valid value for your data source.

## Global variables
<a name="v12-dash-variable-add-global"></a>

Grafana has global built-in variables that can be used in expressions in the query editor. This topic lists them in alphabetical order and defines them. These variables are useful in queries, dashboard links, panel links, and data links.

**\$1\$1\$1dashboard**

This variable is the name of the current dashboard.

**\$1\$1\$1from and \$1\$1\$1to**

Grafana has two built-in time range variables: `$__from` and `$__to`. They are currently always interpolated as epoch milliseconds by default, but you can control date formatting.


| Syntax | Example result | Description | 
| --- | --- | --- | 
|  `${__from}`  |  1594671549254  |  Unix millisecond epoch  | 
|  `${__from:date}`  |  2020-07-13T20:19:09.254Z  |  No args, defaults to ISO 8601/RFC 3339  | 
|  `${__from:date:iso}`  |  2020-07-13T20:19:09.254Z  |  ISO 8601/RFC 3339  | 
|  `${__from:date:seconds}`  |  1594671549  |  Unix seconds epoch  | 
|  `${__from:date:YYYY-MM}`  |  2020-07  |  Any custom date format that does not include the : character  | 

The syntax above also works with `${__to}`.

**\$1\$1\$1interval**

You can use the `$__interval` variable as a parameter to group by time (for InfluxDB, MySQL, Postgres, MSSQL), Date histogram interval (for Elasticsearch), or as a *summarize* function parameter (for Graphite).

Grafana automatically calculates an interval that can be used to group by time in queries. When there are more data points than can be shown on a graph, the queries can be made more efficient by grouping by a larger interval. For example, if you are looking at a graph of 3 months worth of data, you might not be able to see detail at the minute level. Grouping by the hour or day makes the query more efficient without affecting what the graph shows. The `$__interval` is calculated using the time range and the width of the graph (the number of pixels).

Approximate Calculation: `(to - from) / resolution`

For example, when the time range is 1 hour and the graph is full screen, then the interval might be calculated to `2m` - points are grouped in 2 minute intervals. If the time range is 6 months and the graph is full screen, then the interval might be `1d` (1 day) - points are grouped by day.

In the InfluxDB data source, the legacy variable `$interval` is the same variable. `$__interval` should be used instead.

The InfluxDB and Elasticsearch data sources have `Group by time interval` fields that are used to hard code the interval or to set the minimum limit for the `$__interval` variable (by using the `>` syntax, for example `>10m`).

**\$1\$1\$1interval\$1ms**

This variable is the `$__interval` variable in milliseconds, not a time interval formatted string. For example, if the `$__interval` is `20m` then the `$__interval_ms` is `1200000`.

**\$1\$1\$1org**

This variable is the ID of the current organization. `${__org.name}` is the name of the current organization.

**\$1\$1\$1user**

`${__user.id}` is the ID of the current user. `${__user.login}` is the login handle of the current user. `${__user.email}` is the email for the current user.

**\$1\$1\$1range**

Only supported for Prometheus and Loki data sources. This variable represents the range for the current dashboard. It is calculated by `to - from`. It has a millisecond and a second representation called `$__range_ms` and `$__range_s`.

**\$1\$1\$1rate\$1interval**

Only supported for Prometheus data sources. The `$__rate_interval` variable is meant to be used in the rate function.

**\$1timeFilter or \$1\$1\$1timeFilter**

The `$timeFilter` variable returns the currently selected time range as an expression. For example, the time range interval `Last 7 days` expression is `time > now() - 7d`.

This is used in several places, including:
+ The WHERE clause for the InfluxDB data source. Grafana adds it automatically to InfluxDB queries when in Query Editor mode. You can add it manually in Text Editor mode: `WHERE $timeFilter`.
+ Log Analytics queries in the Azure Monitor data source.
+ SQL queries in MySQL, Postgres, and MSSQL.
+ The `$__timeFilter` variable is used in the MySQL data source.

**\$1\$1\$1timezone**

The `$__timezone` variable returns the currently selected time zone, either `utc` or an entry of the IANA time zone data base (for example, `America/New_York`).

If the currently selected time zone is *Browser Time*, Grafana will try to determine your browser time zone.

## Chained variables
<a name="v12-dash-variable-add-chained"></a>

*Chained variables*, also called *linked variables* or *nested variables*, are query variables with one or more other variables in their variable query.

Chained variable queries are different for every data source, but the premise is the same for all. You can use chained variable queries in any data source that allows them.

Extremely complex linked templated dashboards are possible, 5 or 10 levels deep. Technically, there is no limit to how deep or complex you can go, but the more links you have, the greater the query load.

**Best practices and tips**

The following practices will make your dashboards and variables easier to use.

**Creating new linked variables**
+ Chaining variables create parent/child dependencies. You can envision them as a ladder or a tree.
+ The easiest way to create a new chained variable is to copy the variable that you want to base the new one on. In the variable list, click the **Duplicate variable** icon to the right of the variable entry to create a copy. You can then add on to the query for the parent variable.
+ New variables created this way appear at the bottom of the list. You might need to drag it to a different position in the list to get it into a logical order.

**Variable order**

You can change the orders of variables in the dashboard variable list by clicking the up and down arrows on the right side of each entry. Grafana lists variable dropdowns left to right according to this list, with the variable at the top on the far left.
+ List variables that do not have dependencies at the top, before their child variables.
+ Each variable should follow the one it is dependent on.
+ Remember there is no indication in the UI of which variables have dependency relationships. List the variables in a logical order to make it easy on other users (and yourself).

**Complexity consideration**

The more layers of dependency you have in variables, the longer it will take to update dashboards after you change variables.

For example, if you have a series of four linked variables (country, Region, server, metric) and you change a root variable value (country), then Grafana must run queries for all the dependent variables before it updates the visualizations in the dashboard.

## Manage variables
<a name="v12-dash-variable-add-manage"></a>

The variables page lets you add variables and manage existing variables. It also allows you to [inspect](v12-dash-variable-add-inspect.md) variables and identify whether a variable is being referenced (or used) in other variables or dashboard.

**Move** – You can move a variable up or down the list using drag and drop.

**Clone** – To clone a variable, click the clone icon from the set of icons on the right. This creates a copy of the variable with the name of the original variable prefixed with `copy_of_`.

**Delete** – To delete a variable, click the trash icon from the set of icons on the right.

## Filter variables with regex
<a name="v12-dash-variable-add-filter"></a>

Using the Regex Query option, you filter the list of options returned by the variable query or modify the options returned.

This page shows how to use regex to filter/modify values in the variable dropdown.

Using the Regex Query Option, you filter the list of options returned by the Variable query or modify the options returned. For more information, refer to the Mozilla guide on [Regular expressions](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions).

The following examples show filtering on the following list of options

```
backend_01
backend_02
backend_03
backend_04
```

**Filter so that only the options that end with `01` or `02` are returned**

Regex:

```
/
(
01|02 
) 
$/
```

Result:

```
backend_01
backend_02
```

**Filter and modify the options using a regex capture group to return part of the text**

Regex:

```
/.* 
(
01|02 
)
/
```

Result:

```
01
02
```

**Filter and modify - Prometheus Example**

For this list of options:

```
up{instance="demo.robustperception.io:9090",job="prometheus"} 1 1521630638000
up{instance="demo.robustperception.io:9093",job="alertmanager"} 1 1521630638000
up{instance="demo.robustperception.io:9100",job="node"} 1 1521630638000
```

This regex:

```
/. *instance="
(
[^"]*
)
.*/
```

Returns these results:

```
demo.robustperception.io:9090
demo.robustperception.io:9093
demo.robustperception.io:9100
```

**Filter and modify using named text and value capture groups**

Using named capture groups, you can capture separate ’text’ and ‘value’ parts from the options returned by the variable query. This allows the variable dropdown list to contain a friendly name for each value that can be selected.

For example, when querying the `node_hwmon_chip_names` Prometheus metric, the `chip_name` is a lot friendlier that the `chip` value. So the following variable query result:

```
node_hwmon_chip_names{chip="0000:d7:00_0_0000:d8:00_0",chip_name="enp216s0f0np0"} 1
node_hwmon_chip_names{chip="0000:d7:00_0_0000:d8:00_1",chip_name="enp216s0f0np1"} 1
node_hwmon_chip_names{chip="0000:d7:00_0_0000:d8:00_2",chip_name="enp216s0f0np2"} 1
node_hwmon_chip_names{chip="0000:d7:00_0_0000:d8:00_3",chip_name="enp216s0f0np3"} 1
```

Passed through the following Regex:

```
/chip_name="(?<text>[ ^ " ] + ) |chip=" (?<value >[ ^ " ] + )/g
```

Would produce the following dropdown list:

```
Display Name          Value
------------          -------------------------
enp216s0f0np0         0000:d7:00_0_0000:d8:00_0
enp216s0f0np1         0000:d7:00_0_0000:d8:00_1
enp216s0f0np2         0000:d7:00_0_0000:d8:00_2
enp216s0f0np3         0000:d7:00_0_0000:d8:00_3
```

Only `text` and `value` capture group names are supported.

# Inspect Variables
<a name="v12-dash-variable-add-inspect"></a>

The variables page lets you easily identify whether a variable is being referenced (or used) in other variables or dashboard.

Any variable that is referenced or used has a green check mark next to it, while unreferenced variables have an orange caution icon next to them. In addition, all referenced variables have a dependency icon next to the green check mark. You can select the icon to view the dependency map. The dependency map can be moved. You can zoom in or out with the mouse wheel or equivalent.

# Variable syntax
<a name="v12-dash-variable-syntax"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 12.x**.  
For Grafana workspaces that support Grafana version 10.x, see [Working in Grafana version 10](using-grafana-v10.md).  
For Grafana workspaces that support Grafana version 9.x, see [Working in Grafana version 9](using-grafana-v9.md).  
For Grafana workspaces that support Grafana version 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

Panel titles and metric queries can refer to variables using two different syntaxes.
+ `$varname` – This syntax is easy to read, but it does not allow you to use a variable in the middle of a word.

  **Example:** `apps.frontend.$server.requests.count`
+ `${var_name}` – Use this syntax when you want to use a variable in the middle of an expression.
+ `${var_name:<format>}` – This format gives you more control over how Grafana interprets values. For more information, see *Advanced variable format options*, following this list.
+ `[[varname]]` – Do not use. This syntax is old and has been deprecated. It will be removed in a future release.

Before queries are sent to your data source the query is *interpolated*, meaning the variable is replaced with its current value. During interpolation, the variable value might be *escaped* in order to conform to the syntax of the query language and where it is used. For example, a variable used in a regex expression in an InfluxDB or Prometheus query will be regex escaped.

**Advanced variable format options**

The formatting of the variable interpolation depends on the data source, but there are some situations where you might want to change the default formatting.

For example, the default for the MySQL data source is to join multiple values as comma-separated with quotes: `'server01','server02'`. In some cases, you might want to have a comma-separated string without quotes: `server01,server02`. You can make that happen with advanced variable formatting options listed below.

**General syntax**

Syntax: `${var_name:option}`

If any invalid formatting option is specified, then `glob` is the default/fallback option.

**CSV**

Formats variables with multiple values as a comma-separated string.

```
servers = [ 'test1',  'test2' ]
String to interpolate:  '${servers:csv}'
Interpolation result:  'test1,test2'
```

**Distributed - OpenTSDB**

Formats variables with multiple values in custom format for OpenTSDB.

```
servers = [ 'test1',  'test2' ]
String to interpolate:  '${servers:distributed}'
Interpolation result:  'test1,servers=test2'
```

**Doublequote**

Formats single- and multi-valued variables into a comma-separated string, escapes `"` in each value by `\"` and quotes each value with `"`.

```
servers = [ 'test1',  'test2' ]
String to interpolate:  '${servers:doublequote}'
Interpolation result:  '"test1","test2"'
```

**Glob - Graphite**

Formats variables with multiple values into a glob (for Graphite queries).

```
servers = [ 'test1',  'test2' ]
String to interpolate:  '${servers:glob}'
Interpolation result:  '{test1,test2}'
```

**JSON**

Formats variables with multiple values as a comma-separated string.

```
servers = [ 'test1',  'test2' ]
String to interpolate:  '${servers:json}'
Interpolation result:  '["test1", "test2"]'
```

**Lucene - Elasticsearch**

Formats variables with multiple values in Lucene format for Elasticsearch.

```
servers = [ 'test1',  'test2' ]
String to interpolate:  '${servers:lucene}'
Interpolation result:  '("test1" OR "test2")'
```

**Percentencode**

Formats single and multivalued variables for use in URL parameters.

```
servers = [ 'foo()bar BAZ',  'test2' ]
String to interpolate:  '${servers:percentencode}'
Interpolation result:  'foo%28%29bar%20BAZ%2Ctest2'
```

**Pipe**

Formats variables with multiple values into a pipe-separated string.

```
servers = [ 'test1.',  'test2' ]
String to interpolate:  '${servers:pipe}'
Interpolation result:  'test1.|test2'
```

**Raw**

Turns off data source-specific formatting, such as single quotes in an SQL query.

```
servers = [ 'test.1',  'test2' ]
String to interpolate:  '${var_name:raw}'
Interpolation result:  'test.1,test2'
```

**Regex**

Formats variables with multiple values into a regex string.

```
servers = [ 'test1.',  'test2' ]
String to interpolate:  '${servers:regex}'
Interpolation result:  '(test1\.|test2)'
```

**Singlequote**

Formats single- and multi-valued variables into a comma-separated string, escapes `'` in each value by `\'` and quotes each value with `'`.

```
servers = [ 'test1',  'test2' ]
String to interpolate:  '${servers:singlequote}'
Interpolation result:  "'test1','test2'"
```

**Sqlstring**

Formats single- and multi-valued variables into a comma-separated string, escapes `'` in each value by `''` and quotes each value with `'`.

```
servers = [ "test'1",  "test2" ]
String to interpolate:  '${servers:sqlstring}'
Interpolation result:  "'test''1','test2'"
```

**Text**

Formats single- and multi-valued variables into their text representation. For a single variable, it will just return the text representation. For multi-valued variables, it will return the text representation combined with `+`.

```
servers = [ "test1",  "test2" ]
String to interpolate:  '${servers:text}'
Interpolation result:  "test1 + test2"
```

**Query parameters**

Formats single- and multi-valued variables into their query parameter representation. Example: `var-foo=value1&var-foo=value2`

```
servers = [ "test1",  "test2" ]
String to interpolate:  '${servers:queryparam}'
Interpolation result:  "var-servers=test1&var-servers=test2"
```

# Assessing dashboard usage
<a name="v12-dash-assess-dashboard-usage"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 12.x**.  
For Grafana workspaces that support Grafana version 10.x, see [Working in Grafana version 10](using-grafana-v10.md).  
For Grafana workspaces that support Grafana version 9.x, see [Working in Grafana version 9](using-grafana-v9.md).  
For Grafana workspaces that support Grafana version 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

For every dashboard and data source, you can access usage information.

**Dashboard insights**

To see dashboard usage information, select **Dashboard insights** in the top bar.

Dashboard insights show the following information.
+ **Stats** – The number of daily queries and errors for the past 30 days.
+ **Users & activity** – The daily view count for the last 30 days; last activities on the dashboard and recent users (with a limit of 20).

**Data source insights**

Data source insights provide information about how a data source has been used in the past 30 days, such as:
+ Queries per day
+ Errors per day
+ Query load time per day (averaged in ms)

**To find data source insights**

1. Select **Connections** in the main navigation of your workspace.

1. Select **Data sources**.

1. Choose a data source.

1. Select the **Insights** tab.

## Presence indicator
<a name="v12-dash-presence-indicator"></a>

When you are signed in and look at a dashboard, you can know who is looking at the same dashboard as you are through a presence indicator, which displays avatars of users who have recently interacted with the dashboard. The default timeframe is 10 minutes. To see the user’s name, hover over the user’s avatar. The avatars come from [Gravatar](https://gravatar.com/) based on the user’s email.

When there are more active users on a dashboard than can fit within the presence indicator, click the **\$1X** icon. Doing this will open dashboard insights, which contain more details about recent user activity.

## Sorting dashboards by using insights data
<a name="v12-dash-sort-dashboards"></a>

In the search view, you can use insights data to help you find most-used, broken, and unused dashboards. You can sort dashboards by the following.
+ Views
+ Errors
+ Views
+ Created time
+ Updated time

# Troubleshoot dashboards
<a name="v12-dash-troubleshoot"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 12.x**.  
For Grafana workspaces that support Grafana version 10.x, see [Working in Grafana version 10](using-grafana-v10.md).  
For Grafana workspaces that support Grafana version 9.x, see [Working in Grafana version 9](using-grafana-v9.md).  
For Grafana workspaces that support Grafana version 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

 Use the following strategies to help you troubleshoot common dashboard problems. 

## Dashboard is slow
<a name="v12-dash-dashboard-is-slow"></a>
+ Are you trying to render dozens (or hundreds or thousands) of time series on a graph? This can cause the browser to lag. Try using functions like `highestMax` (in Graphite) to reduce the number of returned series.
+ Sometimes series names can be very large. This causes larger response sizes. Try using `alias` to reduce the size of the returned series names.
+ Are you querying many time series or a long time range? Both of these conditions can cause Grafana or your data source to pull in a lot of data, which may slow the dashboard down. Try reducing one or both of these.
+ There could be high load on your network infrastructure. If the slowness isn’t consistent, this may be the problem.

## Dashboard refresh rate issues
<a name="v12-dash-refresh-rate-issues"></a>

By default, Grafana queries your data source every 30 seconds. However, setting a low refresh rate on your dashboards puts unnecessary stress on the backend. In many cases, querying this frequently isn’t necessary because the data source isn’t sending data often enough for there to be changes every 30 seconds.

We recommend the following:
+ Only enable auto-refreshing on dashboards, panels, or variables if necessary. Users can refresh their browser manually.
+ If you require auto-refreshing, then set the refresh rate to a longer time period that makes sense, such as once a minute, every 10 minutes, or every hour.
+ Check the time range of your dashboard. If your dashboard has a longer time range, such as a week, then you really don’t need automated refreshing and you should disable it.

## Handling or rendering null data is wrong or confusing
<a name="v12-dash-handling-or-rendering-null-data-is-wrong-or-confusing"></a>

Some applications publish data intermittently; for example, they only post a metric when an event occurs. By default, Grafana graphs connect lines between the data points, but this can be deceptive.

Graphs that have the **Connect null values** option set to **Always**, will connect lines where there are missing values.

One way to fix this is to use bars instead of lines and have the **No value** option (under **Standard options**) set to `0`. In this case, the missing data will show up as areas of the graph with no data.

# Searching Dashboards in Grafana version 12
<a name="v12-search"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 12.x**.  
For Grafana workspaces that support Grafana version 10.x, see [Working in Grafana version 10](using-grafana-v10.md).  
For Grafana workspaces that support Grafana version 9.x, see [Working in Grafana version 9](using-grafana-v9.md).  
For Grafana workspaces that support Grafana version 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

You can search for dashboards by dashboard name and by panel title. When you search for dashboards, the system returns all dashboards available within the Grafana instance, even if you do not have permission to view the contents of the dashboard.

## Search dashboards using dashboard name
<a name="v12-search-by-name"></a>

Enter any part of the dashboard name in the search bar. The search returns results for any partial string match in real-time, as you type.

Dashboard search is:
+ Real-time
+ *Not* case sensitive
+ Functional across stored and file based dashboards.

**Tip**  
You can use your keyboard arrow keys to navigate the results and press `Enter` to open the selected dashboard.

## Search dashboards using panel title
<a name="v12-search-by-title"></a>

You can search for a dashboard by the title of a panel that appears in a dashboard. If a panel’s title matches your search query, the dashboard appears in the search results.

## Filter dashboard search results by tags
<a name="v12-search-by-tag"></a>

Tags are a great way to organize your dashboards, especially as the number of dashboards grow. You can add and manage tags in dashboard **Settings**.

When you select multiple tags, Grafana shows dashboards that include all selected tags.

To filter dashboard search result by a tag, complete one of the following steps:
+ To filter dashboard search results by tag, choose a tag that appears in the right column of the search results.

  You can continue filtering by choosing additional tags.
+ To see a list of all available tags, click the **Filter by tags** dropdown menu and select a tag.

  All tags will be shown, and when you select a tag, the dashboard search will be instantly filtered.

**Tip**  
When using only a keyboard, press the `tab` key and navigate to the **Filter by tag** dropdown menu, press the down arrow key to activate the menu and locate a tag, and press `Enter` to select the tag.

## Command palette
<a name="v12-search-palette"></a>

You can use the command palette to do the following:
+ Search for and open dashboards and folders.
+ Create dashboards and alert rules.
+ Locate pages within Grafana.
+ Change the theme to dark or light.

To open the command palette, enter `ctrl+k` (`cmd+k` in MacOS). You can also select the search input in the Grafana navigation bar.

**Note**  
To go to the previous step, press `backspace` with the command palette empty.