

# Working in Grafana version 9
<a name="using-grafana-v9"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

When you create your Grafana workspace, you have the option of which version of Grafana to use. The following topics describe using a Grafana workspace that uses version 9 of Grafana.

**Topics**
+ [Dashboards in Grafana version 9](v9-dashboards.md)
+ [Panels and visualizations in Grafana version 9](v9-panels.md)
+ [Explore in Grafana version 9](v9-explore.md)
+ [Alerts in Grafana version 9](v9-alerts.md)

# Dashboards in Grafana version 9
<a name="v9-dashboards"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

A dashboard is a set of one or more [panels](v9-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).

Dashboard snapshots are static. Queries and expressions cannot be re-run 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](v9-dash-using-dashboards.md)
+ [Building dashboards](v9-dash-building-dashboards.md)
+ [Managing dashboards](v9-dash-managing-dashboards.md)
+ [Sharing dashboards and panels](v9-dash-sharing.md)
+ [Managing playlists](v9-dash-managing-playlists.md)
+ [Adding and managing dashboard variables](v9-dash-variables.md)
+ [Assessing dashboard usage](v9-dash-assess-dashboard-usage.md)
+ [Searching Dashboards in Grafana version 9](v9-search.md)

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

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 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="v9-dash-features"></a>

You can use dashboards to customize the presentation of your data in the following ways.


|  Feature  |  Description  | 
| --- | --- | 
| **1. Home** | Click the Grafana home icon to be redirected to the home page configured in the Grafana instance. | 
| **2. Title** | When you click the dashboard title, you can search for dashboard 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. Dashboard settings** | Use this option to change dashboard name, folder, and tags and manage variables and annotation queries. For more information about dashboard settings, see [Modifying dashboard settings](v9-dash-modify-settings.md). | 
| **6. Time picker dropdown** |  Click to select relative time range options and set custom absolute time ranges. [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/grafana/latest/userguide/v9-dash-using-dashboards.html)  | 
| **7. Zooming out time range**  | Click to zoom out the time range. For more information about how to use time range controls, see [Setting dashboard time range](#v9-dash-setting-dashboard-time-range).  | 
| **8. Refreshing dashboard** | Click to immediately trigger queries and refresh dashboard data. | 
| **9. Refreshing dashboard time interval** | Click to select a dashboard auto refresh time interval. | 
| **10. View mode**  | Click to display the dashboard on a large screen such as a TV or a kiosk. View mode hides irrelevant information such as navigation menus.  | 
| **11. Dashboard panel** |  The primary building block of a dashboard is the panel. To add a new panel, dashboard row, or library panel, click **Add panel**. [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/grafana/latest/userguide/v9-dash-using-dashboards.html)  | 
| **12. Graph legend** | Change series colors, y-axis, and series visibility directly from the legend. | 
| **13. Dashboard search** | Click **Search** to search for dashboards by name or panel title. | 
| **14. 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/v9-dash-using-dashboards.html)  | 

## Keyboard shortcuts
<a name="v9-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="v9-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 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 `now+n` for future timestamps and `now-1n/n` for *start of n until end of n* timestamps. 

**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). 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**.

*Other time range features*

1. To zoom out, click **Cmd\$1Z** or **Ctrl\$1Z**. Click the icon to view a larger time range in the dashboard or panel visualization.

1. To use the zoom in feature, click and drag to select the time range in the visualization that you want to view.

**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](#v9-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="v9-dash-building-dashboards"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 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. 

**Topics**
+ [Creating dashboards](v9-dash-creating.md)
+ [Add or edit panels](v9-dash-edit-panels.md)
+ [Modifying dashboard settings](v9-dash-modify-settings.md)
+ [Dashboard URL variables](v9-dash-dashboard-url-variables.md)
+ [Adding a library panel to your dashboard](v9-dash-manage-library-panels.md)
+ [Managing dashboard version history](v9-dash-manage-version-history.md)
+ [Managing dashboard links](v9-dash-manage-dashboard-links.md)
+ [Dashboard JSON model](v9-dash-dashboard-json-model.md)

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

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 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.

 To create a dashboard:

1. Sign into Grafana, hover your cursor over **Dashboard**, and click **\$1 New Dashboard**.

1. Click **Add a new panel**.

1. In the first line of the **Query** tab, click the dropdown list and select a data source.

1. Write or construct a query in the query language of your data source.

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](v9-panels-viz.md).

1. Adjust panel settings in the following ways.
   + [Configure value mappings](v9-panels-configure-value-mappings.md)
   + [Visualization-specific options](v9-panels-viz.md)
   + [Override field values](v9-panels-configure-overrides.md)
   + [Configure thresholds](v9-panels-configure-thresholds.md)
   + [Configure standard options](v9-panels-configure-standard-options.md)
**Note**  
Most visualizations need some adjustment before they properly display the information you need.

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.

**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.

1. On the dashboard home page, click **Add panel**.

1. On the **Add a panel** dialog box, click **Add a new row**.

1. Hover over the row title and click the cog icon.

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. 

**To move a panel**

1. Open the dashboard.

1. Click 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, click and drag the lower-right corner of the panel. You can size a dashboard panel to suits your needs.

# Add or edit panels
<a name="v9-dash-edit-panels"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

After you have created a dashboard, you can add, edit, or remove panels at any time.
+ **View dashboard**: To view a dashboard, from the **Home** menu, select **Dashboards**, then choose the dashboard you want to view. You might have to expand the folder that contains the dashboard.
+ **Add panel**: To add a panel to a dashboard, choose the **Add panel** icon in the menu bar near the top of the page.
+ **Edit panel**To edit an existing panel on a dashboard, choose the menu icon that appears when you hover over the panel, and then choose **Edit**.
+ **Remove panel**To remove an existing panel on a dashboard, choose the menu icon that appears when you hover over the panel, and then choose **Remove**.

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

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 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 specifies 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.
   + 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.
   + The time zone configured for the viewing user browser, the *local browser time*, 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** customizes the options displayed for relative time and the auto-refresh options Entries are comma separated and accept any valid time unit.
+ **Now delay** overrides 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** removes the Grafana time picker display.

**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 n 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.

**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](v9-dash-variables.md).

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, the 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. 

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

1.  Enter title and 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**  
Tags are useful creating a dynamic dropdown of dashboards that all have a specific tag. 

1.  To add a 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 metadata of its dashboard. Dashboard metadata includes dashboard properties, metadata from panels, template variables, panel queries, and so on. 

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

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

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

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 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](v9-dash-manage-dashboard-links.md) and [Templates and variables](v9-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](v9-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]().

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.

# Adding a library panel to your dashboard
<a name="v9-dash-manage-library-panels"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 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.

1. Open a panel in edit mode.

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

1. To open the **Create** dialog box, click the **Library panels** option, and then click **Create library panel**.

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

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

1. To save your changes, click **Create library panel**.

1. To save the dashboard, click **Save**.

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.

**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.

1. Hover over the **Dashboards** option on the left menu, then select **New dashboard** from the dropdown options. The **Add panel **dialog box will open.

1. Click the **Add a panel** from the panel library option. 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.

1. Hover over **Dashboard** on the left menu, and then click **Library panels**.

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

1. Select the panel that you want to unlink.

1. Click the title of the panel and then click **Edit**. The panel will open in edit mode.

1. Click the **Unlink** option on the top right corner of the page.

**Viewing a list of library panels**

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

1. Hover over the **Dashboard** option on the left menu, then click **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.

1. Hover over **Dashboard** on the left menu, and select **Library panels**.

1. Select the panel that you want to delete.

1. Click the delete icon next to the library name.

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

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 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 never lost. A list of these versions is available by entering the dashboard settings and then selecting **Versions** in the left side menu.

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.

Upon clicking the button, you’ll be brought to the 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 as well by clicking the **View JSON Diff** button at the bottom.

If you want to restore to the version you are diffing against, you can do so by clicking the **Restore to version <x>** button in the top right.

**Restoring to a previously saved dashboard version**

If you need to restore to a previously saved dashboard version, you can either click the **Restore** button on the right of a row in the dashboard version list, or click the **Restore to version <x>** button appearing in the diff view. Clicking the button will bring up the following pop-up prompting 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 is done simply to ensure your previous dashboard versions are not affected by the change.

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

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 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 time range using the 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](https://github.com/grafana/grafana/issues/new?title=Dashboard%3A%20HTTP%20Requests).

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.

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

1. Click **Links** and then click **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 lots of dashboards, then you probably want to select this option and add an optional title to the dropdown. Otherwise, Grafana displays the dashboard links side by side across the top of your dashboard.
   + **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](v9-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.

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

1. Click **Links** and then click **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. For more information, see this [Github example](https://github.com/grafana/grafana/issues/new?title=Dashboard%3A%20HTTP%20Requests).
   + **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` 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.
   + **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. Click **Add**.

**Updating a dashboard link**

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

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

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

**Duplicating a dashboard link**

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

**Deleting a dashboard link**

To delete an existing dashboard link, click the trash icon next to the duplicate icon 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, click the icon on the top left corner of a panel.
+ **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 that you want to add a link to and then press `e`. Or click the dropdown arrow next to the panel title and then click **Edit**.

  1. On the **Panel** tab, scroll down to the **Links** section. 

  1. Expand **Links** and then click **Add link**.

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

  1. Enter the **URL** you want to link to. You can even add one of the template variables defined in the dashboard. Press `Ctrl+Space` or `Cmd+Space` and click in the URL field to see the 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. On the **Panel** tab, find the link you want to make changes to.

  1. Click the **Edit** (pencil) icon to open the Edit link window.

  1. Make any necessary changes.

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

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

  1. On the **Panel** tab, find the link that you want to make changes to.

  1. Click the **X** icon next to the link you want to delete.

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

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

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 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, click the **Dashboard settings** (gear) icon.

1. Click **JSON Model**.

**JSON fields**

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": [],
  "style": "dark",
  "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** | if 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](#v9-dash-dashboard-json-model) for details | 
| **templating** | templating metadata, see [templating section](#v9-dash-dashboard-json-model) for details | 
| **annotations** | annotations metadata, see [annotations](v9-panels-annotate-visualizations.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 said schema | 
| **version** | version of the dashboard (integer), incremented each time the dashboard is updated | 
| **panels** | panels array (see below for detail) | 

**Panels**

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–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 same unit as `w`.
+ `y`: The y position, in 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"
      }
    ]
  }
```

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

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

A dashboard is a set of one or more [panels](v9-panels.md) that visually presents your data in one or more rows.

For more information about creating dashboards, see [Add and organize panels]().

## Creating dashboard folders
<a name="v9-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.

**Prerequisites**

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

**To create a dashboard folder**

1. Sign in to Grafana and on the side menu, click **Dashboards > New folder**

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.

## Managing dashboards and folders
<a name="v9-dash-manage-dashboard-folder"></a>

On the **Manage dashboards and folders** page, you can:
+ Create a folder
+ Create a dashboard
+ Move dashboards into folders
+ Delete multiple dashboards
+ Navigate to a folder page where you can assign folder and dashboard permissions

**Dashboard folder page**

You can complete the following tasks on the **Dashboard Folder** page:
+ Move or delete dashboards in a folder.
+ Rename a folder (available under the **Settings** tab).
+ Assign permissions to folders (which are inherited by the dashboards in the folder).

To navigate to the dashboard folder page, click the cog appears when you hover over a folder in the dashboard search result list or the **Manage dashboards and folders** page.

**Dashboard permissions**

You can assign permissions to a folder. Any permissions you assign are inherited by the dashboards in the folder. An Access Control List (ACL) is used where **Organization Role**, **Team**, and a **User **can be assigned permissions.

See [permissions](Grafana-permissions.md) for more information.

## Exporting and importing dashboards
<a name="v9-dash-export-import-dashboards"></a>

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

**Exporting a dashboard**

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.

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

1. Open the dashboard that you want to export.

1. Select the share icon.

1. Choose **Export**.

1. Choose **Save to file.**

**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.

**Importing a dashboard**

1. Choose **Dashboards** in the side menu.

1. Choose **New**, then select **Import** from the dropdown menu.

1. Perform one of the following steps.
   + Upload a dashboard JSON file.
   + Paste a [Grafana.com](https://grafana.com/) dashboard URL.
   + Paste dashboard JSON text directly into the text area.

   The import process enables you to change the name of the dashboard, pick the data source you want the dashboard to use, and specify any metric prefixes (if the dashboard uses any).

## Troubleshooting dashboards
<a name="v9-dash-troubleshooting"></a>

This section provides information to help you solve common dashboard problems. 

**Dashboard is slow**

If your dashboard is slow, consider the following:
+ 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 returned series.
+ Sometimes the 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 for a long range of time? Both of these conditions can cause Grafana or your data source to pull in a lot of data, which can slow it down.
+ It could be high load on your network infrastructure. If the slowness isn’t consistent, this might be the problem.

**Dashboard refresh rate issues**

By default, Grafana queries your data source every 30 seconds. 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 isn’t being sent to the system such that changes would be seen.

If you have this issue, the following solutions are recommended.
+ Do not enable auto-refreshing on dashboards, panels, or variables unless you need it. Users can refresh their browser manually, or you can set the refresh rate for a time period that makes sense (such as very ten minutes or every hour).
+ If it is required, then set the refresh rate to once a minute. Users can always refresh the dashboard manually.
+ If your dashboard has a longer time period (such as one week), then automated refreshing might not be necessary.

**Handling or rendering null data is wrong or confusing**

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.

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

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 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.

The same permission is also required to view embedded links unless you have anonymous access permission enabled for your Grafana instance.

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="v9-dash-share-dashboard"></a>

You can share a dashboard as a direct link or as a snapshot. You can also export a dashboard.

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

1. Navigate to the home page of your Grafana instance.

1. Click on the share icon in the top navigation.

   The share dialog box will open and show 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.

1. Click **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.

1. Click **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 [Export and import dashboards](v9-dash-managing-dashboards.md#v9-dash-export-import-dashboards).

## Sharing a panel
<a name="v9-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.

1. Click a panel title to open the panel menu.

1. Click **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. 

1. Click **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.

1. You also optionally click **Direct link rendered image** to share an image of the panel.

**Querying string parameters for server-side rendered images**
+ **width**: Width in pixels. The default is 800.
+ **height**: Height in pixels. The default is 400.
+ **tz**: Timezone in the format `UTC%2BHH%3AMM` where HH and MM are offset in hours and minutes after UTC.
+ **timeout**: Number of seconds. The timeout can be increased if the query for the panel needs more than the default 30 seconds.
+ **scale**: Numeric value to configure device scale factor. Default is 1. Use a higher value to produce more detailed images (higher DPI). Supported in Grafana v7.0\$1.

**Publishing a snapshot**

A panel snapshot shares 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.

1. In the **Share Panel** dialog box, click **Snapshot** to open the tab.

1. Click **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.

1. Click **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 **General** folder is selected.

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

1. Click **Save** to save the dashboard.

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

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 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="v9-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.

**Accessing a playlist**

1. Hover your cursor over Grafana’s side menu.

1. Click **Playlists**.

   You will see a 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.

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.

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

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.


| Mode | Description | 
| --- | --- | 
| Normal mode |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/grafana/latest/userguide/v9-dash-managing-playlists.html)  | 
| TV mode |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/grafana/latest/userguide/v9-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/v9-dash-managing-playlists.html)  | 
| Kiosk mode |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/grafana/latest/userguide/v9-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/v9-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="v9-dash-create-playlist"></a>

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

1. Click **New playlist** on the playlist page.

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

1. Enter a time interval in the **Interval** text box.
**Note**  
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 dashboard you have added using the up and down arrow icon.
   + Remove a dashboard from the playlist by clicking the **X **icon beside dashboard.

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

## Saving a playlist
<a name="v9-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.

1. To access the playlist feature, hover your cursor over Grafana’s side menu.

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

1. Click on 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. Click **Save** to save your changes.

## Editing or deleting a playlist
<a name="v9-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.

**Editing a playlist**

1. Click **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. Click **Save** to save your changes.

**Deleting a playlist**

1. Click **Playlists**.

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

**Rearranging dashboard order**

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

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

**Removing a dashboard**

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

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

## Sharing a playlist in view mode
<a name="v9-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.

1. From the **Dashboards** submenu, click **Playlists**.

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

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

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

1. Paste the URL to your destination.

# Adding and managing dashboard variables
<a name="v9-dash-variables"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 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).

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

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

The following table lists the types of variables shipped with Grafana.


| Variable type | Description | 
| --- | --- | 
|  Query  |  Query-generated list of values such as metric names, server names, sensor IDs, data centers, and so on. Add a query variable.  | 
|  Custom  |  Define the variable options manually using a comma-separated list. Add a custom variable.  | 
|  Text box  |  Display a free text input field with an optional default value. Add a text box variable.  | 
|  Constant  |  Define a hidden constant. Add a constant variable.  | 
|  Data source  |  Quickly change the data source for an entire dashboard. Add a data source variable.  | 
|  Interval  |  Interval variables represent time spans. Add an interval variable.  | 
|  Ad hoc filters  |  Key-value filters that are automatically added to all metric queries for a data source (Prometheus, Loki, InfluxDB, and Elasticsearch only). Add ad hoc filters.  | 
|  Global variables  |  Built-in variables that can be used in expressions in the query editor. Refer to Global variables.  | 
|  Chained variables  |  Variable queries can contain other variables. Refer to Chained variables.  | 

## Entering General options
<a name="v9-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**.

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="v9-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.
   + 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](#v9-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](#v9-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="v9-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](#v9-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](#v9-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="v9-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="v9-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](https://grafana.com/docs/grafana/latest/dashboards/variables/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="v9-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.

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](#v9-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="v9-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="v9-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.

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="v9-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="v9-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 would, in this case, be interpolated as `{host1,host2,host3}` if the current variable value was *host1*, *host2*, and *host3*.

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

InfluxDB and Prometheus use regex expressions, so the same variable would be interpolated as `(host1|host2|host3)`. Every value would also be regex escaped. If 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 would be formatted as `("host1" OR "host2" OR "host3")`. In this case, every value must be 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 variable format](https://grafana.com/docs/grafana/latest/dashboards/variables/variable-syntax/#raw).

### Include All option
<a name="v9-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="v9-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="v9-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 -> `>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**

Currently 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**

Currently 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.

## Chained variables
<a name="v9-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. This section explains how chained variables work and provides links to example dashboards that use chained variables.

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="v9-dash-variable-add-manage"></a>

The variables page lets you [add](https://grafana.com/docs/grafana/latest/dashboards/variables/add-template-variables/) variables and manage existing variables. It also allows you to [inspect](https://grafana.com/docs/grafana/latest/dashboards/variables/inspect-variable/) 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="v9-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**

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
```

Regex:

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

Result:

```
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.

## 
<a name="v9-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="v9-dash-variable-syntax"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 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*.
+ `[[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="v9-dash-assess-dashboard-usage"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

Usage insights enable you to have a better understanding of how your Grafana instance is used.

The usage insights feature collects a number of aggregated data and stores them in the database.
+ Dashboard views (aggregated and per user)
+ Data source errors
+ Data source queries

The aggregated data provides you access to several features, including dashboard and data source insights, presence indicator, sorting dashboards by using insights data, and visualizing usage insight data in a dashboard.

This feature also generates detailed logs that can be exported to Loki.

## Dashboard and data source insights
<a name="v9-dash-insights"></a>

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

**Dashboard insights**

To see dashboard usage information, click **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. Go to the **Data source** list view.

1. Click on **Data source**.

1. Click the **Insights** tab.

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

When you sign 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="v9-dash-sort-dashboards"></a>

In the search view, you can use insights data to help you find most-used, broken, and unused dashboards.
+ Errors total
+ Errors 30 days
+ Views total
+ Views 30 days

# Searching Dashboards in Grafana version 9
<a name="v9-search"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 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="v9-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="v9-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="v9-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.

# Panels and visualizations in Grafana version 9
<a name="v9-panels"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

 The *panel* is the basic visualization building block in Grafana. Each panel has a query editor specific to the data source selected in the panel. The query editor allows you to build a query that returns the data you want to visualize. 

 There are a wide variety of styling and formatting options for each panel. Panels can be dragged, dropped, and resized to rearrange them on the dashboard. 

 Before you add a panel, ensure that you have configured a data source. 

Additional panel types might be available by installing additional [plugins](grafana-plugins.md) to your workspace.
+  For details about using specific data sources, see [Connect to data sources](AMG-data-sources.md). 

**Topics**
+ [Panel editor overview](v9-panels-editor-overview.md)
+ [Configure panel options](v9-panels-configure-panel-options.md)
+ [Configure standard options](v9-panels-configure-standard-options.md)
+ [Query and transform data](v9-panels-query-xform.md)
+ [Configure thresholds](v9-panels-configure-thresholds.md)
+ [Configure data links](v9-panels-configure-data-links.md)
+ [Configure field overrides](v9-panels-configure-overrides.md)
+ [Configure value mappings](v9-panels-configure-value-mappings.md)
+ [Configure a legend](v9-panels-configure-legend.md)
+ [Calculation types](v9-panels-calculation-types.md)
+ [Annotating visualizations](v9-panels-annotate-visualizations.md)
+ [The panel inspect view](v9-panels-panel-inspector.md)
+ [Visualizations available in Grafana version 9](v9-panels-viz.md)

# Panel editor overview
<a name="v9-panels-editor-overview"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

 This section describes the areas of the Grafana panel editor. 
+  Panel header: The header section lists the dashboard in which the panel appears and the following controls: 
  +  **Dashboard settings (gear) icon:** Click to access the dashboard settings. 
  +  **Discard:** Discards changes you have made to the panel since you last saved the dashboard. 
  +  **Save:** Saves changes you made to the panel. 
  +  **Apply:** Applies changes you made and closes the panel editor, returning you to the dashboard. You will have to save the dashboard to persist the applied changes. 
+  Visualization preview: The visualization preview section contains the following options: 
  +  **Table view:** Convert any visualization to a table so you can see the data. Table views are helpful for troubleshooting. This view only contains the raw data. It does not include transformations you might have applied to the data or the formatting options available in the [Table](v9-panels-table.md) visualization. 
  +  **Fill:** The visualization preview fills the available space. If you change the width of the side pane or height of the bottom pane the visualization changes to fill the available space. 
  +  **Actual:** The visualization preview will have the exact size as the size on the dashboard. If not enough space is available, the visualization will scale down preserving the aspect ratio. 
  +  **Time range controls:** **Default** is either the browser local timezone or the timezone selected at a higher level. 
+  Data section: The data section contains tabs where you enter queries, transform your data, and create alert rules (if applicable). 
  +  **Query tab:** Select your data source and enter queries here. 
  +  **Transform tab:** Apply data transformations. 
  +  **Alert tab:** Write alert rules. 
+  Panel display options: The display options section contains tabs where you configure almost every aspect of your data visualization. 

## Open the panel inspect drawer
<a name="v9-panels-editor-open-panel"></a>

 The inspect drawer helps you understand and troubleshoot your panels. You can view the raw data for any panel, export that data to a comma-separated values (CSV) file, view query requests, and export panel and data JSON. 

 **Note:** Not all panel types include all tabs. For example, dashboard list panels do not have raw data to inspect, so they do not display the Stats, Data, or Query tabs. 

 The panel inspector consists of the following options: 
+  The panel inspect drawer displays opens a drawer on the right side. Click the arrow in the upper right corner to expand or reduce the drawer pane. 
+  **Data tab -** Shows the raw data returned by the query with transformations applied. Field options such as overrides and value mappings are not applied by default. 
+  **Stats tab -** Shows how long your query takes and how much it returns. 
+  **JSON tab -** Allows you to view and copy the panel JSON, panel data JSON, and data frame structure JSON. This is useful if you are provisioning or administering Grafana. 
+  **Query tab -** Shows you the requests to the server sent when Grafana queries the data source. 
+  **Error tab -** Shows the error. Only visible when query returns error. 

# Configure panel options
<a name="v9-panels-configure-panel-options"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

 A Grafana panel is the user interface you use to define a data source query, and transform and format data that appears in visualizations. 

 A panel editor includes a query builder and a series of options that you can use to transform data and add information to your panels. 

 This topic describes how to: 
+  Open a panel for editing 
+  Add a panel title and description 
+  View a panel JSON model 
+  Add repeating rows and panels 

## Edit a panel
<a name="v9-panels-edit-a-panel"></a>

 After you add a panel to a dashboard, you can open it at any time to change change or update queries, add data transformation, and change visualization settings. 

1.  Open the dashboard that contains the panel you want to edit. 

1.  Hover over any part of the panel to display the actions menu on the top right corner. 

1.  Click the menu and select **Edit**. 

    To use a keyboard shortcut to open the panel, hover over the panel and press **e**. 

    The panel opens in edit mode. 

## Add a title and description to a panel
<a name="v9-panels-add-title-description"></a>

 Add a title and description to a panel to share with users any important information about the visualization. For example, use the description to document the purpose of the visualization. 

1.  Edit a panel. 

1.  In the panel display options pane, locate the **Panel options** section. 

1.  Enter a **Title**. 

    Text entered in this field appears at the top of your panel in the panel editor and in the dashboard. 

1.  Write a description of the panel and the data you are displaying. 

    Text entered in this field appears in a tooltip in the upper-left corner of the panel. 

    You can use [variables you have defined](v9-dash-variables.md) in the **Title** and **Description** field, but not [global variables](v9-dash-variable-add.md#v9-dash-variable-add-global).

    

## View a panel JSON model
<a name="v9-panels-json-model"></a>

 Explore and export panel, panel data, and data frame JSON models. 

1.  Open the dashboard that contains the panel. 

1.  Hover over any part of the panel to display the actions menu on the top right corner. 

1.  Click the menu and select **Inspect > Panel JSON**. 

1.  In the **Select source** field, select one of the following options: 
   +  **Panel JSON:** Displays a JSON object representing the panel. 
   +  **Panel data:** Displays a JSON object representing the data that was passed to the panel. 
   +  **DataFrame structure:** Displays the raw result set with transformations, field configurations, and override configurations applied. 

1.  To explore the JSON, click **>** to expand or collapse portions of the JSON model. 

## Configure repeating panels
<a name="v9-panels-configure-repeating-panels"></a>

 You can configure Grafana to dynamically add panels or rows to a dashboard. A dynamic panel is a panel that the system creates based on the value of a variable. Variables dynamically change your queries across all panels in a dashboard.

**Note**  
Repeating panels require variables to have one or more items selected; you cannot repeat a panel zero times to hide it. 

 **Before you begin:** 
+  Ensure that the query includes a multi-value variable. 

 **To configure repeating panels:** 

1. Edit the panel you want to repeat.

1.  On the display options pane, click **Panel options > Repeat options**. 

1.  Select a **direction**. 
   +  Choose **horizontal** to arrange panels side-by-side. Grafana adjusts the width of a repeated panel. Currently, you cannot mix other panels on a row with a repeated panel. 
   +  Choose **vertical** to arrange panels in a column. The width of repeated panels is the same as the original, repeated panel. 

1.  To propagate changes to all panels, reload the dashboard. 

# Configure standard options
<a name="v9-panels-configure-standard-options"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

 The data model used in Grafana is a columnar-oriented table structure that unifies both time series and table query results. Each column within this structure is called a *field*. A field can represent a single time series or table column. 

 Field options allow you to change how the data is displayed in your visualizations. Options and overrides that you apply do not change the data, they change how Grafana displays the data. When you change an option, it is applied to all fields, meaning all series or columns. For example, if you change the unit to percentage, then all fields with numeric values are displayed in percentages. 

 For a complete list of field formatting options, refer to [Standard options definitions](#v9-panels-standard-options-definitions).

**Note**  
 You can apply standard options to most built-in Grafana panels. Some older panels and community panels that have not updated to the new panel and data model will be missing either all or some of these field options. 

1.  Open a dashboard, click the panel title, and click **Edit**. 

1.  In the panel display options pane, locate the **Standard options** section. 

1.  Select the standard options you want to apply. 

1.  To preview your change, click outside of the field option box you are editing or press **Enter**. 

## Standard options definitions
<a name="v9-panels-standard-options-definitions"></a>

 This section explains all available standard options. 

 You can apply standard options to most built-in Grafana panels. Some older panels and community panels that have not updated to the new panel and data model will be missing either all or some of these field options. 

 Most field options will not affect the visualization until you click outside of the field option box you are editing or press Enter. 

**Note**  
 We are constantly working to add and expand options for all visualization, so all options might not be available for all visualizations. 

### Unit
<a name="v9-panels-standard-options-unit"></a>

 Lets you choose what unit a field should use. Click in the **Unit** field, then drill down until you find the unit you want. The unit you select is applied to all fields except time. 

#### Custom units
<a name="v9-panels-standard-options-custom-units"></a>

 You can use the unit dropdown to also specify custom units, custom prefix or suffix and date time formats. 

 To select a custom unit enter the unit and select the last **Custom: xxx** option in the dropdown. 
+  **suffix:<suffix>** for custom unit that should go after value. 
+  **prefix:<prefix>** for custom unit that should go before value. 
+  **time:<format>** For custom date time formats type for example **time:YYYY-MM-DD**. See [formats](https://momentjs.com/docs/#/displaying/) for the format syntax and options.
+  **si:<base scale><unit characters>** for custom SI units. For example: **si: mF**. This one is a bit more advanced as you can specify both a unit and the source data scale. So if your source data is represented as milli (thousands of) something prefix the unit with that SI scale character. 
+  **count:<unit>** for a custom count unit. 
+  **currency:<unit>** for custom a currency unit. 

 You can also paste a native emoji in the unit picker and pick it as a custom unit. 

#### String units
<a name="v9-panels-standard-options-string-units"></a>

 Grafana can sometimes be too aggressive in parsing strings and displaying them as numbers. To configure Grafana to show the original string value, create a field override and add a unit property with the **String** unit. 

### Min
<a name="v9-panels-standard-options-min"></a>

 Lets you set the minimum value used in percentage threshold calculations. Leave blank for auto calculation based on all series and fields. 

### Max
<a name="v9-panels-standard-options-max"></a>

 Lets you set the maximum value used in percentage threshold calculations. Leave blank for auto calculation based on all series and fields. 

### Decimals
<a name="v9-panels-standard-options-decimals"></a>

 Specify the number of decimals Grafana includes in the rendered value. If you leave this field blank, Grafana automatically truncates the number of decimals based on the value. For example 1.1234 will display as 1.12 and 100.456 will display as 100. 

 To display all decimals, set the unit to **String**. 

### Display name
<a name="v9-panels-standard-options-displayname"></a>

 Lets you set the display title of all fields. You can use [variables](v9-dash-variables.md).

 When multiple stats, fields, or series are shown, this field controls the title in each stat. You can use expressions like **\$1\$1\$1\$1field.name\$1** to use only the series name or the field name in title. 

 Given a field with a name of Temp, and labels of \$1"Loc"="PBI", "Sensor"="3"\$1 


|  Expression syntax  |  Example  |  Renders to  |  Explanation  | 
| --- | --- | --- | --- | 
|  \$1\$1\$1\$1field.displayName\$1  |  Same as syntax  |  Temp \$1Loc="PBI", Sensor="3"\$1  |  Displays the field name, and labels in \$1\$1 if they are present. If there is only one label key in the response, then for the label portion, Grafana displays the value of the label without the enclosing braces.  | 
|  \$1\$1\$1\$1field.name\$1  |  Same as syntax  |  Temp  |  Displays the name of the field (without labels).  | 
|  \$1\$1\$1\$1field.labels\$1  |  Same as syntax  |  Loc="PBI", Sensor="3"  |  Displays the labels without the name.  | 
|  \$1\$1\$1\$1field.labels.X\$1  |  \$1\$1\$1\$1field.labels.Loc\$1  |  PBI  |  Displays the value of the specified label key.  | 
|  \$1\$1\$1\$1field.labels.\$1\$1values\$1  |  Same as Syntax  |  PBI, 3  |  Displays the values of the labels separated by a comma (without label keys).  | 

 If the value is an empty string after rendering the expression for a particular field, then the default display method is used. 

### Color scheme
<a name="v9-panels-standard-options-color-scheme"></a>

 The color options and their effect on the visualization depends on the visualization you are working with. Some visualizations have different color options. 

 You can specify a single color, or select a continuous (gradient) color schemes, based on a value. Continuous color interpolates a color using the percentage of a value relative to min and max. 

 Select one of the following palettes: 


|  Color mode  |  Description  | 
| --- | --- | 
|  Single color  |  Specify a single color, useful in an override rule  | 
|  From thresholds  |  Informs Grafana to take the color from the matching threshold  | 
|  Classic palette  |  Grafana will assign color by looking up a color in a palette by series index. Useful for Graphs and pie charts and other categorical data visualizations  | 
|  Green-Yellow-Red (by value)  |  Continuous color scheme  | 
|  Blue-Yellow-Red (by value)  |  Continuous color scheme  | 
|  Blues (by value)  |  Continuous color scheme (panel background to blue)  | 
|  Reds (by value)  |  Continuous color scheme (panel background color to blue)  | 
|  Greens (by value)  |  Continuous color scheme (panel background color to blue)  | 
|  Purple (by value)  |  Continuous color scheme (panel background color to blue)  | 

### No value
<a name="v9-panels-standard-options-no-value"></a>

 Enter what Grafana should display if the field value is empty or null. The default value is a hyphen (-). 

# Query and transform data
<a name="v9-panels-query-xform"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

Grafana supports many types of [data sources](AMG-data-sources.md). Data source *queries* return data that Grafana can *transform* and visualize. Each data source uses its own query language, and data source plugins each implement a query-building user interface called a query editor.

## About queries
<a name="v9-panels-query-xform-about"></a>

Grafana panels communicate with data sources via queries, which retrieve data for the visualization. A query is a question written in the query language used by the data source.

You can configure query frequency and data collection limits in the panel’s data source options. Grafana supports up to 26 queries per panel.

You can find more information about each data source’s query language in the [Data sources](AMG-data-sources.md) section.

**Query editors**

Each data source’s *query editor* provides a customized user interface that helps you write queries that take advantage of its unique capabilities.

Because of the differences between query languages, each data source query editor looks and functions differently. Depending on your data source, the query editor might provide auto-completion features, metric names, variable suggestions, or a visual query-building interface.

For details on a specific data source’s unique query editor features, refer to its documentation:
+ For data sources included with Grafana, see [Built-in data sources](AMG-data-sources-builtin.md).
+ For data sources included with Grafana Enterprise editiion, see [Connect to Enterprise data sources](AMG-data-sources-enterprise.md).

**Query syntax**

Data sources use different query languages to request data. For details on a specific data source’s unique query language, refer to its documentation.

**PostgreSQL example:**

```
SELECT hostname FROM host WHERE region IN($region)
```

**PromQL example:**

```
query_result(max_over_time(<metric>[${__range_s}s]) != <state>)
```

**Special data sources**

Grafana also includes three special data sources: **Grafana**, **Mixed**, and **Dashboard**. For details, refer to Data sources

## Navigate the query tab
<a name="v9-panels-query-xform-navigate"></a>

A panel’s **Query** tab consists of the following elements:
+ **Data source selector** – Selects the data source to query.
+ **Query options:** – Sets maximum data retrieval parameters and query run time intervals.
+ **Query inspector button:** – Opens the query inspector panel, where you can view and optimize your query.
+ **Query editor list:** – Lists the queries you’ve written.
+ **Expressions:** – Uses the expression builder to create alert expressions. For more information about expressions, see [Write expression queries](v9-panels-query-xform-expressions.md).

## Add a query
<a name="v9-panels-query-xform-add"></a>

A query returns data that Grafana visualizes in dashboard panels. When you create a panel, Grafana automatically selects the default data source.

**To add a query**

1. Edit the panel to which you’re adding a query.

1. Choose the **Query** tab.

1. Choose the **Data source** dropdown menu and select a data source.

1. Choose **Query options** to configure the maximum number of data points you need. For more information about query options, see [Query options](#v9-panels-query-xform-options).

1. Write the query using the query editor.

1. Choose **Apply**.

Grafana queries the data source and visualizes the data.

## Manage queries
<a name="v9-panels-query-xform-manage"></a>

Grafana organizes queries in collapsible query rows. Each query row contains a query editor and is identified with a letter (A, B, C, and so on).

To manage your queries, you can copy queries, hide queries, remove a query, reorder queries, and toggle help for the query editor.

## Query options
<a name="v9-panels-query-xform-options"></a>

Choose **Query options** next to the data source selector to see settings for the selected data source. Changes you make here affect only queries made in this panel.

Grafana sets defaults that are shown in dark gray text. Changes are displayed in white text. To return a field to the default setting, delete the white text from the field.

Panel data source query options include:
+ **Max data points** – If the data source supports it, this sets the maximum number of data points for each series returned. If the query returns more data points than the max data points setting, then the data source reduces the number of points returned by aggregating them together by average, max, or another function.

  You can limit the number of points to improve query performance or smooth the visualized line. The default value is the width (or number of pixels) of the graph, because you can only visualize as many data points as the graph panel has room to display.
+ **Min interval** – Sets a minimum limit for the automatically calculated interval, which is typically the minimum scrape interval. If a data point is saved every 15 seconds, you don’t benefit from having an interval lower than that. You can also set this to a higher minimum than the scrape interval to retrieve queries that are more coarse-grained and well-functioning.
+ **Interval** – Sets a time span that you can use when aggregating or grouping data points by time.

  Grafana automatically calculates an appropriate interval that you can use as a variable in templated queries. The variable is measured in either seconds (`$__interval`) or milliseconds (`$__interval_ms`).

  Intervals are typically used in aggregation functions like sum or average. For example, this is a Prometheus query that uses the interval variable: `rate(http_requests_total[$__interval])`.

  This automatic interval is calculated based on the width of the graph. As the user zooms out on a visualization, the interval grows, resulting in a more coarse-grained aggregation. Likewise, if the user zooms in, the interval decreases, resulting in a more fine-grained aggregation.

  For more information, see [Global variables](v9-dash-variable-add.md#v9-dash-variable-add-global).
+ **Relative time** – Overrides the relative time range for individual panels, which causes them to be different than what is selected in the dashboard time picker in the top-right corner of the dashboard. You can use this to show metrics from different time periods or days on the same dashboard.
**Note**  
Panel time overrides have no effect when the dashboard’s time range is absolute.    
[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/grafana/latest/userguide/v9-panels-query-xform.html)
+ **Time shift** – Overrides the time range for individual panels by shifting its start and end relative to the time picker. For example, you can shift the time range for the panel to be two hours earlier than the dashboard time picker.
**Note**  
Panel time overrides have no effect when the dashboard's time range is absolute.    
[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/grafana/latest/userguide/v9-panels-query-xform.html)
+ **Cache timeout** – *(Visible only if available in the data source)* Overrides the default cache timeout if your time series store has a query cache. Specify this value as a numeric value in seconds.

# Write expression queries
<a name="v9-panels-query-xform-expressions"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

Server-side expressions enable you to manipulate data returned from queries with math and other operations. Expressions create new data and do not manipulate the data returned by data sources.

## About expressions
<a name="v9-panels-query-about"></a>

Server-side expressions allow you to manipulate data returned from queries with math and other operations. Expressions create new data and do not manipulate the data returned by data sources, aside from some minor data restructuring to make the data acceptable input for expressions.

**Using expressions**

Expressions are primarily used by [Grafana Alerting](v9-alerts.md). The processing is done server-side, so expressions can operate without a browser session. However, expressions can also be used with backend data sources and visualization.

**Note**  
Expressions do not work with legacy dashboard alerts.

Expressions are meant to augment data sources by enabling queries from different data sources to be combined or by providing operations unavailable in a data source.

**Note**  
When possible, you should do data processing inside the data source. Copying data from storage to the Grafana server for processing is inefficient, so expressions are targeted at lightweight data processing.

Expressions work with data source queries that return time series or number data. They also operate on [multiple-dimensional data](getting-started-grafanaui.md#time-series-dimensions). For example, a query that returns multiple series, where each series is identified by labels or tags.

An individual expression takes one or more queries or other expressions as input and adds data to the result. Each individual expression or query is represented by a variable that is a named identifier known as its RefID (e.g., the default letter `A` or `B`).

To reference the output of an individual expression or a data source query in another expression, this identifier is used as a variable.

**Types of expressions**

Expressions work with two types of data.
+ A collection of time series.
+ A collection of numbers, where each number is an item.

Each collection is returned from a single data source query or expression and represented by the RefID. Each collection is a set, where each item in the set is uniquely identified by its dimensions which are stored as [labels](getting-started-grafanaui.md#labels) or key-value pairs.

**Data source queries**

Server-side expressions only support data source queries for backend data sources. The data is generally assumed to be labeled time series data. In the future we intended to add an assertion of the query return type (number or time series) data so expressions can handle errors better.

Data source queries, when used with expressions, are run by the expression engine. When it does this, it restructures data to be either one time series or one number per data frame. So for example if using a data source that returns multiple series on one frame in the table view, you might notice it looks different when run with expressions.

Currently, the only non-time series format (number) is supported when using data frames are you have a table response that returns a data frame with no time, string columns, and one number column:


| Loc | Host | Avg\$1CPU | 
| --- | --- | --- | 
|  MIA  |  A  |  1  | 
|  NYC  |  B  |  2  | 

The example above will produce a number that works with expressions. The string columns become labels and the number column the corresponding value. For example `{"Loc": "MIA", "Host": "A"}` with a value of 1.

**Operations**

You can use the following operations in expressions: math, reduce, and resample.

**Math**

Math is for free-form math formulas on time series or number data. Math operations take numbers and time series as input and changes them to different numbers and time series.

Data from other queries or expressions are referenced with the RefID prefixed with a dollar sign, for example `$A`. If the variable has spaces in the name, then you can use a brace syntax like `${my variable}`.

Numeric constants can be in decimal (`2.24`), octal (with a leading zero like `072`), or hex (with a leading 0x like `0x2A`). Exponentials and signs are also supported (e.g., `-0.8e-2`).

**Operators**

The arithmetic (`+`, binary and unary `-`, `*`, `/`, `%`, exponent `**`), relational (`<`, `>`, `==`, `!=`, `>=`, `<=`), and logical (`&&`, `||`, and unary `!`) operators are supported.

How the operation behaves with data depends on if it is a number or time series data.

With binary operations, such as `$A + $B` or `$A || $B`, the operator is applied in the following ways depending on the type of data:
+ If both `$A` and `$B` are a number, then the operation is performed between the two numbers.
+ If one variable is a number, and the other variable is a time series, then the operation between the value of each point in the time series and the number is performed.
+ If both `$A` and `$B` are time series data, then the operation between each value in the two series is performed for each time stamp that exists in both `$A` and `$B`. The `Resample` operation can be used to line up time stamps.

Summary:
+ Number OP number = number
+ Number OP series = series
+ Series OP series = series

Because expressions work with multiple series or numbers represented by a single variable, binary operations also perform a union (join) between the two variables. This is done based on the identifying labels associated with each individual series or number.

So if you have numbers with labels like `{host=web01}` in `$A` and another number in `$B` with the same labels then the operation is performed between those two items within each variable, and the result will share the same labels. The rules for the behavior of this union are as follows:
+ An item with no labels will join to anything.
+ If both `$A` and `$B` each contain only one item (one series, or one number), they will join.
+ If labels are exact math they will join.
+ If labels are a subset of the other, for example an item in `$A` is labeled `{host=A,dc=MIA}` and an item in `$B` is labeled `{host=A}` they will join.
+ If within a variable such as `$A` there are different tag keys for each item, the join behavior is undefined.

The relational and logical operators return 0 for false 1 for true.

**Math Functions**

While most functions exist in the own expression operations, the math operation does have some functions that similar to math operators or symbols. When functions can take either numbers or series, than the same type as the argument will be returned. When it is a series, the operation of performed for the value of each point in the series.

*abs*

abs returns the absolute value of its argument which can be a number or a series. For example `abs(-1)` or `abs($A)`.

*is\$1inf*

is\$1inf takes a number or a series and returns `1` for `Inf` values (negative or positive) and `0` for other values. For example `is_inf($A)`.

**Note**  
If you need to specifically check for negative infinity for example, you can do a comparison like `$A == infn()`.

*is\$1nan*

is\$1nan takes a number or a series and returns `1` for `NaN` values and `0` for other values. For example `is_nan($A)`. This function exists because `NaN` is not equal to `NaN`.

*is\$1null*

is\$1null takes a number or a series and returns `1` for `null` values and `0` for other values. For example `is_null($A)`.

*is\$1number*

is\$1number takes a number or a series and returns `1` for all real number values and `0` for other values (which are `null`, `Inf+`, `Inf-`, and `NaN`). For example `is_number($A)`.

*log*

Log returns the natural logarithm of its argument which can be a number or a series. If the value is less than 0, `NaN` is returned. For example `log(-1)` or `log($A)`.

*inf, infn, nan, and null*

The inf, infn, nan, and null functions all return a single value of the name. They primarily exist for testing. Example: `null()`.

*round*

Round returns a rounded integer value. For example, `round(3.123)` or `round($A)`.

*ceil*

Ceil rounds the number up to the nearest integer value. For example, `ceil(3.123)` returns `4`.

*floor*

Floor rounds the number down to the nearest integer value. For example, `floor(3.123`) returns `3`.

**Reduce**

Reduce takes one or more time series returned from a query or an expression and turns each series into a single number. The labels of the time series are kept as labels on each outputted reduced number.

*Fields:*
+ **Function** – The reduction function to use
+ **Input** – The variable (refID (such as `A`)) to resample
+ **Mode** – Allows control behavior of reduction function when a series contains non-numerical values (null, NaN, \$1-Inf)

**Reduction Functions**

*Count*

Count returns the number of points in each series.

*Mean*

Mean returns the total of all values in each series divided by the number of points in that series. In `strict` mode if any values in the series are null or nan, or if the series is empty, NaN is returned.

*Min and Max*

Min and Max return the smallest or largest value in the series respectively. In `strict` mode if any values in the series are null or nan, or if the series is empty, NaN is returned.

*Sum*

Sum returns the total of all values in the series. If series is of zero length, the sum will be 0. In `strict` mode if there are any NaN or Null values in the series, NaN is returned.

*Last*

Last returns the last number in the series. If the series has no values then returns NaN.

**Reduction Modes**

*Strict*

In Strict mode the input series is processed as is. If any values in the series are non-numeric (null, NaN or \$1-Inf), NaN is returned.

*Drop Non-Numeric*

In this mode all non-numeric values (null, NaN or \$1-Inf) in the input series are filtered out before running the reduction function.

*Replace Non-Numeric*

In this mode all non-numeric values are replaced by a pre-defined value.

**Resample**

Resample changes the time stamps in each time series to have a consistent time interval. The main use case is so you can resample time series that do not share the same timestamps so math can be performed between them. This can be done by resample each of the two series, and then in a Math operation referencing the resampled variables.

*Fields:*
+ **Input** – The variable of time series data (refID (such as `A`)) to resample
+ **Resample** to – The duration of time to resample to, for example `10s.` Units can be `s` seconds, `m` for minutes, `h` for hours, `d` for days, `w` for weeks, and `y` for years.
+ **Downsample** – The reduction function to use when there are more than one data point per window sample. See the reduction operation for behavior details.
+ **Upsample** – The method to use to fill a window sample that has no data points.
  + **pad** fills with the last know value
  + **backfill** with next known value
  + **fillna** to fill empty sample windows with NaNs

## Write an expression
<a name="v9-panels-query-write"></a>

If your data source supports them, then Grafana displays the **Expression** button and shows any existing expressions in the query editor list.

**To write an expression**

1. Open the panel.

1. Below the query, choose **Expression**.

1. In the **Operation** field, select the type of expression you want to write.

1. Write the expression.

1. Choose **Apply**.

## Special cases
<a name="v9-panels-query-special"></a>

When any queried data source returns no series or numbers, the expression engine returns `NoData`. For example, if a request contains two data source queries that are merged by an expression, if `NoData` is returned by at least one of the data source queries, then the returned result for the entire query is `NoData`. For more information about how Grafana Alerting processes `NoData` results, see [Handling no data or error cases](v9-alerting-managerules-grafana.md#v9-alerting-rule-no-data-error).

# Share query results with another panel
<a name="v9-panels-query-share"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

Grafana let you use the query result from one panel for any other panel in the dashboard. Sharing query results across panels reduces the number of queries made to your data source, which can improve the performance of your dashboard.

The Dashboard data source lets you select a panel in your dashboard that contains the queries you want to share the results for. Instead of sending a separate query for each panel, Grafana sends one query and other panels use the query results to construct visualizations.

This strategy can drastically reduce the number of queries being made when you for example have several panels visualizing the same data.

**To share query results**

1. [Create a dashboard](v9-dash-creating.md).

1. Change the title to `Source panel`. You'll use this panel as a source for the other panels.

1. Define the query or queries that you want to share.

   If you don't have a data source available, use the **TestData** data source, which returns a random time series that you can use for testing.

1. Add a second panel and select the **Dashboard** data source in the query editor.

1. In the **Use results from panel list**, select the first panel you created.

All queries defined in the source panel are now available to the new panel. Queries made in the source panel can be shared with multiple panels.

You can click on any of the queries to go to the panel where they are defined.

# Transform data
<a name="v9-panels-xform"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

Transformations are a powerful way to manipulate data returned by a query before the system applies a visualization. Using transformations, you can:
+ Rename fields
+ Join time series data
+ Perform mathematical operations across queries
+ Use the output of one transformation as the input to another transformation

For users that rely on multiple views of the same dataset, transformations offer an efficient method of creating and maintaining numerous dashboards.

You can also use the output of one transformation as the input to another transformation, which results in a performance gain.

**Note**  
Sometimes the system cannot graph transformed data. When that happens, click the **Table view** toggle above the visualization to switch to a table view of the data. This can help you understand the final result of your transformations.

## Transformation types
<a name="v9-panels-xform-types"></a>

Grafana provides a number of ways that you can transform data. There is a complete list of transformation functions below.

## Order of transformations
<a name="v9-panels-xform-order"></a>

When there are multiple transformations, Grafana applies them in the order they are listed. Each transformation creates a result set that then passes on to the next transformation in the processing pipeline.

The order in which Grafana applies transformations directly impacts the results. For example, if you use a Reduce transformation to condense all the results of one column into a single value, then you can only apply transformations to that single value.

## Add a transformation function to data
<a name="v9-panels-xform-add"></a>

The following steps guide you in adding a transformation to data.

**To add a transformation to a panel**

1. Navigate to the panel where you want to add one or more transformations.

1. Choose the panel title and then click **Edit**.

1. Choose the **Transform** tab.

1. Choose a transformation. A transformation row appears where you configure the transformation options.

1. To apply another transformation, Choose **Add transformation**. This transformation acts on the result set returned by the previous transformation.

## Debug a transformation
<a name="v9-panels-xform-debug"></a>

To see the input and the output result sets of the transformation, choose the bug icon on the right side of the transformation row.

The input and output results sets can help you debug a transformation.

## Delete a transformation
<a name="v9-panels-xform-delete"></a>

We recommend that you remove transformations that you don’t need. When you delete a transformation, you remove the data from the visualization.

Prerequisites:

Identify all dashboards that rely on the transformation and inform impacted dashboard users.

**To delete a transformation**

1. Open a panel for editing.

1. Choose the **Transform** tab.

1. Choose the trash icon next to the transformation you want to delete.

## Transformation functions
<a name="v9-panels-xform-functions"></a>

You can perform the following transformations on your data.

**Add field from calculation**

Use this transformation to add a new field calculated from two other fields. Each transformation allows you to add one new field.
+ **Mode** - Select a mode:
  + **Reduce row** – Apply selected calculation on each row of selected fields independently.
  + **Binary option** – Apply basic math operation(sum, multiply, etc) on values in a single row from two selected fields.
+ **Field name** – Select the names of fields you want to use in the calculation for the new field.
+ **Calculation** – If you select **Reduce row** mode, then the **Calculation** field appears. Click in the field to see a list of calculation choices you can use to create the new field. For information about available calculations, refer to [Calculation types](v9-panels-calculation-types.md).
+ **Operation** – If you select **Binary option** mode, then the **Operation** fields appear. These fields allow you to do basic math operations on values in a single row from two selected fields. You can also use numerical values for binary operations.
+ **Alias** – (Optional) Enter the name of your new field. If you leave this blank, then the field will be named to match the calculation.
+ **Replace all fields** – (Optional) Select this option if you want to hide all other fields and display only your calculated field in the visualization.

**Concatenate fields**

This transformation combines all fields from all frames into one result. Consider these two queries.

Query A:


| Temp | Uptime | 
| --- | --- | 
|  15.4  |  1230233  | 

Query B:


| AQI | Errors | 
| --- | --- | 
|  3.2  |  5  | 

After you concatenate the fields, the data frame would be:


| Temp | Uptime | AQI | Errors | 
| --- | --- | --- | --- | 
|  15.4  |  1230233  |  3.2  |  5  | 

**Config from query results**

This transformation allow you to select one query and from it extract standard options like **Min**, **Max**, **Unit** and **Thresholds** and apply it to other query results. This enables dynamic query driven visualization configuration.

If you want to extract a unique config for every row in the config query result then try the rows to fields transformation.

**Options**
+ **Config query** – Select the query that returns the data you want to use as configuration.
+ **Apply to** – Select what fields or series to apply the configuration to.
+ **Apply to options** – Usually a field type or field name regex depending on what option you selected in **Apply to**.

**Convert field type**

This transformation changes the field type of the specified field.
+ **Field** – Select from available fields
+ **as** – Select the FieldType to convert to
  + **Numeric** – attempts to make the values numbers
  + **String** – will make the values strings
  + **Time** – attempts to parse the values as time
    + Will show an option to specify a DateFormat as input by a string like yyyy-mm-dd or DD MM YYYY hh:mm:ss
  + **Boolean** – will make the values Boolean

For example the following query could be modified by selecting the time field, as Time, and Date Format as YYYY.


| Time | Mark | Value | 
| --- | --- | --- | 
|  7/1/2017  |  above  |  25  | 
|  8/2/2018  |  below  |  22  | 
|  9/2/2019  |  below  |  29  | 
|  10/4/2020  |  above  |  22  | 

The result:


| Time | Mark | Value | 
| --- | --- | --- | 
|  1/1/2017  |  above  |  25  | 
|  1/1/2018  |  below  |  22  | 
|  1/1/2019  |  below  |  29  | 
|  1/1/2020  |  above  |  22  | 

**Filter data by name**

Use this transformation to remove portions of the query results.

Grafana displays the **Identifier** field, followed by the fields returned by your query.

You can apply filters in one of two ways:
+ Enter a regex expression.
+ Choose a field to toggle filtering on that field. Filtered fields are displayed with dark gray text, unfiltered fields have white text.

**Filter data by query**

Use this transformation in panels that have multiple queries, if you want to hide one or more of the queries.

Grafana displays the query identification letters in dark gray text. Click a query identifier to toggle filtering. If the query letter is white, then the results are displayed. If the query letter is dark, then the results are hidden.

**Note**  
This transformation is not available for Graphite because this data source does not support correlating returned data with queries.

**Filter data by value**

This transformation allows you to filter your data directly in Grafana and remove some data points from your query result. You have the option to include or exclude data that match one or more conditions you define. The conditions are applied on a selected field.

This transformation is useful if your data source does not natively filter by values. You might also use this to narrow values to display if you are using a shared query.

The available conditions for all fields are:
+ **Regex** – Match a regex expression
+ **Is Null** – Match if the value is null
+ **Is Not Null** – Match if the value is not null
+ **Equal** – Match if the value is equal to the specified value
+ **Different** – match if the value is different than the specified value

The available conditions for number fields are:
+ **Greater** – Match if the value is greater than the specified value
+ **Lower** – Match if the value is lower than the specified value
+ **Greater or equal** – Match if the value is greater or equal
+ **Lower or equal** – Match if the value is lower or equal
+ **Range** – Match a range between a specified minimum and maximum, min and max included

Consider the following data set:


| Time | Temperature | Altitude | 
| --- | --- | --- | 
|  7/7/2020 11:34:23 AM  |  32  |  101  | 
|  7/7/2020 11:34:22 AM  |  28  |  125  | 
|  7/7/2020 11:34:21 AM  |  26  |  110  | 
|  7/7/2020 11:34:20 AM  |  23  |  98  | 
|  7/7/2020 10:32:24 AM  |  31  |  95  | 
|  7/7/2020 10:31:22 AM  |  20  |  85  | 
|  7/7/2020 9:30:57 AM  |  19  |  101  | 

If you **Include** the data points that have a temperature below 30°C, the configuration will look as follows:
+ **Filter Type** – `Include`
+ **Condition** – Rows where `Temperature` matches `Lower Than 30`

And you will get the following result, where only the temperatures below 30°C are included:


| Time | Temperature | Altitude | 
| --- | --- | --- | 
|  7/7/2020 11:34:22 AM  |  28  |  125  | 
|  7/7/2020 11:34:21 AM  |  26  |  110  | 
|  7/7/2020 11:34:20 AM  |  23  |  98  | 
|  7/7/2020 10:31:22 AM  |  20  |  85  | 
|  7/7/2020 9:30:57 AM  |  19  |  101  | 

You can add more than one condition to the filter. For example, you might want to include the data only if the altitude is greater than 100. To do so, add that condition to the following configuration:
+ Filter type – `Include` rows that `Match All` conditions
+ Condition 1 – Rows where `Temperature` matches `Lower` than `30`
+ Condition 2 – Rows where `Altitude` matches `Greater` than `100`

When you have more than one condition, you can choose if you want the action (include / exclude) to be applied on rows that **Match all** conditions or **Match any** of the conditions you added.

In the example above we chose **Match all** because we wanted to include the rows that have a temperature lower than 30 AND an altitude higher than 100. If we wanted to include the rows that have a temperature lower than 30 OR an altitude higher than 100 instead, then we would select **Match any**. This would include the first row in the original data, which has a temperature of 32°C (does not match the first condition) but an altitude of 101 (which matches the second condition), so it is included.

Conditions that are invalid or incompletely configured are ignored.

**Group by**

This transformation groups the data by a specified field (column) value and processes calculations on each group. Click to see a list of calculation choices.

Here’s an example of original data.


| Time | Server ID | CPU Temperature | Server Status | 
| --- | --- | --- | --- | 
|  7/7/2020 11:34:20 AM  |  server 1  |  80  |  Shutdown  | 
|  7/7/2020 11:34:20 AM  |  server 3  |  62  |  OK  | 
|  7/7/2020 10:32:20 AM  |  server 2  |  90  |  Overload  | 
|  7/7/2020 10:31:22 AM  |  server 3  |  55  |  OK  | 
|  7/7/2020 9:30:57 AM  |  server 3  |  62  |  Rebooting  | 
|  7/7/2020 9:30:05 AM  |  server 2  |  88  |  OK  | 
|  7/7/2020 9:28:06 AM  |  server 1  |  80  |  OK  | 
|  7/7/2020 9:25:05 AM  |  server 2  |  88  |  OK  | 
|  7/7/2020 9:23:07 AM  |  server 1  |  86  |  OK  | 

This transformation goes in two steps. First you specify one or multiple fields to group the data by. This will group all the same values of those fields together, as if you sorted them. For instance if we group by the Server ID field, then it would group the data this way:


| Time | Server ID | CPU Temperature | Server Status | 
| --- | --- | --- | --- | 
|  7/7/2020 11:34:20 AM  |  server 1  |  80  |  Shutdown  | 
|  7/7/2020 9:28:06 AM  |  server 1  |  80  |  OK  | 
|  7/7/2020 9:23:07 AM  |  server 1  |  86  |  OK  | 
|  7/7/2020 10:32:20 AM  |  server 2  |  90  |  Overload  | 
|  7/7/2020 9:30:05 AM  |  server 2  |  88  |  OK  | 
|  7/7/2020 9:25:05 AM  |  server 2  |  88  |  OK  | 
|  7/7/2020 11:34:20 AM  |  server 3  |  62  |  OK  | 
|  7/7/2020 10:31:22 AM  |  server 3  |  55  |  OK  | 
|  7/7/2020 9:30:57 AM  |  server 3  |  62  |  Rebooting  | 

All rows with the same value of Server ID are grouped together.

After choosing which field you want to group your data by, you can add various calculations on the other fields, and apply the calculation to each group of rows. For instance, we could want to calculate the average CPU temperature for each of those servers. So we can add the *mean* calculation applied on the CPU Temperature field to get the following:


| Server ID | CPU Temperature (mean) | 
| --- | --- | 
|  server 1  |  82  | 
|  server 2  |  88.6  | 
|  server 3  |  59.6  | 

And we can add more than one calculation. For instance:
+ For field Time, we can calculate the *Last* value, to know when the last data point was received for each server
+ For field Server Status, we can calculate the *Last* value to know what is the last state value for each server
+ For field Temperature, we can also calculate the *Last* value to know what is the latest monitored temperature for each server

We would then get:


| Server ID | CPU Temperature (mean) | CPU Temperature (last) | Time (last) | Server Status (last) | 
| --- | --- | --- | --- | --- | 
|  server 1  |  82  |  80  |  7/7/2020 11:34:20 AM  |  Shutdown  | 
|  server 2  |  88.6  |  90  |  7/7/2020 10:32:20 AM  |  Overload  | 
|  server 3  |  59.6  |  62  |  7/7/2020 11:34:20 AM  |  OK  | 

This transformation enables you to extract key information from your time series and display it in a convenient way.

**Join by field**

Use this transformation to join multiple results into a single table. This is especially useful for converting multiple time series results into a single wide table with a shared time field.

*Inner join*

An inner join merges data from multiple tables where all tables share the same value from the selected field. This type of join excludes data where values do not match in every result.

Use this transformation to combine the results from multiple queries (combining on a passed join field or the first time column) into one result, and drop rows where a successful join cannot occur.

In the following example, two queries return table data. It is visualized as two separate tables before applying the inner join transformation.

Query A:


| Time | Job | Uptime | 
| --- | --- | --- | 
|  7/7/2020 11:34:20 AM  |  node  |  25260122  | 
|  7/7/2020 11:24:20 AM  |  postgre  |  123001233  | 
|  7/7/2020 11:14:20 AM  |  postgre  |  345001233  | 

Query B:


| Time | Server | Errors | 
| --- | --- | --- | 
|  7/7/2020 11:34:20 AM  |  server 1  |  15  | 
|  7/7/2020 11:24:20 AM  |  server 2  |  5  | 
|  7/7/2020 11:04:20 AM  |  server 3  |  10  | 

The result after applying the inner join transformation looks like the following:


| Time | Job | Uptime | Server | Errors | 
| --- | --- | --- | --- | --- | 
|  7/7/2020 11:34:20 AM  |  node  |  25260122  |  server 1  |  15  | 
|  7/7/2020 11:24:20 AM  |  postgre  |  123001233  |  server 2  |  5  | 

*Outer join*

An outer join includes all data from an inner join and rows where values do not match in every input. While the inner join joins Query A and Query B on the time field, the outer join includes all rows that don’t match on the time field.

In the following example, two queries return table data. It is visualized as two tables before applying the outer join transformation.

Query A:


| Time | Job | Uptime | 
| --- | --- | --- | 
|  7/7/2020 11:34:20 AM  |  node  |  25260122  | 
|  7/7/2020 11:24:20 AM  |  postgre  |  123001233  | 
|  7/7/2020 11:14:20 AM  |  postgre  |  345001233  | 

Query B:


| Time | Server | Errors | 
| --- | --- | --- | 
|  7/7/2020 11:34:20 AM  |  server 1  |  15  | 
|  7/7/2020 11:24:20 AM  |  server 2  |  5  | 
|  7/7/2020 11:04:20 AM  |  server 3  |  10  | 

The result after applyign the outer join transformation looks like the following:


| Time | Job | Uptime | Server | Errors | 
| --- | --- | --- | --- | --- | 
|  7/7/2020 11:04:20 AM  |    |    |  server 3  |  10  | 
|  7/7/2020 11:14:20 AM  |  postgre  |  345001233  |    |    | 
|  7/7/2020 11:34:20 AM  |  node  |  25260122  |  server 1  |  15  | 
|  7/7/2020 11:24:20 AM  |  postgre  |  123001233  |  server 2  |  5  | 

**Labels to fields**

This transformation changes time series results that include labels or tags into a table where each label keys and values are included in the table result. The labels can be displayed either as columns or as row values.

Given a query result of two time series:
+ Series 1 – labels Server=Server A, Datacenter=EU
+ Series 2 – labels Server=Server B, Datacenter=EU

In **Columns** mode, the result looks like this:


| Time | Server | Datacenter | Value | 
| --- | --- | --- | --- | 
|  7/7/2020 11:34:20 AM  |  Server A  |  EU  |  1  | 
|  7/7/2020 11:34:20 AM  |  Server B  |  EU  |  2  | 

In “Rows” mode, the result has a table for each series and show each label value like this:


| label | value | 
| --- | --- | 
|  Server  |  Server A  | 
|  Datacenter  |  EU  | 


| label | value | 
| --- | --- | 
|  Server  |  Server B  | 
|  Datacenter  |  EU  | 

*Value field name*

If you selected Server as the **Value field name**, then you would get one field for every value of the Server label.


| Time | Datacenter | Server A | Server B | 
| --- | --- | --- | --- | 
|  7/7/2020 11:34:20 AM  |  EU  |  1  |  2  | 

*Merging behavior*

The labels to fields transformer is internally two separate transformations. The first acts on single series and extracts labels to fields. The second is the merge transformation that joins all the results into a single table. The merge transformation tries to join on all matching fields. This merge step is required and cannot be turned off. 

**Note**  
The *merge* transformation can be used on its own, and is described in detail below.

To illustrate this, here is an example where you have two queries that return time series with no overlapping labels.
+ Series 1 – labels Server=ServerA
+ Series 2 – labels Datacenter=EU

This will first result in these two tables:


| Time | Server | Value | 
| --- | --- | --- | 
|  7/7/2020 11:34:20 AM  |  ServerA  |  10  | 


| Time | Datacenter | Value | 
| --- | --- | --- | 
|  7/7/2020 11:34:20 AM  |  EU  |  20  | 

After merge:


| Time | Server | Value | Datacenter | 
| --- | --- | --- | --- | 
|  7/7/2020 11:34:20 AM  |  ServerA  |  10  |    | 
|  7/7/2020 11:34:20 AM  |    |  20  |  EU  | 

**Merge**

Use this transformation to combine the result from multiple queries into one single result. This is helpful when using the table panel visualization. Values that can be merged are combined into the same row. Values are mergeable if the shared fields contain the same data.

In the example below, we have two queries returning table data. It is visualized as two separate tables before applying the transformation.

Query A:


| Time | Job | Uptime | 
| --- | --- | --- | 
|  7/7/2020 11:34:20 AM  |  node  |  25260122  | 
|  7/7/2020 11:24:20 AM  |  postgre  |  123001233  | 

Query B:


| Time | Job | Errors | 
| --- | --- | --- | 
|  7/7/2020 11:34:20 AM  |  node  |  15  | 
|  7/7/2020 11:24:20 AM  |  postgre  |  5  | 

Here is the result after applying the Merge transformation:


| Time | Job | Errors | Uptime | 
| --- | --- | --- | --- | 
|  7/7/2020 11:34:20 AM  |  node  |  15  |  25260122  | 
|  7/7/2020 11:24:20 AM  |  postgre  |  5  |  123001233  | 

**Organize fields**

Use this transformation to rename, reorder, or hide fields returned by the query.

**Note**  
This transformation only works in panels with a single query. If your panel has multiple queries, then you must either apply an Outer join transformation or remove the extra queries.

Grafana displays a list of fields returned by the query. You can:
+ Change field order by hovering your cursor over a field. The cursor turns into a hand and then you can drag the field to its new place.
+ Hide or show a field by clicking the eye icon next to the field name.
+ Rename fields by typing a new name in the Rename box.

**Partition by values**

This transformation can help eliminate the need for multiple queries to the same datasource with different `WHERE` clauses when graphing multiple series. Consider a metrics SQL table with the following data:


| Time | Region | Value | 
| --- | --- | --- | 
|  10/20/2022 12:00:00 PM  |  US  |  1520  | 
|  10/20/2022 12:00:00 PM  |  EU  |  2936  | 
|  10/20/2022 1:00:00 AM  |  US  |  1327  | 
|  10/20/2022 1:00:00 AM  |  EU  |  912  | 

Prior to v9.3, if you wanted to plot a red trendline for US and a blue one for EU in the same TimeSeries panel, you would likely have to split this into two queries:

```
SELECT Time, Value FROM metrics WHERE Time > '2022-10-20' AND Region='US'
SELECT Time, Value FROM metrics WHERE Time > '2022-10-20' AND Region='EU'
```

This also requires you to know ahead of time which regions actually exist in the metrics table.

With the *Partition by values* transformer, you can now issue a single query and split the results by unique values in one or more columns (`fields`) of your choosing. The following example uses `Region`.

```
SELECT Time, Region, Value FROM metrics WHERE Time > '2022-10-20'
```


| Time | Region | Value | 
| --- | --- | --- | 
|  10/20/2022 12:00:00 PM  |  US  |  1520  | 
|  10/20/2022 1:00:00 AM  |  US  |  1327  | 


| Time | Region | Value | 
| --- | --- | --- | 
|  10/20/2022 12:00:00 PM  |  EU  |  2936  | 
|  10/20/2022 1:00:00 AM  |  EU  |  912  | 

**Reduce**

The *Reduce* transformation applies a calculation to each field in the frame and return a single value. Time fields are removed when applying this transformation.

Consider the input:

Query A:


| Time | Temp | Uptime | 
| --- | --- | --- | 
|  7/7/2020 11:34:20 AM  |  12.3  |  256122  | 
|  7/7/2020 11:24:20 AM  |  15.4  |  1230233  | 

Query B:


| Time | AQI | Errors | 
| --- | --- | --- | 
|  7/7/2020 11:34:20 AM  |  6.5  |  15  | 
|  7/7/2020 11:24:20 AM  |  3.2  |  5  | 

The reduce transformer has two modes:
+ **Series to rows** - Creates a row for each field and a column for each calculation.
+ **Reduce fields** - Keeps the existing frame structure, but collapses each field into a single value.

For example, if you used the **First** and **Last** calculation with a **Series to rows** transformation, then the result would be:


| Field | First | Last | 
| --- | --- | --- | 
|  Temp  |  12.3  |  15.4  | 
|  Uptime  |  256122  |  1230233  | 
|  AQI  |  6.5  |  3.2  | 
|  Errors  |  15  |  5  | 

The Reduce fields with the Last calculation, results in two frames, each with one row:

Query A:


| Temp | Uptime | 
| --- | --- | 
|  15.4  |  1230233  | 

Query B:


| AQI | Errors | 
| --- | --- | 
|  3.2  |  5  | 

**Rename by regex**

Use this transformation to rename parts of the query results using a regular expression and replacement pattern.

You can specify a regular expression, which is only applied to matches, along with a replacement pattern that support back references. For example, let’s imagine you’re visualizing CPU usage per host and you want to remove the domain name. You could set the regex to `([^\.]+)\..+` and the replacement pattern to `$1`, `web-01.example.com` would become `web-01`.

**Rows to fields**

The rows to fields transformation converts rows into separate fields. This can be useful as fields can be styled and configured individually. It can also use additional fields as sources for dynamic field configuration or map them to field labels. The additional labels can then be used to define better display names for the resulting fields.

This transformation includes a field table which lists all fields in the data returned by the config query. This table gives you control over what field should be mapped to each config property (the \$1Use as\$1\$1 option). You can also choose which value to select if there are multiple rows in the returned data.

This transformation requires:
+ One field to use as the source of field names.

  By default, the transform uses the first string field as the source. You can override this default setting by selecting **Field name** in the **Use as** column for the field you want to use instead.
+ One field to use as the source of values.

  By default, the transform uses the first number field as the source. But you can override this default setting by selecting **Field value** in the **Use as** column for the field you want to use instead.

Useful when visualizing data in:
+ Gauge
+ Stat
+ Pie chart

*Map extra fields to labels*

If a field does not map to config property Grafana will automatically use it as source for a label on the output field-

Example:


| Name | DataCenter | Value | 
| --- | --- | --- | 
|  ServerA  |  US  |  100  | 
|  ServerB  |  EU  |  200  | 

Output:


| ServerA (labels: DataCenter: US) | ServerB (labels: DataCenter: EU) | 
| --- | --- | 
|  10  |  20  | 

The extra labels can now be used in the field display name provide more complete field names.

If you want to extract config from one query and apply it to another you should use the config from query results transformation.

*Example*

Input:


| Name | Value | Max | 
| --- | --- | --- | 
|  ServerA  |  10  |  100  | 
|  ServerB  |  20  |  200  | 
|  ServerC  |  30  |  300  | 

Output:


| ServerA (config: max=100) | ServerB (config: max=200) | ServerC (config: max=300) | 
| --- | --- | --- | 
|  10  |  20  |  30  | 

As you can see each row in the source data becomes a separate field. Each field now also has a max config option set. Options like Min, Max, Unit and Thresholds are all part of field configuration and if set like this will be used by the visualization instead of any options manually configured in the panel editor options pane.

**Prepare time series**

Prepare time series transformation is useful when a data source returns time series data in a format that isn’t supported by the panel you want to use.

This transformation helps you resolve this issue by converting the time series data from either the wide format to the long format or the other way around.

Select the **Multi-frame time series** option to transform the time series data frame from the wide to the long format.

Select the **Wide time series** option to transform the time series data frame from the long to the wide format.

**Series to rows**

Use this transformation to combine the result from multiple time series data queries into one single result. This is helpful when using the table panel visualization.

The result from this transformation will contain three columns: Time, Metric, and Value. The Metric column is added so you easily can see from which query the metric originates from. Customize this value by defining Label on the source query.

In the example below, we have two queries returning time series data. It is visualized as two separate tables before applying the transformation.

Query A:


| Time | Temperature | 
| --- | --- | 
|  7/7/2020 11:34:20 AM  |  25  | 
|  7/7/2020 10:31:22 AM  |  22  | 
|  7/7/2020 9:30:05 AM  |  19  | 

Query B:


| Time | Humidity | 
| --- | --- | 
|  7/7/2020 11:34:20 AM  |  24  | 
|  7/7/2020 10:32:20 AM  |  29  | 
|  7/7/2020 9:30:57 AM  |  33  | 

Here is the result after applying the Series to rows transformation.


| Time | Metric | Value | 
| --- | --- | --- | 
|  7/7/2020 11:34:20 AM  |  Temperature  |  25  | 
|  7/7/2020 11:34:20 AM  |  Humidity  |  22  | 
|  7/7/2020 10:32:20 AM  |  Humidity  |  29  | 
|  7/7/2020 10:31:22 AM  |  Temperature  |  22  | 
|  7/7/2020 9:30:57 AM  |  Humidity  |  33  | 
|  7/7/2020 9:30:05 AM  |  Temperature  |  19  | 

**Sort by**

This transformation will sort each frame by the configured field, When `reverse` is checked, the values will return in the opposite order.

**Limit**

Use this transformation to limit the number of rows displayed.

In the example below, we have the following response from the data source:


| Time | Metric | Value | 
| --- | --- | --- | 
|  7/7/2020 11:34:20 AM  |  Temperature  |  25  | 
|  7/7/2020 11:34:20 AM  |  Humidity  |  22  | 
|  7/7/2020 10:32:20 AM  |  Humidity  |  29  | 
|  7/7/2020 10:31:22 AM  |  Temperature  |  22  | 
|  7/7/2020 9:30:57 AM  |  Humidity  |  33  | 
|  7/7/2020 9:30:05 AM  |  Temperature  |  19  | 

Here is the result after adding a Limit transformation with a value of ‘3’:


| Time | Metric | Value | 
| --- | --- | --- | 
|  7/7/2020 11:34:20 AM  |  Temperature  |  25  | 
|  7/7/2020 11:34:20 AM  |  Humidity  |  22  | 
|  7/7/2020 10:32:20 AM  |  Humidity  |  29  | 

# Troubleshoot queries
<a name="v9-panels-query-troubleshoot"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

This page provides information to solve common dashboard problems.

**I get different results when I rearrange my functions**

Function order is very important. Just like in math, the order that you place your functions can affect the result.

**Inspect your query request and response**

The most common problems are related to the query and response from your data source. Even if it looks like a bug or visualization issue in Grafana, it is almost always a problem with the data source query or the data source response. Start by inspecting your panel query and response.

For more information, refer to [Inspect request and response data](v9-panels-panel-inspector.md).

**My query is slow**

How many data points is your query returning? A query that returns lots of data points will be slow. Try this:
+ In **Query options**, limit the **Max data points** returned.
+ In **Query options**, increase the **Min interval** time.
+ In your query, use a `group by` function.

# Configure thresholds
<a name="v9-panels-configure-thresholds"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

 This section includes information about using thresholds in your visualizations. You’ll learn about thresholds and their defaults, how to add or delete a threshold, and adding a threshold to a legacy panel. 

## About thresholds
<a name="v9-panels-thresholds-about"></a>

 A threshold is a value that you specify for a metric that is visually reflected in a dashboard when the threshold value is met or exceeded. 

 Thresholds provide one method for you to conditionally style and color your visualizations based on query results. You can apply thresholds to most, but not all, visualizations. For more information about visualizations, refer to [Visualization panels](v9-panels.md).

 You can use thresholds to: 
+  Color grid lines or grid ares areas in the [Time-series visualization](v9-panels-time-series.md) 
+  Color lines in the [Time-series visualization](v9-panels-time-series.md) 
+  Color the background or value text in the [Stat visualization](v9-panels-stat.md) 
+  Color the gauge and threshold markers in the [Gauge visualization](v9-panels-gauge.md) 
+  Color markers in the [Geomap visualization](v9-panels-geomap.md) 
+  Color cell text or background in the [Table visualization](v9-panels-table.md) 
+  Define regions and region colors in the [State timeline visualization](v9-panels-state-timeline.md) 

 There are two types of thresholds: 
+  **Absolute** thresholds are defined by a number. For example, 80 on a scale of 1 to 150. 
+  **Percentage** thresholds are defined relative to minimum or maximum. For example, 80 percent. 

### Default thresholds
<a name="v9-panels-thresholds-default"></a>

 On visualizations that support it, Grafana sets default threshold values of: 
+  80 = red 
+  Base = green 
+  Mode = Absolute 

 The **Base** value represents minus infinity. It is generally the "good" color. 

## Add or delete a threshold
<a name="v9-panels-thresholds-add-delete"></a>

 You can add as many thresholds to a panel as you want. Grafana automatically sorts thresholds values from highest to lowest. 

 Delete a threshold when it is no longer relevant to your business operations. When you delete a threshold, the system removes the threshold from all visualizations that include the threshold. 

1.  To add a threshold: 

   1.  Edit the panel to which you want to add a threshold. 

   1.  In the options side pane, locate the **Thresholds** section and click **\$1 Add threshold**. 

   1.  Select a threshold color, number, and mode. Threshold mode applies to all thresholds on this panel. 

   1.  For a time-series panel, select a **Show thresholds** option. 

1.  To delete a threshold, navigate to the panel that contains the threshold and click the trash icon next to the threshold you want to remove. 

## Add a threshold to a legacy graph panel
<a name="v9-panels-thresholds-legacy-graph"></a>

 In the Graph panel visualization, thresholds enable you to add lines or sections to a graph to make it easier to recognize when the graph crosses a threshold. 

1.  Navigate to the graph panel to which you want to add a threshold. 

1.  On the **Panel** tab, click **Thresholds**. 

1.  Click **Add threshold**. 

1.  Complete the following fields: 
   +  **T1 -** Both values are required to display a threshold. 
     +  **lt** or **gt** - Select **lt** for less than or **gt** for greater than to indicate what the threshold applies to. 
     +  **Value -** Enter a threshold value. Grafana draws a threshold line along the Y-axis at that value. 
   +  **Color -** Choose a condition that corresponds to a color, or define your own color. 
     +  **custom -** You define the fill color and line color. 
     +  **critical -** Fill and line color are red. 
     +  **warning -** Fill and line color are yellow. 
     +  **ok -** Fill and line color are green. 
   +  **Fill -** Controls whether the threshold fill is displayed. 
   +  **Line -** Controls whether the threshold line is displayed. 
   +  **Y-Axis -** Choose **left** or **right**. 

1.  Click **Save** to save the changes in the dashboard. 

# Configure data links
<a name="v9-panels-configure-data-links"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

 You can use data link variables or data links to create links between panels. 

## Data link variables
<a name="v9-panels-data-link-variables"></a>

 You can use variables in data links to refer to series fields, labels, and values. For more information about data links, see [Data links](#v9-panels-data-links).

 To see a list of available variables, type **\$1** in the data link **URL** field to see a list of variables that you can use. 

**Note**  
 These variables changed in 6.4, so if you have an older version of Grafana, then use the version picker to select docs for an older version of Grafana. 

 You can also use template variables in your data links URLs, see [Adding and managing dashboard variables](v9-dash-variables.md).

## Time range panel variables
<a name="v9-panels-time-range-panel-variables"></a>

 These variables allow you to include the current time range in the data link URL. 
+  **\$1\$1url\$1time\$1range** - current dashboard’s time range (i.e. **?from=now-6h&to=now**) 
+  **\$1\$1\$1from and \$1\$1\$1to** - For more information, see [Global variables](v9-dash-variable-add.md#v9-dash-variable-add-global).

## Series variables
<a name="v9-panels-series-variables"></a>

 Series specific variables are available under **\$1\$1series** namespace: 
+  **\$1\$1series.name** - series name to the URL 

## Field variables
<a name="v9-panels-field-variables"></a>

 Field-specific variables are available under **\$1\$1field** namespace: 
+  **\$1\$1field.name** - the name of the field 
+  **\$1\$1field.labels.<LABEL>** - label’s value to the URL. If your label contains dots, then use **\$1\$1field.labels["<LABEL>"]** syntax. 

## Value variables
<a name="v9-panels-value-variables"></a>

 Value-specific variables are available under **\$1\$1value** namespace: 
+  **\$1\$1value.time** - value’s timestamp (Unix ms epoch) to the URL (i.e. **?time=1560268814105**) 
+  **\$1\$1value.raw** - raw value 
+  **\$1\$1value.numeric** - numeric representation of a value 
+  **\$1\$1value.text** - text representation of a value 
+  **\$1\$1value.calc** - calculation name if the value is result of calculation 

## Template variables
<a name="v9-panels-template-variables"></a>

 When linking to another dashboard that uses template variables, select variable values for whoever clicks the link. 

 **\$1\$1var-myvar:queryparam\$1** - where **var-myvar** is the name of the template variable that matches one in the current dashboard that you want to use. 


|  Variable state  |  Result in the created URL  | 
| --- | --- | 
|  selected one value  |  var-myvar=value1  | 
|  selected multiple values  |  var-myvar=value1&var-myvar=value2  | 
|  selected All  |  var-myvar=All  | 

 If you want to add all of the current dashboard’s variables to the URL, then use **\$1\$1\$1\$1all\$1variables\$1**. 

## Data links
<a name="v9-panels-data-links"></a>

 Data links allow you to provide more granular context to your links. You can create links that include the series name or even the value under the cursor. For example, if your visualization showed four servers, you could add a data link to one or two of them. 

 The link itself is accessible in different ways depending on the visualization. For the Graph you need to click on a data point or line, for a panel like Stat, Gauge, or Bar Gauge you can click anywhere on the visualization to open the context menu. 

 You can use variables in data links to send people to a detailed dashboard with preserved data filters. For example, you could use variables to specify a time range, series, and variable selection. For more information, see [Data link variables](#v9-panels-data-link-variables).

### Typeahead suggestions
<a name="v9-panels-typeahead-suggestions"></a>

 When creating or updating a data link, press Cmd\$1Space or Ctrl\$1Space on your keyboard to open the typeahead suggestions to more easily add variables to your URL. 

### Add a data link
<a name="v9-panels-add-a-datalink"></a>

1.  Hover your cursor over the panel that you want to add a link to and then press **e**. Or click the dropdown arrow next to the panel title and then click **Edit**. 

1.  On the Field tab, scroll down to the Data links section. 

1.  Expand Data links and then click **Add link**. 

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

1.  Enter the **URL** you want to link to. 

    You can even add one of the template variables defined in the dashboard. Click in the **URL** field and then type **\$1** or press Ctrl\$1Space or Cmd\$1Space to see a list of 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. For more information, see [Data link variables](#v9-panels-data-link-variables).

1.  If you want the link to open in a new tab, then select **Open in a new tab**. 

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

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

### Update a data link
<a name="v9-panels-update-a-datalink"></a>

1.  On the Field tab, find the link that you want to make changes to. 

1.  Click the Edit (pencil) icon to open the Edit link window. 

1.  Make any necessary changes. 

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

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

### Delete a data link
<a name="v9-panels-delete-a-datalink"></a>

1.  On the Field tab, find the link that you want to delete. 

1.  Click the **X** icon next to the link you want to delete. 

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

# Configure field overrides
<a name="v9-panels-configure-overrides"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

 Overrides allow you to customize visualization settings for specific fields or series. This is accomplished by adding an override rule that targets a particular set of fields and that can each define multiple options. 

 For example, you set the unit for all fields that include the text "bytes" by adding an override using the **Fields with name matching regex** matcher and then add the Unit option to the override rule. 

## Example 1: Format temperature
<a name="v9-panels-overrides-format-temperature"></a>

 Let’s assume that our result set is a data frame that consists of two fields: time and temperature. 


|  time  |  temperature  | 
| --- | --- | 
|  2020-01-02 03:04:00  |  45.0  | 
|  2020-01-02 03:05:00  |  47.0  | 
|  2020-01-02 03:06:00  |  48.0  | 

 Each field (column) of this structure can have field options applied that alter the way its values are displayed. This means that you can, for example, set the Unit to Temperature > Celsius, resulting in the following table: 


|  time  |  temperature  | 
| --- | --- | 
|  2020-01-02 03:04:00  |  45.0 °C  | 
|  2020-01-02 03:05:00  |  47.0 °C  | 
|  2020-01-02 03:06:00  |  48.0 °C  | 

 In addition, the decimal place is not required, so we can remove it. You can change the Decimals from **auto** to zero (**0**), resulting in the following table: 


|  time  |  temperature  | 
| --- | --- | 
|  2020-01-02 03:04:00  |  45 °C  | 
|  2020-01-02 03:05:00  |  47 °C  | 
|  2020-01-02 03:06:00  |  48 °C  | 

## Example 2: Format temperature and humidity
<a name="v9-panels-overrides-format-humidity"></a>

 Let’s assume that our result set is a data frame that consists of four fields: time, high temp, low temp, and humidity. 


|  time  |  high temp  |  low temp  |  humidity  | 
| --- | --- | --- | --- | 
|  2020-01-02 03:04:00  |  45.0  |  30.0  |  67  | 
|  2020-01-02 03:05:00  |  47.0  |  34.0  |  68  | 
|  2020-01-02 03:06:00  |  48.0  |  31.0  |  68  | 

 Let’s add the Celsius unit and get rid of the decimal place. This results in the following table: 


|  time  |  high temp  |  low temp  |  humidity  | 
| --- | --- | --- | --- | 
|  2020-01-02 03:04:00  |  45 °C  |  30 °C  |  67 °C  | 
|  2020-01-02 03:05:00  |  47 °C  |  34 °C  |  68 °C  | 
|  2020-01-02 03:06:00  |  48 °C  |  31 °C  |  68 °C  | 

 The temperature fields look good, but the humidity must now be changed. We can fix this by applying a field option override to the humidity field and change the unit to Misc > percent (0-100). 


|  time  |  high temp  |  low temp  |  humidity  | 
| --- | --- | --- | --- | 
|  2020-01-02 03:04:00  |  45 °C  |  30 °C  |  67%  | 
|  2020-01-02 03:05:00  |  47 °C  |  34 °C  |  68%  | 
|  2020-01-02 03:06:00  |  48 °C  |  31 °C  |  68%  | 

## Add a field override
<a name="v9-panels-overrides-add-a-field"></a>

 A field override rule can customize the visualization settings for a specific field or series. 

1.  Edit the panel to which you want to add an override. 

1.  In the panel options side pane, click **Add field override** at the bottom of the pane. 

1.  Select which fields an override rule will be applied to: 
   +  **Fields with name:** Select a field from the list of all available fields. Properties you add to a rule with this selector are only applied to this single field. 
   +  **Fields with name matching regex:** Specify fields to override with a regular expression. Properties you add to a rule with this selector are applied to all fields where the field name match the regex. 
   +  **Fields with type:** Select fields by type, such as string, numeric, and so on. Properties you add to a rule with this selector are applied to all fields that match the selected type. 
   +  **Fields returned by query:** Select all fields returned by a specific query, such as A, B, or C. Properties you add to a rule with this selector are applied to all fields returned by the selected query. 

1.  Click **Add override property**. 

1.  Select the field option that you want to apply. 

1.  Enter options by adding values in the fields. To return options to default values, delete the white text in the fields. 

1.  Continue to add overrides to this field by clicking **Add override property**, or you can click **Add override** and select a different field to add overrides to. 

1.  When finished, click **Save** to save all panel edits to the dashboard. 

## Delete a field override
<a name="v9-panels-overrides-delete-a-field"></a>

 Delete a field override when you no longer need it. When you delete an override, the appearance of value defaults to its original format. This change impacts dashboards and dashboard users that rely on an affected panel. 

1.  Edit the panel that contains the override you want to delete. 

1.  In panel options side pane, scroll down until you see the overrides. 

1.  Click the override you want to delete and then click the associated trash icon. 

## View field overrides
<a name="v9-panels-overrides-view"></a>

 You can view field overrides in the panel display options. 

1.  Edit the panel that contains the overrides you want to view. 

1.  In panel options side pane, scroll down until you see the overrides. 

 The override settings that appear on the **All** tab are the same as the settings that appear on the **Overrides** tab. 

## Edit a field override
<a name="v9-panels-overrides-edit-a-field"></a>

 Edit a field override when you want to make changes to an override setting. The change you make takes effect immediately. 

1.  Edit the panel that contains the overrides you want to edit. 

1.  In panel options side pane, scroll down until you see the overrides. 

1.  Locate the override that you want to change. 

1.  Perform any of the following: 
   +  Edit settings on existing overrides or field selection parameters. 
   +  Delete existing override properties by clicking the **X** next to the property. 
   +  Add an override properties by clicking **Add override property**. 

# Configure value mappings
<a name="v9-panels-configure-value-mappings"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

 In addition to field overrides, value mapping is a technique that you can use to change the visual treatment of data that appears in a visualization. 

 Values mapped via value mappings bypass the unit formatting. This means that a text value mapped to a numerical value is not formatted using the configured unit. 

 If value mappings are present in a panel, then Grafana displays a summary in the side pane of the panel editor. 

**Note**  
 The new value mappings are not compatible with some visualizations, such as Graph (old), Text, and Heatmap. 

## Types of value mappings
<a name="v9-panels-value-mappings-types"></a>

 Grafana supports the following value mappings: 
+  **Value:** Maps text values to a color or different display text. For example, you can configure a value mapping so that all instances of the value **10** appear as **Perfection\$1** rather than the number. 
+  **Range:** Maps numerical ranges to a display text and color. For example, if a value is within a certain range, you can configure a range value mapping to display **Low** or **High** rather than the number. 
+  **Regex:** Maps regular expressions to replacement text and a color. For example, if a value is **www.example.com**, you can configure a regex value mapping so that Grafana displays **www** and truncates the domain. 
+  **Special** Maps special values like **Null**, **NaN** (not a number), and boolean values like **true** and **false** to a display text and color. For example, you can configure a special value mapping so that **null** values appear as **N/A**. 

 You can also use the dots on the left to drag and reorder value mappings in the list. 

## Map a value
<a name="v9-panels-value-mappings-map-a-value"></a>

 Map a value when you want to format a single value. 

1.  Open a panel for which you want to map a value. 

1.  In panel display options, locate the **Value mappings** section and click **Add value mappings**. 

1.  Click **Add a new mapping** and then select **Value**. 

1.  Enter the value for Grafana to match. 

1.  (Optional) Enter display text. 

1.  (Optional) Set the color. 

1.  Click **Update** to save the value mapping. 

## Map a range
<a name="v9-panels-value-mappings-map-a-range"></a>

 Map a range of values when you want to format multiple, continuous values. 

1.  Edit the panel for which you want to map a range of values. 

1.  In panel display options, in the **Value mappings** section, click **Add value mappings**. 

1.  Click **Add a new mapping** and then select **Range**. 

1.  Enter the beginning and ending values in the range for Grafana to match. 

1.  (Optional) Enter display text. 

1.  (Optional) Set the color. 

1.  Click **Update** to save the value mapping. 

## Map a regular expression
<a name="v9-panels-value-mappings-map-a-regex"></a>

 Map a regular expression when you want to format the text and color of a regular expression value. 

1.  Edit the panel for which you want to map a regular expression. 

1.  In the **Value mappings** section of the panel display options, click **Add value mappings**. 

1.  Click **Add a new mapping** and then select **Regex**. 

1.  Enter the regular expression pattern for Grafana to match. 

1.  (Optional) Enter display text. 

1.  (Optional) Set the color. 

1.  Click **Update** to save the value mapping. 

## Map a special value
<a name="v9-panels-value-mappings-map-a-special-value"></a>

 Map a special value when you want to format uncommon, boolean, or empty values. 

1.  Edit the panel for which you want to map a special value. 

1.  In panel display options, locate the **Value mappings** section and click **Add value mappings**. 

1.  Click **Add a new mapping** and then select **Special**. 

1.  Select the special value for Grafana to match. 

1.  (Optional) Enter display text. 

1.  (Optional) Set the color. 

1.  Click **Update** to save the value mapping. 

## Edit a value mapping
<a name="v9-panels-value-mappings-edit-a-value"></a>

 You can change a value mapping at any time. 

1.  Edit the panel that contains the value mapping you want to edit. 

1.  In the panel display options, in the **Value mappings** section, click **Edit value mappings**. 

1.  Make the changes and click **Update**. 

# Configure a legend
<a name="v9-panels-configure-legend"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

A panel includes a legend that you can use to interpret data displayed in a visualization. Each legend option adds context and clarity to the data illustrated in a visualization.

## Isolating series data in a visualization
<a name="v9-panels-legend-isolate"></a>

Visualizations can often be visually complex, and include many data series. You can simplify the view by removing series data from the visualization, which isolates the data you want to see. Grafana automatically creates a new override in the **Override** tab.

When you apply your changes, the visualization changes appear to all users of the panel.

**To isolate series data in a visualization**

1. Open the panel.

1. In the legend, select the label of the series you want to isolate.

   The system removes from view all other series data.

1. To incrementally add series data to an isolated series, press the **Ctrl** or **Command** key and select the label of the series you want to add.

1. To revert back to the default view that includes all data, click any series label twice.

1. To save your changes so that they appear to all viewers of the panel, select **Apply**.

This topic currently applies to the following visualizations:
+ [Bar chart](v9-panels-bar-chart.md)
+ [Histogram](v9-panels-histogram.md)
+ [Pie chart](v9-panels-piechart.md)
+ [State timeline](v9-panels-state-timeline.md)
+ [Status history](v9-panels-status-history.md)
+ [Time series](v9-panels-time-series.md)

## Adding values to a legend
<a name="v9-panels-legend-add-values"></a>

As way to add more context to a visualization, you can add series data values to a legend. You can add as many values as you’d like; after you apply your changes, you can horizontally scroll the legend to see all values.

**To add values to a legend**

1. Edit a panel.

1. In the panel display options pane, locate the **Legend** section.

1. In the **Legend values** field, select the values you want to appear in the legend.

1. Choose **Apply** to save your changes are navigate back to the dashboard.

## Changing a series color
<a name="v9-panels-legend-change-color"></a>

By default, Grafana specifies the color of your series data, which you can change.

**To change a series color**

1. Edit a panel.

1. In the legend, select the color bar associated with the series.

1. Select a pre-set color or a custom color from the color palette.

1. Choose **Apply** to save your changes are navigate back to the dashboard.

## Sort series
<a name="v9-panels-legend-sort"></a>

You can change legend mode to **Table** and choose [Calculation types](v9-panels-calculation-types.md) to be displayed in the legend. Select the calculation name header in the legend table to sort the values in the table in ascending or descending order.

The sort order affects the positions of the bars in the Bar chart panel as well as the order of stacked series in the Time series and Bar chart panels.

**Note**  
This feature is only supported in these panels: Bar chart, Histogram, Time series, XY Chart.

# Calculation types
<a name="v9-panels-calculation-types"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

 The following table contains a list of calculations you can perform in Grafana. You can find these calculations in the **Transform** tab and in the bar gauge, gauge, and stat visualizations. 


|  Calculation  |  Description  | 
| --- | --- | 
|  All nulls  |  True when all values are null  | 
|  All zeros  |  True when all values are 0  | 
|  Change count  |  Number of times the field’s value changes  | 
|  Count  |  Number of values in a field  | 
|  Delta  |  Cumulative change in value, only counts increments  | 
|  Difference  |  Difference between first and last value of a field  | 
|  Difference percent  |  Percentage change between first and last value of a field  | 
|  Distinct count  |  Number of unique values in a field  | 
|  First (not null)  |  First, not null value in a field  | 
|  Max  |  Maximum value of a field  | 
|  Mean  |  Mean value of all values in a field  | 
|  Variance  |  Variance of all values in a field  | 
|  StdDev  |  Standard deviation of all values in a field  | 
|  Min  |  Minimum value of a field  | 
|  Min (above zero)  |  Minimum, positive value of a field  | 
|  Range  |  Difference between maximum and minimum values of a field  | 
|  Step  |  Minimal interval between values of a field  | 
|  Total  |  Sum of all values in a field  | 

# Annotating visualizations
<a name="v9-panels-annotate-visualizations"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

Annotations provide a way to mark points on the graph with rich events. 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.

**Native annotations**

Grafana comes with a native annotation store and the ability to add annotation events directly from the graph panel or through the HTTP API.

**Adding an annotation**

1. In the dashboard, click on the **Time series** panel. A context menu will appear.

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

1. Add an annotation description, and optionally, tags.

1. Click **Save**.

Alternatively, to add an annotation, `Ctrl+Click` or `Cmd+Click` on the **Time series** panel and the **Add annotation** popover will appear.

**Adding region annotation**

1. In the dashboard, `Ctrl+Click` or `Cmd+Click`on the **Time series** panel.

1. In the context menu, click on **Add annotation**.

1. Add an annotation description, and optionally, tags.

1. Click **Save**.

**Editing an annotation**

1. In the dashboard, hover over an annotation indicator on the **Time series** panel.

1. Click on the edit (pencil) icon in the annotation tooltip.

1. Modify the description, and optionally, tags.

1. Click **Save**.

**Deleting an annotation**

1. In the dashboard, hover over an annotation indicator on the **Time series** panel.

1. Click on the trash icon in the annotation tooltip.

**Built-in query**

After you added 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 and show them on the panel where they were created. This includes alert state history annotations. You can stop annotations from being fetched and drawn by opening the **Annotations** settings (through Dashboard cogs menu) and modifying the query named `Annotations & Alerts (Built-in)`.

When you copy a dashboard using the **Save As** feature, it will get a new dashboard id so annotations created on 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. This only works if the annotations on the source dashboard had tags to filter by.

**Querying by tag**

You can create new queries to fetch annotations from the native annotation store through the `-- Grafana --` data source by setting** Filter by** to `Tags`.

Grafana v8.1 and later versions also support typeahead of existing tags, provide at least one tag.

For example, create an annotation query name `outages` and specify a tag `outage`. This query will show all annotations (from any dashboard or through 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.

In Grafana v5.3\$1 it’s possible to use template variables in the tag query. So if you have a dashboard showing stats for different services and a template variable that dictates which services to show, you can now use the same template variable in your annotation query to only show annotations for those services.

**Querying other data sources**

Annotation events are fetched through annotation queries. To add a new annotation query to a dashboard open the dashboard settings menu, then select **Annotations**. This will open the dashboard annotations settings view. To create a new annotation query hit the **New** button.

Specify a name for the annotation query. This name is given to the toggle (check box) that will allow you to enable or disable showing annotation events from this query. For example you might have two annotation queries named `Deploys` and `Outages`. The toggle will allow you to decide what annotations to show.

**Annotation query details**

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

# The panel inspect view
<a name="v9-panels-panel-inspector"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

 The panel inspect view, which you can open via the panel menu, helps you understand and troubleshoot your panels. You can inspect the raw data for any Grafana panel, export that data to a comma-separated values (CSV) file, view query requests, and export panel and data JSON. 

**Note**  
 Not all panel types include all tabs. For example, dashboard list panels do not have raw data to inspect, so they do not display the Stats, Data, or Query tabs. 

 The panel inspector consists of the following options: 

1.  The panel inspector displays **Inspect: [NameOfPanelBeingInspected]** at the top of the pane. Click the arrow in the upper right corner to expand or reduce the pane. 

1.  **Data tab -** Shows the raw data returned by the query with transformations applied. Field options such as overrides and value mappings are not applied by default. 

1.  **Stats tab -** Shows how long your query takes and how much it returns. 

1.  **JSON tab -** Allows you to view and copy the panel JSON, panel data JSON, and data frame structure JSON. This is useful if you are provisioning or administering Grafana. 

1.  **Query tab -** Shows you the requests to the server sent when Grafana queries the data source. 

1.  **Error tab -** Shows the error. Only visible when query returns error. 

## Download raw query results
<a name="v9-panels-raw-query-results"></a>

 Grafana generates a CSV file that contains your data, including any transformations to that data. You can choose to view the data before or after the panel applies field options or field option overrides. 

1.  Edit the panel that contains the query data you want to download. 

1.  In the query editor, click **Query Inspector**. 

1.  Click **Data**. 

    If your panel contains multiple queries or queries multiple nodes, then you have additional options. 
   +  **Select result**: Choose which result set data you want to view. 
   +  **Transform data** 
   +  **Join by time**: View raw data from all your queries at once, one result set per column. Click a column heading to reorder the data. 

1.  To see data before the system applies field overrides, click the **Formatted data** toggle. 

1.  To download a CSV file specifically formatted for Excel, click the **Download for Excel** toggle . 

1.  Click **Download CSV**. 

## Inspect query performance
<a name="v9-panels-query-performance"></a>

 The **Stats** tab displays statistics that tell you how long your query takes, how many queries you send, and the number of rows returned. This information can help you troubleshoot your queries, especially if any of the numbers are unexpectedly high or low. 

1.  Edit the panel that contains the query with performance you want to inspect. 

1.  In the query editor, click **Query Inspector**. 

1.  Click **Stats**. 

 Statistics are displayed in read-only format. 

## Inspect query request and response
<a name="v9-panels-query-request-response"></a>

 Inspect query request and response data when you want to troubleshoot a query that returns unexpected results, or fails to return expected results. 

1.  Edit the panel that contains the query you want to export. 

1.  In the query editor, click **Query Inspector**. 

1.  Click **Refresh**. 

    The panel populates with response data. 

1.  Make adjustments, as necessary and re-run the query. 

1.  To download the query request and response data, click the **Copy to clipboard** icon and paste the results into another application. 

# Visualizations available in Grafana version 9
<a name="v9-panels-viz"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

Grafana offers a variety of visualizations to support different use cases. This section of the documentation highlights the built-in panels, their options and typical usage.

A common panel to get started with, and to learn the basics of using panels, is the [Time series panel](v9-panels-time-series.md) panel.

**Topics**
+ [Alert list panel](v9-panels-alert-list.md)
+ [Annotations panel](v9-panels-annotations.md)
+ [Bar chart panel](v9-panels-bar-chart.md)
+ [Bar gauge](v9-panels-bar-gauge.md)
+ [Candlestick panel](v9-panels-candlestick.md)
+ [Canvas panel](v9-panels-canvas.md)
+ [Clock panel](v9-panels-clock.md)
+ [Dashboard list](v9-panels-dashboard-list.md)
+ [Gauge panel](v9-panels-gauge.md)
+ [Geomap panel](v9-panels-geomap.md)
+ [Graph panel](v9-panels-graph.md)
+ [Heatmap panel](v9-panels-heatmap.md)
+ [Histogram panel](v9-panels-histogram.md)
+ [Logs panel](v9-panels-logs.md)
+ [News panel](v9-panels-news.md)
+ [Node graph panel](v9-panels-node-graph.md)
+ [Pie chart panel](v9-panels-piechart.md)
+ [Plotly panel](v9-panels-plotly.md)
+ [Sankey panel](v9-panels-sankey.md)
+ [Scatter panel](v9-panels-scatter.md)
+ [Stat panel](v9-panels-stat.md)
+ [State timeline panel](v9-panels-state-timeline.md)
+ [Status history panel](v9-panels-status-history.md)
+ [Table panel](v9-panels-table.md)
+ [Text panel](v9-panels-text.md)
+ [Time series panel](v9-panels-time-series.md)
+ [Traces panel (Beta)](v9-panels-traces.md)
+ [WindRose](v9-panels-windrose.md)

# Alert list panel
<a name="v9-panels-alert-list"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

The alert list panel displays your dashboards alerts. You can configure the list to show current state or recent state changes. For more information about alerts, see [Alerts in Grafana version 9](v9-alerts.md).

Use these settings to refine your visualization.

## Options
<a name="v9-panels-alert-list-options"></a>
+  **Group mode** – Choose **Default grouping** to show alert instances grouped by their alert rule, or **Custom grouping** to group alert instances by a custom set of labels.
+  **Max Items** – Set the maximum number of alerts to list.
+  **Sort order** – Select how to order the alerts displayed.
  +  **Alphabetical (asc)** – Alphabetical order
  +  **Alphabetical (desc)** – Reverse alphabetical order
  +  **Importance** – By importance according to the following values, with 1 being the highest:
    + `alerting` or `firing`: 1
    + `no_data`: 2
    + `pending`: 3
    + `ok`: 4
    + `paused` or `inactive`: 5
+  **Alerts from this dashboard** – Show alerts only from the dashboard that the alert list is in.

## Filter
<a name="v9-panels-alert-filter"></a>

Use the following options to filter the alerts to match the query, folder, or tags that you choose:
+  **Alert name** – Enter an alert name query. 
+  **Alert instance label** – Filter alert instances using label querying. For example, `{severity="critical", instance=~"cluster-us-.+"}`.
+  **Folder** – Select a folder. Only alerts from dashboards in the selected folder will be displayed.
+  **Datasource** – Filter alerts from the selected data source. 

## State filter
<a name="v9-panels-alert-state-filter"></a>

Choose which alert states to display in this panel.
+ Alerting / Firing
+ Pending
+ No data
+ Normal
+ Error

# Annotations panel
<a name="v9-panels-annotations"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

The Annotations panel shows a list of available annotations you can use to view annotated data. Various options are available to filter the list based on tags and on the current dashboard.

## Annotation query
<a name="v9-panels-annotations-query"></a>

The following options control the source query for the list of annotations.

**Query Filter**

Use the query filter to create a list of annotations from all dashboards in your organization or the current dashboard in which this panel is located. It has the following options:
+ All dashboards - List annotations from all dashboards in the current organization.
+ This dashboard - Limit the list to the annotations on the current dashboard.

**Time Range**

Use the time range option to specify whether the list should be limited to the current time range. It has the following options:
+ None - no time range limit for the annotations query.
+ This dashboard - Limit the list to the time range of the dashboard where the annotation list panel is available.

**Tags**

Use the tags option to filter the annotations by tags. You can add multiple tags in order to refine the list.

**Note**  
Optionally, leave the tag list empty and filter on the fly by selecting tags that are listed as part of the results on the panel itself.

*Limit*

Use the limit option to limit the number of results returned.

## Display
<a name="v9-panels-annotations-display"></a>

These options control additional metadata included in the annotations panel display.

**Show user**

Use this option to show or hide which user created the annotation.

**Show time**

Use this option to show or hide the time the annotation creation time.

**Show Tags**

Use this option to show or hide the tags associated with an annotation. *NB*: You can use the tags to live-filter the annotation list on the panel itself.

## Link behavior
<a name="v9-panels-annotations-links"></a>

**Link target**

Use this option to chose how to view the annotated data. It has the following options.
+ Panel - This option will take you directly to a full-screen view of the panel with the corresponding annotation
+ Dashboard - This option will focus the annotation in the context of a complete dashboard

**Time before**

Use this option to set the time range before the annotation. Use duration string values like “1h” = 1 hour, “10m” = 10 minutes, etc.

**Time after**

Use this option to set the time range after the annotation.

# Bar chart panel
<a name="v9-panels-bar-chart"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

This panel visualization allows you to graph categorical data.

## Supported data formats
<a name="v9-panels-bar-chart-formats"></a>

Only one data frame is supported and it needs to have at least one string field that will be used as the category for an X or Y axis and one or more numerical fields. The following is an example of data formats:


|  Browser  |  Market share  | 
| --- | --- | 
|  Chrome  |  50  | 
|  Internet Explorer  |  17.5  | 

If you have more than one numerical field, the panel shows grouped bars.

### Visualizing time series or multiple result sets
<a name="v9-panels-bar-chart-visualization"></a>

If you have multiple time series or tables, you first need to join them using a join, or reduce transform. For example, if you have multiple time series and you want to compare their last and max value, add the **Reduce** transform and specify **Max** and **Last **as options under **Calculations**.

## Bar chart options
<a name="v9-panels-bar-chart-options"></a>

Use these options to refine your visualizations:

**Orientation**
+  **Auto ** – Grafana decides the bar orientation based on the panel dimensions.
+  **Horizontal** – Makes the X axis the category axis.
+  **Vertical** – Makes the Y axis the category axis.

**X-axis tick label maximum length** sets the maximum length of bar chart labels. Labels longer than the maximum length are truncated (with ellipses).

**Bar labels minimum spacing** sets the minimum spacing between bar labels.

**Show values**

Controls whether values are shown on top of or to the left of bars.
+  **Auto ** – Values are shown if there is space.
+  **Always** – Always show values.
+  **Never** – Never show values.

**Stacking**

Controls bar chart stacking.
+  **Off** – Bars will not be stacked.
+  **Normal** – Bars will be stacked on top of each other.
+  **Percent** – Bars will be stacked on top of each other, and the height of each bar is the percentage of the total height of the stack (all bar stacks will be the same height, adding up to 100 percent).

**Group width** controls the width of groups. 0=min and 1=max width.

**Bar width** controls the width of bars. 0=min and 1=max width.

**Bar radius** controls the radius of the bars, 0 = minimum and 0.5 = maximum radius.

**Highlight full area on hover** controls if the surrounding area of the bar is highlighted when you hover over the bar with a pointer.

**Line width** controls line width of the bars.

**Fill opacity** controls the fill opacity of the bars.

**Gradient mode** sets the mode of the gradient fill. Fill gradient is based on the line color. To change the color, use the standard color scheme field option. Gradient appearance is influenced by the **Fill opacity** setting.
+  **None ** – no gradient fill, this is the default setting.
+  **Opacity** – Transparency of the gradient is calculated based on the values on the y-axis. Opacity of the fill is increasing with the values on the Y-axis.
+  **Hue** – Gradient color is generated based on the hue of the line color.

**Tooltip mode** – When you hover your cursor over the visualization, Grafana can display tooltips. Choose how tooltips behave.
+  **Single ** – The hover tooltip shows only a single series, the one that you are hovering over on the visualization.
+  **All** – The hover tooltip shows all series in the visualization. Grafana highlights the series that you are hovering over in bold in the series list in the tooltip.
+  **Hidden** – Do not display the tooltip when you interact with the visualization.

**Note**  
You can use an override to hide individual series from the tooltip.

**Legend mode** – Use these settings to refine how the legend appears in your visualization. For more information, see [Configure a legend](v9-panels-configure-legend.md).
+  **List ** – Displays the legend as a list. This is a default display mode of the legend.
+  **Table** – Displays the legend as a table.
+  **Hidden** – Hides the legend.

**Legend placement** – Choose where to place the legend.
+  **Bottom ** – Below the graph.
+  **Right** – To the right of the graph.

**Legend calculations** – Choose which of the standard calculations to show in the legend. You can have more than one.

**Text size** – Enter a value to change the size of the text on your bar chart.

**Axis** – Use the following field settings to refine how your axes display. Some field options will not affect the visualization until you click outside of the field option box you are editing or press Enter.
+  **Placement ** – Sets the placement of the Y-axis.
+  **Auto** – Grafana automatically assigns Y-axis to the series. When there are two or more series with different units, then Grafana assigns the left axis to the first unit and right to the following units.
+  **Left** – Display all Y-axes on the left side.
+  **Right** – Display all Y-axes on the right side.
+  **Hidden** – Hide all Y-axes.
+  **Label** – Set a Y-axis text label. If you have more than one Y-axis, then you can assign different labels with an override.
+  **Width** – Set a fixed width of the axis. By default, Grafana dynamically calculates the width of an axis.

  By setting the width of the axis, data with different axes types can share the same display proportions. This makes it easier to compare more than one graph’s worth of data because the axes are not shifted or stretched within visual proximity of each other.
+  **Soft min and soft max** – Set a soft min and soft max option for better control of Y-axis limits. By default, Grafana sets the range for the Y-axis automatically based on the dataset.

  Soft min and soft max settings can prevent blips from turning into mountains when the data is mostly flat, and hard min or max derived from standard min and max field options can prevent intermittent spikes from flattening useful detail by clipping the spikes past a defined point.

  You can set standard min/max options to define hard limits of the Y-axis.

# Bar gauge
<a name="v9-panels-bar-gauge"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

The bar gauge simplifies your data by reducing every field to a single value. You choose how Grafana calculates the reduction.

This panel can show one or more bar gauges depending on how many series, rows, or columns your query returns.

## Value options
<a name="v9-panels-bar-gauge-value"></a>

Use the following options to refine how your visualization displays the value:

**Show** – Choose how Grafana displays your data.

**Calculate** – Show a calculated value based on all rows.
+ **Calculation** – Select a reducer function that Grafana will use to reduce many fields to a single value. For a list of available calculations, refer to Calculation types.
+ **Fields** – Select the fields display in the panel.

**All values** – Show a separate stat for every row. If you select this option, then you can also limit the number of rows to display.
+ **Limit** – The maximum number of rows to display. Default is 5,000.
+ **Fields** – Select the fields display in the panel.

## Bar gauge options
<a name="v9-panels-bar-gauge-options"></a>

Adjust how the bar gauge is displayed.

**Orientation** – Choose a stacking direction.
+ **Auto** – Grafana selects what it thinks is the best orientation.
+ **Horizontal** – Bars stretch horizontally, left to right.
+ **Vertical** – Bars stretch vertically, bottom to top.

**Display mode** – Choose a display mode.
+ **Gradient** – Threshold levels define a gradient.
+ **Retro LCD** – The gauge is split into small cells that are lit or unlit.
+ **Basic** – Single color based on the matching threshold.

**Show unfilled area** – Select this if you want to render the unfilled region of the bars as dark gray. Not applicable to Retro LCD display mode.

**Min width**

Limit the minimum width of the bar column in the vertical direction.

Automatically show x-axis scrollbar when there is a large amount of data.

**Min height**

Limit the minimum height of the bar row in the horizontal direction.

Automatically show y-axis scrollbar when there is a large amount of data.

# Candlestick panel
<a name="v9-panels-candlestick"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

The Candlestick panel allows you to visualize data that includes a number of consistent dimensions focused on price movement. The Candlestick panel includes an Open-High-Low-Close (OHLC) mode, as well as support for additional dimensions based on time series data.

The Candlestick panel builds upon the foundation of the [Time series panel](v9-panels-time-series.md) and includes many common configuration settings.

**Mode**

The mode options allow you to toggle which dimensions are used for the visualization.
+ **Candles** limits the panel dimensions to the open, high, low, and close dimensions used by candlestick visualizations.
+ **Volume** limits the panel dimension to the volume dimension.
+ **Both** is the default behavior for the candlestick panel. It includes both candlestick and volume visualizations.

**Candle style**
+ **Candles** is the default display style and creates candle-style visualizations between the open and close dimensions.
+ **OHLC Bars** displays the four core dimensions open, high, low, and close values.

**Color strategy**
+ **Since Open** is the default behavior. This mode will utilize the *Up* color (below) if the intra-period price movement is positive. In other words, if the value on close is greater or equal to the value on open, the *Up* color is used.
+ **Since Prior Close** is an alternative display method where the color of the candle is based on the interperiod price movement or change in value. In other words, if the value on open is greater than the previous value on close, the *Up* color is used. If the value on open is lower than the previous value on close, the *Down* color is used. *This option also triggers the hollow candlestick visualization mode*. Hollow candlesticks indicate that the intra-period movement is positive (value is higher on close than on open), filled candlesticks indicate the intra-period change is negative (value is lower on close than on open). To learn more, see the [explanation of the differences](https://thetradingbible.com/how-to-read-hollow-candlesticks).

**Up & Down Colors**

The **Up color** and **Down color** options select which colors are used when the price movement is up or down. The *Color strategy* above will determine if intra-period or inter-period price movement is used to select the candle or OHLC bar color.

**Open, High, Low, Close**

The candlestick panel will attempt to map fields to the appropriate dimension. The **Open**, **High**, **Low**, and **Close** options allow you to map your data to these dimensions if the panel is unable to do so.

**Note**  
These values are hidden from the legend.
+ **Open** corresponds to the starting value of the given period.
+ **High** corresponds to the highest value of the given period.
+ **Low** corresponds to the lowest value of the given period.
+ **Close** corresponds to the final (end) value of the given period.
+ **Volume** corresponds to the sample count in the given period. (e.g. number of trades)

**Additional fields**

The candlestick panel is based on the time series panel. It can visualize additional data dimensions beyond open, high, low, close, and volume The **Include** and **Ignore** options allow the panel to visualize other included data such as simple moving averages, Bollinger bands and more, using the same styles and configurations available in the [Time series panel](v9-panels-time-series.md).

# Canvas panel
<a name="v9-panels-canvas"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

Canvas is a new panel that combines the power of Grafana with the flexibility of custom elements. Canvas visualizations are extensible form-built panels that allow you to explicitly place elements within static and dynamic layouts. This empowers you to design custom visualizations and overlay data in ways that aren’t possible with standard Grafana panels, all within Grafana’s UI. If you’ve used popular UI and web design tools, then designing Canvas panels will feel very familiar.

## Elements
<a name="v9-panels-canvas-elements"></a>

**Metric value**

The metric value element enables you to easily select the data you want to display on canvas. This element has a unique “edit” mode that can be triggered either through the context menu “Edit” option or by double-clicking. When in edit mode you can select which field data that you want to display.

**Text**

The text element enables you to easily add text to the canvas. The element also supports an editing mode, triggered via either double-clicking or the edit menu option in the context menu.

**Rectangle**

The rectangle element enables you to add a basic rectangle to the canvas. Rectangle elements support displaying text (both fixed and field data) as well as can change background color based on data thresholds.

**Icon**

The icon element enables you to add a supported icon to the canvas. Icons can have their color set based on thresholds or value mappings.

## Canvas Editing
<a name="v9-panels-canvas-editing"></a>

**Inline editor**

Canvas introduces a new editing experience. You can now edit your canvas panel inline while in the context of dashboard mode.

**Context menu**

The context menu gives you access to common tasks. Supported functionality includes opening and closing the inline editor, duplicating an element, deleting an element, and more.

The context menu is triggered by a right click action over the panel or a given canvas element. When right clicking the panel, you are able to set a background image and easily add elements to the canvas.

When right clicking an element, you are able to edit, delete, and duplicate the element, or modify the element’s layer positioning.

## Canvas Options
<a name="v9-panels-canvas-options"></a>

**Inline editing**

The inline editing toggle enables you to lock or unlock the canvas panel. When turned off the canvas panel becomes *locked*, freezing elements in place and preventing unintended modifications.

# Clock panel
<a name="v9-panels-clock"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

The clock panel shows the current time or a countdown. It updates every second.
+ **Mode** – The default is **time**. If you choose **countdown**, set the **Countdown Deadline** to start the countdown.
+ **12 or 24 hour** – The options for showing the time are 12-hour format and 24-hour format.
+ **Timezone** – The time zones are supplied by the moment timezone library. The default is the time zone on your computer.
+ **Countdown Deadline** – Specify the time and date to count down to, if you have set **Mode** to **countdown**.
+ **Countdown End Text** – Specify the text to show when the countdown ends.
+ **Date/Time formatting options** – Customize the font size, weight, and date/time formatting. If you are showing a countdown and don't want to see the seconds ticking down, change the time format to `hh:mm` for the 24-hour clock or `h:mm A` for the 12-hour clock. For a complete list of options, see [ Display](https://momentjs.com/docs/#/displaying/).
+ **Bg Color** – Select a background color for the clock.

# Dashboard list
<a name="v9-panels-dashboard-list"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

The dashboard list visualization allows you to display dynamic links to other dashboards. The list can be configured to use starred dashboards, recently viewed dashboards, a search query, and dashboard tags.

On each dashboard load, this panel queries the dashboard list, always providing the most up-to-date results.

**Options**

Use these options to refine your visualization.
+ **Starred** – Display starred dashboards in alphabetical order.
+ **Recently viewed** – Display recently viewed dashboards in alphabetical order.
+ **Search** – Display dashboards by search query or tags. You must enter at least one value in **Query** or **Tags**. For the **Query** and **Tags** fields, variable interpolation is supported, for example, `$my_var` or `${my_var}`.
+ **Show headings** – The chosen list selection (Starred, Recently viewed, Search) is shown as a heading.
+ **Max items** – Sets the maximum number of items to list per section. For example, if you left this at the default value of 10 and displayed Starred and Recently viewed dashboards, then the panel would display up to 20 total dashboards, ten in each section.

**Search**

These options only apply if the **Search** option is selected.
+ **Query** – Enter the query you want to search by. Queries are case-insensitive, and partial values are accepted.
+ **Folder** – Select the dashboard folders that you want to display.
+ **Tags** – Here is where you enter your tags you want to search by. Existing tags will not appear as you type, and they *are* case sensitive.

**Note**  
When multiple tags and strings appear, the dashboard list displays those matching *all* conditions.

# Gauge panel
<a name="v9-panels-gauge"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

Gauge is a single-value visualization that can repeat a gauge for every series, column or row.

**Value options**

Use the following options to refine how your visualization displays the value:

**Show**

Choose how Grafana displays your data.

**Calculate**

Show a calculated value based on all rows.
+ **Calculation** – Select a reducer function that Grafana will use to reduce many fields to a single value. For a list of available calculations, refer to [Calculation types](v9-panels-calculation-types.md).
+ **Fields** – Select the fields to display in the panel.

**All values**

Show a separate stat for every row. If you select this option, then you can also limit the number of rows to display.
+ **Limit** – The maximum number of rows to display. Default is 5,000.
+ **Fields** – Select the fields to display in the panel.

**Gauge**

Adjust how the gauge is displayed.
+ **Show threshold labels** – Controls if threshold values are shown.
+ **Show threshold markers** – Controls if a threshold band is shown outside the inner gauge value band.

**Text size**

Adjust the sizes of the gauge text.
+ **Title** – Enter a numeric value for the gauge title size.
+ **Value** – Enter a numeric value for the gauge value size.

# Geomap panel
<a name="v9-panels-geomap"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

The Geomap panel visualization allows you to view and customize the world map using geospatial data. You can configure various overlay styles and map view settings to easily focus on the important location-based characteristics of the data.

## Map View
<a name="v9-panels-geomap-view"></a>

The map view controls the initial view of the map when the dashboard loads.

**Initial View**

The initial view configures how the GeoMap panel renders when the panel is first loaded.
+ **View** sets the center for the map when the panel first loads.
  + **Fit to data** fits the map view based on the data extents of Map layers and updates when data changes.
    + **Data** option allows selection of extent based on data from “All layers”, a single “Layer”, or the “Last value” from a selected layer.
    + **Layer** can be selected if fitting data from a single “Layer” or the “Last value” of a layer.
    + **Padding** sets padding in relative percent beyond data extent (not available when looking at “Last value” only).
    + **Max Zoom** sets the maximum zoom level when fitting data.
  + **Coordinates** sets the map view based on:
    + **Latitude**
    + **Longitude**
  + Default Views are also available including:
    + **(0°, 0°)**
    + **North America**
    + **South America**
    + **Europe**
    + **Africa**
    + **West Asia**
    + **South Asia**
    + **South-East Asia**
    + **East Asia**
    + **Australia**
    + **Oceania**
+ **Zoom** sets the initial zoom level.

## Map layers
<a name="v9-panels-geomap-layers"></a>

The Geomap visualization supports showing multiple layers. Each layer determines how you visualize geospatial data on top of the base map.

**Types**

There are three map layer types to choose from in the Geomap visualization.
+ [Markers layer](#v9-panels-geomap-markers) renders a marker at each data point.
+ [Heatmap layer](#v9-panels-geomap-heatmap) visualizes a heatmap of the data.
+ [GeoJSON layer](#v9-panels-geomap-geojson) renders static data from a GeoJSON file.

There are also five layer types that are currently in alpha.
+ [Night / Day layer (Alpha)](#v9-panels-geomap-nightday) renders a night or day region.
+ **Icon at last point (alpha)** renders an icon at the last data point.
+ **Dynamic GeoJSON (alpha)** styles a GeoJSON file based on query results.
+ **Route (alpha)** render data points as a route.
+ [Photos layer (Alpha)](#v9-panels-geomap-photos) renders a photo at each data point.

**Layer Controls**

The layer controls allow you to create layers, change their name, reorder and delete layers.
+ **Add layer** creates an additional, configurable data layer for the Geomap visualization. When you add a layer, you are prompted to select a layer type. You can change the layer type at any point during panel configuration. See the **Layer Types** section above for details on each layer type.
+ The layer controls allow you to rename, delete, and reorder the layers of the panel.
  + **Edit layer name** (pencil icon) renames the layer.
  + **Trash Bin** deletes the layer.
  + **Reorder** (six dots/grab handle) allows you to change the layer order. Data on higher layers will appear above data on lower layers. The panel will update the layer order as you drag and drop to help simplify choosing a layer order.

You can add multiple layers of data to a single Geomap panel in order to create rich, detailed visualizations.

**Location**

The Geomap panel needs a source of geographical data. This data comes from a database query, and there are four mapping options for your data.
+ **Auto** automatically searches for location data. Use this option when your query is based on one of the following names for data fields.
  + geohash: “geohash”
  + latitude: “latitude”, “lat”
  + longitude: “longitude”, “lng”, “lon”
  + lookup: “lookup”
+ **Coords** specifies that your query holds coordinate data. You will get prompted to select numeric data fields for latitude and longitude from your database query.
+ **Geohash** specifies that your query holds geohash data. You will be prompted to select a string data field for the geohash from your database query.
+ **Lookup** specifies that your query holds location name data that needs to be mapped to a value. You will be prompted to select the lookup field from your database query and a gazetteer. The gazetteer is the directory that is used to map your queried data to a geographical point.

## Markers layer
<a name="v9-panels-geomap-markers"></a>

The markers layer allows you to display data points as different marker shapes such as circles, squares, triangles, stars, and more.

Markers have many customization options.
+ **Marker Color** configures the color of the marker. The default `Single color` keeps all points a single color. There is an alternate option to have multiple colors depending on the data point values and the threshold set at the `Thresholds` section.
+ **Marker Size** configures the size of the marker. The default is `Fixed size`, which makes all marker sizes the same regardless of the data points. However, there is also an option to scale the circles to the corresponding data points. `Min` and `Max` marker size has to be set such that the Marker layer can scale within this range.
+ **Marker Shape** allows you to choose the shape, icon, or graphic to aid in providing additional visual context to your data. Choose from assets that are included with Grafana such as simple shapes or the Unicon library. You can also specify a URL containing an image asset. The image must be a scalable vector graphic (SVG).
+ **Fill opacity** configures the transparency of each marker.

## Heatmap layer
<a name="v9-panels-geomap-heatmap"></a>

The heatmap layer clusters various data points to visualize locations with different densities. To add a heatmap layer:

Click on the dropdown menu under Data Layer and choose `Heatmap`.

Similar to `Markers`, you are prompted with options to determine which data points to visualize and how you want to visualize them.
+ **Weight values** configure the intensity of the heatmap clusters. `Fixed value` keeps a constant weight value throughout all data points. This value should be in the range of 0\$11. Similar to Markers, there is an alternate option in the dropdown to automatically scale the weight values depending on data values.
+ **Radius** configures the size of the heatmap clusters.
+ **Blur** configures the amount of blur on each cluster.

## GeoJSON layer
<a name="v9-panels-geomap-geojson"></a>

The GeoJSON layer allows you to select and load a static GeoJSON file from the filesystem.
+ **GeoJSON URL** provides a choice of GeoJSON files that ship with Grafana.
+ **Default Style** controls which styles to apply when no rules above match.
  + **Color** configures the color of the default style
  + **Opacity** configures the default opacity
+ **Style Rules** apply styles based on feature properties
  + **Rule** allows you to select a *feature*, *condition*, and *value* from the GeoJSON file in order to define a rule. The trash bin icon can be used to delete the current rule.
  + **Color** configures the color of the style for the current rule
  + **Opacity** configures the transparency level for the current rule
+ **Add style rule** creates additional style rules.

## CARTO layer
<a name="v9-panels-geomap-carto"></a>

A CARTO layer is from [CARTO](https://carto.com/about-us/) Raster basemaps.

**Options**
+ **Theme**

   Choose a theme, either a **Light** theme, **Dark** theme, or **Auto** theme.
+ **Show labels** shows the Country details on top of the map.
+ **Opacity** from 0 (transparent) to 1 (opaque)

## XYZ tile layer
<a name="v9-panels-geomap-xyz"></a>

The XYZ tile layer is a map from a generic tile layer.

**Note**  
For more information about generic tile layers, see [Tiled Web Maps](https://en.wikipedia.org/wiki/Tiled_web_map), and [List of Open Street Map Tile Servers](https://wiki.openstreetmap.org/wiki/Tile_servers).

**Options**
+ **URL template**
**Note**  
Set a valid tile server url, with \$1z\$1/\$1x\$1/\$1y\$1 for example: `https://tile.openstreetmap.org/{z}/{x}/{y}.png`.
+ **Attribution** sets the reference string for the layer if displayed in [map controls](#v9-panels-geomap-controls)
+ **Opacity** from 0 (transparent) to 1 (opaque)

## Open Street Map layer
<a name="v9-panels-geomap-osm"></a>

A map from [Open Street Map](https://www.openstreetmap.org/about), a collaborative, free geographic world database.

**Options**
+ **Opacity** from 0 (transparent) to 1 (opaque)

## ArcGIS layer
<a name="v9-panels-geomap-arcgis"></a>

An [ArcGIS](https://services.arcgisonline.com/arcgis/rest/services) layer is a layer from an [ESRI](https://www.esri.com/en-us/about/about-esri/overview) ArcGIS MapServer.

**Options**
+ **Server Instance** to select from the following map types.
  + World Street Map
  + World Imagery
  + World Physical
  + Topographic
  + USA Topographic
  + World Ocean
  + Custom MapServer (see [XYZ](#v9-panels-geomap-xyz) for formatting)
    + URL template
    + Attribution
+ **Opacity** from 0 (transparent) to 1 (opaque)

## Night / Day layer (Alpha)
<a name="v9-panels-geomap-nightday"></a>

The Night / Day layer displays night and day regions based on the current time range.

**Note**  
For more information, see[Extensions for OpenLayers - DayNight](https://viglino.github.io/ol-ext/examples/layer/map.daynight.html).

**Options**
+ **Show** toggles time source from panel time range
+ **Night region color** picks color for night region
+ **Display sun** toggles sun icon
+ **Opacity** from 0 (transparent) to 1 (opaque)

## Photos layer (Alpha)
<a name="v9-panels-geomap-photos"></a>

The Photos layer renders a photo at each data point.

**Note**  
For more information, see [Extensions for OpenLayers - Image Photo Style](http://viglino.github.io/ol-ext/examples/style/map.style.photo.html).

**Options**
+ **Image Source Field**

  Select a string field containing image data in either of the following formats:
  + **Image URLs**
  + **Base64 encoded** image binary (`data:image/png;base64,…`)
+ **Kind**

   select the frame style around the images
  + **Square**
  + **Circle**
  + **Anchored**
  + **Folio**
+ **Crop** toggle if the images are cropped to fit
+ **Shadow** toggle a box shadow behind the images
+ **Border** set the border size around images
+ **Border color** set the border color around images
+ **Radius** set the overall size of images in pixels

## Map Controls
<a name="v9-panels-geomap-controls"></a>

The map controls interface contains the following options for map information and tool overlays.

**Zoom**

This section describes each of the zoom controls.

*Show zoom control*

Displays zoom controls in the upper left corner.

*Mouse wheel zoom*

Turns on or off using the mouse wheel for zooming in or out.

**Show attribution**

Displays attribution for basemap layers on the map.

**Show scale**

Displays scale information in the bottom left corner.

**Note**  
Displays units in [m]/[km].

**Show measure tools**

Displays measure tools in the upper right corner. Measurements appear only when this control is open.
+ **Click** to start measuring
+ **Continue clicking** to continue measurement
+ **Double-click** to end measurement

**Note**  
When you change measurement type or units, the previous measurement is removed from the map.  
If the control is closed and then re-opened, the most recent measurement is displayed.  
A measurement can be modified by clicking and dragging on it.

*Length*

Get the spherical length of a geometry. This length is the sum of the great circle distances between coordinates. For multi-part geometries, the length is the sum of the length of each part. Geometries are assumed to be in ‘EPSG:3857’.

You can choose the following units for length measurements:
+ **Metric (m/km)**
+ **Feet (ft)**
+ **Miles (mi)**
+ **Nautical miles (nmi)**

*Area*

Get the spherical area of a geometry. This area is calculated assuming that polygon edges are segments of great circles on a sphere. Geometries are assumed to be in ‘EPSG:3857’.

You can choose the following units for area measurements:
+ **Square Meters (m²)**
+ **Square Kilometers (km²)**
+ **Square Feet (ft²)**
+ **Square Miles (mi²)**
+ **Acres (acre)**
+ **Hectare (ha)**

**Show debug**

Displays debug information in the upper right corner of the map. This can be useful for debugging or validating a data source.
+ **Zoom** displays the current zoom level of the map.
+ **Center** displays the current **longitude**, and **latitude** of the map center.

**Tooltip**
+ **None** displays tooltips only when a data point is clicked.
+ **Details** displays tooltips when a pointer hovers over a data point.

# Graph panel
<a name="v9-panels-graph"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

A graph panel can render as a line, a path of dots, or a series of bars. This type of graph is versatile enough to display almost any time-series data.

## Data and field options
<a name="v9-panels-graph-data-and-field-options"></a>

When using graph visualizations, you can apply the following options:
+  [Transform data](v9-panels-xform.md) 
+ Alerts. This is the only type of visualization that allows you to set alerts. For more information, see [Alerts in Grafana version 9](v9-alerts.md).
+  [Configure thresholds](v9-panels-configure-thresholds.md) 

## Display options
<a name="v9-panels-graph-display-options"></a>

To refine your visualization, use the following settings:
+  **Bars** – Display values as a bar chart. 
+  **Lines** – Display values as a line graph. 
+  **Line width** – Specify the width of the line for a series. The default is 1.
+  **Staircase** – Draw adjacent points as staircase.
+  **Area fill** – Specify the amount of color fill for a series. The default is 1; 0 is none.
+  **Fill gradient** – Specify the degree of gradient on the area fill. The default is 0, which is no gradient; 10 is a steep gradient.
+  **Points** – Display points for values. 
+  **Point radius** – Control how large the points are.
+  **Alert thresholds** – Display alert thresholds and Regions on the panel.

### Stacking and null value
<a name="v9-panels-graph-stacking-and-null-value"></a>
+  **Stack** – Each series is stacked on top of another.
+  **Percent** – Each series is drawn as a percentage of the total of all series. This option is available when **Stack** is selected.
+  **Null value** – Specify how null values are displayed. *This is an important setting.* See the note below.
  +  **connected** – If there is a gap in the series, meaning one or more null values, the line will skip the gap and connect to the next non-null value. 
  +  **null** If there is a gap in the series, meaning a null value, the line in the graph will be broken and show the gap. This is the default setting.
  +  **null as zero** – If there is a gap in the series, meaning a null value, it will be displayed as a zero value in the graph panel.

**Important**  
If you are monitoring a server’s CPU load and the load reaches 100 percent, the server will lock up, and the agent sending statistics will not be able to collect the load statistic. This leads to a gap in the metrics, and using the default *null* setting means that Amazon Managed Grafana will show the gaps and indicate that something is wrong. If this is set to *connected*, it will be easy to miss this signal. 

### Hover tooltip
<a name="v9-panels-graph-hover-tooltip"></a>

Use these settings to change the appearance of the tooltip that appears when you pause over the graph visualization.
+  **Mode** – Determines how many series the hover tooltip shows.
  +  **All series** – The hover tooltip shows all series in the graph. In the series list in the tooltip, the Grafana workspace highlights the series that you are pausing on in bold.
  +  **Single** – The hover tooltip shows only a single series, the one that you are pausing on in the graph.
+  **Sort order** – Sorts the order of series in the hover tooltip if you have selected **All series** mode. When you pause on a graph, Amazon Managed Grafana displays the values associated with the lines. Generally, users are most interested in the highest or lowest values. Sorting these values can make it much easier to find the data that you want.
  +  **None** – The order of the series in the tooltip is determined by the sort order in your query. For example, you can sort the series alphabetically by series name.
  +  **Increasing** – The series in the hover tooltip are sorted by value and in increasing order, with the lowest value at the top of the list.
  +  **Decreasing** – The series in the hover tooltip are sorted by value and in decreasing order, with the highest value at the top of the list.

## Series overrides
<a name="v9-panels-graph-series-overrides"></a>

Series overrides allow a series in a graph panel to be rendered differently from the others. You can customize display options on a per-series basis or by using regex rules. For example, one series can have a thicker line width to make it stand out or be moved to the right Y-axis.

You can add multiple series overrides.

**To add a series override**

1. Choose **Add series override**.

1. In **Alias or regex**, type or select a series. Choose the field to see a list of available series.

   For example, `/Network.*/` would match two series named `Network out` and `Network in`.

1. Choose **\$1** and then select a style to apply to the series. You can add multiple styles to each entry.
+  **Bars** – Show series as a bar graph. 
+  **Lines** – Show series as a line graph. 
+  **Line fill** – Show a line graph with area fill. 
+  **Fill gradient** – Specify the area fill gradient amount.
+  **Line width** – Set line width.
+  **Null point mode** – Use this option to ignore null values or replace them with zero. This is important if you want to ignore gaps in your data.
+  **Fill below to** – Fill the area between two series.
+  **Staircase line** – Show series as a staircase line.
+  **Dashes** – Show a line with dashes. 
+  **Hidden Series** – Hide the series. 
+  **Dash Length** – Set the length of dashes in the line.
+  **Dash Space** – Set the length of the spaces between the dashes in the line.
+  **Points** – Show series as separate points.
+  **Point Radius** – Set the radius for point rendering.
+  **Stack** – Set the stack group for the series.
+  **Color** – Set the series color.
+  **Y-axis** – Set the series y-axis.
+  **Z-index** – Set the series z-index (rendering order). This option is important when you are overlaying different styles, such as bar charts and area charts.
+  Transform – Transform value to negative to render below the y-axis.
+  **Legend** – Control whether a series is shown in the legend.
+  **Hide in tooltip** – Control whether a series is shown in a graph tooltip.

## Axes
<a name="v9-panels-graph-axes"></a>

Use these options to control the display of axes in the visualization.

### Left Y/Right Y
<a name="v9-panels-graph-left-yright-y"></a>

Options are identical for both y-axes.
+  **Show** – Choose to show or hide the axis.
+  **Unit** – Choose the display unit for the y value.
+  **Scale** – Choose the scale to use for the y value: **linear**, or **logarithmic**. The default is **linear**.
+  **Y-Min** – The minimum y value. The default is **auto**.
+  **Y-Max** – The maximum Y value. The default is **auto**.
+  **Decimals** – Define how many decimals are displayed for the y value. The default is **auto**. 
+  **Label** – Specify the y axis label. The default is “",

### Y-Axes
<a name="v9-panels-graph-y-axes"></a>
+  **Align** – Align left and right y-axes by value. The default is unchecked/false.
+  **Level** – Enter the value to use for alignment of left and right y-axes, starting from Y=0. The default is 0. This option is available when **Align** is selected. 

### X-Axis
<a name="v9-panels-graph-x-axis"></a>
+  **Show** – Choose to show or hide the axis.
+  **Mode** – The display mode completely changes the visualization of the graph panel. It’s like three panels in one. The main mode is the time series mode with time on the x-axis. The other two modes are a basic bar chart mode with series on the x-axis instead of time and a histogram mode.
  +  **Time** (default) – The x-axis represents time and the data is grouped by time (for example, by hour, or by minute).
  +  **Series** – The data is grouped by series, and not by time. The y-axis still represents the value.
    +  **Value** – This is the aggregation type to use for the values. The default is **total** (summing the values together).
  +  **Histogram** – This option converts the graph into a histogram. A histogram is a kind of bar chart that groups numbers into ranges, often called buckets or bins. Taller bars show that more data falls in that range.

    For more information about histograms, see [Introduction to histograms and heatmaps](getting-started-grafanaui.md#introduction-to-histograms-and-heatmaps).
    +  **Buckets** – Sets the number of buckets to group the values by. If left empty, Amazon Managed Grafana tries to calculate a suitable number of buckets.
    +  **X-Min** – Filters out values from the histogram that are less than this minimum limit.
    +  **X-Max** – Filters out values that are greater than this maximum limit.

## Legend
<a name="v9-panels-graph-legend"></a>

Use these settings to refine how the legend appears in your visualization.

### Options
<a name="v9-panels-graph-legends-options"></a>
+  **Show** – Clear to hide the legend. The default is selected (true).
+  **As Table** – Select to display the legend in the table. The default is checked (true).
+  **To the right** – Select to display the legend to the right.
+  Width – Enter the minimum width for the legend in pixels. This option is available when **To the right** is selected.

### Values
<a name="v9-panels-graph-values"></a>

Additional values can be shown alongside the legend names.
+  **Min** – The minimum value returned from the metric query.
+  **Max** – The maximum value returned from the metric query.
+  **Avg** – The average value returned from the metric query.
+  **Current** – The last value returned from the metric query.
+  **Total** – The sum of all values returned from the metric query.
+  **Decimals** – How many decimals are displayed for legend values and graph hover tooltips.

Amazon Managed Grafana calculates the legend values on the client side. These legend values depend on the type of aggregation or point consolidation that your metric query is using. All the above legend values cannot be correct at the same time.

For example, if you plot a rate such requests/second, which is probably using average as an aggregator, the Total in the legend will not represent the total number of requests. It is just the sum of all data points received by Amazon Managed Grafana. 

### Hide series
<a name="v9-panels-graph-hide-series"></a>

Hide series when all values of a series from a metric query are of a specific value.
+  **With only nulls** – Value=null (default unchecked)
+  **With only zeroes** – Value=zero (default unchecked)

### Time regions
<a name="v9-panels-graph-time-regions"></a>

You can highlight specific time regions on the graph to make it easier to see, for example, weekends, business hours, and off-work hours. All configured time regions refer to UTC time.

# Heatmap panel
<a name="v9-panels-heatmap"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

The Heatmap panel visualization allows you to view histograms over time. For more information about histograms, refer to [Introduction to histograms and heatmaps](getting-started-grafanaui.md#introduction-to-histograms-and-heatmaps).

## Calculate from data
<a name="v9-panels-heatmap-calculate"></a>

This setting determines if the data is already a calculated heatmap (from the data source/transformer), or one that should be calculated in the panel.

**X Bucket**

This setting determines how the X-axis is split into buckets. You can specify a time interval in the **Size** input. For example, a time range of `1h` makes the cells 1-hour wide on the X-axis.

**Y Bucket**

This setting determines how the Y-axis is split into buckets.

**Y Bucket scale**

Select one of the following Y-axis value scales:
+ **linear** – Linear scale.
+ **log (base 2)** – Logarithmic scale with base 2.
+ **log (base 10)** – Logarithmic scale with base 10.

## Y Axes
<a name="v9-panels-heatmap-y-axes"></a>

Defines how the Y axis is displayed

 **Placement**
+ **Left** – On the left
+ **Right** – On the right
+ **Hidden** – Hidden

**Unit**

Unit configuration

**Decimals**

This setting determines decimal configuration.

**Min/Max value**

This setting configures the axis range.

**Reverse**

When selected, the axis appears in reverse order.

## Colors
<a name="v9-panels-heatmap-colors"></a>

The color spectrum controls the mapping between value count (in each bucket) and the color assigned to each bucket. The leftmost color on the spectrum represents the minimum count and the color on the right most side represents the maximum count. Some color schemes are automatically inverted when using the light theme.

You can also change the color mode to Opacity. In this case, the color will not change but the amount of opacity will change with the bucket count
+ **Mode**
  + **Scheme** – Bucket value represented by cell color.
    + **Scheme** – If the mode is **scheme**, then select a color scheme.
  + **opacity** – Bucket value represented by cell opacity. Opaque cell means maximum value.
    + **Color** – Cell base color.
    + **Scale** – Scale for mapping bucket values to the opacity.
      + **linear** – Linear scale. Bucket value maps linearly to the opacity.
      + **sqrt** – Power scale. Cell opacity calculated as `value ^ k`, where `k` is a configured **Exponent** value. If exponent is less than `1`, you will get a logarithmic scale. If exponent is greater than `1`, you will get an exponential scale. In case of `1`, scale will be the same as linear.
    + **Exponent** – value of the exponent, greater than `0`.

**Start/end color from value**

By default, Grafana calculates cell colors based on minimum and maximum bucket values. With Min and Max you can overwrite those values. Consider a bucket value as a Z-axis and Min and Max as Z-Min and Z-Max, respectively.
+ **Start** – Minimum value using for cell color calculation. If the bucket value is less than Min, then it is mapped to the “minimum” color. The series min value is the default value.
+ **End** – Maximum value using for cell color calculation. If the bucket value is greater than Max, then it is mapped to the “maximum” color. The series max value is the default value.

## Cell display
<a name="v9-panels-heatmap-cell"></a>

Use cell display settings to refine the visualization of the cells in your heatmap.

## Additional display options
<a name="v9-panels-heatmap-options"></a>

**Tooltip**
+ **Show tooltip** – Show heatmap tooltip.
+ **Show Histogram** – Show a Y-axis histogram on the tooltip. A histogram represents the distribution of the bucket values for a specific timestamp.

**Legend**

Choose whether you want to display the heatmap legend on the visualization.

**Exemplars**

Set the color used to show exemplar data.

# Histogram panel
<a name="v9-panels-histogram"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

The histogram visualization calculates the distribution of values and presents them as a bar chart. The Y-axis and the height of each bar represent the count of values that fall into each bracket while the X-axis represents the value range.

Histogram visualization supports time series and any table results with one or more numerical fields.

## Supported formats
<a name="v9-panels-histogram-formats"></a>

Histogram visualization supports time series and any table results with one or more numerical fields.

## Display options
<a name="v9-panels-histogram-options"></a>

Use these options to refine your visualizations:

**Bucket size**

The size of the buckets. Leave this empty for automatic bucket sizing (\$110% of the full range).

**Bucket offset**

If the first bucket should not start at zero. A non-zero offset shifts the aggregation window. For example, 5-sized buckets that are 0–5, 5–10, 10–15 with a default 0 offset would become 2–7, 7–12, 12–17 with an offset of 2; offsets of 0, 5, or 10, in this case, would effectively do nothing. Typically, this option would be used with an explicitly defined bucket size rather than automatic. For this setting to affect, the offset amount should be greater than 0 and less than the bucket size; values outside this range will have the same effect as values within this range.

**Combine series**

This will merge all series and fields into a combined histogram.

**Line width** controls line width of the bars.

**Fill opacity** controls the fill opacity of the bars.

**Gradient mode** sets the mode of the gradient fill. Fill gradient is based on the line color. To change the color, use the standard color scheme field option. Gradient appearance is influenced by the Fill opacity setting.
+  **None ** – No gradient fill, this is the default setting.
+  **Opacity** – Transparency of the gradient is calculated based on the values on the Y-axis. Opacity of the fill is increasing with the values on the Y-axis.
+  **Hue** – Gradient color is generated based on the hue of the line color.

**Tooltip mode** When you hover your cursor over the graph, Grafana can display tooltips. Choose how tooltips behave:
+  **Single** – The hover tooltip shows only the series that you are hovering over.
+  **All** – The hover tooltip shows all the series in the visualization. Grafana highlights the series that you are hovering over in bold in the series list in the tooltip.
+  **Hidden** – Do not display the tooltip. 

**Note**  
Use an override to hide individual series from the tooltip.

## Legend options
<a name="v9-panels-histogram-legend"></a>

When the legend option is enabled, it can show either the value mappings or the threshold brackets. To show the value mappings in the legend, it’s important that the Color scheme option under standard options is set to Single color or Classic palette. To see the threshold brackets in the legend, set the Color scheme to From thresholds.

**Legend mode** Use these settings to refine how the legend appears in your visualization.
+  **List ** – Displays the legend as a list. This is a default display mode of the legend.
+  **Table** – Displays the legend as a table.
+  **Hidden** – Hides the legend.

**Legend placement** Choose where to place the legend.
+  **Bottom ** – Below the graph.
+  **Right** – To the right of the graph.

**Legend Values**

Choose which of the standard calculations to show in the legend. You can have more than one. For more information, see [Calculation types](v9-panels-calculation-types.md).

**Legend calculations**

Choose which calculations to show in the legend. You can select more than one.

# Logs panel
<a name="v9-panels-logs"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

The logs panel visualization shows log lines from data sources that support logs, such as Elastic, Influx, and Loki. Typically, you would use this panel next to a graph panel to display the log output of a related process.

The logs panel shows the result of queries that were entered on the **Query** tab. The results of multiple queries are merged and sorted by time. You can scroll inside the panel if the data source returns more lines than can be displayed.

To limit the number of lines rendered, you can use the **Max data points** setting in the **Query options**. If it is not set, the data source will usually enforce a default limit.

## Log level
<a name="v9-panels-logs-level"></a>

For logs where a **level** label is specified, we use the value of the label to determine the log level and update color accordingly. If the log doesn’t have a level label specified, we try to find out if its content matches any of the supported expressions (see below for more information). The log level is always determined by the first match. In case Grafana is not able to determine a log level, it will be visualized with **unknown** log level. For more information, see [Logs visualization](v9-explore-logs.md#v9-explore-logs-viz).

## Log details
<a name="v9-panels-logs-details"></a>

Each log row has an extendable area with its labels and detected fields, for more robust interaction. Each field or label has a stats icon to display statistics in relation to all displayed logs.

**Data links**

By using data links, you can turn any part of a log message into an internal or external link. The created link is visible as a button in the **Links** section inside the **Log details** view.

**Display options**

Use the following settings to refine your visualization:
+  **Time** – Show or hide the time column. This is the timestamp associated with the log line as reported from the data source.
+  **Unique labels** – Show or hide the unique labels column, which shows only non-common labels.
+ **Common labels** – Show or hide the common labels
+  **Wrap lines** – Toggle line wrapping. 
+ **Prettify JSON** – Set this to `true` to pretty print all JSON logs. This setting does not affect logs in any format other than JSON.
+ **Enable log details** – Toggle option to see the log details view for each log row. The default setting is `true`.
+  **Order** – Display results in descending or ascending time order. The default is **Descending**, showing the newest logs first. Set to **Ascending** to show the oldest log lines first.

# News panel
<a name="v9-panels-news"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

This panel displays an RSS feed. By default, it displays articles from the Grafana Labs blog.

Enter the URL of an RSS in the **Display** section. This panel type does not accept any other queries.

**Note**  
RSS feeds are loaded by the Grafana front end without a proxy. As a result, only RSS feeds that are configured with the appropriate [CORS headers](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS) will load. If the RSS feed you're trying to display fails to load, consider re-hosting the RSS feed or creating your own proxy.

# Node graph panel
<a name="v9-panels-node-graph"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

The node graph panel visualizes directed graphs or networks. It uses directed force layout to effectively position the nodes so it can help with displaying complex infrastructure maps, hierarchies, or run diagrams.

## Data requirements
<a name="v9-panels-node-graph-requirements"></a>

The node graph panel requires a specific shape of the data to be able to display its nodes and edges. Not every data source or query can be visualized in this panel.

The Node graph visualization consists of *nodes* and *edges*.
+ A *node* is displayed as a circle. A node might represent an application, a service, or anything else that is relevant from an application perspective.
+ An *edge* is displayed as a line that connects two nodes. The connection might be a request, an operation, or some other relationship between the two nodes.

Both nodes and edges can have associated metadata or statistics. The data source defines what information and values is shown, so different data sources can show different type of values or not show some values.

## Nodes
<a name="v9-panels-node-graph-nodes"></a>

Usually, nodes show two statistical values inside the node and two identifiers just below the node, usually name and type. Nodes can also show another set of values as a color circle around the node, with sections of different color represents different values that should add up to 1. For example, you can have the percentage of errors represented by red portion of the circle.

Additional details can be displayed in a context menu, which is displayed when you choose the node. There also can be additional links in the context menu that can target either other parts of the Grafana workspace or any external link.

**Note**  
Node graph can show only 1,500 nodes. If this limit is crossed, a warning is visible in the upper right corner, and some nodes will be hidden. You can expand hidden parts of the graph by clicking on the **Hidden nodes** markers in the graph.

## Edges
<a name="v9-panels-node-graph-edges"></a>

Edges can also show statistics when you hover over the edge. Similar to nodes, you can open a context menu with additional details and links by choosing the edge.

The first data source supporting this visualization is the AWS X-Ray data source for its service map feature. For more information, see [Connect to an AWS X-Ray data source](x-ray-data-source.md).

## Navigating the node graph
<a name="v9-panels-node-graph-navigation"></a>

You can pan within the node graph by choosing outside of any node or edge and dragging the pointer.

You can zoom by using the buttons on the upper left corner of the node graph.

**Hidden nodes**

The number of nodes shown at a given time is limited to maintain a reasonable performance. Nodes that are outside this limit are hidden behind clickable markers that show an approximate number of hidden nodes that are connected to that edge. You can choose the marker to expand the graph around that node.

**Grid view**

You can switch to the grid view to have a better overview of the most interesting nodes in the graph. Grid view shows nodes in a grid without edges and can be sorted by stats shown inside the node or by stats represented by the a colored border of the nodes.

To sort the nodes, choose the stats inside the legend. The marker next to the stat name shows which stat is currently used for sorting and sorting direction.

Choose the node and then the **Show in Graph layout** option to switch back to graph layout with focus on the selected node, to show it in context of the full graph.

## Data API
<a name="v9-panels-node-graph-data-api"></a>

This visualization needs a specific shape of the data to be returned from the data source in order to correctly display it.

Node Graph at minimum requires a data frame describing the edges of the graph. By default, node graph will compute the nodes and any stats based on this data frame. Optionally a second data frame describing the nodes can be sent in case there is need to show more node specific metadata. You have to set `frame.meta.preferredVisualisationType = 'nodeGraph'` on both data frames or name them `nodes` and `edges` respectively for the node graph to render.

**Edges data from structure**

Required fields:


| Field name | Type | Description | 
| --- | --- | --- | 
|  id  |  string  |  Unique identifier of the edge.  | 
|  source  |  string  |  Id of the source node.  | 
|  target  |  string  |  Id of the target.  | 

Optional fields:


| Field name | Type | Description | 
| --- | --- | --- | 
|  mainstat  |  string/number  |  First stat shown in the overlay when hovering over the edge. It can be a string showing the value as is or it can be a number. If it is a number, any unit associated with that field is also shown  | 
|  secondarystat  |  string/number  |  Same as mainStat, but shown right under it.  | 
|  detail\$1\$1\$1  |  string/number  |  Any field prefixed with `detail__` will be shown in the header of context menu when clicked on the edge. Use `config.displayName` for a more human readable label.  | 

**Nodes data from structure**

Required fields:


| Field name | Type | Description | 
| --- | --- | --- | 
|  id  |  string  |  Unique identifier of the node. This ID is referenced by edge in its source and target field.  | 

Optional fields:


| Field name | Type | Description | 
| --- | --- | --- | 
|  title  |  string  |  Name of the node visible in just under the node.  | 
|  subtitle  |  string  |  Additional, name, type or other identifier shown under the title.  | 
|  mainstat  |  string/number  |  First stat shown inside the node itself. It can either be a string showing the value as is or a number. If it is a number, any unit associated with that field is also shown.  | 
|  secondarystat  |  string/number  |  Same as mainStat, but shown under it inside the node.  | 
|  arc\$1\$1\$1  |  number  |  Any field prefixed with `arc__` will be used to create the color circle around the node. All values in these fields should add up to 1. You can specify color using `config.color.fixedColor`.  | 
|  detail\$1\$1\$1  |  string/number  |  Any field prefixed with `detail__` will be shown in the header of context menu when clicked on the node. Use `config.displayName` for more human readable label.  | 

# Pie chart panel
<a name="v9-panels-piechart"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

The pie chart displays reduced series, or values in a series, from one or more queries, as they relate to each other, in the form of slices of a pie. The arc length, area and central angle of a slice are all proportional to the slices value, as it relates to the sum of all values. This type of chart is best used when you want a quick comparison of a small set of values in an aesthetically pleasing form.

## Value options
<a name="v9-panels-piechart-value"></a>

Use the following options to refine the value in your visualization.

**Show**

Choose how much information to show.
+ **Calculate** – Reduces each value to a single value per series.
+ **All values** – Displays every value from a single series.

**Calculation**

Select a calculation to reduce each series when Calculate has been selected. For information about available calculations, refer to [Calculation types](v9-panels-calculation-types.md).

**Limit**

When displaying every value from a single series, this limits the number of values displayed.

**Fields**

Select which field or fields to display in the visualization. Each field name is available on the list, or you can select one of the following options:
+ **Numeric fields** – All fields with numerical values.
+ **All fields** – All fields that are not removed by transformations.
+ **Time** – All fields with time values.

## Pie chart options
<a name="v9-panels-piechart-options"></a>

Use these options to refine how your visualization looks.

**Pie chart type**

Select the pie chart display style. Can be either:
+ **Pie** – A standard pie chart
+ **Donut** – A pie chart with a hole in the middle

**Labels**

Select labels to display on the pie chart. You can select more than one.
+ **Name** – The series or field name.
+ **Percent** – The percentage of the whole.
+ **Value** – The raw numerical value.

Labels are displayed in white over the body of the chart by default. You can select darker chart colors to make them more visible. Long names or numbers might be clipped.

**Tooltip mode**

When you hover your cursor over the visualization, Grafana can display tooltips. Choose how tooltips behave.
+ **Single** – The hover tooltip shows only a single series, the one that you are hovering over on the visualization.
+ **All** – The hover tooltip shows all series in the visualization. Grafana highlights the series that you are hovering over in bold in the series list in the tooltip.
+ **Hidden** – Do not display the tooltip when you interact with the visualization.

Use an override to hide individual series from the tooltip.

**Legend mode**

Use these settings to define how the legend appears in your visualization. For more information about the legend, refer to [Configure a legend](v9-panels-configure-legend.md).
+ **List** – Displays the legend as a list. This is a default display mode of the legend.
+ **Table** – Displays the legend as a table.
+ **Hidden** – Hides the legend.

**Legend placement**

Choose where to display the legend.
+ **Bottom** – Below the graph.
+ **Right** – To the right of the graph.

**Legend values**

Choose which of the [standard calculations](v9-panels-calculation-types.md) to show in the legend. You can have more than one.

Select values to display in the legend. You can select more than one.
+ **Percent** – The percentage of the whole.
+ **Value** – The raw numerical value.

For more information about the legend, refer to [Configure a legend](v9-panels-configure-legend.md).

# Plotly panel
<a name="v9-panels-plotly"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

The Plotly panel renders charts using [Plotly](https://plotly.com/javascript/), an open source javascript graphing library.

The **Data**, **Layout** and **Config** fields match the common parameters described in the [Plotly documentation](https://plotly.com/javascript/plotlyjs-function-reference/). They must be in JSON format.

Data provided by the datasource can be transformed via a user-defined script before to be injected in the Plotly chart. The script includes 2 arguments.
+ `data` – Data returned by the data source.
+ `variables` – An object that contains [Grafana variables](templates-and-variables.md) in the current dashboard (user variables and these few global variables: `__from`, `__to`, `__interval`, and `__interval_ms`).

The script must return an object with one or more of the following properties: `data`, `layout`, `config` and `frames`. The following is an example.

```
let x  = data.series[0].fields[0].values.buffer
let y  = data.series[0].fields[1].values.buffer
let serie = {
    x : x,
    y : y,
    name : variables.project //where project is the name of a Grafana’s variable
}

return {
    data : [serie],
    config : {
    displayModeBar: false
    }
}
```

Object returned by the script and JSON provided in the *Data*, *Layout* and *Config* fields will be merged (deep merge).

If no script is provided, the panel will use only *Data*, *Layout* and *Config* fields.

# Sankey panel
<a name="v9-panels-sankey"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

The Sankey panel shows Sankey diagrams, which are good for visualizing flow data, with the width of the flow being proportional to the selected metric. The following image shows a Sankey diagram with two groups of source and destinations.

![\[Sankey diagram showing flow between source organizations, science disciplines, and projects.\]](http://docs.aws.amazon.com/grafana/latest/userguide/images/sankey-panel.png)


**How it works**

The sankey panel requires at least 2 columns of data, a source and destination for the flows. Your query should group your data into at least two groups. The panel will draw links from the first column of data points, to the last in order of the query. The thickness of the links will be proportionate to the value as assigned by the metric in the query.

**Customizing**
+ **Links** – There are currently two options for link color: multi or single. It is multi-colored by default. To choose a single color for the links, toggle the **Single Link color only** option and choose your color from Grafana's color picker.
+ **Nodes** – You can change the color of the rectangular nodes by changing the **Node color** option
+ **Node Width** – The width of the nodes can be adjusted with the **Node Width** slider or entering a number in the input box. This number must be an integer.
+ **Node Padding** – The vertical padding between nodes can be adjusted with the **Node Padding** slider or entering a number in the input box. This number must be an integer. If your links are too thin, try adjusting this number
+ **Headers** – The column headers can be changed by using a **Display Name** override in the editor panel. They will be the same color you choose for **Text color**
+ **Sankey Layout** – The layout of the Sankey links can be adjusted slightly using the **Layout iteration** slider. This number must be an integer and is the number of relaxation iterations used to generate the layout.

# Scatter panel
<a name="v9-panels-scatter"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

The scatter panel shows an X/Y scatter plot for table data with a simpler interface than other graphing panels. Unlike the graph panel, the scatter panel does not require the data to be in a time series. The scatter panel requires a table formatted dataset with two or more numeric columns of data.

One of these can be assigned to the X axis. One or more can be assigned to a series of Y axis values and the resulting data plotted as a series of dots. Each series can optionally also show a regression line using one of a number of statistical best fits.

**Creating a scatter panel**

The following procedure describes how to create a scatter plot using the scatter panel. For this example, we will assume that there is data, as in the following table called `HEIGHT` with three columns of numerical values, `Age`, `Boys`, and `Girls`, showing the average height of boys and girls by age.


| Age | Boy's Height | Girl's Height | 
| --- | --- | --- | 
|  5  |  109.7  |  109.5  | 
|  6  |  115.6  |  115.4  | 
|  7  |  121.1  |  120.8  | 
|  8  |  126.3  |  126  | 
|  9  |  131.3  |  131.3  | 
|  10  |  136.2  |  137.1  | 
|  11  |  141.2  |  143.2  | 
|  12  |  147  |  148.7  | 
|  13  |  153.6  |  152.6  | 
|  14  |  159.9  |  155.1  | 
|  15  |  164.4  |  156.7  | 
|  16  |  167.3  |  157.6  | 
|  17  |  169  |  158  | 
|  18  |  170  |  158.3  | 
|  19  |  170.8  |  158.6  | 

**To create a scatter plot with the scatter panel**

1. In your Grafana dashboard, choose **Add Panel**.

1. For the Query, write a query that will return the data needed. In this case, you would use a query such as `SELECT * FROM HEIGHT`.

1. Select the **Scatter** visualization.

This will create a scatter plot, using the first column as the X axis, and the other numeric columns as Y axes.

**Configuration options**

The scatter panel provides the following four custom configuration options.
+ **X Axis** – You can choose which field to use as the X axis, as well as extents and title and display information for the axis.
+ **Y Axis** – You can choose which fields to display on the Y axis, including display options for each field, and extents and title information for the axis. You can also choose to display a regression line for each field. See the following information for more details on regression line configuration.
+ **Legend** – You can turn a legend for the panel on or off, as well as choose the size of the text in the legend.
+ **Display** – You can set other options for the chart, including grid color and border style.

**Regression line configuration**

Each Y axis dataset can display a line, in addition to the individual dots. There are five options for the line type.
+ **None** – Do not display a regression line.
+ **Simple** – Display a regression line that connects the dataset points.
+ **Linear** – Display a straight line, using the least-squares, best-fit method.
+ **Exponential** – Display an exponential best-fit regression line.
+ **Power** – Display a power best-fit regression line.

# Stat panel
<a name="v9-panels-stat"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

The Stat panel visualization shows a one large stat value with an optional graph sparkline. You can control the background or value color using thresholds.

By default, the Stat panel displays one of the following:
+ Just the value for a single series or field.
+ Both the value and name for multiple series or fields.

You can use the **Text mode** to control whether the text is displayed or not.

## Automatic layout adjustment
<a name="v9-panels-stat-automatic-adjust"></a>

The panel automatically adjusts the layout depending on available width and height in the dashboard. It automatically hides the graph (sparkline) if the panel becomes too small.

## Value options
<a name="v9-panels-stat-value"></a>

Use the following options to refine how your visualization displays the value:

**Show**

Choose how Grafana displays your data.

**Calculate**

Show a calculated value based on all rows.
+ **Calculation** – Select a reducer function that Grafana will use to reduce many fields to a single value. For a list of available calculations, see [standard calculations](v9-panels-calculation-types.md).
+ **Fields** – Select the fields display in the panel.

**All values**

Show a separate stat for every row. If you select this option, then you can also limit the number of rows to display.
+ **Limit** – The maximum number of rows to display. Default is 5,000.
+ **Fields** – Select the fields display in the panel.

## Stat styles
<a name="v9-panels-stat-styles"></a>

Style your visualization.

**Orientation**

Choose a stacking direction.
+ **Auto** – Grafana selects what it thinks is the best orientation.
+ **Horizontal** – Bars stretch horizontally, left to right.
+ **Vertical** – Bars stretch vertically, top to bottom.

**Text mode**

You can use the Text mode option to control what text the panel renders. If the value is not important, only the name and color is, then change the **Text mode** to **Name**. The value will still be used to determine color and is displayed in a tooltip.
+ **Auto** – If the data contains multiple series or fields, show both name and value.
+ **Value** – Show only value, never name. Name is displayed in the hover tooltip instead.
+ **Value and name** – Always show value and name.
+ **Name** – Show name instead of value. Value is displayed in the hover tooltip.
+ **None** – Show nothing (empty). Name and value are displayed in the hover tooltip.

**Color mode**

Select a color mode.
+ **Value** – Colors only the value and graph area.
+ **Background** – Colors the background as well.

**Graph mode**

Select a graph and sparkline mode.
+ **None** – Hides the graph and only shows the value.
+ **Area** – Shows the area graph below the value. This requires that your query returns a time column.

**Text alignment**

Choose an alignment mode.
+ **Auto** – If only a single value is shown (no repeat), then the value is centered. If multiple series or rows are shown, then the value is left-aligned.
+ **Center** – Stat value is centered.

Text size

Adjust the sizes of the gauge text.
+ **Title** – Enter a numeric value for the gauge title size.
+ **Value** – Enter a numeric value for the gauge value size.

# State timeline panel
<a name="v9-panels-state-timeline"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

The state timeline panel visualization shows discrete state changes over time. Each field or series is rendered as its unique horizontal band. State regions can either be rendered with or without values. This panel works well with string or boolean states but can also be used with time series. When used with time series, the thresholds are used to turn the numerical values into discrete state regions.

## State timeline options
<a name="v9-panels-state-timeline-options"></a>

Use these options to refine your visualizations:

**Merge equal consecutive values**

Controls whether Grafana merges identical values if they are next to each other.

**Show values**

Controls whether values are rendered inside the state regions. Auto will render values if there is sufficient space.

**Align values**

Controls value alignment inside state regions.

**Row height**

Controls space between rows. 1 = no space = 0.5 = 50% space.

**Line width**

Controls the line width of state regions.

**Fill opacity**

Controls the opacity of state regions.

## Value mappings
<a name="v9-panels-state-timeline-valuemap"></a>

To assign colors to boolean or string values, use [Configure value mappings](v9-panels-configure-value-mappings.md).

## Time series data with thresholds
<a name="v9-panels-state-timeline-threshold"></a>

The panel can be used with time series data as well. In this case, the thresholds are used to turn the time series into discrete colored state regions.

## Legend options
<a name="v9-panels-state-timeline-legend"></a>

When the legend option is enabled, it can show either the value mappings or the threshold brackets. To show the value mappings in the legend, it’s important that the Color scheme option under Standard options is set to Single color or Classic palette. To see the threshold brackets in the legend, set the Color scheme to From thresholds.

**Legend mode** Use these settings to refine how the legend appears in your visualization.
+  **List ** – Displays the legend as a list. This is a default display mode of the legend.
+  **Table** – Displays the legend as a table.
+  **Hidden** – Hides the legend.

**Legend placement** Choose where to place the legend.
+  **Bottom ** – Below the graph.
+  **Right** – To the right of the graph.

**Legend values**

Choose which of the [standard calculations](v9-panels-calculation-types.md) to show in the legend. You can have more than one.

# Status history panel
<a name="v9-panels-status-history"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

The Status history visualization shows periodic states over time. Each field or series is rendered as a horizontal row. Boxes are rendered and centered around each value.

Status history visualization works with string, boolean, and numerical fields or time series. A time field is required. You can use value mappings to color strings or assign text values to numerical ranges.

## Display options
<a name="v9-panels-status-history-timeline-options"></a>

Use these options to refine your visualizations:

**Show values**

Controls whether values are rendered inside the value boxes. Auto will render values if there is sufficient space.

**Column width** controls the width of boxes. 1=max and 0=Min width.

**Line width** controls line width of state regions.

**Fill opacity** controls the fill opacity of state regions.

## Value mappings
<a name="v9-panels-status-history-valuemap"></a>

To assign colors to boolean or string values, use [Configure value mappings](v9-panels-configure-value-mappings.md).

## Time series data with thresholds
<a name="v9-panels-status-history-threshold"></a>

The panel can be used with time series data as well. In this case, the thresholds are used to color the boxes. You can also use gradient color schemes to color values.

## Legend options
<a name="v9-panels-status-history-legend"></a>

When the legend option is enabled, it can show either the value mappings or the threshold brackets. To show the value mappings in the legend, it’s important that the Color scheme option under Standard options is set to Single color or Classic palette. To see the threshold brackets in the legend set the Color scheme to From thresholds.

**Legend mode** Use these settings to refine how the legend appears in your visualization.
+  **List ** – Displays the legend as a list. This is a default display mode of the legend.
+  **Table** – Displays the legend as a table.
+  **Hidden** – Hides the legend.

**Legend placement** Choose where to place the legend.
+  **Bottom ** – Below the graph.
+  **Right** – To the right of the graph.

**Legend values**

Choose which of the [standard calculations](v9-panels-calculation-types.md) to show in the legend. You can have more than one.

# Table panel
<a name="v9-panels-table"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

The table panel visualization is very flexible, supporting multiple modes for time series and for tables, annotation, and raw JSON data. This panel also provides date formatting, value formatting, and coloring options.

## Sort column
<a name="v9-panels-table-sort"></a>

Click a column title to change the sort order from default to descending to ascending. Each time you click, the sort order changes to the next option in the cycle. You can only sort by one column at a time.

## Table options
<a name="v9-panels-table-options"></a>

**Show header**

Show or hide column names imported from your data source.

## Column width
<a name="v9-panels-table-width"></a>

By default, Grafana automatically calculates the column width based on the table size and the minimum column width. This field option can override the setting and define the width for all columns in pixels.

For example, if you enter `100` in the field, then when you click outside the field, all the columns will be set to 100 pixels wide.

## Minimum column width
<a name="v9-panels-table-min"></a>

By default, the minimum width of the table column is 150 pixels. This field option can override that default and will define the new minimum column width for the table panel in pixels.

For example, if you enter `75` in the field, then when you click outside the field, all the columns will scale to no smaller than 75 pixels wide.

For small-screen devices, such as smartphones or tablets, reduce the default `150` pixel value to `50` to allow table based panels to render correctly in dashboards.

## Column alignment
<a name="v9-panels-table-alignment"></a>

Choose how Grafana should align cell contents:
+ Auto (default)
+ Left
+ Center
+ Right

## Cell type
<a name="v9-panels-table-cell-type"></a>

By default, Grafana automatically chooses display settings. You can override the settings by choosing one of the following options to set the default for all fields. Additional configuration is available for some cell types.

**Note**  
If you set these in the **Field** tab, then the type will apply to all fields, including the time field. You can set them in the **Override** tab to apply the change to one or more fields.

**Color text**

If thresholds are set, then the field text is displayed in the appropriate threshold color.

**Color background (gradient or solid)**

If thresholds are set, then the field background is displayed in the appropriate threshold color.

**Gauge**

Cells can be displayed as a graphical gauge, with several different presentation types.

**Basic**

The basic mode will show a simple gauge with the threshold levels defining the color of gauge.

**Gradient**

The threshold levels define a gradient.

**LCD**

The gauge is split up in small cells that are lit or unlit.

**JSON view**

Shows value formatted as code. If a value is an object the JSON view allowing browsing the JSON object will appear on hover.

## Cell value inspect
<a name="v9-panels-table-cell-value"></a>

Enables value inspection from table cell. The raw value is presented in a modal window.

**Note**  
Cell value inspection is only available when cell display mode is set to Auto, Color text, Color background or JSON View.

## Column filter
<a name="v9-panels-table-col-filter"></a>

You can temporarily change how column data is displayed. For example, you can order values from highest to lowest or hide specific values. For more information, refer to [Filter table columns](#v9-panels-table-filter), below.

## Pagination
<a name="v9-panels-table-pagination"></a>

Use this option to enable or disable pagination. It is a front-end option that does not affect queries. When enabled, the page size automatically adjusts to the height of the table.

## Filter table columns
<a name="v9-panels-table-filter"></a>

If you turn on the **Column filter**, then you can filter table options.

**To turn on column filtering**

1. In Grafana, navigate to the dashboard with the table with the columns that you want to filter.

1. On the table panel you want to filter, open the panel editor.

1. Choose the **Field** tab.

1. In **Table** options, turn on the **Column filter** option.

A filter icon appears next to each column title.

**Filter column values**

To filter column values, choose the filter (funnel) icon next to a column title. Grafana displays the filter options for that column.

Choose the check box next to the values that you want to display. Enter text in the search field at the top to show those values in the display so that you can select them rather than scroll to find them.

**Clear column filters**

Columns with filters applied have a blue funnel displayed next to the title.

To remove the filter, choose the blue funnel icon and then select Clear filter.

## Table footer
<a name="v9-panels-table-footer"></a>

You can use the table footer to show [calculations](v9-panels-calculation-types.md) on fields.

After you enable the table footer, you can select the **Calculation**, and then the **Fields** that you want to calculate.

The system applies the calculation to all numeric fields if you do not select a field.

**Count rows**

If you want to show the number of rows in the dataset instead of the number of values in the selected fields, select the **Count** calculation and enable **Count rows**.

# Text panel
<a name="v9-panels-text"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

The text panel enables you to directly include text or HTML in your dashboards. This can be used to add contextual information and descriptions or embed complex HTML.

**Mode**

Mode determines how embedded content appears. It has the following options
+ **Markdown** – This option formats the content as markdown.
+ **HTML** – This setting renders the content as sanitized HTML.
+ **Code** – This setting renders content inside a read-only code editor. Select an appropriate language to apply syntax highlighting to the embedded text.

**Variables**

Variables in the content will be expanded for display.

# Time series panel
<a name="v9-panels-time-series"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

The time series panel can render a time series as a line, a path of dots, or a series of bars. This type of graph is versatile enough to display almost any time-series data.

**Note**  
You can migrate Graph panel visualizations to Time series visualizations. To migrate, on the **Panel** tab, choose **Time series visualization**. Grafana transfers all applicable settings.

**Topics**
+ [Tooltip options](v9-time-series-panel-tooltip.md)
+ [Legend options](v9-time-series-panel-legend.md)
+ [Graph style options](v9-time-series-graph.md)
+ [Axis options](v9-time-series-axis.md)
+ [Color options](v9-time-series-color.md)

# Tooltip options
<a name="v9-time-series-panel-tooltip"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

When you hover your cursor over the graph, Grafana can display tooltips. Choose how tooltips behave:
+  **Single** – The hover tooltip shows only the series that you are hovering over.
+  **All** – The hover tooltip shows all the series in the graph. Grafana highlights the series that you are hovering over in bold in the series list in the tooltip.
+  **Hidden** – Do not display the tooltip. 

# Legend options
<a name="v9-time-series-panel-legend"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

**Legend mode** – Choose how the legend appears.
+  **List** – Displays the legend as a list. This is the default.
+  **Table** – Displays the legend as a table. 
+  **Hidden** – Hides the legend.

**Legend placement** – Choose where to display the legend.
+  **Bottom** – Below the graph.
+  **Right** – To the right of the graph. 

**Legend calculations**

Choose which calculations to show in the legend. For more information, see [Calculation types](v9-panels-calculation-types.md).

# Graph style options
<a name="v9-time-series-graph"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

**Graph style**

Use this option to define how to display your time series data. You can use overrides to combine multiple styles in the same graph. There are three style options. Some of the other style options only apply to certain graph styles.
+ **Lines** – Display the time series as a line on a graph.
+ **Bars** – Display the time series as a series of bars on a graph, one for each data point.
+ **Points** – Display the time series as dots on a graph, one for each data point.

**Bar alignment**

For bar graphs, , sets the position of the bar, relative to where the point would be drawn on the graph. Because a bar has a width, it can be placed before, after, or centered on the point. The choices for this option are **Before**, **Center**, or **After**.

**Line width**

Sets the thickness of the line for Line graphs, or the thickness of the outline for each bar in a bar graph.

**Fill opacity**

Sets the opacity of a fill color. Fills are used, for example, to show the area under the line in a line graph, or as the color of bars in a bar graph.

**Gradient mode**

Gradient mode specifies the gradient fill, which is based on the series color. To change the color, use the standard color scheme field option. For more information, see [Color scheme](v9-panels-configure-standard-options.md#v9-panels-standard-options-color-scheme). The gradient mode options are:
+ **None** – No gradient fill.
+ **Opacity** – An opacity gradient where the opacity of the fill increases as the Y-axis values increase.
+ **Hue** – A gradient that is based on the hue of the series color.
+ **Scheme** – A color gradient defined by your color scheme. This setting can be used by the fill and the line. For more information, see [Color options](v9-time-series-color.md).

The gradient appearance is also modified by the **Fill opacity** setting. 

**Show points**

You can configure your visualization to add points to line or bar graphs. You can choose **Always**, **Never**, or **Auto**. When using **Auto**, Grafana determines whether to show points based on the density of the data. If the density of the data is low enough, points are shown.

**Point size**

Sets the size of drawn points, from 1 to 40 pixels in diameter.

**Line interpolation**

Choose how Grafana interpolates the series line. The choices are **Linear**, **Smooth**, **Step before**, and **Step after**.

**Line style**

Set the style of the line. To change the color, use the standard color scheme field option.

Line style appearance is influenced by the settings for **Line width** and **Fill opacity**.

The choices for line style are **Solid**, **Dash**, and **Dots**.

**Connect null values**

Choose how null values (gaps in the data) appear on the graph. Null values can be connected to form a continuous line or, optionally, set a threshold above which gaps in the data should no longer be connected. You can choose to **Never** connect data points with gaps, **Always** connect data points with gaps, or set a **Threshold** at which gaps in the data should no longer be connected.

**Stack series**

*Stacking* allows Grafana to display series on top of each other. Be cautious when using stacking in the visualization as it can easily create misleading graphs. To read more about why stacking might not be the best approach, refer to [The Issue with Stacking](https://www.data-to-viz.com/caveat/stacking.html).

The options for stacking are:
+ **Off** – Turns off series stacking.
+ **Normal** – Stacks series on top of each other.
+ **100%** – Stack by percentage, where all series together add up to 100%.

**Stack series in groups**

You can override the stacking behavior to stack series in groups. For more information about creating an override, see [Configure field overrides](v9-panels-configure-overrides.md). When creating the override, give the name of the stacking group you want the series to be part of.

**Fill below to**

The **Fill below to** option fills the area between two series. This options is only available as a series or field override. Using this option you can fill the area between two series, rather than from the series line down to 0. For example, if you had two series called *Max* and *Min*, you could select the **Max** series and override it to **Fill below to** the **Min** series.. This would fill only the area between the two series lines.

# Axis options
<a name="v9-time-series-axis"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

Options under the axis category change how the X and Y axes are rendered. Some options do not take effect until you click outside of the field option box you are editing. You can also or press `Enter`.

**Placement**

Select the placement of the Y-axis. The options are:
+ **Auto** – Grafana automatically assigns the Y-axis to the series. When there are two or more series with different units, Grafana assigns the left axis to the first unit, and the right axis to the units that follow.
+ **Left** – Display all Y-axes on the left side.
+ **Right** – Display all Y-axes on the right side.
+ **Hidden** – Hide all Y-axes.

To assign axes for each field or series, [add field overrides](v9-panels-configure-overrides.md).

**Label**

Set a Y-axis text label. If you have more than one Y-axis, then you can assign different labels using an override.

**Width**

Set a fixed width of the axis. By default, Grafana dynamically calculates the width of an axis.

By setting the width of the axis, data with different axes types can share the same display proportions. This setting makes it easier for you to compare more than one graph’s worth of data because the axes are not shifted or stretched within visual proximity to each other.

**Soft min and soft max**

Set a **Soft min** or **soft max** option for better control of Y-axis limits. By default, Grafana sets the range for the Y-axis automatically based on the dataset.

Soft min and soft max settings allow visibility into small changes when big changes aren't present. Hard min or max derived from standard min and max field options can prevent intermittent spikes from flattening useful detail by clipping the spikes past a specific point.

To define hard limits of the Y-axis, You can set standard min/max options. For more information, refer to [Configure standard options](v9-panels-configure-standard-options.md).

**Scale**

Set how the Y-axis scales. The choices are **Linear** or **Logarithmic**. If you choose logarithmic, you can further choose between base 2 or base 10 logarithmic scales.

**Transform**

You can override a series to apply a transform to values on a graph (without affecting the underlying values or the values in tooltips, context menus, or legends). You have two transform options:
+ **Negative Y transform** – Flip the results to negative values on the Y axis.
+ **Constant** – Show the first value as a constant line.

# Color options
<a name="v9-time-series-color"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

By default, the graph uses the standard [Color scheme](v9-panels-configure-standard-options.md#v9-panels-standard-options-color-scheme) option to assign series colors. You can also use the legend to open the color picker by clicking the legend series color icon. Setting color this way automatically creates an override rule that set’s a specific color for a specific series.

The following are additional options that you can use to override series color defaults.

**Classic Palette**

The most common setup is to use the **Classic palette** for graphs. This scheme automatically assigns a color for each field or series based on its order. If the order of a field changes in your query, the color also changes. You can manually configure a color for a specific field using an override rule.

**Single color**

Use this mode to specify a color. You can also click the colored line icon next to each series in the Legend to open the color picker. This automatically creates a new override that sets the color scheme to single color and the selected color.

**By value color schemes**

If you select a by value color scheme like **From thresholds (by value)** or **Green-Yellow-Red (by value)**, the **Color series by** option appears. This option controls which value (Last, Min, Max) to use to assign the series its color.

**Scheme gradient mode**

The **Gradient mode** option located under the **Graph styles** has a mode named **Scheme**. When you enable **Scheme**, the line or bar receives a gradient color defined from the selected **Color scheme**.

**From thresholds**

If the **Color scheme** is set to **From thresholds (by value)** and **Gradient mode** is set to **Scheme**, then the line or bar color changes as they cross the defined thresholds. You will see only the exact colors chosen in the scheme.

**Gradient color schemes**

Using a gradient color scheme *without* setting the **Gradient mode** to **Scheme**, means that the colors chosen will form a gradient between the colors chosen, as the values in the series move between the thresholds set.

# Traces panel (Beta)
<a name="v9-panels-traces"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

*Traces* are a visualization that enables you to track and log a request as it traverses the services in your infrastructure.

For more information about traces, see [Tracing in Explore](v9-explore-tracing.md).

# WindRose
<a name="v9-panels-windrose"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

The WindRose panel receives raw time series data converts the data and maps it in a WindRose chart.

![\[WindRose panel with two circular charts showing wind direction and speed data distribution.\]](http://docs.aws.amazon.com/grafana/latest/userguide/images/windrose.png)


## Options
<a name="v9-panels-windrose-options"></a>

The WindRose panel supports the following options:
+ Axis frequency
+ Axis style (degrees or compass)
+ Scale (linear, square, log)

# Explore in Grafana version 9
<a name="v9-explore"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

Grafana’s dashboard UI provides functionality to build dashboards for visualization. *Explore* strips away the dashboard and panel options so that you can focus on the query. It helps you iterate until you have a working query and then you can build a dashboard from the query.

**Note**  
If you just want to explore your data and do not want to create a dashboard, then Explore makes this much easier. If your data source supports graph and table data, then Explore shows the results both as a graph and a table. This allows you to see trends in the data and more details at the same time.

## Start exploring
<a name="v9-explore-start"></a>

**Note**  
In order to access Explore, you must have an editor or an administrator role.

**To access Explore**

1. In your Grafana workspace, choose the Explore menu item from the left menu bar.

   An empty Explore tab opens.

   Alternately, to start with an existing query in a panel, choose the Explore option from the Panel menu. This opens an Explore tab with the query from the panel and allows you to tweak or iterate in the query outside of your dashboard.

1. Choose your data source from the dropdown in the top left. [Prometheus](prometheus-data-source.md) has a custom Explore implementation, the other data sources use their standard query editor.

1. In the query field, write your query to explore your data. There are three buttons beside the query field, a clear button (X), an add query button (\$1) and the remove query button (-). Just like the normal query editor, you can add and remove multiple queries.

   For more details about queries, see [Query and transform data](v9-panels-query-xform.md).

## Split and compare
<a name="v9-explore-compare"></a>

The split view provides an easy way to compare graphs and tables side-by-side or to look at related data together on one page.

**Top open a split view**

1. In the Explore view, choose the **Split** button to duplicate the current query and split the page into two side-by-side queries.
**Note**  
It is possible to select another data source for the new query which for example, allows you to compare the same query for two different servers or to compare the staging environment to the production environment.

   In split view, timepickers for both panels can be linked (if you change one, the other gets changed as well) by selecting a time-sync button attached to one of the timepickers. Linking timepickers keeps the start and the end times of the split view queries in sync. It ensures that you’re looking at the same time interval in both split panels.

1. To close the newly created query, click on the Close Split button.

## Share shortened link
<a name="v9-explore-share"></a>

The Share shortened link capability allows you to create smaller and simpler URLs of the format /goto/:uid instead of using longer URLs with query parameters. To create a shortened link to the query results, select the **Share** option in the Explore toolbar. A shortened link that is never used will automatically get deleted after seven (7) days.

# Query management in Explore
<a name="v9-explore-manage"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

To help with debugging queries, Explore allows you to investigate query requests and responses, as well as query statistics, via the Query inspector. This functionality is similar to the panel inspector tasks [Inspect query performance](v9-panels-panel-inspector.md#v9-panels-query-performance) and [Inspect query request and response data](v9-panels-panel-inspector.md#v9-panels-query-request-response).

## Query history
<a name="v9-explore-manage-history"></a>

Query history is a list of queries that you used in Explore. The history is stored in the Grafana database and it is not shared with other users. The retention period for queries in history is two weeks. Queries older than two weeks are automatically deleted. To open and interact with your history, select the **Query history** button in Explore.

**Note**  
Starred (favorited) queries are not subject to the two weeks retention period and they are not deleted.

**View query history**

Query history lets you view the history of your querying. For each individual query, you can:
+ Run a query.
+ Create and/or edit a comment.
+ Copy a query to the clipboard.
+ Copy a shortened link with the query to the clipboard.
+ Star (favorite) a query.

**Manage favorite queries**

All queries that have been starred in the Query history tab are displayed in the Starred list. This allows you to access your favorite queries faster and to reuse these queries without typing them from scratch.

**Sorting query history**

By default, query history shows you the most recent queries. You can sort your history by date or by data source name in ascending or descending order.

**To sort your query history**

1. Select the **Sort queries by** field.

1. Select one of the following options:
   + Newest first
   + Oldest first

**Filtering query history**

You can filter your query history in Query history and Starred tab to a specific data source.

**Filtering history to a data source**

1. Select the **Filter queries for specific data source(s)** field.

1. Select the data source for which you would like to filter your history. You can select multiple data sources.

In the **Query history** tab it is also possible to filter queries by date using the slider:
+ Use the vertical slider to filter queries by date.
+ Adjust the start date by dragging the top handle.
+ Adjust the end date by dragging the top handle.

**Searching in query history**

You can search in your history across queries and your comments. Search is possible for queries in the Query history tab and Starred tab.

**To search in query history**

1. Select the **Search queries** field.

1. Enter the term you are searching for into search field.

**Query history settings**

You can customize the query history in the Settings tab. Options are described in the table below.


| Setting | Default value | 
| --- | --- | 
| Change the default active tab | Query history tab | 

**Note**  
Query history settings are global, and applied to both panels in split mode.

## Prometheus-specific Features
<a name="v9-explore-manage-prometheus"></a>

Explore features a custom querying experience for Prometheus. When a query is run, it actually runs two queries, a normal Prometheus query for the graph and an *Instant Query* for the table. An Instant Query returns the last value for each time series which shows a good summary of the data shown in the graph.

**Metrics explorer**

On the left side of the query field, choose **Metrics** to open the Metric Explorer. This shows a hierarchical menu with metrics grouped by their prefix. For example, all Alertmanager metrics are grouped under the `alertmanager` prefix. This is a good starting point if you just want to explore which metrics are available.

**Query field**

The Query field supports autocomplete for metric names and functions, comparable to the standard Prometheus query editor. You can press the Enter key to create a new line and Shift\$1Enter to run a query.

The autocomplete menu can be triggered by pressing Ctrl\$1Space. The Autocomplete menu contains a new History section with a list of recently run queries.

Suggestions can appear under the query field - select on them to update your query with the suggested change.
+ For counters (monotonically increasing metrics), a rate function will be suggested.
+ For buckets, a histogram function will be suggested.
+ For recording rules, possible to expand the rules.

**Table filters**

Select the filter button in the **label** column of a Table panel to add filters to the query expression. You can add filters for multiple queries as well - the filter is added for all the queries.

# Logs in Explore
<a name="v9-explore-logs"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

Along with metrics, Explore allows you to investigate your logs in the following data sources:
+ [OpenSearch](using-opensearch-in-AMG.md)
+ [InfluxDB](using-influxdb-in-AMG.md)
+ [Loki](using-loki-in-AMG.md)

During an infrastructure monitoring and incident response, you can dig deeper into the metrics and logs to find the cause. Explore also allows you to correlate metrics and logs by viewing them side-by-side. This creates a new debugging workflow.

1. Receive an alert.

1. Drill down and examine metrics.

1. Drill down again and search logs related to the metric and time interval (and in the future, distributed traces).

## Logs visualization
<a name="v9-explore-logs-viz"></a>

Results of log queries are shown as histograms in the graph and individual logs are explained in the following sections.

If the data source supports a full range log volume histogram, the graph with log distribution for all entered log queries is shown automatically. This feature is currently supported by OpenSearch and Loki data sources.

**Note**  
In Loki, this full range log volume histogram is rendered by metric query which can be expensive depending on time range queried. This query can be particularly challenging for smaller Loki installations to process. To mitigate this, we recommend using a proxy like [nginx](https://www.nginx.com/) in front of Loki to set a custom timeout (e.g. 10 seconds) for these queries. Log volume histogram queries can be identified by looking for queries with the HTTP header `X-Query-Tags` with value `Source=logvolhist`; these headers are added by Grafana to all log volume histogram queries.

If the data source does not support loading full range log volume histogram, the logs model computes a time series based on the log row counts bucketed by an automatically calculated time interval, and the first log row’s timestamp then anchors the start of the histogram from the result. The end of the time series is anchored to the time picker’s **To** range.

**Log level**

For logs where a level label is specified, Grafana uses the value of the label to determine the log level and update color accordingly. If the log doesn’t have a level label specified, it tries to find out if its content matches any of the supported expressions (see below for more information). The log level is always determined by the first match. In case Grafana is not able to determine a log level, it will be visualized with an unknown log level.

**Tip**  
If you use Loki data source and the `level` is in your log-line, use parsers (JSON, logfmt, regex,..) to extract the level information into a level label that is used to determine log level. This will allow the histogram to show the various log levels in separate bars.

**Supported log levels and mapping of log level abbreviation and expressions:**


| Supported expressions | Log level | Color | 
| --- | --- | --- | 
| emerg | critical | purple | 
| fatal | critical | purple | 
| alert | critical | purple | 
| crit | critical | purple | 
| critical | critical | purple | 
| err | error | red | 
| eror | error | red | 
| error | error | red | 
| warn | warning | yellow | 
| warning | warning | yellow | 
| info | info | green | 
| information | info | green | 
| notice | info | green | 
| dbug | debug | blue | 
| debug | debug | blue | 
| trace | trace | light blue | 
| \$1 | unknown | grey | 

## Logs navigation
<a name="v9-explore-logs-nav"></a>

The logs navigation interface, next to the log lines, can be used to request more logs. You can do this by selecting the **Older logs** button on the bottom of navigation. When you hit the line limit and you want to see more logs, you can use this to fetch more logs. Each request is displayed in the navigation as a separate page. Every page shows the from and to timestamp of the incoming log lines. You can see previous results by clicking on the page to view. Explore caches the last five requests run from the logs navigation, so it does not re-run the same query when clicking on those pages.

## Visualization options
<a name="v9-explore-logs-vis-options"></a>

You can customize how logs are displayed and select which columns are shown.

**Time**

Shows or hides the time column. This is the timestamp associated with the log line as reported from the data source.

**Unique labels**

Shows or hides the unique labels column that includes only non-common labels. All common labels are displayed above.

**Wrap lines**

Set this to True if you want the display to use line wrapping. If set to False, it will result in horizontal scrolling.

**Prettify JSON**

Set this to `true` to pretty print all JSON logs. This setting does not affect logs in any format other than JSON.

**Deduplication**

Log data can be very repetitive and Explore can help by hiding duplicate log lines. There are a few different deduplication algorithms that you can use:
+ **Exact** – Exact matches are done on the whole line except for date fields.
+ **Numbers** – Matches on the line after stripping out numbers such as durations, IP addresses, and so on.
+ **Signature** – The most aggressive deduplication, this strips all letters and numbers and matches on the remaining whitespace and punctuation.

**Flip results order**

You can change the order of received logs from the default descending order (newest first) to ascending order (oldest first).

**Labels and detected fields**

Each log row has an extendable area with its labels and detected fields, for more robust interaction. For all labels we have added the ability to filter for (positive filter) and filter out (negative filter) selected labels. Each field or label also has a stats icon to display statistics in relation to all displayed logs.

**Escaping newlines**

Explore automatically detects some incorrectly escaped sequences in log lines, such as newlines (`\n`, `\r`) or tabs (`\t`). When it detects such sequences, Explore provides an “Escape newlines” option.

Explore can automatically fix incorrectly escaped sequences that it has detected

**To automatically fix escape sequences**

1. Select **Escape newlines** to replace the sequences.

1. Manually review the replacements to confirm their correctness.

Explore replaces these sequences. When it does so, the option will change from **Escape newlines** to **Remove escaping**. Evaluate the changes as the parsing might not be accurate based on the input received. You can revert the replacements by selecting **Remove escaping**.

**Data links**

By using data links, you can turn any part of a log message into an internal or external link. The created link is visible as a button in the **Links** section inside the **Log details** view.

**Toggle field visibility**

Expand a log line and click the eye icon to show or hide fields.

## Loki-specific features
<a name="v9-explore-logs-loki"></a>

Loki is the open source log aggregation system from Grafana Labs. Loki is designed to be cost effective, as it does not index the contents of the logs, but rather a set of labels for each log stream. The logs from Loki are queried in a similar way to querying with label selectors in Prometheus. It uses labels to group log streams which can be made to match up with your Prometheus labels. For more information about Grafana Loki, you can see the [Grafana Loki](https://github.com/grafana/loki) Github.

For more information, see [Loki](using-loki-in-AMG.md) on how to query for log data.

**Switch from metrics to logs**

If you switch from a Prometheus query to a logs query (you can do a split first to have your metrics and logs side by side) then it will keep the labels from your query that exist in the logs and use those to query the log streams. For example, if you have the following Prometheus query:

```
grafana_alerting_active_alerts{job="grafana"}
```

after switching to the Logs data source, it will change to:

```
{job="grafana"}
```

This will return a chunk of logs in the selected time range that can be searched.

## Logs sample
<a name="v9-explore-logs-sample"></a>

If the selected data source implements logs sample, and supports both log and metric queries, then for metric queries you will be able to automatically see samples of log lines that contributed to visualized metrics. This feature is currently supported by Loki data sources.

# Tracing in Explore
<a name="v9-explore-tracing"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

Explore allows you to visualize traces from tracing data sources.

The following data sources are supported.
+ [Jaeger](jaeger-data-source.md)
+ [Tempo](tempo-data-source.md)
+ [AWS X-Ray](x-ray-data-source.md)
+ [Zipkin](zipkin-data-source.md)

For information on how to configure queries for the data sources listed above, refer to the documentation for specific data source.

## Trace View explanation
<a name="v9-explore-trace-view"></a>

This section explains the elements of the Trace View dashboard.

**Header**

The header of the trace view has the following elements
+ Header title: Shows the name of the root span and trace ID.
+ Search: Highlights spans containing the searched text.
+ Metadata: Various metadata about the trace.

**Minimap**

Shows condensed view or the trace timeline. Drag your pointer over the minimap to zoom into smaller time range. Zooming will also update the main timeline, so it is easy to see shorter spans. Hovering over the minimap, when zoomed, will show Reset Selection button which resets the zoom.

**Timeline**

Shows list of spans within the trace. Each span row consists of these components:
+ Expand children button: Expands or collapses all the children spans of selected span.
+ Service name: Name of the service logged the span.
+ Operation name: Name of the operation that this span represents.
+ Span duration bar: Visual representation of the operation duration within the trace.

**Span details**

Clicking anywhere on the span row shows span details, including the following.
+ Operation name
+ Span metadata
+ Tags: Any tags associated with this span.
+ Process metadata: Metadata about the process that logged this span.
+ Logs: List of logs logged by this span and associated key values. In case of Zipkin logs section shows Zipkin annotations.

**Node graph**

You can optionally expand the node graph for the displayed trace. Depending on the data source, this can show spans of the trace as nodes in the graph, or add some additional context, including the service graph based on the current trace.

**Trace to logs**

You can navigate from a span in a trace view directly to logs relevant for that span. This is available for Tempo, Jaeger, and Zipkin data sources. Refer to their relevant documentation for instructions on how to configure each data source.

Click the document icon to open a split view in Explore with the configured data source and query relevant logs for the span.

## Service Graph view
<a name="v9-explore-trace-graph"></a>

The Service Graph view visualizes the span metrics (traces data for rates, error rates, and durations (RED)) and service graphs. Once the requirements are set up, this pre-configured view is immediately available.

For more information, see [Tempo](tempo-data-source.md) data source page. You can also see the [service graph view page](https://grafana.com/docs/tempo/latest/metrics-generator/service-graph-view/) in the *Tempo documentation*.

# Inspector in Explore
<a name="v9-explore-inspector"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

The inspector helps you understand and troubleshoot your queries. You can inspect the raw data, export that data to a comma-separated values (CSV) file, export log results in TXT format, and view query requests.

## Inspector UI
<a name="v9-explore-inspector-ui"></a>

The inspector has the following tabs:
+ **Stats tab** – Shows how long your query takes and how much it returns.
+ **Query tab** – Shows you the requests to the server sent when Grafana queries the data source.
+ **JSON tab** – Allows you to view and copy the data JSON and data frame structure JSON.
+ **Data tab** – Shows the raw data returned by the query.
+ **Error tab** – Shows the error. Only visible when query returns error.

## Inspector tasks
<a name="v9-explore-inspector-tasks"></a>

You can perform a variety of tasks in the Explore inspector.

**Open the Inspector**

After you run the query you would like to inspect, select the **Inspector** button.

The inspector pane opens on the bottom of the screen.

*Inspect raw query results*

You can view raw query results that is the data returned by the query in a table.

In the **Inspector** tab, click the **Data** tab.

For multiple queries or for queries multiple nodes, there are additional options.
+ **Show data frame:** Select the result set data you want to view.
+ **Series joined by time:** View the raw data from all of your queries at once, one result set per column. You can click a column heading to sort the data.

**Download raw query results as CSV**

After you are viewing the raw query results, you can generate a CSV file of the results. You will get a CSV file of the result you see, so be sure to refine the results to get the results you want before generating the CSV file.

To generate the CSV file, select **Download CSV** in the **Inspector** tab.

In order to download a CSV file specifically formatted for Excel, expand **Data options** and then turn on the **Download for Excel** toggle before you select the **Download CSV** option.

*Download log results as TXT*

You can generate a TXT file of the logs you are currently viewing, by selecting **Download logs** in the **Inspector**tab.

**Download trace results**

Based on the data source type, Grafana can generate a JSON file for the trace results in one of the supported formats: Jaeger, Zipkin, or OTLP formats.

To download the traces, select **Download traces** on the **Inspector**tab.

**Inspect query performance**

The **Stats** tab displays statistics that tell you how long your query takes, how many queries you send, and the number of rows returned. This information can help you troubleshoot your queries, especially if any of the numbers are unexpectedly high or low.

Statistics are read-only.

**View JSON model**

You can explore and export data as well as data frame JSON models.

**To view the JSON model**

1. In the Inspector panel, click the **JSON** tab.

1. From the **Select source** dropdown, choose one of the following options:
   + **Data** – Displays a JSON object representing the data that was returned to Explore.
   + **DataFrame structure** – Displays the raw result set.

1. You can expand or collapse portions of the JSON to view separate sections. You can also select the **Copy to clipboard** option to copy JSON body and paste it into another application.

**View raw request and response to data source**

As you are working with Explore and the Inspector tab, you can view the raw request and response data that you are generating with a query. In the Inspector, select the **Query** tab and choose **Refresh** to see the raw data.

Grafana sends the query to the server and displays the result. You can drill down on specific portions of the query, expand or collapse all of it, or copy the data to the clipboard to use in other applications.

# Alerts in Grafana version 9
<a name="v9-alerts"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

Grafana alerting provides you with robust and actionable alerts that help you learn about problems in the systems moments after they occur, minimizing disruption to your services.

Amazon Managed Grafana includes access to an updated alerting system, *Grafana alerting*, that centralizes alerting information in a single, searchable view. It includes the following features:
+ Create and manage Grafana alerts in a centralized view.
+ Create and manage Cortex and Loki managed alerts through a single interface.
+ View alerting information from Prometheus, Amazon Managed Service for Prometheus, and other Alertmanager compatible data sources.

When you create your Amazon Managed Grafana workspace, you have the choice of using Grafana alerting, or the [Classic dashboard alerts](old-alerts-overview.md). This section covers Grafana alerting.

**Note**  
If you created your workspace with the Classic alerts enabled, and want to switch to Grafana alerting, you can [switch between the two alerting systems.](v9-alerting-use-grafana-alerts.md).

## Grafana alerting limitations
<a name="v9-alert-limitations"></a>
+ The Grafana alerting system can retrieve rules from all available Amazon Managed Service for Prometheus, Prometheus, Loki, and Alertmanager data sources. It might not be able to fetch rules from other supported data sources.
+ Alert rules defined in Grafana, rather than in Prometheus, send multiple notifications to your contact point. If you are using native Grafana alerts, we recommend that you stay on classic dashboard alerting and not enable the new Grafana alerting feature. If you would like to view Alerts defined in your Prometheus data source, then we recommend you enable Grafana Alerting, which sends only a single notification for alerts created in Prometheus Alertmanager.
**Note**  
This limitation is no longer a limitation in Amazon Managed Grafana workspaces that support Grafana v10.4 and later.

**Topics**
+ [Grafana alerting limitations](#v9-alert-limitations)
+ [Overview](v9-alerting-overview.md)
+ [Exploring alerting](v9-alerting-explore.md)
+ [Set up Alerting](v9-alerting-setup.md)
+ [Migrating classic dashboard alerts to Grafana alerting](v9-alerting-use-grafana-alerts.md)
+ [Manage your alert rules](v9-alerting-managerules.md)
+ [Manage your alert notifications](v9-alerting-managenotifications.md)

# Overview
<a name="v9-alerting-overview"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

The following gives you an overview of how Grafana Alerting works and introduces you to some of the key concepts that work together and form the core of its flexible and powerful alerting engine.

1. **Data source**

   Connects to data to be used by alerting. This data is often time-series data, for alerts, and shows the details of a system to be monitored and analyzed. For more information, see [data sources](AMG-data-sources-builtin.md).

1. **Alert rules**

   Set evaluation criteria that determines whether an alert instance will fire. An alert rule consists of one or more queries and expressions to pull data from the datasource, a condition describing what constitutes the need for an alert, the frequency of evaluation, and optionally, the duration over which the condition must be met for an alert to fire.

   Grafana managed alerts support multi-dimensional alerting, which means that each alert rule can create multiple alert instances. This is exceptionally powerful if you are observing multiple series in a single expression.

1. **Labels**

   Match an alert rule and its instances to notification policies and silences. They can also be used to group your alerts by severity.

1. **Notification policies**

   Set where, when, and how the alerts get routed to notify your team when the alert fires. Each notification policy specifies a set of label matchers to indicate which alerts they are responsible for. A notification policy has a contact point assigned to it that consists of one or more notifiers.

1. **Contact points**

   Define how your contacts are notified when an alert fires. We support a multitude of ChatOps tools to ensure the alerts come to your team.

## Features
<a name="v9-alerting-features"></a>

**One page for all alerts**

A single Grafana Alerting page consolidates both Grafana-managed alerts and alerts that reside in your Prometheus-compatible data source in one single place.

**Multi-dimensional alerts**

Alert rules can create multiple individual alert instances per alert rule, known as multi-dimensional alerts, giving you the power and flexibility to gain visibility into your entire system with just a single alert.

**Routing alerts**

Route each alert instance to a specific contact point based on labels you define. Notification policies are the set of rules for where, when, and how the alerts are routed to contact points.

**Silencing alerts**

Silences allow you to stop receiving persistent notifications from one or more alerting rules. You can also partially pause an alert based on certain criteria. Silences have their own dedicated section for better organization and visibility, so that you can scan your paused alert rules without cluttering the main alerting view.

**Mute timings**

With mute timings, you can specify a time interval when you don’t want new notifications to be generated or sent. You can also freeze alert notifications for recurring periods of time, such as during a maintenance period.

# Exploring alerting
<a name="v9-alerting-explore"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

Whether you’re starting or expanding your implementation of Grafana Alerting, learn more about the key concepts and available features that help you create, manage, and take action on your alerts and improve your team’s ability to resolve issues quickly.

First of all, let’s look at the different alert rule types that Grafana Alerting offers.

## Alert rule types
<a name="v9-alerting-explore-rule-types"></a>

**Grafana-managed rules**

Grafana-managed rules are the most flexible alert rule type. They allow you to create alerts that can act on data from any of our supported data sources. In addition to supporting multiple data sources, you can also add expressions to transform your data and set alert conditions. This is the only type of rule that allows alerting from multiple data sources in a single rule definition.

**Mimir and Loki rules**

To create Mimir or Loki alerts you must have a compatible Prometheus or Loki data source. You can check if your data source supports rule creation via Grafana by testing the data source and observing if the ruler API is supported.

**Recording rules**

Recording rules are only available for compatible Prometheus or Loki data sources. A recording rule allows you to pre-compute frequently needed or computationally expensive expressions and save their result as a new set of time series. This is useful if you want to run alerts on aggregated data or if you have dashboards that query computationally expensive expressions repeatedly.

## Key concepts and features
<a name="v9-alerting-explore-features"></a>

The following table includes a list of key concepts, features and their definitions, designed to help you make the most of Grafana Alerting.


| Key concept or feature | Definition | 
| --- | --- | 
|  Data sources for Alerting  |  Select data sources you want to query and visualize metrics, logs and traces from.  | 
|  Provisioning for Alerting  |  Manage your alerting resources and provision them into your Grafana system using file provisioning or Terraform.  | 
|  Alertmanager  |  Manages the routing and grouping of alert instances.  | 
|  Alert rule  |  A set of evaluation criteria for when an alert rule should fire. An alert rule consists of one or more queries and expressions, a condition, the frequency of evaluation, and the duration over which the condition is met. An alert rule can produce multiple alert instances.  | 
|  Alert instance  |  An alert instance is an instance of an alert rule. A single-dimensional alert rule has one alert instance. A multidimensional alert rule has one or more alert instances. A single alert rule that matches to multiple results, such as CPU against 10 VMs, is counted as multiple (in this case 10) alert instances. This number can vary over time. For example, an alert rule that monitors CPU usage for all VMs in a system has more alert instances as VMs are added. For more information about alert-instance quotas, see [Quota reached errors](v9-alerting-managerules-grafana.md#v9-alerting-rule-quota-reached).  | 
|  Alert group  |  The Alertmanager groups alert instances by default using the labels for the root notification policy. This controls de-duplication and groups of alert instances, which are sent to contact points.  | 
|  Contact point  |  Define how your contacts are notified when an alert rule fires.  | 
|  Message templating  |  Create reusable custom templates and use them in contact points.  | 
|  Notification policy  |  Set of rules for where, when, and how the alerts are grouped and routed to contact points.  | 
|  Labels and label matchers  |  Labels uniquely identify alert rules. They link alert rules to notification policies and silences, determining which policy should handle them and which alert rules should be silenced.  | 
|  Silences  |  Stop notifications from one or more alert instances. The difference between a silence and a mute timing is that a silence only lasts for only a specified window of time whereas a mute timing is meant to be recurring on a schedule. Uses label matchers to silence alert instances.  | 
|  Mute timings  |  Specify a time interval when you don’t want new notifications to be generated or sent. You can also freeze alert notifications for recurring periods of time, such as during a maintenance period. Must be linked to an existing notification policy.  | 

# Data sources
<a name="v9-alerting-explore-datasources"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

There are a number of [data sources](AMG-data-sources-builtin.md) that are compatible with Grafana Alerting. Each data source is supported by a plugin. You can use one of the built-in data sources listed below.

These are the data sources that are compatible with and supported by Amazon Managed Grafana.
+ [Connect to an Alertmanager data source](data-source-alertmanager.md)
+ [Connect to an Amazon CloudWatch data source](using-amazon-cloudwatch-in-AMG.md)
+ [Connect to an Amazon OpenSearch Service data source](using-Amazon-OpenSearch-in-AMG.md)
+ [Connect to an AWS IoT SiteWise data source](using-iotsitewise-in-AMG.md)
+ [Connect to an AWS IoT TwinMaker data source](AMG-iot-twinmaker.md)
+ [Connect to Amazon Managed Service for Prometheus and open-source Prometheus data sources](prometheus-data-source.md)
+ [Connect to an Amazon Timestream data source](timestream-datasource.md)
+ [Connect to an Amazon Athena data source](AWS-Athena.md)
+ [Connect to an Amazon Redshift data source](AWS-Redshift.md)
+ [Connect to an AWS X-Ray data source](x-ray-data-source.md)
+ [Connect to an Azure Monitor data source](using-azure-monitor-in-AMG.md)
+ [Connect to a Google Cloud Monitoring data source](using-google-cloud-monitoring-in-grafana.md)
+ [Connect to a Graphite data source](using-graphite-in-AMG.md)
+ [Connect to an InfluxDB data source](using-influxdb-in-AMG.md)
+ [Connect to a Loki data source](using-loki-in-AMG.md)
+ [Connect to a Microsoft SQL Server data source](using-microsoft-sql-server-in-AMG.md)
+ [Connect to a MySQL data source](using-mysql-in-AMG.md)
+ [Connect to an OpenTSDB data source](using-opentsdb-in-AMG.md)
+ [Connect to a PostgreSQL data source](using-postgresql-in-AMG.md)
+ [Connect to a Jaeger data source](jaeger-data-source.md)
+ [Connect to a Zipkin data source](zipkin-data-source.md)
+ [Connect to a Tempo data source](tempo-data-source.md)
+ [Configure a TestData data source for testing](testdata-data-source.md)

# About alert rules
<a name="v9-alerting-explore-rules"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

An alerting rule is a set of evaluation criteria that determines whether an alert instance will fire. The rule consists of one or more queries and expressions, a condition, the frequency of evaluation, and optionally, the duration over which the condition is met.

While queries and expressions select the data set to evaluate, a condition sets the threshold that an alert must meet or exceed to create an alert.

An interval specifies how frequently an alerting rule is evaluated. Duration, when configured, indicates how long a condition must be met. The alert rules can also define alerting behavior in the absence of data.

**Topics**
+ [Alert rule types](v9-alerting-explore-rules-types.md)
+ [Alert instances](v9-alerting-rules-instances.md)
+ [Namespaces and groups](v9-alerting-rules-grouping.md)
+ [Notification templating](v9-alerting-rules-notification-templates.md)

# Alert rule types
<a name="v9-alerting-explore-rules-types"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

Grafana supports several alert rule types. The following sections will explain their merits and demerits and help you choose the right alert type for your use case.

Grafana managed rules

Grafana-managed rules are the most flexible alert rule type. They allow you to create alerts that can act on data from any of your existing data sources.

In addition to supporting any data source, you can add [expressions](v9-panels-query-xform-expressions.md) to transform your data and express alert conditions.

Mimir, Loki and Cortex rules

To create Mimir, Loki or Cortex alerts you must have a compatible Prometheus data source. You can check if your data source is compatible by testing the data source and checking the details if the ruler API is supported.

Recording rules

Recording rules are only available for compatible Prometheus data sources like Mimir, Loki and Cortex.

A recording rule allows you to save an expression’s result to a new set of time series. This is useful if you want to run alerts on aggregated data or if you have dashboards that query the same expression repeatedly.

Read more about [recording rules](https://prometheus.io/docs/prometheus/latest/configuration/recording_rules/) in Prometheus.

# Alert instances
<a name="v9-alerting-rules-instances"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

Grafana managed alerts support multi-dimensional alerting. Each alert rule can create multiple alert instances. This is powerful if you are observing multiple series in a single expression.

Consider the following PromQL expression:

```
sum by(cpu) (
  rate(node_cpu_seconds_total{mode!="idle"}[1m])
)
```

A rule using this expression will create as many alert instances as the amount of CPUs observed during evaluation, allowing a single rule to report the status of each CPU.

# Namespaces and groups
<a name="v9-alerting-rules-grouping"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

Alerts can be organized using Folders for Grafana-managed rules and namespaces for Mimir, Loki, or Prometheus rules and group names.

**Namespaces**

When creating Grafana-managed rules, the folder can be used to perform access control and grant or deny access to all rules within a specific folder.

**Groups**

All rules within a group are evaluated at the same **interval**.

Alert rules and recording rules within a group will always be evaluated **sequentially**, meaning no rules will be evaluated at the same time and in order of appearance.

**Tip**  
If you want rules to be evaluated concurrently and with different intervals, consider storing them in different groups.

# Notification templating
<a name="v9-alerting-rules-notification-templates"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

Notifications sent via contact points are built using notification templates. Grafana’s default templates are based on the [Go templating system](https://golang.org/pkg/text/template) where some fields are evaluated as text, while others are evaluated as HTML (which can affect escaping).

The default template [default\$1template.go](https://github.com/grafana/alerting/blob/main/templates/default_template.go) is a useful reference for custom templates.

Since most of the contact point fields can be templated, you can create reusable custom templates and use them in multiple contact points. To learn about custom notifications using templates, see [Customize notifications](v9-alerting-notifications.md).

**Nested templates**

You can embed templates within other templates.

For example, you can define a template fragment using the `define` keyword.

```
{{ define "mytemplate" }}
  {{ len .Alerts.Firing }} firing. {{ len .Alerts.Resolved }} resolved.
{{ end }}
```

You can then embed custom templates within this fragment using the `template` keyword. For example:

```
Alert summary:
{{ template "mytemplate" . }}
```

You can use any of the following built-in template options to embed custom templates.


| Name | Notes | 
| --- | --- | 
|  `default.title`  |  Displays high-level status information.  | 
|  `default.message`  |  Provides a formatted summary of firing and resolved alerts.  | 
|  `teams.default.message`  |  Similar to `default.messsage`, formatted for Microsoft Teams.  | 

**HTML in notification templates**

HTML in alerting notification templates is escaped. We do not support rendering of HTML in the resulting notification.

Some notifiers support alternative methods of changing the look and feel of the resulting notification. For example, Grafana installs the base template for alerting emails to `<grafana-install-dir>/public/emails/ng_alert_notification.html`. You can edit this file to change the appearance of all alerting emails.

# Alerting on numeric data
<a name="v9-alerting-explore-numeric"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

This topic describes how Grafana handles alerting on numeric rather than time series data.

Among certain data sources numeric data that is not time series can be directly alerted on, or passed into Server Side Expressions (SSE). This allows for more processing and resulting efficiency within the data source, and it can also simplify alert rules. When alerting on numeric data instead of time series data, there is no need to reduce each labeled time series into a single number. Instead labeled numbers are returned to Grafana instead.

**Tabular Data**

This feature is supported with backend data sources that query tabular data:
+ SQL data sources such as MySQL, Postgres, MSSQL, and Oracle.
+ The Azure Kusto based services: Azure Monitor (Logs), Azure Monitor (Azure Resource Graph), and Azure Data Explorer.

A query with Grafana managed alerts or SSE is considered numeric with these data sources, if:
+ The “Format AS” option is set to “Table” in the data source query.
+ The table response returned to Grafana from the query includes only one numeric (e.g. int, double, float) column, and optionally additional string columns.

If there are string columns, then those columns become labels. The name of column becomes the label name, and the value for each row becomes the value of the corresponding label. If multiple rows are returned, then each row should be uniquely identified their labels.

**Example**

For a MySQL table called “DiskSpace”:


| Time | Host | Disk | PercentFree | 
| --- | --- | --- | --- | 
|  2021-June-7  |  web1  |  /etc  |  3  | 
|  2021-June-7  |  web2  |  /var  |  4  | 
|  2021-June-7  |  web3  |  /var  |  8  | 
|  ...  |  ...  |  ...  |  ...  | 

You can query the data filtering on time, but without returning the time series to Grafana. For example, an alert that would trigger per Host, Disk when there is less than 5% free space:

```
SELECT Host , Disk , CASE WHEN PercentFree  < 5.0 THEN PercentFree  ELSE 0 END FROM ( 
   SELECT
      Host, 
      Disk, 
      Avg(PercentFree) 
   FROM DiskSpace
   Group By
      Host, 
      Disk 
   Where __timeFilter(Time)
```

This query returns the following Table response to Grafana:


| Host | Disk | PercentFree | 
| --- | --- | --- | 
|  web1  |  /etc  |  3  | 
|  web2  |  /var  |  4  | 
|  web3  |  /var  |  0  | 

When this query is used as the **condition** in an alert rule, then the non-zero will be alerting. As a result, three alert instances are produced:


| Labels | Status | 
| --- | --- | 
|  \$1Host=web1,disk=/etc\$1  |  Alerting  | 
|  \$1Host=web2,disk=/var\$1  |  Alerting  | 
|  \$1Host=web3,disk=/var\$1  |  Normal  | 

# Labels and annotations
<a name="v9-alerting-explore-labels"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

Labels and annotations contain information about an alert. Both labels and annotations have the same structure: a set of named values; however their intended uses are different. An example of label, or the equivalent annotation, might be `alertname="test"`.

The main difference between a label and an annotation is that labels are used to differentiate an alert from all other alerts, while annotations are used to add additional information to an existing alert.

For example, consider two high CPU alerts: one for `server1` and another for `server2`. In such an example, we might have a label called `server` where the first alert has the label `server="server1"` and the second alert has the label `server="server2"`. However, we might also want to add a description to each alert such as `"The CPU usage for server1 is above 75%."`, where `server1` and `75%` are replaced with the name and CPU usage of the server (please refer to the documentation on [Templating labels and annotations](v9-alerting-explore-labels-templating.md) for how to do this). This kind of description would be more suitable as an annotation.

## Labels
<a name="v9-alerting-explore-labels-labels"></a>

Labels contain information that identifies an alert. An example of a label might be `server=server1`. Each alert can have more than one label, and the complete set of labels for an alert is called its label set. It is this label set that identifies the alert.

For example, an alert might have the label set `{alertname="High CPU usage",server="server1"}` while another alert might have the label set `{alertname="High CPU usage",server="server2"}`. These are two separate alerts because although their `alertname` labels are the same, their `server` labels are different.

The label set for an alert is a combination of the labels from the datasource, custom labels from the alert rule, and a number of reserved labels such as `alertname`.

**Custom Labels**

Custom labels are additional labels from the alert rule. Like annotations, custom labels must have a name, and their value can contain a combination of text and template code that is evaluated when an alert is fired. Documentation on how to template custom labels can be found [here](v9-alerting-explore-labels-templating.md).

When using custom labels with templates, it is important to make sure that the label value does not change between consecutive evaluations of the alert rule as this will end up creating large numbers of distinct alerts. However, it is OK for the template to produce different label values for different alerts. For example, do not put the value of the query in a custom label as this will end up creating a new set of alerts each time the value changes. Instead use annotations.

It is also important to make sure that the label set for an alert does not have two or more labels with the same name. If a custom label has the same name as a label from the datasource then it will replace that label. However, should a custom label have the same name as a reserved label then the custom label will be omitted from the alert.

## Annotations
<a name="v9-alerting-explore-labels-annotations"></a>

Annotations are named pairs that add additional information to existing alerts. There are a number of suggested annotations in Grafana such as `description`, `summary`, `runbook_url`, `dashboardUId` and `panelId`. Like custom labels, annotations must have a name, and their value can contain a combination of text and template code that is evaluated when an alert is fired. If an annotation contains template code, the template is evaluated once when the alert is fired. It is not re-evaluated, even when the alert is resolved. Documentation on how to template annotations can be found [here](v9-alerting-explore-labels-templating.md).

# How label matching works
<a name="v9-alerting-explore-labels-matching"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

Use labels and label matchers to link alert rules to notification policies and silences. This allows for a very flexible way to manage your alert instances, specify which policy should handle them, and which alerts to silence.

A label matchers consists of 3 distinct parts, the **label**, the **value** and the **operator**.
+ The **Label** field is the name of the label to match. It must exactly match the label name.
+ The **Value** field matches against the corresponding value for the specified **Label** name. How it matches depends on the **Operator** value.
+ The **Operator** field is the operator to match against the label value. The available operators are:


| Operator | Description | 
| --- | --- | 
|  `=`  |  Select labels that are exactly equal to the value.  | 
|  `!=`  |  Select labels that are not equal to the value.  | 
|  `=~`  |  Select labels that regex-match the value.  | 
|  `!~`  |  Select labels that do not regex-match the value.  | 

If you are using multiple label matchers, they are combined using the AND logical operator. This means that all matchers must match in order to link a rule to a policy.

**Example scenario**

If you define the following set of labels for your alert:

```
{ foo=bar, baz=qux, id=12 }
```

then:
+ A label matcher defined as `foo=bar` matches this alert rule.
+ A label matcher defined as `foo!=bar` does *not* match this alert rule.
+ A label matcher defined as `id=~[0-9]+` matches this alert rule.
+ A label matcher defined as `baz!~[0-9]+` matches this alert rule.
+ Two label matchers defined as `foo=bar` and `id=~[0-9]+` match this alert rule.

# Labels in Grafana Alerting
<a name="v9-alerting-explore-labels-alerting"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

This topic explains why labels are a fundamental component of alerting.
+ The complete set of labels for an alert is what uniquely identifies an alert within Grafana alerts.
+ The Alertmanager uses labels to match alerts for silences and alert groups in notification policies.
+ The alerting UI shows labels for every alert instance generated during evaluation of that rule.
+ Contact points can access labels to dynamically generate notifications that contain information specific to the alert that is resulting in a notification.
+ You can add labels to an [alerting rule](v9-alerting-managerules.md). Labels are manually configurable, use template functions, and can reference other labels. Labels added to an alerting rule take precedence in the event of a collision between labels (except in the case of Grafana reserved labels, see below for more information).

**External Alertmanager Compatibility**

Grafana’s built-in Alertmanager supports both Unicode label keys and values. If you are using an external Prometheus Alertmanager, label keys must be compatible with their [data model](https://prometheus.io/docs/concepts/data_model/#metric-names-and-labels). This means that label keys must only contain **ASCII letters**, **numbers**, as well as **underscores** and match the regex `[a-zA-Z_][a-zA-Z0-9_]*`. Any invalid characters will be removed or replaced by the Grafana alerting engine before being sent to the external Alertmanager according to the following rules:
+ `Whitespace` will be removed.
+ `ASCII characters` will be replaced with `_`.
+ `All other characters` will be replaced with their lower-case hex representation. If this is the first character it will be prefixed with `_`.

**Note**  
If multiple label keys are sanitized to the same value, the duplicates will have a short hash of the original label appended as a suffix.

**Grafana reserved labels**

**Note**  
Labels prefixed with `grafana_` are reserved by Grafana for special use. If a manually configured label is added beginning with `grafana_` it can be overwritten in case of collision.

Grafana reserved labels can be used in the same way as manually configured labels. The current list of available reserved labels are:


| Label | Description | 
| --- | --- | 
|  grafana\$1folder  |  Title of the folder containing the alert.  | 

# Templating labels and annotations
<a name="v9-alerting-explore-labels-templating"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

In Grafana, you template labels and annotations just like you would in Prometheus. If you have used Prometheus before then you should be familiar with the `$labels` and `$value` variables, which contain the labels and value of the alert. You can use the same variables in Grafana, even if the alert does not use a Prometheus datasource. If you haven’t used Prometheus before then don’t worry as each of these variables, and how to template them, will be explained as you follow the rest of this page.

## Go’s templating language
<a name="v9-alerting-explore-labels-templating-go"></a>

Templates for labels and annotations are written in Go’s templating language, [text/template](https://pkg.go.dev/text/template).

**Opening and closing tags**

In text/template, templates start with `{{` and end with `}}` irrespective of whether the template prints a variable or runs control structures such as if statements. This is different from other templating languages such as Jinja where printing a variable uses `{{` and `}}` and control structures use `{%` and `%}`.

**Print**

To print the value of something use `{{` and `}}`. You can print the the result of a function or the value of a variable. For example, to print the `$labels` variable you would write the following:

```
{{ $labels }}
```

**Iterate over labels**

To iterate over each label in `$labels` you can use a `range`. Here `$k` refers to the name and `$v` refers to the value of the current label. For example, if your query returned a label `instance=test` then `$k` would be `instance` and `$v` would be `test`.

```
{{ range $k, $v := $labels }}
{{ $k }}={{ $v }}
{{ end }}
```

## The labels, value and values variables
<a name="v9-alerting-explore-labels-templating-variables"></a>

**The labels variable**

The `$labels` variable contains the labels from the query. For example, a query that checks if an instance is down might return an instance label with the name of the instance that is down. For example, suppose you have an alert rule that fires when one of your instances has been down for more than 5 minutes. You want to add a summary to the alert that tells you which instance is down. With the `$labels` variable, you can create a summary that prints the instance label in the summary:

```
Instance {{ $labels.instance }} has been down for more than 5 minutes
```

**Labels with dots**

If the label you want to print contains a dot (full stop or period) in its name using the same dot in the template will not work:

```
Instance {{ $labels.instance.name }} has been down for more than 5 minutes
```

This is because the template is attempting to use a non-existing field called `name` in `$labels.instance`. You should instead use the `index` function, which prints the label `instance.name` in the `$labels` variable:

```
Instance {{ index $labels "instance.name" }} has been down for more than 5 minutes
```

**The value variable**

The `$value` variable works different from Prometheus. In Prometheus `$value` is a floating point number containing the value of the expression, but in Grafana it is a string containing the labels and values of all Threshold, Reduce and Math expressions, and Classic Conditions for this alert rule. It does not contain the results of queries, as these can return anywhere from 10s to 10,000s of rows or metrics.

If you were to use the `$value` variable in the summary of an alert:

```
{{ $labels.service }} has over 5% of responses with 5xx errors: {{ $value }})
```

The summary might look something like the following:

```
api has an over 5% of responses with 5xx errors: [ var='B' labels={service=api} value=6.789 ]
```

Here `var='B'` refers to the expression with the RefID B. In Grafana, all queries and expressions are identified by a RefID that identifies each query and expression in an alert rule. Similarly `labels={service=api}` refers to the labels, and `value=6.789` refers to the value.

You might have observed that there is no RefID A. That is because in most alert rules the RefID A refers to a query, and since queries can return many rows or time series they are not included in `$value`.

**The values variable**

If the `$value` variable contains more information than you need, you can instead print the labels and value of individual expressions using `$values`. Unlike `$value`, the `$values` variable is a table of objects containing the labels and floating point values of each expression, indexed by their RefID.

If you were to print the value of the expression with RefID `B` in the summary of the alert:

```
{{ $labels.service }} has over 5% of responses with 5xx errors: {{ $values.B }}%
```

The summary will contain just the value:

```
api has an over 5% of responses with 5xx errors: 6.789%
```

However, while `{{ $values.B }}` prints the number 6.789, it is actually a string as you are printing the object that contains both the labels and value for RefID B, not the floating point value of B. To use the floating point value of RefID B you must use the `Value` field from `$values.B`. If you were to humanize the floating point value in the summary of an alert:

```
{{ $labels.service }} has over 5% of responses with 5xx errors: {{ humanize $values.B.Value }}%
```

**No data, runtime errors and timeouts**

If the query in your alert rule returns no data, or fails because of a datasource error or timeout, then any Threshold, Reduce or Math expressions that use that query will also return no data or an error. When this happens these expression will be absent from `$values`. It is good practice to check that a RefID is present before using it as otherwise your template will break should your query return no data or an error. You can do this using an if statement:

```
{{ if $values.B }}{{ $labels.service }} has over 5% of responses with 5xx errors: {{ humanizePercentage $values.B.Value }}{{ end }}
```

## Classic Conditions
<a name="v9-alerting-explore-labels-templating-classic"></a>

If the rule uses Classic Conditions instead of Threshold, Reduce and Math expressions, then the `$values` variable is indexed by both the Ref ID and position of the condition in the Classic Condition. For example, if you have a Classic Condition with RefID B containing two conditions, then `$values` will contain two conditions `B0` and `B1`.

```
The first condition is {{ $values.B0 }}, and the second condition is {{ $values.B1 }}
```

## Functions
<a name="v9-alerting-explore-labels-templating-functions"></a>

The following functions are also available when expanding labels and annotations:

**args**

The `args` function translates a list of objects to a map with keys arg0, arg1 etc. This is intended to allow multiple arguments to be passed to templates.

**Example**

```
{{define "x"}}{{.arg0}} {{.arg1}}{{end}}{{template "x" (args 1 "2")}}
```

```
1 2
```

**externalURL**

The `externalURL` function returns the external URL of the Grafana server as configured in the ini file(s).

**Example**

```
{{ externalURL }}
```

```
https://example.com/grafana
```

**graphLink**

The `graphLink` function returns the path to the graphical view in [Explore in Grafana version 9](v9-explore.md) for the given expression and data source.

**Example**

```
{{ graphLink "{\"expr\": \"up\", \"datasource\": \"gdev-prometheus\"}" }}
```

```
/explore?left=["now-1h","now","gdev-prometheus",{"datasource":"gdev-prometheus","expr":"up","instant":false,"range":true}]
```

**humanize**

The `humanize` function humanizes decimal numbers.

**Example**

```
{{ humanize 1000.0 }}
```

```
1k
```

**humanize1024**

The `humanize1024` works similar to `humanize` but uses 1024 as the base rather than 1000.

**Example**

```
{{ humanize1024 1024.0 }}
```

```
1ki
```

**humanizeDuration**

The `humanizeDuration` function humanizes a duration in seconds.

**Example**

```
{{ humanizeDuration 60.0 }}
```

```
1m 0s
```

**humanizePercentage**

The `humanizePercentage` function humanizes a ratio value to a percentage.

**Example**

```
{{ humanizePercentage 0.2 }}
```

```
20%
```

**humanizeTimestamp**

The `humanizeTimestamp` function humanizes a Unix timestamp.

**Example**

```
{{ humanizeTimestamp 1577836800.0 }}
```

```
2020-01-01 00:00:00 +0000 UTC
```

**match**

The `match` function matches the text against a regular expression pattern.

**Example**

```
{{ match "a.*" "abc" }}
```

```
true
```

**pathPrefix**

The `pathPrefix` function returns the path of the Grafana server as configured in the ini file(s).

**Example**

```
{{ pathPrefix }}
```

```
/grafana
```

**tableLink**

The `tableLink` function returns the path to the tabular view in [Explore in Grafana version 9](v9-explore.md) for the given expression and data source.

**Example**

```
{{ tableLink "{\"expr\": \"up\", \"datasource\": \"gdev-prometheus\"}" }}
```

```
/explore?left=["now-1h","now","gdev-prometheus",{"datasource":"gdev-prometheus","expr":"up","instant":true,"range":false}]
```

**title**

The `title` function capitalizes the first character of each word.

**Example**

```
{{ title "hello, world!" }}
```

```
Hello, World!
```

**toLower**

The `toLower` function returns all text in lowercase.

**Example**

```
{{ toLower "Hello, world!" }}
```

```
hello, world!
```

**toUpper**

The `toUpper` function returns all text in uppercase.

**Example**

```
{{ toUpper "Hello, world!" }}
```

```
HELLO, WORLD!
```

**reReplaceAll**

The `reReplaceAll` function replaces text matching the regular expression.

**Example**

```
{{ reReplaceAll "localhost:(.*)" "example.com:$1" "localhost:8080" }}
```

```
example.com:8080
```

# State and health of alerting rules
<a name="v9-alerting-explore-state"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

The state and health of alerting rules help you understand several key status indicators about your alerts.

There are three key components: *alert rule state*, *alert instance state*, and *alert rule health*. Although related, each component conveys subtly different information.

**Alert rule state**

An alert rule can be in either of the following states:


| State | Description | 
| --- | --- | 
|  Normal  |  None of the time series returned by the evaluation engine is in a `Pending` or `Firing` state.  | 
|  Pending  |  At least one time series returned by the evaluation engine is `Pending`.  | 
|  Firing  |  At least one time series returned by the evaluation engine is `Firing`.  | 

**Note**  
Alerts will transition first to `pending` and then `firing`, thus it will take at least two evaluation cycles before an alert is fired.

**Alert instance state**

An alert instance can be in either of the following states:


| State | Description | 
| --- | --- | 
|  Normal  |  The state of an alert that is neither firing nor pending, everything is working correctly.  | 
|  Pending  |  The state of an alert that has been active for less than the configured threshold duration.  | 
|  Alerting  |  The state of an alert that has been active for longer than the configured threshold duration.  | 
|  NoData  |  No data has been received for the configured time window.  | 
|  Error  |  The error that occurred when attempting to evaluate an alerting rule.  | 

**Alert rule health**

An alert rule can have one the following health statuses:


| State | Description | 
| --- | --- | 
|  Ok  |  No error when evaluating an alerting rule.  | 
|  Error  |  An error occurred when evaluating an alerting rule.  | 
|  NoData  |  The absence of data in at least one time series returned during a rule evaluation.  | 

**Special alerts for `NoData` and `Error`**

When evaluation of an alerting rule produces state `NoData` or `Error`, Grafana Alerting will generate alert instances that have the following additional labels:


| Label | Description | 
| --- | --- | 
|  alertname  |  Either `DatasourceNoData` or `DatasourceError` depending on the state.  | 
|  datasource\$1uid  |  The UID of the data source that caused the state.  | 

You can handle these alerts the same way as regular alerts by adding a silence, route to a contact point, and so on.

# Contact points
<a name="v9-alerting-explore-contacts"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

Use contact points to define how your contacts are notified when an alert rule fires. A contact point can have one or more contact point types, for example, email, Slack, webhook, and so on. When an alert rule fires, a notification is sent to all contact point types listed for a contact point. Contact points can be configured for the Grafana Alertmanager as well as external alertmanagers.

You can also use notification templating to customize notification messages for contact point types.

**Supported contact point types**

The following table lists the contact point types supported by Grafana.


| Name | Type | 
| --- | --- | 
|  Amazon SNS  |  `sns`  | 
|  OpsGenie  |  `opsgenie`  | 
|  Pager Duty  |  `pagerduty`  | 
|  Slack  |  `slack`  | 
|  VictorOps  |  `victorops`  | 

For more information about contact points, see [Working with contact points](v9-alerting-contact-points.md) and [Customize notifications](v9-alerting-notifications.md).

# Notifications
<a name="v9-alerting-explore-notifications"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

Grafana uses Alertmanagers to send notifications for firing and resolved alerts. Grafana has its own Alertmanager, referred to as “Grafana” in the user interface, but also supports sending notifications from other Alertmanagers too, such as the [Prometheus Alertmanager](https://prometheus.io/docs/alerting/latest/alertmanager/). The Grafana Alertmanager uses notification policies and contact points to configure how and where a notification is sent; how often a notification should be sent; and whether alerts should all be sent in the same notification, sent in grouped notifications based on a set of labels, or as separate notifications.

## Notification policies
<a name="v9-alerting-explore-notifications-policies"></a>

Notification policies control when and where notifications are sent. A notification policy can choose to send all alerts together in the same notification, send alerts in grouped notifications based on a set of labels, or send alerts as separate notifications. You can configure each notification policy to control how often notifications should be sent as well as having one or more mute timings to inhibit notifications at certain times of the day and on certain days of the week.

Notification policies are organized in a tree structure where at the root of the tree there is a notification policy called the root policy. There can be only one root policy and the root policy cannot be deleted.

Specific routing policies are children of the root policy and can be used to match either all alerts or a subset of alerts based on a set of matching labels. A notification policy matches an alert when its matching labels match the labels in the alert.

A specific routing policy can have its own child policies, called nested policies, which allow for additional matching of alerts. An example of a specific routing policy could be sending infrastructure alerts to the Ops team; while a child policy might send high priority alerts to Pagerduty and low priority alerts to Slack.

All alerts, irrespective of their labels, match the root policy. However, when the root policy receives an alert it looks at each specific routing policy and sends the alert to the first specific routing policy that matches the alert. If the specific routing policy has further child policies, then it can attempt to the match the alert against one of its nested policies. If no nested policies match the alert then the specific routing policy is the matching policy. If there are no specific routing policies, or no specific routing policies match the alert, then the root policy is the matching policy.

## Contact points
<a name="v9-alerting-explore-notifications-contacts"></a>

Contact points contain the configuration for sending notifications. A contact point is a list of integrations, each of which sends a notification to a particular email address, service or URL. Contact points can have multiple integrations of the same kind, or a combination of integrations of different kinds. For example, a contact point could contain a Pager Duty integration; a Pager Duty and Slack integration; or a Pager Duty integration, a Slack integration, and two Amazon SNS integrations. You can also configure a contact point with no integrations; in which case no notifications are sent.

A contact point cannot send notifications until it has been added to a notification policy. A notification policy can only send alerts to one contact point, but a contact point can be added to a number of notification policies at the same time. When an alert matches a notification policy, the alert is sent to the contact point in that notification policy, which then sends a notification to each integration in its configuration.

**Note**  
For information about supported integrations for contact points, see [Contact points](v9-alerting-explore-contacts.md).

## Templating notifications
<a name="v9-alerting-explore-notifications-templating"></a>

You can customize notifications with templates. For example, templates can be used to change the title and message of notifications sent to Slack.

Templates are not limited to an individual integration or contact point, but instead can be used in a number of integrations in the same contact point and even integrations across different contact points. For example, a Grafana user can create a template called `custom_subject_or_title` and use it for both templating subjects in Pager Duty and titles of Slack messages without having to create two separate templates.

All notifications templates are written in [Go’s templating language](https://pkg.go.dev/text/template), and are in the Contact points tab on the Alerting page.

## Silences
<a name="v9-alerting-explore-notifications-silences"></a>

You can use silences to mute notifications from one or more firing rules. Silences do not stop alerts from firing or being resolved, or hide firing alerts in the user interface. A silence lasts as long as its duration which can be configured in minutes, hours, days, months or years.

# Set up Alerting
<a name="v9-alerting-setup"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

Configure the features and integrations that you need to create and manage your alerts.

**Topics**
+ [Add an external Alertmanager](v9-alerting-setup-alertmanager.md)
+ [Provisioning Grafana Alerting resources](v9-alerting-setup-provision.md)

# Add an external Alertmanager
<a name="v9-alerting-setup-alertmanager"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

Set up Grafana to use an external Alertmanager as a single Alertmanager to receive all of your alerts. This external Alertmanager can then be configured and administered from within Grafana itself.

Once you have added the Alertmanager, you can use the Grafana Alerting UI to manage silences, contact points, and notification policies. A dropdown option in these pages allows you to switch between alertmanagers.

**Note**  
Starting with Grafana 9.2, the URL configuration of external alertmanagers from the Admin tab on the Alerting page is deprecated. It will be removed in a future release.

External alertmanagers should now be configured as data sources using Grafana Configuration from the main Grafana navigation menu. This enables you to manage the contact points and notification policies of external alertmanagers from within Grafana and also encrypts HTTP basic authentication credentials that were previously visible when configuring external alertmanagers by URL.

To add an external Alertmanager, complete the following steps.

1. Click Configuration and then Data sources.

1. Search for Alertmanager.

1. Choose your Implementation and fill out the fields on the page, as required.

   If you are provisioning your data source, set the flag `handleGrafanaManagedAlerts` in the `jsonData` field to `true` to send Grafana-managed alerts to this Alertmanager.
**Note**  
Prometheus, Grafana Mimir, and Cortex implementations of Alertmanager are supported. For Prometheus, contact points and notification policies are read-only in the Grafana Alerting UI.

1. Click Save & test.

# Provisioning Grafana Alerting resources
<a name="v9-alerting-setup-provision"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

Alerting infrastructure is often complex, with many pieces of the pipeline that often live in different places. Scaling this across multiple teams and organizations is an especially challenging task. Grafana Alerting provisioning makes this process easier by enabling you to create, manage, and maintain your alerting data in a way that best suits your organization.

There are two options to choose from:

1. Provision your alerting resources using the Alerting Provisioning HTTP API.
**Note**  
Typically, you cannot edit API-provisioned alert rules from the Grafana UI.  
In order to enable editing, add the x-disable-provenance header to the following requests when creating or editing your alert rules in the API:  

   ```
   POST /api/v1/provisioning/alert-rules
   PUT /api/v1/provisioning/alert-rules/{UID}
   ```

1. Provision your alerting resources using Terraform.

**Note**  
Currently, provisioning for Grafana Alerting supports alert rules, contact points, mute timings, and templates. Provisioned alerting resources using file provisioning or Terraform can only be edited in the source that created them and not from within Grafana or any other source. For example, if you provision your alerting resources using files from disk, you cannot edit the data in Terraform or from within Grafana.

**Topics**
+ [Create and manage alerting resources using Terraform](v9-alerting-setup-provision-terraform.md)
+ [Viewing provisioned alerting resources in Grafana](v9-alerting-setup-provision-view.md)

# Create and manage alerting resources using Terraform
<a name="v9-alerting-setup-provision-terraform"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

Use Terraform’s Grafana Provider to manage your alerting resources and provision them into your Grafana system. Terraform provider support for Grafana Alerting makes it easy to create, manage, and maintain your entire Grafana Alerting stack as code.

For more information on managing your alerting resources using Terraform, refer to the [Grafana Provider](https://registry.terraform.io/providers/grafana/grafana/latest/docs) documentation in the Terraform documentation.

Complete the following tasks to create and manage your alerting resources using Terraform.

1. Create an API key for provisioning.

1. Configure the Terraform provider.

1. Define your alerting resources in Terraform.

1. Run `terraform apply` to provision your alerting resources.

## Prerequisites
<a name="v9-alerting-setup-provision-tf-prerequisites"></a>
+ Ensure you have the grafana/grafana [Terraform provider](https://registry.terraform.io/providers/grafana/grafana/1.28.0) 1.27.0 or higher.
+ Ensure you are using Grafana 9.1 or higher. If you created your Amazon Managed Grafana instance with Grafana version 9, this will be true.

## Create an API key for provisioning
<a name="v9-alerting-setup-provision-tf-apikey"></a>

You can [create a normal Grafana API key](Using-Grafana-APIs.md) to authenticate Terraform with Grafana. Most existing tooling using API keys should automatically work with the new Grafana Alerting support. For information specifically about creating keys for use with Terraform, see [Using Terraform for Amazon Managed Grafana automation](https://aws-observability.github.io/observability-best-practices/recipes/recipes/amg-automation-tf/).

**To create an API key for provisioning**

1. Create a new service account for your CI pipeline.

1. Assign the role “Access the alert rules Provisioning API.”

1. Create a new service account token.

1. Name and save the token for use in Terraform.

Alternatively, you can use basic authentication. To view all the supported authentication formats, see [Grafana authentication](https://registry.terraform.io/providers/grafana/grafana/latest/docs#authentication) in the Terraform documentation.

## Configure the Terraform provider
<a name="v9-alerting-setup-provision-tf-configure"></a>

Grafana Alerting support is included as part of the [Grafana Terraform provider](https://registry.terraform.io/providers/grafana/grafana/latest/docs).

The following is an example you can use to configure the Terraform provider.

```
terraform {
    required_providers {
        grafana = {
            source = "grafana/grafana"
            version = ">= 1.28.2"
        }
    }
}

provider "grafana" {
    url = <YOUR_GRAFANA_URL>
    auth = <YOUR_GRAFANA_API_KEY>
}
```

## Provision contact points and templates
<a name="v9-alerting-setup-provision-tf-contacts"></a>

Contact points connect an alerting stack to the outside world. They tell Grafana how to connect to your external systems and where to deliver notifications. There are over fifteen different [integrations](https://registry.terraform.io/providers/grafana/grafana/latest/docs/resources/contact_point#optional) to choose from. This example uses a Slack contact point.

**To provision contact points and templates**

1. Copy this code block into a .tf file on your local machine. Replace *<slack-webhook-url>* with your Slack webhook URL (or other contact

   This example creates a contact point that sends alert notifications to Slack.

   ```
   resource "grafana_contact_point" "my_slack_contact_point" {
       name = "Send to My Slack Channel"
   
       slack {
           url = <slack-webhook-url>
           text = <<EOT
   {{ len .Alerts.Firing }} alerts are firing!
   
   Alert summaries:
   {{ range .Alerts.Firing }}
   {{ template "Alert Instance Template" . }}
   {{ end }}
   EOT
       }
   }
   ```

1. Enter text for your notification in the text field.

   The `text` field supports [Go-style templating](https://pkg.go.dev/text/template). This enables you to manage your Grafana Alerting notification templates directly in Terraform.

1. Run the command `terraform apply`.

1. Go to the Grafana UI and check the details of your contact point.

   You cannot edit resources provisioned via Terraform from the UI. This ensures that your alerting stack always stays in sync with your code.

1. Click **Test** to verify that the contact point works correctly.

**Note**  
You can re-use the same templates across many contact points. In the example above, a shared template ie embedded using the statement `{{ template "Alert Instance Template" . }}`  
This fragment can then be managed separately in Terraform:  

```
resource "grafana_message_template" "my_alert_template" {
    name = "Alert Instance Template"

    template = <<EOT
{{ define "Alert Instance Template" }}
Firing: {{ .Labels.alertname }}
Silence: {{ .SilenceURL }}
{{ end }}
EOT
}
```

## Provision notification policies and routing
<a name="v9-alerting-setup-provision-tf-notifications"></a>

Notification policies tell Grafana how to route alert instances, as opposed to where. They connect firing alerts to your previously defined contact points using a system of labels and matchers.

**To provision notification policies and routing**

1. Copy this code block into a .tf file on your local machine.

   In this example, the alerts are grouped by `alertname`, which means that any notifications coming from alerts which share the same name, are grouped into the same Slack message.

   If you want to route specific notifications differently, you can add sub-policies. Sub-policies allow you to apply routing to different alerts based on label matching. In this example, we apply a mute timing to all alerts with the label a=b.

   ```
   resource "grafana_notification_policy" "my_policy" {
       group_by = ["alertname"]
       contact_point = grafana_contact_point.my_slack_contact_point.name
   
       group_wait = "45s"
       group_interval = "6m"
       repeat_interval = "3h"
   
       policy {
           matcher {
               label = "a"
               match = "="
               value = "b"
           }
           group_by = ["..."]
           contact_point = grafana_contact_point.a_different_contact_point.name
           mute_timings = [grafana_mute_timing.my_mute_timing.name]
   
           policy {
               matcher {
                   label = "sublabel"
                   match = "="
                   value = "subvalue"
               }
               contact_point = grafana_contact_point.a_third_contact_point.name
               group_by = ["..."]
           }
       }
   }
   ```

1. In the mute\$1timings field, link a mute timing to your notification policy.

1. Run the command `terraform apply`.

1. Go to the Grafana UI and check the details of your notification policy.
**Note**  
You cannot edit resources provisioned from Terraform from the UI. This ensures that your alerting stack always stays in sync with your code.

1. Click **Test** to verify that the notification point is working correctly.

## Provision mute timings
<a name="v9-alerting-setup-provision-tf-mutetiming"></a>

Mute timings provide the ability to mute alert notifications for defined time periods.

**To provision mute timings**

1. Copy this code block into a .tf file on your local machine.

   In this example, alert notifications are muted on weekends.

   ```
   resource "grafana_mute_timing" "my_mute_timing" {
       name = "My Mute Timing"
   
       intervals {
           times {
             start = "04:56"
             end = "14:17"
           }
           weekdays = ["saturday", "sunday", "tuesday:thursday"]
           months = ["january:march", "12"]
           years = ["2025:2027"]
       }
   }
   ```

1. Run the command `terraform apply`.

1. Go to the Grafana UI and check the details of your mute timing.

1. Reference your newly created mute timing in a notification policy using the `mute_timings` field. This will apply your mute timing to some or all of your notifications.
**Note**  
You cannot edit resources provisioned from Terraform from the UI. This ensures that your alerting stack always stays in sync with your code.

1. Click **Test** to verify that the mute timing is working correctly.

## Provision alert rules
<a name="v9-alerting-setup-provision-tf-rules"></a>

[Alert rules](v9-alerting-managerules.md) enable you to alert against any Grafana data source. This can be a data source that you already have configured, or you can [define your data sources in Terraform](https://registry.terraform.io/providers/grafana/grafana/latest/docs/resources/data_source) alongside your alert rules.

**To provision alert rules**

1. Create a data source to query and a folder to store your rules in.

   In this example, the [Configure a TestData data source for testing](testdata-data-source.md) data source is used.

   Alerts can be defined against any backend datasource in Grafana.

   ```
   resource "grafana_data_source" "testdata_datasource" {
       name = "TestData"
       type = "testdata"
   }
   
   resource "grafana_folder" "rule_folder" {
       title = "My Rule Folder"
   }
   ```

1. Define an alert rule.

   For more information on alert rules, refer to [how to create Grafana-managed alerts](https://grafana.com/blog/2022/08/01/grafana-alerting-video-how-to-create-alerts-in-grafana-9/).

1. Create a rule group containing one or more rules.

   In this example, the `grafana_rule_group` resource group is used.

   ```
   resource "grafana_rule_group" "my_rule_group" {
       name = "My Alert Rules"
       folder_uid = grafana_folder.rule_folder.uid
       interval_seconds = 60
       org_id = 1
   
       rule {
           name = "My Random Walk Alert"
           condition = "C"
           for = "0s"
   
           // Query the datasource.
           data {
               ref_id = "A"
               relative_time_range {
                   from = 600
                   to = 0
               }
               datasource_uid = grafana_data_source.testdata_datasource.uid
               // `model` is a JSON blob that sends datasource-specific data.
               // It's different for every datasource. The alert's query is defined here.
               model = jsonencode({
                   intervalMs = 1000
                   maxDataPoints = 43200
                   refId = "A"
               })
           }
   
           // The query was configured to obtain data from the last 60 seconds. Let's alert on the average value of that series using a Reduce stage.
           data {
               datasource_uid = "__expr__"
               // You can also create a rule in the UI, then GET that rule to obtain the JSON.
               // This can be helpful when using more complex reduce expressions.
               model = <<EOT
   {"conditions":[{"evaluator":{"params":[0,0],"type":"gt"},"operator":{"type":"and"},"query":{"params":["A"]},"reducer":{"params":[],"type":"last"},"type":"avg"}],"datasource":{"name":"Expression","type":"__expr__","uid":"__expr__"},"expression":"A","hide":false,"intervalMs":1000,"maxDataPoints":43200,"reducer":"last","refId":"B","type":"reduce"}
   EOT
               ref_id = "B"
               relative_time_range {
                   from = 0
                   to = 0
               }
           }
   
           // Now, let's use a math expression as our threshold.
           // We want to alert when the value of stage "B" above exceeds 70.
           data {
               datasource_uid = "__expr__"
               ref_id = "C"
               relative_time_range {
                   from = 0
                   to = 0
               }
               model = jsonencode({
                   expression = "$B > 70"
                   type = "math"
                   refId = "C"
               })
           }
       }
   }
   ```

1. Go to the Grafana UI and check your alert rule.

   You can see whether the alert rule is firing. You can also see a visualization of each of the alert rule’s query stages.

   When the alert fires, Grafana routes a notification through the policy you defined.

   For example, if you chose Slack as a contact point, Grafana’s embedded [Alertmanager](https://github.com/prometheus/alertmanager) automatically posts a message to Slack.

# Viewing provisioned alerting resources in Grafana
<a name="v9-alerting-setup-provision-view"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

 You can verify that your alerting resources were created in Grafana.

**To view your provisioned resources in Grafana**

1. Open your Grafana instance.

1. Navigate to Alerting.

1. Click an alerting resource folder, for example, Alert rules.

   Provisioned resources are labeled **Provisioned**, so that it is clear that they were not created manually.

**Note**  
You cannot edit provisioned resources from Grafana. You can only change the resource properties by changing the provisioning file and restarting Grafana or carrying out a hot reload. This prevents changes being made to the resource that would be overwritten if a file is provisioned again or a hot reload is carried out.

# Migrating classic dashboard alerts to Grafana alerting
<a name="v9-alerting-use-grafana-alerts"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

Workspaces that choose not to use Grafana alerting, use the classic dashboard alerting. To switch to the new Grafana alerting, you must opt in to the feature.

You can configure your Amazon Managed Grafana instance to use Grafana alerting using the AWS Management Console, the AWS CLI, or the Amazon Managed Grafana API. For details about how to configure Amazon Managed Grafana, including turning Grafana alerting on or off, see [Configure a Amazon Managed Grafana workspace](AMG-configure-workspace.md).

**Note**  
When using Grafana alerting, alert rules defined in Grafana, rather than in Prometheus, send multiple notifications to your contact point. If you are using native Grafana alerts, we recommend that you stay on classic dashboard alerting and not enable the new Grafana alerting feature. If you would like to view Alerts defined in your Prometheus data source, then we recommend you enable Grafana Alerting, which sends only a single notification for alerts created in Prometheus Alertmanager.  
This limitation has been removed in Amazon Managed Grafana workspaces that support Grafana v10.4 and later.

## Migrating to Grafana alerting system
<a name="v9-alerting-use-grafana-alerts-opt-in"></a>

When Grafana alerting is turned on, existing classic dashboard alerts migrate in a format compatible with the Grafana alerting. In the Alerting page of your Grafana instance, you can view the migrated alerts alongside new alerts. With Grafana alerting, your Grafana-managed alert rules send multiple notifications rather than a single alert when they are matched.

Read and write access to classic dashboard alerts and Grafana alerts are governed by the permissions of the folders storing them. During migration, classic dashboard alert permissions are matched to the new rules permissions as follows:
+ If the original alert's dashboard has permissions, migration creates a folder named with this format `Migrated {"dashboardUid": "UID", "panelId": 1, "alertId": 1}` to match permissions of the original dashboard (including the inherited permissions from the folder).
+ If there are no dashboard permissions and the dashboard is under a folder, then the rule is linked to this folder and inherits its permissions.
+ If there are no dashboard permissions and the dashboard is under the General folder, then the rule is linked to the General Alerting folder, and the rule inherits the default permissions.

**Note**  
Since there is no `Keep Last State` option for `NoData` in Grafana alerting, this option becomes `NoData` during the classic rules migration. Option `Keep Last State` for `Error` handling is migrated to a new option `Error`. To match the behavior of the `Keep Last State`, in both cases, during the migration Amazon Managed Grafana automatically creates a silence for each alert rule with a duration of one year.

Notification channels are migrated to an Alertmanager configuration with the appropriate routes and receivers. Default notification channels are added as contact points to the default route. Notification channels not associated with any Dashboard alert go to the `autogen-unlinked-channel-recv` route.

### Limitations
<a name="v9-alerting-use-grafana-alerts-limitations"></a>
+ Grafana alerting system can retrieve rules from all available Prometheus, Loki, and Alertmanager data sources. It might not be able to fetch alerting rules from other supported data sources.
+ Migrating back and forth between Grafana alerts and the classic dashboard alerting can result in data loss for features supported in one system, but not the other.
**Note**  
If you migrate back to the classic dashboard alerting, you lose all changes made to alerting configuration made while you had Grafana alerting enabled, including any new alert rules that were created.

# Manage your alert rules
<a name="v9-alerting-managerules"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

An alert rule is a set of evaluation criteria that determines whether an alert will fire. The alert rule consists of one or more queries and expressions, a condition, the frequency of evaluation, and optionally, the duration over which the condition is met.

While queries and expressions select the data set to evaluate, a condition sets the threshold that an alert must meet or exceed to create an alert. An interval specifies how frequently an alert rule is evaluated. Duration, when configured, indicates how long a condition must be met. Alert rules can also define alerting behavior in the absence of data.

**Note**  
Grafana managed alert rules can only be edited or deleted by users with Edit permissions for the folder storing the rules.  
Alert rules for an external Grafana Mimir or Loki instance can be edited or deleted by users with Editor or Admin roles.

**Topics**
+ [Creating Grafana managed alert rules](v9-alerting-managerules-grafana.md)
+ [Creating Grafana Mimir or Loki managed alert rules](v9-alerting-managerules-mimir-loki.md)
+ [Creating Grafana Mimir or Loki managed recording rules](v9-alerting-managerules-mimir-loki-recording.md)
+ [Grafana Mimir or Loki rule groups and namespaces](v9-alerting-managerules-mimir-loki-groups.md)
+ [View and edit alerting rules](v9-alerting-managerules-view-edit.md)

# Creating Grafana managed alert rules
<a name="v9-alerting-managerules-grafana"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

Grafana allows you to create alerting rules that query one or more data sources, reduce or transform the results and compare them to each other or to fixed thresholds. When these are run, Grafana sends notifications to the contact point.

**To add a Grafana managed rule**

1. From your Grafana console, in the Grafana menu, choose the **Alerting** (bell) icon to open the **Alerting** page listing existing alerts.

1. Choose **New alert rule**.

1. In **Step 1**, add the rule name, type and storage location, as follows:
   + In **Rule name**, add a descriptive name. This name is displayed in the alert rules list. It is also the `alertname` label for every alert instance that is created from this rule.
   + From the **Rule type** dropdown, select **Grafana managed alert**.
   + From the **Folder** dropdown, select the folder where you want to store the rule. If you do not select a folder, the rule is stored in the `General` folder. To create a folder, select the dropdown and enter a new folder name.

1. In **Step 2**, add the queries and expressions to evaluate.
   + Keep the default name or hover over and choose the edit icon to change the name.
   + For queries, select a data source from the dropdown.
   + Add one or more [queries or expressions](v9-panels-query-xform-expressions.md).
   + For each expression, select either **Classic condition** to create a single alert rule, or choose from **Math**, **Reduce**, **Resample **options to generate separate alerts for each series. For details on these options, see [Single and multidimensional rules](#v9-alerting-single-multi-rule).
   + Choose **Run queries** to verify that the query is successful.

1. In **Step 3**, add conditions.
   + From the **Condition** dropdown, select the query or expression to initiate the alert rule.
   + For **Evaluate every**, specify the frequency of evaluation. Must be a multiple of 10 seconds. For example, `1m`, `30s`.
   + For **Evaluate for**, specify the duration for which the condition must be true before an alert is initiated.
**Note**  
After a condition is breached, the alert goes into `Pending` state. If the condition remains breached for the duration specified, the alert transitions to the `Firing` state. If it is no longer met, it reverts to the `Normal` state.
   + In **Configure no data and error handling**, configure alerting behavior in the absence of data. use the guidelines in [Handling no data or error cases](#v9-alerting-rule-no-data-error).
   + Choose **Preview alerts** to check the result of running the query at this moment. Preview excludes no data and error handling conditions.

1. In **Step 4**, add additional metadata associated with the rule.
   + Add a description and summary to customize alert messages. Use the guidelines in [Labels and annotations](v9-alerting-explore-labels.md).
   + Add Runbook URL, panel, dashboard, and alert IDs.
   + Add custom labels.

1. Choose **Save** to save the rule or **Save and exit** to save the rule and go back to the **Alerting** page.

After you have created your rule, you can create a notification for your rule. For more information about notifications, see [Manage your alert notifications](v9-alerting-managenotifications.md).

## Single and multidimensional rules
<a name="v9-alerting-single-multi-rule"></a>

For Grafana managed alert rules, you can create a rule with a classic condition or you can create a multidimensional rule.

**Single dimensional rule (classic condition)**

Use a classic condition expression to create a rule that initiates a single alert when its condition is met. For a query that returns multiple series, Grafana does not track the alert state of each series. As a result, Grafana sends only a single alert even when alert conditions are met for multiple series.

For more information about how to format expressions, see [Expressions](https://grafana.com/docs/grafana/next/panels/query-a-data-source/) in the *Grafana documentation*.

**Multidimensional rule**

To generate a separate alert instance for each series returned in the query, create a multidimensional rule.

**Note**  
Each alert instance generated by a multi-dimensional rule counts toward your total quota of alerts. Rules are not evaluated when you reach your quota of alerts. For more information about quotas for multi-dimensional rules, see [Quota reached errors](#v9-alerting-rule-quota-reached).

To create multiple instances from a single rule, use `Math`, `Reduce`, or `Resample` expressions to create a multidimensional rule. For example, you can:
+ Add a `Reduce` expression for each query to aggregate values in the selected time range into a single value. (Not needed for [rules using numeric data](v9-alerting-explore-numeric.md)).
+ Add a `Math` expression with the condition for the rule. This is not needed in case a query or a reduce expression already returns 0 if rule should not initiate an alert, or a positive number if it should initiate an alert. 

  Some examples: 
  + `$B > 70` if it should initiate an alert in case value of B query/expression is more than 70. 
  + `$B < $C * 100` in case it should initiate an alert if value of B is less than value of C multiplied by 100. If queries being compared have multiple series in their results, series from different queries are matched if they have the same labels, or one is a subset of the other.

**Note**  
Grafana does not support alert queries with template variables. More information is available at the community page [Template variables are not supported in alert queries while setting up Alert](https://community.grafana.com/t/template-variables-are-not-supported-in-alert-queries-while-setting-up-alert/2514).



**Performance considerations for multidimensional rules**

Each alert instance counts toward the alert quota. Multidimensional rules that create more instances than can be accommodated within the alert quota are not evaluated and return a quota error. For more information, see [Quota reached errors](#v9-alerting-rule-quota-reached).

Multidimensional alerts can have a high impact on the performance of your Grafana workspace, as well as on the performance of your data sources as Grafana queries them to evaluate your alert rules. The following considerations can be helpful as you are trying to optimize the performance of your monitoring system.
+ **Frequency of rule evaluation** – The **Evaluate Every** property of an alert rule controls the frequency of rule evaluation. We recommend using the lowest acceptable evaluation frequency. 
+ **Result set cardinality** – The number of alert instances you create with a rule affects its performance. Suppose you are monitoring API response errors for every API path, on every VM in your fleet. This set has a cardinality of the number of paths multiplied by the number of VMs. You can reduce the cardinality of the result set, for example, by monitoring total errors per VM instead of per path per VM.
+ **Complexity of the query** – Queries that data sources can process and respond to quickly consume fewer resources. Although this consideration is less important than the other considerations listed above, if you have reduced those as much as possible, looking at individual query performance could make a difference. You should also be aware of the performance impact that evaluating these rules has on your data sources. Alerting queries are often the vast majority of queries handled by monitoring databases, so the same load factors that affect the Grafana instance affect them as well.

## Quota reached errors
<a name="v9-alerting-rule-quota-reached"></a>

There is a quota for the number of alert instances you can have within a single workspace. When you reach that number, you can no longer create new alert rules in that workspace. With multidimensional alerts, the number of alert instances can vary over time.

The following are important to remember when working with alert instances.
+ If you create only single-dimensional rules, each rule is a single alert instance. You can create the same number of rules in a single workspace as your alert-instance quota, and no more.
+ Multidimensional rules create multiple alert instances, however, the number is not known until they are evaluated. For example, if you create an alert rule that tracks the CPU usage of your Amazon EC2 instances, there might be 50 EC2 instances when you create it (and therefore 50 alert instances), but if you add 10 more EC2 instances a week later, the next evaluation has 60 alert instances.

  The number of alert instances is evaluated when you create a multidimensional alert, and you can't create one that immediately puts you over your alert instance quota. Because the number of alert instances can change, your quota is checked each time that your rules are evaluated.
+ At rule evaluation time, if a rule causes you to go beyond your quota for alert instances, that rule is not evaluated until an update is made to the alert rule that brings the total count of alert instances below the service quota. When this happens, you receive an alert notification letting you know that your quota has been reached (the notification uses the notification policy for the rule being evaluated). The notification includes an `Error` annotation with the value `QuotaReachedError`.
+ A rule that causes a `QuotaReachedError` stops being evaluated. Evaluation is only resumed when an update is made and the evaluation after the update does not itself cause a `QuotaReachedError`. A rule that is not being evaluated shows the **Quota reached** error in the Grafana console.
+ You can lower the number of alert instances by removing alert rules, or by editing multidimensional alerts to have fewer alert instances (for example, by having one alert on errors per VM, rather than one alert on error per API in a VM).
+ To resume evaluations, update the alert and save it. You can update it to lower the number of alert instances, or if you have made other changes to lower the number of alert instances, you can save it with no changes. If it can be resumed, it is. If it causes another `QuotaReachedError`, you are not able to save it.
+ When an alert is saved and resumes evaluation without going over the alerts quota, the **Quota reached** error can continue to show in the Grafana console for some time (up to its evaluation interval), however, the alert rule evaluation does start and alerts are sent if the rule threshold is met.
+ For details on the alerts quota, as well as other quotas, see [Amazon Managed Grafana service quotas](AMG_quotas.md).

## Handling no data or error cases
<a name="v9-alerting-rule-no-data-error"></a>

Choose options for how to handle alerting behavior in the absence of data or when there are errors.

The options for handling no data are listed in the following table.


| No Data option | Behavior | 
| --- | --- | 
|  No Data  |  Create an alert `DatasourceNoData` with the name and UID of the alert rule, and UID of the data source that returned no data as labels.  | 
|  Alerting  |  Set alert rule state to `Alerting`.  | 
|  OK  |  Set alert rule state to `Normal`.  | 

The options for handling error cases are listed in the following table.


| Error or timeout option | Behavior | 
| --- | --- | 
|  Alerting  |  Set alert rule state to `Alerting`  | 
|  OK  |  Set alert rule state to `Normal`  | 
|  Error  |  Create an alert `DatasourceError` with the name and UID of the alert rule, and UID of the data source that returned no data as labels.  | 

# Creating Grafana Mimir or Loki managed alert rules
<a name="v9-alerting-managerules-mimir-loki"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

Using Grafana, you can create alerting rules for an external Grafana Mimir or Loki instance.

**Note**  
Grafana Mimir can connect to Amazon Managed Service for Prometheus and Prometheus data sources.

**Prerequisites**
+ Verify that you have write permissions to the Prometheus data source. Otherwise, you are not able to create or update Cortex managed alerting rules.
+ For Grafana Mimir and Loki data sources, enable the ruler API by configuring their respective services.
  + **Loki** – The `local` rule storage type, default for the Loki data source, supports only viewing of rules. To edit rules, configure one of the other storage types.
  + **Grafana Mimir** – Use the legacy `/api/prom` prefix, not `/prometheus`. The Prometheus data source supports both Grafana Mimir and Prometheus, and Grafana expects that both the Query API and Ruler API are under the same URL. You cannot provide a separate URL for the Ruler API.

**Note**  
If you do not want to manage alerting rules for a particular Loki or Prometheus data source, go to its settings and clear the **Manage alerts via Alerting UI** checkbox.

**To add a Grafana Mimir or Loki managed alerting rule**

1. From your Grafana console, in the Grafana menu, choose the **Alerting** (bell) icon to open the **Alerting** page listing existing alerts.

1. Choose **Create alert rule**.

1. In **Step 1**, choose the rule type, and details, as follows:
   + Choose **Mimir or Loki alert**.
   + In **Rule name**, add a descriptive name. This name is displayed in the alert rules list. It is also the `alertname` label for every alert instance that is created from this rule.
   + From the **Select data source** dropdown, select a Prometheus, or Loki data source.
   + From the **Namespace** dropdown, select an existing rule namespace. Otherwise, choose **Add new** and enter a name to create one. Namespaces can contain one or more rule groups and only have an organizational purpose. For more information, see [Cortex or Loki rule groups and namespaces](alert-rules.md#alert-rule-groups).
   + From the **Group** dropdown, select an existing group within the selected namespace. Otherwise, choose **Add new** and enter a name to create one. Newly created rules are appended to the end of the group. Rules within a group run sequentially at a regular interval, with the same evaluation time.

1. In **Step 2**, add the query to evaluate.

   The value can be a PromQL or LogQL expression. The rule initiates an alert if the evaluation result has at least one series with a value that is greater than 0. An alert is created for each series.

1. In **Step 3**, specify the alert evaluation interval.

   In the **For** text box of the condition, specify the duration for which the condition must be true before the alert is initiated. If you specify `5m`, the conditions must be true for five minutes before the alert is initiated.
**Note**  
After a condition is met, the alert goes into `Pending` state. If the condition remains active for the duration specified, the alert transitions to the `Firing` state. If it is no longer met, it reverts to the `Normal` state.

1. In **Step 4**, add additional metadata associated with the rule.
   + Add a description and summary to customize alert messages. Use the guidelines in [Labels and annotations](v9-alerting-explore-labels.md).
   + Add Runbook URL, panel, dashboard, and alert IDs.
   + Add custom labels.

1. Choose **Preview alerts** to evaluate the rule and see what alerts it would produce. It displays a list of alerts with state and value of each one.

1. Choose **Save** to save the rule or **Save and exit** to save the rule and go back to the **Alerting** page.

After you have created your rule, you can create a notification for your rule. For more information about notifications, see [Manage your alert notifications](v9-alerting-managenotifications.md).

# Creating Grafana Mimir or Loki managed recording rules
<a name="v9-alerting-managerules-mimir-loki-recording"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

You can create and manage recording rules for an external Grafana Mimir or Loki instance. Recording rules calculate frequently needed expressions or computationally expensive expressions in advance and save the result as a new set of time series. Querying this new time series is faster, especially for dashboards since they query the same expression every time the dashboards refresh.

**Prerequisites**

For Grafana Mimir and Loki data sources, enable the ruler API by configuring their respective services.
+ **Loki** – The `local` rule storage type, default for the Loki data source, supports only viewing of rules. To edit rules, configure one of the other storage types.
+ **Grafana Mimir** – When configuring a data source to point to Grafana Mimir, use the legacy `/api/prom` prefix, not `/prometheus`. The Prometheus data source supports both Grafana Mimir and Prometheus, and Grafana expects that both the Query API and Ruler API are under the same URL. You cannot provide a separate URL for the Ruler API.

**Note**  
If you do not want to manage alerting rules for a particular Loki or Prometheus data source, go to its settings and clear the **Manage alerts via Alerting UI** check box.

**To add a Grafana Mimir or Loki managed recording rule**

1. From your Grafana console, in the Grafana menu, choose the **Alerting** (bell) icon to open the **Alerting** page listing existing alerts.

1. Choose **Create alert rule**.

1. In **Step 1**, add the rule type, rule name, and storage location, as follows.
   + Select the **Mimir or Loki recording rule** option.
   + In **Rule name**, add a descriptive name. This name is displayed in the alert rules list. It is also the `alertname` label for every alert instance that is created from this rule.
   + From the **Select data source** dropdown, select a Prometheus, or Loki data source.
   + From the **Namespace** dropdown, select an existing rule namespace. Otherwise, choose **Add new** and enter a name to create one. Namespaces can contain one or more rule groups and only have an organizational purpose. For more information, see [Cortex or Loki rule groups and namespaces](alert-rules.md#alert-rule-groups).
   + From the **Group** dropdown, select an existing group within the selected namespace. Otherwise, choose **Add new** and enter a name to create one. Newly created rules are appended to the end of the group. Rules within a group run sequentially at a regular interval, with the same evaluation time.

1. In **Step 2**, add the query to evaluate.

   The value can be a PromQL or LogQL expression. The rule initiates an alert if the evaluation result has at least one series with a value that is greater than 0. An alert is created for each series.

1. In **Step 3**, add additional metadata associated with the rule.
   + Add a description and summary to customize alert messages. Use the guidelines in [Annotations and labels for alerting rules](alert-rules.md#alert-rule-labels).
   + Add Runbook URL, panel, dashboard, and alert IDs.
   + Add custom labels.

1. Choose **Save** to save the rule or **Save and exit** to save the rule and go back to the **Alerting** page.

# Grafana Mimir or Loki rule groups and namespaces
<a name="v9-alerting-managerules-mimir-loki-groups"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

You can organize your rules. Rules are created within rule groups, and rule groups are organized into namespaces. The rules within a rule group are run sequentially at a regular interval. The default interval is one minute. You can rename Grafana Mimir or Loki namespaces and rule groups, and edit rule group evaluation intervals.

**To edit a rule group or namespace**

1. From your Grafana console, in the Grafana menu, choose the **Alerting** (bell) icon to open the **Alerting** page.

1. Navigate to a rule within the rule group or namespace you want to edit.

1. Choose the **Edit** (pen) icon.

1. Make changes to the rule group or namespace.
**Note**  
For namespaces, you can only edit the name. For rule groups, you change the name, or the evaluation interval for rules in the group. For example, you can choose `1m` to have the rules be evaluated once per minute, or `30s` to evaluate once every 30 seconds.

1. Choose **Save changes**.

# View and edit alerting rules
<a name="v9-alerting-managerules-view-edit"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

The **Alerting** page lists alerting rules. By default, rules are grouped by types of data sources. The **Grafana** section lists rules managed by Grafana, and the **Cortex/Loki** section lists rules for Prometheus compatible data sources. You can view alerting rules for Prometheus compatible data sources but you cannot edit them.

The Mimir/Cortex/Loki rules section lists all rules for Mimir, Cortex, or Loki data sources. Cloud alert rules are also listed in this section.

When managing large volumes of alerts, you can use extended alert rule search capabilities to filter on folders, evaluation groups, and rules. Additionally, you can filter alert rules by their properties like labels, state, type, and health.

**Note**  
You can view query definitions for provisioned alerts, but you cannot edit them. Being able to view them allows you to verify that your queries and rule definitions are correct without going back to your provisioning repository for rule definitions.

## View alerting rules
<a name="v9-alerting-managerules-view"></a>

Using Grafana alerts, you can view all of your alerts in one page.

**To view alerting details**

1. From your Grafana console, in the Grafana menu, choose the **Alerting** (bell) icon to open the **Alerting** page. By default, rules are displayed in groups by data source type. You can also view by the current state of each alert (these are described in more detail in the following text).

1. In **View as**, you can toggle between the group and state views by choosing the option you prefer.

1. Choose the arrow next to a row to view more details for that row. The details for a rule include the rule labels, annotations, data sources, and queries, as well as a list of alert instances resulting from the rule.

**Note**  
For more information about understanding the details of your alerts, see [State and health of alerting rules](v9-alerting-explore-state.md).

**Group view**

Group view shows Grafana alert rules grouped by folder and Loki or Prometheus alert rules grouped by `namespace` \$1 `group`. This is the default rule list view, intended for managing rules. You can expand each group to view a list of rules in this group. Expand a rule further to view its details. You can also expand action buttons and alerts resulting from the rule to view their details.

**State view**

State view shows alert rules grouped by state. Use this view to get an overview of which rules are in what state. Each rule can be expanded to view its details. Action buttons and any alerts generated by this rule, and each alert can be further expanded to view its details.

**Filter alerting rules**

You can filter the alerting rules that appear on the **Alerting** page in several ways.
+ You can filter to display the rules that query a specific data source by choosing **Select data sources**, then selecting a data source to filter to.
+ You can filter by labels by choosing search criteria in **Search by label**. For example, you could type `environment=production,region=~US|EU,severity!=warning` to filter on production warnings in the US and EU.
+ You can filter to display the rules in a specific state by choosing **Filter alerts by state**, and then selecting the state you want to view.

## Edit or delete alerting rules
<a name="v9-alerting-managerules-edit"></a>

Grafana managed alerting rules can only be edited or deleted by users with Edit permissions for the folder storing the rules. Alerting rules for an external Mimir or Loki instance can be edited or deleted by users with Editor or Admin roles.

**To edit or delete a rule**

1. Expand a rule until you can see the rule controls for **View**, **Edit**, and **Delete**.

1. Choose **Edit** to open the create rule page. Make updates in the same way that you create a rule. For details, see the instructions in [Creating Grafana managed alert rules](v9-alerting-managerules-grafana.md) or [Creating Grafana Mimir or Loki managed alert rules](v9-alerting-managerules-mimir-loki.md).

1. Optionally, choose **Delete** to delete a rule.

## Export alert rules
<a name="v9-alerting-managerules-export"></a>

You can export rules to YAML or JSON in the Grafana workspace, by choosing **Export**. It will give you the option to define a new rule, then export it. You can create a rule using the UI and then export it for use in the provisioning API or terraform scripts.

**Note**  
This is supported in both the Grafana workspace and the provisioning interface.

# Manage your alert notifications
<a name="v9-alerting-managenotifications"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

Choosing how, when, and where to send your alert notifications is an important part of setting up your alerting system. These decisions will have a direct impact on your ability to resolve issues quickly and not miss anything important.

As a first step, define your *contact points*; where to send your alert notifications to. A contact point can be a set of destinations for matching notifications. Add notification templates to contact points for reuse and consistent messaging in your notifications.

Next, create a *notification policy*, which is a set of rules for where, when and how your alerts are routed to contact points. In a notification policy, you define where to send your alert notifications by choosing one of the contact points you created. Add mute timings to your notification policy. A *mute timing* is a recurring interval of time during which you don’t want any notifications to be sent out.

When an alert rule is evaluated, the alert ruler sends alert instances to the Alertmanager — one alert rule can trigger multiple individual *alert instances*.

The Alertmanager receives these alert instances and then handles mute timings, groups alerts, and sends notifications to your contact points as defined in the notification policy.

**Topics**
+ [Alertmanager](v9-alerting-managenotifications-alertmanager.md)
+ [Working with contact points](v9-alerting-contact-points.md)
+ [Working with notification policies](v9-alerting-notification-policies.md)
+ [Customize notifications](v9-alerting-notifications.md)
+ [Silencing alert notifications for Prometheus data sources](v9-alerting-silences.md)
+ [Mute timings](v9-alerting-notification-muting.md)
+ [View and filter by alert groups](v9-alerting-viewfiltergroups.md)
+ [View notification errors](v9-alerting-viewnotificationerrors.md)

# Alertmanager
<a name="v9-alerting-managenotifications-alertmanager"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

Alertmanager enables you to quickly and efficiently manage and respond to alerts. It receives alerts, handles mutings, inhibition, grouping, and routing by sending notifications out via your channel of choice, for example, email or Slack.

In Grafana, you can use the Grafana Alertmanager, or an external Alertmanager. You can also run multiple alertmanagers; your decision depends on your set up and where your alerts are being generated.

**Grafana Alertmanager**

Grafana Alertmanager is an internal Alertmanager that is pre-configured and available for selection by default if you run Grafana on-premise or open-source.

The Grafana Alertmanager can receive alerts from Grafana, but it cannot receive alerts from outside Grafana, for example, from Mimir or Loki.

**Note**  
Inhibition rules are not supported in the Grafana Alertmanager.

**External Alertmanager**

If you want to use a single alertmanager to receive all your Grafana, Loki, Mimir, and Prometheus alerts, you can set up Grafana to use an external Alertmanager. This external Alertmanager can be configured and administered from within Grafana itself.

Here are two examples of when you might want to configure your own external alertmanager and send your alerts there instead of the Grafana Alertmanager:

1. You already have alertmanagers on-premise in your own Cloud infrastructure that you have set up and still want to use, because you have other alert generators, such as Prometheus.

1. You want to use both Prometheus on-premise and hosted Grafana to send alerts to the same alertmanager that runs in your Cloud infrastructure.

Alertmanagers are visible from the dropdown menu on the Alerting Contact Points, and Notification Policies pages.

If you are provisioning your data source, set the flag `handleGrafanaManagedAlerts` in the `jsonData` field to `true` to send Grafana-managed alerts to this Alertmanager.

# Working with contact points
<a name="v9-alerting-contact-points"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

Use contact points to define how your contacts are notified when an alert is initiated. A contact point can have one or more contact point integrations, for example, Amazon Simple Notification Service or Slack. When an alert is initiated, a notification is sent to all contact point integrations listed for a contact point. Optionally, use [notification templates](v9-alerting-create-templates.md) to customize the notification messages for the contact point types.

**Note**  
You can create and edit contact points for Grafana managed alerts. Contact points for Alertmanager alerts are read-only.

## Working with contact points
<a name="v9-alerting-working-contact-points"></a>

The following procedures detail how to add, edit, test, and delete contact points.

**To add a contact point**

1. From your Grafana console, in the Grafana menu, choose the **Alerting** (bell) icon to open the **Alerting** page.

1. Choose **Contact points**, then **Add contact point**.

1. From the **Alertmanager** dropdown, select an Alertmanager. The Grafana Alertmanager is selected by default.

1. Enter a **Name** for the contact point.

1. From **Contact point integration**, choose a type, and the mandatory fields based on that type. For example, if you choose Slack, enter the Slack channels and users who should be contacted.

1. If available for the contact point you selected, choose any desired **Optional settings** to specify additional settings.

1. Under **Notification settings**, optionally select **Disable resolved message** if you do not want to be notified when an alert resolves.

1. If your contact point needs more contact points types, you can choose **Add contact point integration** and repeat the steps for each contact point type needed.

1. Choose **Save contact point** to save your changes.

**To edit a contact point**

1. Choose **Contact points** to see a list of existing contact points.

1. Select the contact point to edit, then choose the **Edit** icon (pen).

1. Make any necessary changes, and then choose **Save contact point** to save your changes.

After your contact point is created, you can send a test notification to verify that it is configured properly.

**To send a test notification**

1. Choose **Contact points** to open the list of existing contact points.

1. Select the contact point to test, then choose the **Edit** icon (pen).

1. Select the **Test** icon (paper airplane).

1. Choose whether to send a predefined test notification or choose **Custom** to add your own custom annotations and labels in the test notification.

1. Choose **Send test notification** to test the alert with the given contact points.

You can delete contact points that are not in use by a notification policy.

**To delete a contact point**

1. Choose **Contact points** to open the list of existing contact points.

1. Select the contact point to delete, then choose the **Delete** icon (trash can).

1. In the confirmation dialog box, choose **Yes, delete**.

**Note**  
If the contact point is in use by a notification policy, you must delete the notification policy or edit it to use a different contact point before deleting the contact point.

## List of supported notifiers
<a name="v9-alerting-contactpoint-supported-notifiers"></a>


|  Name  |  Type  | 
| --- | --- | 
| Amazon SNS  |  sns  | 
|  OpsGenie  |  opsgenie  | 
| Pager Duty  |  pagerduty  | 
| Slack  |  slack  | 
|  VictorOps  |  victorops  | 

# Working with notification policies
<a name="v9-alerting-notification-policies"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

Notification policies determine how alerts are routed to contact points. Policies have a tree structure, where each policy can have one or more child policies. Each policy, except for the root policy, can also match specific alert labels. Each alert is evaluated by the root policy and then by each child policy. If you enable the `Continue matching subsequent sibling nodes` option for a specific policy, then evaluation continues even after one or more matches. A parent policy’s configuration settings and contact point information govern the behavior of an alert that does not match any of the child policies. A root policy governs any alert that does not match a specific policy.

**Note**  
You can create and edit notification policies for Grafana managed alerts. Notification policies for Alertmanager alerts are read-only.

**Grouping notifications**

Grouping categorizes alert notifications of similar nature into a single funnel. This allows you to control alert notifications during larger outages when many parts of a system fail at once causing a high number of alerts to initiate simultaneously.

**Grouping example**

Suppose you have 100 services connected to a database in different environments. These services are differentiated by the label `env=environmentname`. An alert rule is in place to monitor whether your services can reach the database. The alert rule creates alerts named `alertname=DatabaseUnreachable`.

If a network partition occurs, where half of your services can no longer reach the database, 50 different alerts are initiated. For this situation, you want to receive a single-page notification (as opposed to 50) with a list of the environments that are affected.

You can configure grouping to be `group_by: [alertname]` (not using the `env` label, which is different for each service). With this configuration in place, Grafana sends a single compact notification that has all the affected environments for this alert rule.

**Special Groups**

Grafana has two special groups. The default group, `group_by: null` groups *all* alerts together into a single group. You can also use a special label named `...` to group alerts by all labels, effectively disabling grouping, and sending each alert into its own group.

## Working with notifications
<a name="v9-alerting-notification-policies-working"></a>

The following procedures show you how to create and manage notification policies.

**To edit the root notification policy**

1. From your Grafana console, in the Grafana menu, choose the **Alerting** (bell) icon to open the **Alerting** page.

1. Choose **Notification policies**.

1. From the **Alertmanager** dropdown, select the Alertmanager you want to edit.

1. In the **Root policy** section, choose the **Edit** icon (pen).

1. In **Default contact point**, update the contact point where notifications should be sent for rules when alert rules do not match any specific policy.

1. In **Group by**, choose the labels (or special groups) to group alerts by.

1. In **Timing options**, select from the following options.
   + **Group wait** – Time to wait to buffer alerts of the same group before sending an initial notification. The default is 30 seconds.
   + **Group interval** – Minimum time interval between two notifications for a group. The default is 5 minutes.
   + **Repeat interval** – Minimum time interval before resending a notification if no new alerts were added to the group. The default is 4 hours.

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

**To add a new, top-level specific policy**

1. From your Grafana console, in the Grafana menu, choose the **Alerting** (bell) icon to open the **Alerting** page.

1. Choose **Notification policies**.

1. From the **Alertmanager** dropdown, select the Alertmanager you want to edit.

1. In the **Specific routing** section, choose **New specific policy**.

1. In the **Matching labels** section, add one or more matching alert labels. More information about label matching is later in this topic.

1. In **Contact point**, add the contact point to send notifications to if the alert matches this specific policy. Nested policies override this contact point.

1. Optionally, enable **Continue matching subsequent sibling nodes** to continue matching sibling policies even after the alert matched the current policy. When this policy is enabled, you can get more than one notification for the same alert.

1. Optionally select **Override grouping** to specify a grouping different from the root policy.

1. Optionally select **Override general timings** to override the timing options in the group notification policy.

1. Choose **Save policy** to save your changes.

**To add a nested policy**

1. Expand the specific policy you want to create a nested policy under.

1. Choose **Add nested policy**, then add the details (as when adding a top-level specific policy).

1. Choose **Save policy** to save your changes.

**To edit a specific policy**

1. From the **Alerting** page, choose **Notification policies** to open the page that listing existing policies.

1. Select the policy that you want to edit, then choose the **Edit** icon (pen).

1. Make any changes (as when adding a top-level specific policy).

1. Choose **Save policy**.

**Searching for policies**

You can search within the tree of policies by *Label matchers* or *contact points*.
+ To search by contact point, enter a partial or full name of a contact point in the **Search by contact point** field.
+ To search by label, enter a valid label matcher in the **Search by label** field. Multiple matchers can be entered, separated by a comma. For example, a valid matcher input could be `severity=high, region=~EMEA|NA`.
**Note**  
When searching by label, all matched policies will be exact matches. Partial matches and regex-style matches are not supported.

**How label matching works**

A policy matches an alert if the alert's labels match all the *Matching Labels* specified on the policy.
+ **Label** – The name of the label to match. It must exactly match the label name of the alert.
+ **Operator** – The operator used to compare the label value with the matching label value. The available operators are:
  + `=` Select labels whose value exactly matches the provided string.
  + `!=` Select labels whose value does not match the provided string.
  + `=~` Select labels whose value match the regex interpreted value of the provided string (the provided string is interpreted as a regular expression.
  + `!=` Select labels that do not match the provided regular expression.
+ **Value** – The value to match the label value to. It can match as a string or as a regular expression, depending on the operator chosen.

# Customize notifications
<a name="v9-alerting-notifications"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

Customize your notifications with notifications templates.

You can use notification templates to change the title, message, and format of the message in your notifications.

Notification templates are not tied to specific contact point integrations, such as email or Slack. However, you can choose to create separate notification templates for different contact point integrations.

You can use notification templates to:
+ Add, remove, or re-order information in the notification including the summary, description, labels and annotations, values, and links
+ Format text in bold and italic, and add or remove line breaks

You cannot use notification templates to:
+ Change the design of notifications in instant messaging services such as Slack and Microsoft Teams

**Topics**
+ [Using Go’s templating language](v9-alerting-notifications-go-templating.md)
+ [Create notification templates](v9-alerting-create-templates.md)
+ [Template reference](v9-alerting-template-reference.md)

# Using Go’s templating language
<a name="v9-alerting-notifications-go-templating"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

You write notification templates in Go’s templating language, [text/template](https://pkg.go.dev/text/template).

This section provides an overview of Go’s templating language and writing templates in text/template.

## Dot
<a name="v9-go-dot"></a>

In text/template there is a special cursor called dot, and is written as `.`. You can think of this cursor as a variable whose value changes depending where in the template it is used. For example, at the start of a notification template `.` refers to the `ExtendedData` object, which contains a number of fields including `Alerts`, `Status`, `GroupLabels`, `CommonLabels`, `CommonAnnotations` and `ExternalURL`. However, dot might refer to something else when used in a `range` over a list, when used inside a `with`, or when writing feature templates to be used in other templates. You can see examples of this in [Create notification templates](v9-alerting-create-templates.md), and all data and functions in the [Template reference](v9-alerting-template-reference.md).

## Opening and closing tags
<a name="v9-go-openclosetags"></a>

In text/template, templates start with `{{` and end with `}}` irrespective of whether the template prints a variable or runs control structures such as if statements. This is different from other templating languages such as Jinja where printing a variable uses `{{` and `}}` and control structures use `{%` and `%}`.

## Print
<a name="v9-go-print"></a>

To print the value of something use `{{` and `}}`. You can print the value of dot, a field of dot, the result of a function, and the value of a [variable](#v9-go-variables). For example, to print the `Alerts` field where dot refers to `ExtendedData` you would write the following:

```
{{ .Alerts }}
```

## Iterate over alerts
<a name="v9-go-iterate-alerts"></a>

To print just the labels of each alert, rather than all information about the alert, you can use a `range` to iterate the alerts in `ExtendedData`:

```
{{ range .Alerts }}
{{ .Labels }}
{{ end }}
```

Inside the range dot no longer refers to `ExtendedData`, but to an `Alert`. You can use `{{ .Labels }}` to print the labels of each alert. This works because `{{ range .Alerts }}` changes dot to refer to the current alert in the list of alerts. When the range is finished dot is reset to the value it had before the start of the range, which in this example is `ExtendedData`:

```
{{ range .Alerts }}
{{ .Labels }}
{{ end }}
{{/* does not work, .Labels does not exist here */}}
{{ .Labels }}
{{/* works, cursor was reset */}}
{{ .Status }}
```

## Iterate over annotations and labels
<a name="v9-go-iterate-labels"></a>

Let’s write a template to print the labels of each alert in the format `The name of the label is $name, and the value is $value`, where `$name` and `$value` contain the name and value of each label.

Like in the previous example, use a range to iterate over the alerts in `.Alerts` such that dot refers to the current alert in the list of alerts, and then use a second range on the sorted labels so dot is updated a second time to refer to the current label. Inside the second range use `.Name` and `.Value` to print the name and value of each label:

```
{{ range .Alerts }}
{{ range .Labels.SortedPairs }}
The name of the label is {{ .Name }}, and the value is {{ .Value }}
{{ end }}
{{ range .Annotations.SortedPairs }}
The name of the annotation is {{ .Name }}, and the value is {{ .Value }}
{{ end }}
{{ end }}
```

## If statements
<a name="v9-go-if"></a>

You can use if statements in templates. For example, to print `There are no alerts` if there are no alerts in `.Alerts` you would write the following:

```
{{ if .Alerts }}
There are alerts
{{ else }}
There are no alerts
{{ end }}
```

## With
<a name="v9-go-with"></a>

With is similar to if statements, however unlike if statements, `with` updates dot to refer to the value of the with:

```
{{ with .Alerts }}
There are {{ len . }} alert(s)
{{ else }}
There are no alerts
{{ end }}
```

## Variables
<a name="v9-go-variables"></a>

Variables in text/template must be created within the template. For example, to create a variable called `$variable` with the current value of dot you would write the following:

```
{{ $variable := . }}
```

You can use `$variable` inside a range or `with` and it will refer to the value of dot at the time the variable was defined, not the current value of dot.

For example, you cannot write a template that use `{{ .Labels }}` in the second range because here dot refers to the current label, not the current alert:

```
{{ range .Alerts }}
{{ range .Labels.SortedPairs }}
{{ .Name }} = {{ .Value }}
{{/* does not work because in the second range . is a label not an alert */}}
There are {{ len .Labels }}
{{ end }}
{{ end }}
```

You can fix this by defining a variable called `$alert` in the first range and before the second range:

```
{{ range .Alerts }}
{{ $alert := . }}
{{ range .Labels.SortedPairs }}
{{ .Name }} = {{ .Value }}
{{/* works because $alert refers to the value of dot inside the first range */}}
There are {{ len $alert.Labels }}
{{ end }}
{{ end }}
```

## Range with index
<a name="v9-go-rangeindex"></a>

You can get the index of each alert within a range by defining index and value variables at the start of the range:

```
{{ $num_alerts := len .Alerts }}
{{ range $index, $alert := .Alerts }}
This is alert {{ $index }} out of {{ $num_alerts }}
{{ end }}
```

## Define templates
<a name="v9-go-define"></a>

You can define templates that can be used within other templates, using `define` and the name of the template in double quotes. You should not define templates with the same name as other templates, including default templates such as `__subject`, `__text_values_list`, `__text_alert_list`, `default.title` and `default.message`. Where a template has been created with the same name as a default template, or a template in another notification template, Grafana might use either template. Grafana does not prevent, or show an error message, when there are two or more templates with the same name.

```
{{ define "print_labels" }}
{{ end }}
```

## Embed templates
<a name="v9-go-embed"></a>

You can embed a defined template within your template using `template`, the name of the template in double quotes, and the cursor that should be passed to the template:

```
{{ template "print_labels" . }}
```

## Pass data to templates
<a name="v9-go-passdata"></a>

Within a template dot refers to the value that is passed to the template.

For example, if a template is passed a list of firing alerts then dot refers to that list of firing alerts:

```
{{ template "print_alerts" .Alerts }}
```

If the template is passed the sorted labels for an alert then dot refers to the list of sorted labels:

```
{{ template "print_labels" .SortedLabels }}
```

This is useful when writing reusable templates. For example, to print all alerts you might write the following:

```
{{ template "print_alerts" .Alerts }}
```

Then to print just the firing alerts you could write this:

```
{{ template "print_alerts" .Alerts.Firing }}
```

This works because both `.Alerts` and `.Alerts.Firing` are lists of alerts.

```
{{ define "print_alerts" }}
{{ range . }}
{{ template "print_labels" .SortedLabels }}
{{ end }}
{{ end }}
```

## Comments
<a name="v9-go-comments"></a>

You can add comments with `{{/*` and `*/}}`:

```
{{/* This is a comment */}}
```

To prevent comments from adding line breaks use:

```
{{- /* This is a comment with no leading or trailing line breaks */ -}}
```

## Indentation
<a name="v9-go-indentation"></a>

You can use indentation, both tabs and spaces, and line breaks, to make templates more readable:

```
{{ range .Alerts }}
  {{ range .Labels.SortedPairs }}
    {{ .Name }} = {{ .Value }}
  {{ end }}
{{ end }}
```

However, indentation in the template will also be present in the text. Next we will see how to remove it.

## Remove spaces and line breaks
<a name="v9-go-removespace"></a>

In text/template use `{{-` and `-}}` to remove leading and trailing spaces and line breaks.

For example, when using indentation and line breaks to make a template more readable:

```
{{ range .Alerts }}
  {{ range .Labels.SortedPairs }}
    {{ .Name }} = {{ .Value }}
  {{ end }}
{{ end }}
```

The indentation and line breaks will also be present in the text:

```
    alertname = "Test"

    grafana_folder = "Test alerts"
```

You can remove the indentation and line breaks from the text changing `}}` to `-}}` at the start of each range:

```
{{ range .Alerts -}}
  {{ range .Labels.SortedPairs -}}
    {{ .Name }} = {{ .Value }}
  {{ end }}
{{ end }}
```

The indentation and line breaks in the template are now absent from the text:

```
alertname = "Test"
grafana_folder = "Test alerts"
```

# Create notification templates
<a name="v9-alerting-create-templates"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

Create reusable notification templates to send to your contact points.

You can add one or more templates to your notification template.

Your notification template name must be unique. You cannot have two templates with the same name in the same notification template or in different notification templates. Avoid defining templates with the same name as default templates, such as: `__subject`, `__text_values_list`, `__text_alert_list`, `default.title` and `default.message`.

In the Contact points tab, you can see a list of your notification templates.

## Creating notification templates
<a name="v9-alerting-creating-templates"></a>

**To create a notification template**

1. Click **Add template**.

1. Choose a name for the notification template, such as `email.subject`.

1. Write the content of the template in the content field.

   For example:

   ```
   {{ if .Alerts.Firing -}}
      {{ len .Alerts.Firing }} firing alerts
      {{ end }}
      {{ if .Alerts.Resolved -}}
      {{ len .Alerts.Resolved }} resolved alerts
      {{ end }}
   ```

1. Click Save.

   `{{ define "email.subject" }}` (where `email.subject` is the name of your template) and `{{ end }}` is automatically added to the start and end of the content.

**To create a notification template that contains more than one template:**

1. Click **Add Template**.

1. Enter a name for the overall notification template. For example, `email`.

1. Write each template in the Content field, including `{{ define "name-of-template" }}` and `{{ end }}` at the start and end of each template. You can use descriptive names for each of the templates in the notification template, for example, `email.subject` or `email.message`. In this case, do not reuse the name of the notification template you entered above.

   The following sections show detailed examples for templates you might create.

1. Click Save.

## Creating a template for the subject of an email
<a name="v9-alerting-create-template-subject"></a>

Create a template for the subject of an email that contains the number of firing and resolved alerts, as in this example:

```
1 firing alerts, 0 resolved alerts
```

**To create a template for the subject of an email**

1. Create a template called `email.subject` with the following content:

   ```
   {{ define "email.subject" }}
   {{ len .Alerts.Firing }} firing alerts, {{ len .Alerts.Resolved }} resolved alerts
   {{ end }}
   ```

1. Use the template when creating your contact point integration by putting it into the **Subject** field with the `template` keyword.

   ```
   {{ template "email.subject" . }}
   ```

## Creating a template for the message of an email
<a name="v9-alerting-create-template-message"></a>

Create a template for the message of an email that contains a summary of all firing and resolved alerts, as in this example:

```
There are 2 firing alerts, and 1 resolved alerts

Firing alerts:

- alertname=Test 1 grafana_folder=GrafanaCloud has value(s) B=1
- alertname=Test 2 grafana_folder=GrafanaCloud has value(s) B=2

Resolved alerts:

- alertname=Test 3 grafana_folder=GrafanaCloud has value(s) B=0
```

**To create a template for the message of an email**

1. Create a notification template called `email` with two templates in the content: `email.message_alert` and `email.message`.

   The `email.message_alert` template is used to print the labels and values for each firing and resolved alert while the `email.message` template contains the structure of the email.

   ```
   {{- define "email.message_alert" -}}
   {{- range .Labels.SortedPairs }}{{ .Name }}={{ .Value }} {{ end }} has value(s)
   {{- range $k, $v := .Values }} {{ $k }}={{ $v }}{{ end }}
   {{- end -}}
   
   {{ define "email.message" }}
   There are {{ len .Alerts.Firing }} firing alerts, and {{ len .Alerts.Resolved }} resolved alerts
   
   {{ if .Alerts.Firing -}}
   Firing alerts:
   {{- range .Alerts.Firing }}
   - {{ template "email.message_alert" . }}
   {{- end }}
   {{- end }}
   
   {{ if .Alerts.Resolved -}}
   Resolved alerts:
   {{- range .Alerts.Resolved }}
   - {{ template "email.message_alert" . }}
   {{- end }}
   {{- end }}
   
   {{ end }}
   ```

1. Use the template when creating your contact point integration by putting it into the **Text Body** field with the `template` keyword.

   ```
   {{ template "email.message" . }}
   ```

## Creating a template for the title of a Slack message
<a name="v9-alerting-create-template-slack-title"></a>

Create a template for the title of a Slack message that contains the number of firing and resolved alerts, as in the following example:

```
1 firing alerts, 0 resolved alerts
```

**To create a template for the title of a Slack message**

1. Create a template called `slack.title` with the following content:

   ```
   {{ define "slack.title" }}
   {{ len .Alerts.Firing }} firing alerts, {{ len .Alerts.Resolved }} resolved alerts
   {{ end }}
   ```

1. Use the template when creating your contact point integration by putting it into the **Title** field with the `template` keyword.

   ```
   {{ template "slack.title" . }}
   ```

## Creating a template for the content of a Slack message
<a name="v9-alerting-create-template-slack-message"></a>

Create a template for the content of a Slack message that contains a description of all firing and resolved alerts, including their labels, annotations, and Dashboard URL:

```
1 firing alerts:

[firing] Test1
Labels:
- alertname: Test1
- grafana_folder: GrafanaCloud
Annotations:
- description: This is a test alert
Go to dashboard: https://example.com/d/dlhdLqF4z?orgId=1

1 resolved alerts:

[firing] Test2
Labels:
- alertname: Test2
- grafana_folder: GrafanaCloud
Annotations:
- description: This is another test alert
Go to dashboard: https://example.com/d/dlhdLqF4z?orgId=1
```

**To create a template for the content of a Slack message**

1. Create a template called `slack` with two templates in the content: `slack.print_alert` and `slack.message`.

   The `slack.print_alert` template is used to print the labels, annotations, and DashboardURL while the `slack.message` template contains the structure of the notification.

   ```
   {{ define "slack.print_alert" -}}
   [{{.Status}}] {{ .Labels.alertname }}
   Labels:
   {{ range .Labels.SortedPairs -}}
   - {{ .Name }}: {{ .Value }}
   {{ end -}}
   {{ if .Annotations -}}
   Annotations:
   {{ range .Annotations.SortedPairs -}}
   - {{ .Name }}: {{ .Value }}
   {{ end -}}
   {{ end -}}
   {{ if .DashboardURL -}}
     Go to dashboard: {{ .DashboardURL }}
   {{- end }}
   {{- end }}
   
   {{ define "slack.message" -}}
   {{ if .Alerts.Firing -}}
   {{ len .Alerts.Firing }} firing alerts:
   {{ range .Alerts.Firing }}
   {{ template "slack.print_alert" . }}
   {{ end -}}
   {{ end }}
   {{ if .Alerts.Resolved -}}
   {{ len .Alerts.Resolved }} resolved alerts:
   {{ range .Alerts.Resolved }}
   {{ template "slack.print_alert" .}}
   {{ end -}}
   {{ end }}
   {{- end }}
   ```

1. Use the template when creating your contact point integration by putting it into the **Text Body** field with the `template` keyword.

   ```
   {{ template "slack.message" . }}
   ```

## Template both email and Slack with shared templates
<a name="v9-alerting-create-shared-templates"></a>

Instead of creating separate notification templates for each contact point, such as email and Slack, you can share the same template.

For example, if you want to send an email with this subject and Slack message with this title `1 firing alerts, 0 resolved alerts`, you can create a shared template.

**To create a shared template**

1. Create a template called `common.subject_title` with the following content:

   ```
   {{ define "common.subject_title" }}
   {{ len .Alerts.Firing }} firing alerts, {{ len .Alerts.Resolved }} resolved alerts
   {{ end }}
   ```

1. For email, run the template from the subject field in your email contact point integration:

   ```
   {{ template "common.subject_title" . }}
   ```

1. For Slack, run the template from the title field in your Slack contact point integration:

   ```
   {{ template "common.subject_title" . }}
   ```

## Using notification templates
<a name="v9-alerting-use-notification-templates"></a>

Use templates in contact points to customize your notifications.

**To use a template when creating a contact point**

1. From the **Alerting** menu, choose **Contact points** to see a list of existing contact points.

1. Choose **Add contact point**. Alternately, you can edit an existing contact point by choosing the **Edit** icon (pen) next to the contact point you wish to edit.

1. Enter the templates you wish to use in one or more field, such as **Message** or **Subject**. To enter a template, use the form `{{ template "template_name" . }}`, replacing *template\$1name* with the name of the template you want to use.

1. Click **Save contact point**.

# Template reference
<a name="v9-alerting-template-reference"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

This section provides reference information for creating your templates.

## Template data
<a name="v9-alerting-template-data"></a>

The following data is passed to message templates.


| Name | Type | Notes | 
| --- | --- | --- | 
|  `Receiver`  |  string  |  Name of the contact point that the notification is being sent to.  | 
|  `Status`  |  string  |  firing if at least one alert is firing, otherwise resolved.  | 
|  `Alerts`  |  Alert  |  List of alert objects that are included in this notification (see below).  | 
|  `GroupLabels`  |  KeyValue  |  Labels these alerts were grouped by.  | 
|  `CommonLabels`  |  KeyValue  |  Labels common to all the alerts included in this notification.  | 
|  `CommonAnnotations`  |  KeyValue  |  Annotations common to all the alerts included in this notification.  | 
|  `ExternalURL`  |  string  |  Back link to the Grafana that sent the notification. If using external Alertmanager, back link to this Alertmanager.  | 

The `Alerts` type exposes two functions for filtering the alerts returned.
+ `Alerts.Firing` – Returns a list of firing alerts.
+ `Alerts.Resolved` – Returns a list of resolved alerts.

**Alert (type)**

The alert type contains the following data.


| Name | Type | Notes | 
| --- | --- | --- | 
|  Status  |  string  |  `firing` or `resolved`.  | 
|  Labels  |  KeyValue  |  A set of labels attached to the alert.  | 
|  Annotations  |  KeyValue  |  A set of annotations attached to the alert.  | 
| Values | KeyValue | The values of all expressions, including Classic Conditions | 
|  StartsAt  |  time.Time  |  Time the alert started firing.  | 
|  EndsAt  |  time.Time  |  Only set if the end time of an alert is known. Otherwise set to a configurable timeout period from the time since the last alert was received.  | 
|  GeneratorURL  |  string  |  A back link to Grafana or external Alertmanager.  | 
|  SilenceURL  |  string  |  A link to silence the alert (with labels for this alert pre-filled). Only for Grafana managed alerts.  | 
|  DashboardURL  |  string  |  Link to grafana dashboard, if alert rule belongs to one. Only for Grafana managed alerts.  | 
|  PanelURL  |  string  |  Link to grafana dashboard panel, if alert rule belongs to one. Only for Grafana managed alerts.  | 
|  Fingerprint  |  string  |  Fingerprint that can be used to identify the alert.  | 
|  ValueString  |  string  |  A string that contains the labels and value of each reduced expression in the alert.  | 

 **ExtendedData**

The ExtendedData object contains the following properties.


| Name | Kind | Description | Example | 
| --- | --- | --- | --- | 
|  Receiver  |  `string`  |  The name of the contact point sending the notification.  |  `{{ .Receiver }}`  | 
|  Status  |  `string`  |  The status is `firing if at least one alert is firing, otherwise resolved.`  |  `{{ .Status }}`  | 
|  Alerts  |  `[]Alert`  |  List of all firing and resolved alerts in this notification.  |  `There are {{ len .Alerts }} alerts`  | 
|  Firing alerts  |  `[]Alert`  |  List of all firing alerts in this notification.  |  `There are {{ len .Alerts.Firing }} firing alerts`  | 
|  Resolved alerts  |  `[]Alert`  |  List of all resolved alerts in this notification.  |  `There are {{ len .Alerts.Resolved }} resolved alerts`  | 
|  GroupLabels  |  `KeyValue`  |  The labels that group these alerts int his notification.  |  `{{ .GroupLabels }}`  | 
|  CommonLabels  |  `KeyValue`  |  The labels common to all alerts in this notification.  |  `{{ .CommonLabels }}`  | 
|  CommonAnnotations  |  `KeyValue`  |  The annotations common to all alerts in this notification.  |  `{{ .CommonAnnotations }}`  | 
|  ExternalURL  |  `string`  |  A link to the Grafana workspace or Alertmanager that sent this notification.  |  `{{ .ExternalURL }}`  | 

**KeyValue type**

The `KeyValue` type is a set of key/value string pairs that represent labels and annotations.

In addition to direct access of the data stored as a `KeyValue`, there are also methods for sorting, removing, and transforming the data.


| Name | Arguments | Returns | Notes | Example | 
| --- | --- | --- | --- | --- | 
|  SortedPairs  |    |  Sorted list of key and value string pairs  |    | `{{ .Annotations.SortedPairs }}` | 
|  Remove  |  []string  |  KeyValue  |  Returns a copy of the Key/Value map without the given keys.  | `{{ .Annotations.Remove "summary" }}` | 
|  Names  |    |  []string  |  List of label names  | `{{ .Names }}` | 
|  Values  |    |  []string  |  List of label values  | `{{ .Values }}` | 

**Time**

Time is from the Go [https://pkg.go.dev/time#Time](https://pkg.go.dev/time#Time) package. You can print a time in a number of different formats. For example, to print the time that an alert fired in the format `Monday, 1st January 2022 at 10:00AM`, you write the following template:

```
{{ .StartsAt.Format "Monday, 2 January 2006 at 3:04PM" }}
```

You can find a reference for Go’s time format [here](https://pkg.go.dev/time#pkg-constants).

## Template functions
<a name="v9-alerting-template-functions"></a>

Using template functions you can process labels and annotations to generate dynamic notifications. The following functions are available.


| Name | Argument type | Return type | Description | 
| --- | --- | --- | --- | 
|  `humanize`  |  number or string  |  string  |  Converts a number to a more readable format, using metric prefixes.  | 
|  `humanize1024`  |  number or string  |  string  |  Like humanize, but uses 1024 as the base rather than 1000.  | 
|  `humanizeDuration`  |  number or string  |  string  |  Converts a duration in seconds to a more readable format.  | 
|  `humanizePercentage`  |  number or string  |  string  |  Converts a ratio value to a fraction of 100.  | 
|  `humanizeTimestamp`  |  number or string  |  string  |  Converts a Unix timestamp in seconds to a more readable format.  | 
|  `title`  |  string  |  string  |  strings.Title, capitalizes first character of each word.  | 
|  `toUpper`  |  string  |  string  |  strings.ToUpper, converts all characters to upper case.  | 
|  `toLower`  |  string  |  string  |  strings.ToLower, converts all characters to lower case.  | 
|  `match`  |  pattern, text  |  Boolean  |  regexp.MatchString Tests for an unanchored regexp match.  | 
|  `reReplaceAll`  |  pattern, replacement, text  |  string  |  Regexp.ReplaceAllString Regexp substitution, unanchored.  | 
|  `graphLink`  |  string - JSON Object with `expr` and `datasource` fields  |  string  |  Returns the path to graphical view in Explore for the given expression and data source.  | 
|  `tableLink`  |  string - JSON Object with `expr` and `datasource` fields  |  string  |  Returns the path to tabular view in Explore for the given expression and data source.  | 
|  `args`  |  []interface\$1\$1  |  map[string]interface\$1\$1  |  Converts a list of objects to a map with keys, for example, arg0, arg1. Use this function to pass multiple arguments to templates.  | 
|  `externalURL`  |  nothing  |  string  |  Returns a string representing the external URL.  | 
|  `pathPrefix`  |  nothing  |  string  |  Returns the path of the external URL.  | 

The following table shows examples of using each function.


| Function | TemplateString | Input | Expected | 
| --- | --- | --- | --- | 
|  humanize  |  \$1 humanize \$1value \$1  |  1234567.0  |  1.235M  | 
|  humanize1024  |  \$1 humanize1024 \$1value \$1  |  1048576.0  |  1Mi  | 
|  humanizeDuration  |  \$1 humanizeDuration \$1value \$1  |  899.99  |  14m 59s  | 
|  humanizePercentage  |  \$1 humanizePercentage \$1value \$1  |  0.1234567  |  12.35%  | 
|  humanizeTimestamp  |  \$1 humanizeTimestamp \$1value \$1  |  1435065584.128  |  2015-06-23 13:19:44.128 \$10000 UTC  | 
|  title  |  \$1 \$1value \$1 title \$1  |  aa bB CC  |  Aa Bb Cc  | 
|  toUpper  |  \$1 \$1value \$1 toUpper \$1  |  aa bB CC  |  AA BB CC  | 
|  toLower  |  \$1 \$1value \$1 toLower \$1  |  aa bB CC  |  aa bb cc  | 
|  match  |  \$1 match "a\$1" \$1labels.instance \$1  |  aa  |  true  | 
|  reReplaceAll  |  \$1\$1 reReplaceAll "localhost:(.\$1)" "my.domain:\$11" \$1labels.instance \$1\$1  |  localhost:3000  |  my.domain:3000  | 
|  graphLink  |  \$1\$1 graphLink "\$1\$1"expr\$1": \$1"up\$1", \$1"datasource\$1": \$1"gdev-prometheus\$1"\$1" \$1\$1  |    |  /explore?left=["now-1h","now","gdev-prometheus",\$1"datasource":"gdev-prometheus","expr":"up","instant":false,"range":true\$1]  | 
|  tableLink  |  \$1\$1 tableLink "\$1\$1"expr\$1":\$1"up\$1", \$1"datasource\$1":\$1"gdev-prometheus\$1"\$1" \$1\$1  |    |  /explore?left=["now-1h","now","gdev-prometheus",\$1"datasource":"gdev-prometheus","expr":"up","instant":true,"range":false\$1]  | 
|  args  |  \$1\$1define "x"\$1\$1\$1\$1.arg0\$1\$1 \$1\$1.arg1\$1\$1\$1\$1end\$1\$1\$1\$1template "x" (args 1 "2")\$1\$1  |    |  1 2  | 
|  externalURL  |  \$1 externalURL \$1  |    |  http://localhost/path/prefix  | 
|  pathPrefix  |  \$1 pathPrefix \$1  |    |  /path/prefix  | 

# Silencing alert notifications for Prometheus data sources
<a name="v9-alerting-silences"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

For external Alert manager data sources (including Amazon Managed Service for Prometheus), you can suppress alert notifications with a *silence*. A silence only stops notifications from being created: Silences do not prevent alert rules from being evaluated, and they do not stop alerting instances from being shown in the user interface. When you silence an alert, you specify a window of time for it to be suppressed.

You can configure silences for an external Alertmanager data source.

**Note**  
To suppress alert notifications at regular time intervals, or for other data sources, (for example, during regular maintenance periods), use [Mute timings](v9-alerting-notification-muting.md) rather than silences.

**To add a silence**

1. From your Grafana console, in the Grafana menu, choose the **Alerting** (bell) icon to open the **Alerting** page.

1. Choose **Silences** to open a page listing existing [Working with contact points](v9-alerting-contact-points.md).

1. Choose the external Alertmanager from the **Alertmanager** dropdown.

1. Select **Add Silence**.

1. Select the start and end date in **Silence start and end** to indicate when the silence should go into effect and when it should end.

   As an alternative to setting an end time, in **Duration**, specify how long the silence is enforced. This automatically updates the end time in the **Silence start and end** field.

1. In the **Name** and **Value** fields, enter one or more *Matching Labels*. Matchers determine which rules the silence applies to. Label matching is discussed in more detail following this procedure.

1. Optionally, add a **Comment**, or modify the **Creator** to set the owner of the silence.

1. Choose **Create** to create the silence.

You can edit an existing silence by choosing the **Edit** icon (pen).

**Label matching for alert suppression**

When you create a silence, you create a set of *matching labels* as part of the silence. This is a set of rules about labels that must match for the alert to be suppressed. The matching labels consist of three parts:
+ **Label** – The name of the label to match. It must exactly match the label name of the alert.
+ **Operator** – The operator used to compare the label value with the matching label value. The available operators are:
  + `=` Select labels whose value exactly matches the provided string.
  + `!=` Select labels whose value does not match the provided string.
  + `=~` Select labels whose value match the regex interpreted value of the provided string (the provided string is interpreted as a regular expression).
  + `!=` Select labels that do not match the provided regular expression.
+ **Value** – The value to match the label value to. It can match as a string or as a regular expression, depending on the operator chosen.

A silence ends at the indicated end date, but you can manually end the suppression at any time.

**To end a silence manually**

1. In the **Alerting** page, choose **Silences** to view the list of existing silences.

1. Select the silence that you want to end, and choose **Unsilence**. This ends the alert suppression.
**Note**  
Unsilencing ends the alert suppression, as if the end time was set for the current time. Silences that have ended (automatically or manually) are retained and listed for five days. You cannot remove a silence from the list manually.

**Creating a link to the silence creation form**

You can create a URL to the silence creation form with details already filled in. Operators can use this to suppress an alarm quickly during an operational event.

When creating a link to a silence form, use a `matchers` query parameter to specify the matching labels, and a `comment` query parameter to specify a comment. The `matchers` parameter requires one or more values in the form `[label][operator][value]`, separated by commas.

**Example URL**

To link to a silence form, with matching labels `severity=critical` and `cluster!~europe-.*`, with a comment that says `Silencing critical EU alerts`, use a URL like the following. Replace *mygrafana* with the hostname of your Grafana instance.

```
https://mygrafana/alerting/silence/new?matchers=severity%3Dcritical%2Ccluster!~europe-*&comment=Silence%20critical%20EU%20alert
```

To link to a new silence page for an external Alertmanager, add an `alertmanager` query parameter with the Alertmanage data source name, such as `alertmanager=myAlertmanagerdatasource`.

# Mute timings
<a name="v9-alerting-notification-muting"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

A mute timing is a recurring interval of time when no new notifications for a policy are generated or sent. Use them to prevent alerts from firing a specific and reoccurring period, for example, a regular maintenance period.

Similar to silences, mute timings do not prevent alert rules from being evaluated, nor do they stop alert instances from being shown in the user interface. They only prevent notifications from being created.

You can configure Grafana managed mute timings as well as mute timings for an external Alertmanager data source.

**Mute timings compared to silences**

The following table highlights the differences between mute timings and silences.


| Mute timing | Silence | 
| --- | --- | 
|  Uses time interval definitions that can reoccur.  |  Has a fixed start and end time.  | 
|  Is created and then added to notification policies.  |  Uses labels to match against an alert to determine whether to silence or not.  | 
|  Works with Grafana alerting and external Alertmanagers.  |  Works only with external Alertmanagers.  | 

**To create a mute timing**

1. From your Grafana console, in the Grafana menu, choose the **Alerting** (bell) icon to open the **Alerting** page.

1. Choose **Notification policies**.

1. From the **Alertmanager** dropdown, select the Alertmanager you want to edit.

1. In the **Mute timings** section, choose the **Add mute timing** button.

1. Choose the time interval for which you want the mute timing to apply.

1. Choose **Submit** to create the mute timing.

**To add a mute timing to a notification policy**

1. Select the notification policy you would like to add the mute timing to, and choose the **Edit** button.

1. From the **Mute timings** dropdown, select the mute timings you would like to add to the policy.

   Choose the **Save policy** button.

**Time intervals**

A time interval is a definition for a range of time. If an alert is initiated during this interval it is suppressed. Ranges are supported using `:` (for example, `monday:thursday`). A mute timing can contain multiple time intervals. A time interval consists of multiple fields (details in the following list), all of which must match in order to suppress the alerts. For example, if you specify days of the week `monday:friday` and time range from 8:00-9:00, then alerts are suppressed from 8–9, Monday through Friday, but not, for example, 8–9 on Saturday.
+ **Time range** – The time of day to suppress notifications. Consists of two sub-fields, **Start time** and **End time**. An example time is `14:30`. Time is in 24 hour notation, in UTC.
+ **Days of the week** – The days of the week. Can be a single day, such as `monday`, a range, such as `monday:friday`, or a comma-separate list of days, such as `monday, tuesday, wednesday`.
+ **Months** – The months to select. You can specify months with numeric designations, or with the full month name, for example `1` or `january` both specify January. You can specify a single month, a range of months, or a comma-separated list of months.
+ **Days of the month** – The dates within a month. Values can range from `1`-`31`. Negative values specify days of the month in reverse order, so `-1` represents the last day of the month. Days of the month can be specified as a single day, a range of days, or a comma-separate list of days.
+ **Years** – The year or years for the interval. For example, `2023:2025`.

Each of these elements can be a list, and at least one item in the element must be satisfied to be a match. So if you set years to `2023:2025, 2027`, then it would be true during 2023, 2024, 2025, and 2027 (but not 2026).

If a field is left blank, any moment of time will match the field. A moment of time must match all fields to match a complete time interval.

If you want to specify an exact duration, specify all the options needed for that duration. For example, if you wanted to create a time interval for the first Monday of the month, for March, June, September, and December, between the hours of 12:00 and 24:00 UTC, your time interval specification could be:
+ Time range:
  + Start time: `12:00`
  + End time: `24:00`
+ Days of the week: `monday`
+ Months: `3, 6, 9, 12`
+ Days of the month: `1:7`

# View and filter by alert groups
<a name="v9-alerting-viewfiltergroups"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

Alert groups show grouped alerts from an Alertmanager instance. By default, alert rules are grouped by the label keys for the root policy in notification policies. Grouping common alert rules into a single alert group prevents duplicate alert rules from being fired.

You can view alert groups and also filter for alert rules that match specific criteria.

**To view alert groups**

1. In the Grafana menu, click the **Alerting** (bell) icon to open the Alerting page listing existing alerts.

1. Click **Alert groups** to open the page listing existing groups.

1. From the **Alertmanager** dropdown, select an external Alertmanager as your data source.

1. From **custom group by** dropdown, select a combination of labels to view a grouping other than the default. This is useful for debugging and verifying your grouping of notification policies.

If an alert does not contain labels specified either in the grouping of the root policy or the custom grouping, then the alert is added to a catch all group with a header of `No grouping`.

**To filter by label**
+ In **Search**, enter an existing label to view alerts matching the label.

  For example, `environment=production,region=~US|EU,severity!=warning`.

**To filter by state**
+ In **States**, select from Active, Suppressed, or Unprocessed states to view alerts matching your selected state. All other alerts are hidden.

# View notification errors
<a name="v9-alerting-viewnotificationerrors"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 9.x**.  
For Grafana workspaces that support Grafana version 12.x, see [Working in Grafana version 12](using-grafana-v12.md).  
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 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

View notification errors and understand why they failed to be sent or were not received.

**Note**  
This feature is only supported for Grafana Alertmanager.

**To view notification errors**

1. In the Grafana menu, click the **Alerting** (bell) icon to open the Alerting page listing existing alerts.

1. Choose **Contact points** to see a list of the existing contact points.

   If any contact points are failing, a message at the right-hand corner of the screen alerts the user to the fact that there are errors and how many.

1. Click on a contact point to view the details of errors for that contact point.

   Error details are displayed if you hover over the Error icon.

   If a contact point has more than one integration, you see all errors for each of the integrations listed.

1. In the Health column, check the status of the notification.

   This can be either OK, No attempts, or Error.