

# Working in Grafana version 12
<a name="using-grafana-v12"></a>

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

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 12 of Grafana.

**Topics**
+ [

# Dashboards in Grafana version 12
](v12-dashboards.md)
+ [

# Panels and visualizations in Grafana version 12
](v12-panels.md)
+ [

# Explore in Grafana version 12
](v12-explore.md)
+ [

# Correlations in Grafana version 12
](v12-correlations.md)
+ [

# Alerts in Grafana version 12
](v12-alerts.md)

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

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

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

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

**Topics**
+ [

# Using dashboards
](v12-dash-using-dashboards.md)
+ [

# Building dashboards
](v12-dash-building-dashboards.md)
+ [

# Managing dashboards
](v12-dash-managing-dashboards.md)
+ [

# Managing playlists
](v12-dash-managing-playlists.md)
+ [

# Sharing dashboards and panels
](v12-dash-sharing.md)
+ [

# Variables
](v12-dash-variables.md)
+ [

# Assessing dashboard usage
](v12-dash-assess-dashboard-usage.md)
+ [

# Troubleshoot dashboards
](v12-dash-troubleshoot.md)
+ [

# Searching Dashboards in Grafana version 12
](v12-search.md)

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

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

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

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

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

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



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

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

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

**Focused panel**

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

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

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

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

**Time units and relative ranges**

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

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

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

The following table provides example relative ranges.


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

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

**Common time range controls**

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

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

**Refresh dashboards**

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

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

**Control the time range using a URL**

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

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

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

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

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

**Topics**
+ [

# Creating dashboards
](v12-dash-creating.md)
+ [

# Importing dashboards
](v12-dash-importing.md)
+ [

# Exporting dashboards
](v12-dash-exporting.md)
+ [

# Modifying dashboard settings
](v12-dash-modify-settings.md)
+ [

# Dashboard URL variables
](v12-dash-dashboard-url-variables.md)
+ [

# Managing library panels
](v12-dash-manage-library-panels.md)
+ [

# Managing dashboard version history
](v12-dash-manage-version-history.md)
+ [

# Managing dashboard links
](v12-dash-manage-dashboard-links.md)
+ [

# Annotate visualizations
](v12-dash-annotations.md)
+ [

# Dashboard JSON model
](v12-dash-dashboard-json-model.md)
+ [

# Best practices for dashboards
](v12-dash-bestpractices.md)

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

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

**Creating a dashboard **

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

 To create a dashboard:

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

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

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

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

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

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

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

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

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

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

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

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

1. Choose **Save**.

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

**Copying an existing dashboard**

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

**To copy an existing dashboard**

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

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

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

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

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

1. Select **Save**.

**Configuring repeating rows**

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

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

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

**To configure repeating rows**

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

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

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

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

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

1. Select **Update**.

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

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

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

**To move a panel**

1. Open the dashboard.

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

**To resize a panel**

1. Open the dashboard.

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

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

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

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

**To import a dashboard**

1. Sign into your Amazon Managed Grafana workspace.

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

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

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

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

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

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

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

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

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

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

**Making a dashboard portable**

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

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

**To export a dashboard**

1. Open the dashboard that you want to export.

1. Select the share icon.

1. Choose **Export**.

1. Choose **Save to file.**

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

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

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

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

**To access the dashboard setting page**

1. Open a dashboard in edit mode.

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

**Modifying dashboard time settings**

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

**To modify dashboard time settings**

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

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

1. Specify time settings according to the following descriptions.

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

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

**Adding an annotation query**

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

**To add an annotation query**

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

1. Select **Add annotation query**. 

1. Enter a name and select a data source.

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

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

**Adding a variable**

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

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

**To add a variable**

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

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

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

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

**Adding a link**

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

**To add a link**

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

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

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

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

**View dashboard JSON model **

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

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

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

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

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

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

**Passing variables as query parameters**

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

For example, in this URL: 

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

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

**Passing multiple values for a variable**

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

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

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

**Adding variables to dashboard links**

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

**Passing ad hoc filters**

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

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

For example, in this URL:

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

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

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

**Controlling time range using the URL**

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

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

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

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

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

**Creating a library panel**

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

**To create a library panel**

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

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

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

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

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

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

1. Save the dashboard.

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

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

**Adding a library panel to a dashboard**

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

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

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

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

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

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

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

**Unlinking a library panel**

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

**To unlink a library panel**

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

1. Select **Library panels**.

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

1. Select the panel that you want to unlink.

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

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

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

1. Choose **Yes, unlink**.

**Viewing a list of library panels**

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

**To view a list of library panels**

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

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

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

**Deleting a library panel**

Delete a library panel when you no longer need it.

**To delete a library panel**

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

1. Select **Library panels**.

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

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

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

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

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

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

**Comparing two dashboard versions**

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

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

**Restoring to a previously saved dashboard version**

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

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

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

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

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

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

**Choosing which link to use**

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

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

**Controlling the time range using a URL**

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

**Dashboard links**

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

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

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

**Adding links to dashboards**

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

**To add a link to a dashboard**

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

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

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

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

1. Click **Add**.

**Adding a URL link to a dashboard**

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

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

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

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

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

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

     The variable format is as follows:

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

1. Select **Add**.

**Updating a dashboard link**

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

**To update a dashboard link**

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

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

**Duplicating a dashboard link**

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

**Deleting a dashboard link**

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

**Panel links**

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

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

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

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

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

  1. Select **Add link**.

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

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

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

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

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

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

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

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

  1. Make any necessary changes.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

**To add an annotation**

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

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

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

1. Select **Save**.

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

**Region annotations**

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

**To add a region annotation**

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

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

1.  Click **Save**. 

**To edit an annotation**

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

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

1. Modify the description and/or tags.

1. Select **Save**.

**To delete an annotation**

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

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

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

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

**To add a new annotation query**

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

1. Select **Annotations**.

1. Click **Add annotation query**.

1. Enter a name for the annotation query.

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

1. Select the data source for the annotations.

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

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

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

1. Select a color for the event markers.

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

1. Configure the query.

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

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

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

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

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

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

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

1. Select **Annotations**. 

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

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

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

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

1. Select **Annotations**. 

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

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

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

**Filtering queries by tag**

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

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

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

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

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

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

**To view the JSON of a dashboard**

1. Navigate to a dashboard.

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

1. Select **JSON Model**.

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

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

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

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

The following describes each field in the dashboard JSON.


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

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

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

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

**Panel size and position**

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

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

**Timepicker**

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

**Templating **

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

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

The following table describes the usage of the templating fields.


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

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

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

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

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

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

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

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

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

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

**USE method**

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

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

**RED method**

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

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

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

**The Four Golden Signals**

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

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

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

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

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

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

**Low – default state**

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

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

**Medium – methodical dashboards**

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

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

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

**High – optimized use**

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

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

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

**Before you begin**

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

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

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

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

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

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

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

**Have a monitoring strategy**

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

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

**Write it down**

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

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

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

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

**Before you begin**

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

**Strategic observability**

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

Adapt your strategy to changing needs as necessary.

**Maturity level**

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

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

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

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

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

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

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

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

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

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

**Prerequisites**

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

**To create a dashboard folder**

1. Sign in to Grafana. 

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

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

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

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

**To edit the name of a folder**

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

1. Select the folder to rename

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

   The new folder name is automatically saved.

**Folder permissions**

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

**To modify permissions for a folder**

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

1. Select the folder in the list.

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

1. Update the permissions as desired.

Changes are saved automatically.

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

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

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

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

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

**To access a playlist**

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

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

**Starting a playlist**

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

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

**To start a playlist**

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

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

   The start playlist dialog box will open.

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

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

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


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

**Controlling a playlist**

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


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

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

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

**To create a playlist**

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

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

1. Select **New playlist**.

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

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

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

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

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

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

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

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

**To save a playlist**

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

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

1. Choose the playlist of your choice.

1. Edit the playlist.

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

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

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

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

**To edit a playlist**

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

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

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

**To delete a playlist**

1. Select **Playlists**.

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

**To rearrange dashboard order in a playlist**

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

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

**To remove a dashboard**

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

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

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

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

**To share a playlist in view mode**

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

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

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

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

1. Paste the URL to your destination.

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

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

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

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

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

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

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

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

**To Share a dashboard**

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

1. Choose the dashboard you want to share.

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

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

**Sharing a direct link**

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

**To share a directly link**

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

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

**Publishing a snapshot**

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

You can publish snapshots to your local instance.

**To publish a snapshot**

1. Select the **Snapshot** tab.

1. Select the **Local Snapshot**.

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

**Exporting a dashboard**

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

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

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

**To share a panel**

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

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

**Using a direct link**

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

**To use a direct link**

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

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

**Publishing a snapshot of a panel**

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

You can publish snapshots to your local instance.

**To publish a snapshot of a panel**

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

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

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

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

**Creating a library panel**

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

**To create a library panel**

1. Select **Library panel**.

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

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

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

1. Save the dashboard.

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

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

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

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

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

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

**Templates**

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

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

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

**Examples**

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

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

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

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

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

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

**Topics**
+ [

# Add and manage variables
](v12-dash-variable-add.md)
+ [

# Inspect Variables
](v12-dash-variable-add-inspect.md)
+ [

# Variable syntax
](v12-dash-variable-syntax.md)

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

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

The following table lists the types of variables in Grafana.


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

**Topics**
+ [

## Entering General options
](#v12-dash-variable-options)
+ [

## Adding a query variable
](#v12-dash-variable-add-query)
+ [

## Adding a custom variable
](#v12-dash-variable-add-custom)
+ [

## Adding a text box variable
](#v12-dash-variable-add-text)
+ [

## Adding a constant variable
](#v12-dash-variable-add-constant)
+ [

## Adding a data source variable
](#v12-dash-variable-add-datasource)
+ [

## Adding an interval variable
](#v12-dash-variable-add-internal)
+ [

## Adding ad hoc filters
](#v12-dash-variable-add-adhoc)
+ [

## Configure variable selection options
](#v12-dash-variable-add-selection)
+ [

## Global variables
](#v12-dash-variable-add-global)
+ [

## Chained variables
](#v12-dash-variable-add-chained)
+ [

## Manage variables
](#v12-dash-variable-add-manage)
+ [

## Filter variables with regex
](#v12-dash-variable-add-filter)

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

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

**To enter general options**

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

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

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

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

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

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

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

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

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

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

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

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

**To add a query variable**

1. Enter general options, as above.

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

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

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

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

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

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

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

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

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

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

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

**To add a custom variable**

1. Enter general options, as above.

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

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

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

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

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

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

**To add a text box variable**

1. Enter general options, as above.

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

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

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

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

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

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

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

**To add a constant variable**

1. Enter general options, as above.

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

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

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

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

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

**To add a data source variable**

1. Enter general options, as above.

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

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

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

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

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

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

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

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

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

**To add an interval variable**

1. Enter general options, as above.

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

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

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

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

**Interval variable examples**

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

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

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

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

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

1. Enter general options, as above.

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

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

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

**Create ad hoc filters**

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

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

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

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

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

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

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

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

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

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

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

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

**Troubleshoot multi-value variables**

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

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

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

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

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

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

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

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

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

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

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

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

This variable is the name of the current dashboard.

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

**Best practices and tips**

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

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

**Variable order**

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

**Complexity consideration**

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

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

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

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

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

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

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

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

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

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

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

The following examples show filtering on the following list of options

```
backend_01
backend_02
backend_03
backend_04
```

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

Regex:

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

Result:

```
backend_01
backend_02
```

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

Regex:

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

Result:

```
01
02
```

**Filter and modify - Prometheus Example**

For this list of options:

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

This regex:

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

Returns these results:

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

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

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

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

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

Passed through the following Regex:

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

Would produce the following dropdown list:

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

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

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

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

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

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

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

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

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

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

**Advanced variable format options**

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

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

**General syntax**

Syntax: `${var_name:option}`

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

**CSV**

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

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

**Distributed - OpenTSDB**

Formats variables with multiple values in custom format for OpenTSDB.

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

**Doublequote**

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

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

**Glob - Graphite**

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

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

**JSON**

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

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

**Lucene - Elasticsearch**

Formats variables with multiple values in Lucene format for Elasticsearch.

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

**Percentencode**

Formats single and multivalued variables for use in URL parameters.

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

**Pipe**

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

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

**Raw**

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

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

**Regex**

Formats variables with multiple values into a regex string.

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

**Singlequote**

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

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

**Sqlstring**

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

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

**Text**

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

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

**Query parameters**

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

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

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

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

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

**Dashboard insights**

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

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

**Data source insights**

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

**To find data source insights**

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

1. Select **Data sources**.

1. Choose a data source.

1. Select the **Insights** tab.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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
](v12-panels-editor-overview.md)
+ [

# The panel inspect view
](v12-panels-panel-inspector.md)
+ [

# Query and transform data
](v12-panels-query-xform.md)
+ [

# Configure panel options
](v12-panels-configure-panel-options.md)
+ [

# Configure standard options
](v12-panels-configure-standard-options.md)
+ [

# Configure a legend
](v12-panels-configure-legend.md)
+ [

# Configure data links
](v12-panels-configure-data-links.md)
+ [

# Configure value mappings
](v12-panels-configure-value-mappings.md)
+ [

# Configure thresholds
](v12-panels-configure-thresholds.md)
+ [

# Configure field overrides
](v12-panels-configure-overrides.md)
+ [

# Visualizations available in Grafana version 12
](v12-panels-viz.md)

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

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

In the panel editor, you can update all the elements of a visualization, including the data source, queries, time range, and display options.

To add a panel to a new dashboard, select **\$1 Add visualization** in the middle of the dashboard. To add a panel to an existing dashboard, select **Add** in the dashboard header and select **Visualization** in the drop down. You can also copy and paste an existing panel from the same or a different dashboard.

## Panel menu
<a name="v12-panels-editor-menu"></a>

To access the panel editor, hover over the top-right corner of any panel. Select the panel menu icon that appears and select **Edit**.

The panel menu also gives you access to the following actions:
+ **View** – View the panel in full screen.
+ **Edit** – Open the panel editor to edit panel and visualization options.
+ **Share** – Share the panel as a link, or library panel.
+ **Explore** – Open the panel in **Explore**, where you can focus on your query.
+ **Inspect** – Open the **Inspect** drawer, where you can review the panel data, stats, metadata, JSON, and query.
  + **Data** – Open the **Inspect** drawer in the **Data** tab.
  + **Query** – Open the **Inspect** drawer in the **Query** tab.
  + **Panel JSON** – Open the **Inspect** drawer in the **JSON** tab.
+ **Extensions** – Access other actions provided by installed applications, such as declaring an incident. This option only appears if you have app plugins installed which contribute an extension to the panel menu.
+ **More** – Access other panel actions.
  + **Duplicate** – Make a copy of the panel. Duplicated panels query data separately from the original panel. If you want to use the same query results, you can use the `Dashboard` data source in the second panel.
  + **Copy** – Copy the panel to the clipboard.
  + **Create library panel** – Create a panel that can be imported into other dashboards.
  + **Create alert** – Open the alert rule configuration page in **Alerting**, where you can create a [Grafana-managed alert](v12-alerts.md) based on the panel queries.
  + **Hide legend** – Hide the panel legend.
  + **Get help** – Send a snapshot or panel data to Grafana Labs Technical Support.
+ **Remove** – Remove the panel from the dashboard.

## Panel editor
<a name="v12-panels-editor-view"></a>

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:
  + **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](v12-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. For more information, see [Query and transform data](v12-panels-query-xform.md). When you initially create a dashboard, you are prompted to select a data source. You can update the data source or the query in this tab.
  + **Transform tab** – Apply data transformations. For more information, see [Query and transform data](v12-panels-query-xform.md).
  + **Alert tab** – Write alert rules. For more information, see [Alerts in Grafana version 12](v12-alerts.md).
+ Panel display options – The display options section contains tabs where you configure almost every aspect of your data visualization. The details vary based on the visualization type selected.

## Panel inspect drawer
<a name="v12-panels-editor-inspect"></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 as a drawer on the right side. Select 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 any errors returned by a query. The tab is only visible when a query returns an error.

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

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

The 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 Amazon Managed 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:** at the top of the pane. Select 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 sent to the server when Grafana queries the data source.

1. **Error tab** – Shows any errors. Only visible when a query returns an error.

## Downloading raw query results
<a name="v12-panels-raw-query-results"></a>

Amazon Managed 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.

**To download raw query results**

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

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

1. Select **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. Select a column heading to reorder the data.

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

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

1. Select **Download CSV**.

## Inspecting query performance
<a name="v12-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.

**To inspect query performance**

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

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

1. Select **Stats**.

Statistics are displayed in read-only format.

## Inspecting query request and response
<a name="v12-panels-query-request-response"></a>

You can 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, select **Query Inspector**.

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

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

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

Amazon Managed 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.

**Topics**
+ [

## About queries
](#v12-panels-query-xform-about)
+ [

## Navigate the query tab
](#v12-panels-query-xform-navigate)
+ [

## Adding a query
](#v12-panels-query-xform-add)
+ [

## Manage queries
](#v12-panels-query-xform-manage)
+ [

## Query options
](#v12-panels-query-xform-options)
+ [

# Write expression queries
](v12-panels-query-xform-expressions.md)
+ [

# Share query results with another panel
](v12-panels-query-share.md)
+ [

# Transform data
](v12-panels-xform.md)
+ [

# Troubleshoot queries
](v12-panels-query-troubleshoot.md)
+ [

# Calculation types
](v12-panels-calculation-types.md)

## About queries
<a name="v12-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, including information about queries and syntax, see the data source documentation:
+ For data sources included with Amazon Managed Grafana, see [Built-in data sources](AMG-data-sources-builtin.md).
+ For data sources included with Grafana Enterprise, see [Connect to Enterprise data sources](AMG-data-sources-enterprise.md).
+ For other data source plugins that you install via the [Find plugins with the plugin catalog](grafana-plugins.md#plugin-catalog), the documentation is linked within the listing in the plugin catalog.

**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 more information, see [Connect to data sources](AMG-data-sources.md).

## Navigate the query tab
<a name="v12-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](v12-panels-query-xform-expressions.md).

## Adding a query
<a name="v12-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](#v12-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="v12-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 queries, reorder queries, and toggle help for the query editor.

## Query options
<a name="v12-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.

  With streaming data, Grafana uses the max data points value for the rolling buffer. Streaming is a continuous flow of data, and buffering divides the stream into chunks.
+ **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](v12-dash-variable-add.md#v12-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/v12-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/v12-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="v12-panels-query-xform-expressions"></a>

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

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="v12-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 most commonly used by [Grafana alerting](v12-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 numeric 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. 

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:

The following example table produces 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.


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

**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 (for example, `-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 <Operation> number = number
+ Number <Operation> series = series
+ Series <Operation> 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 match 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 is required for this check 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` for 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 knowm value
  + **backfill** with next known value
  + **fillna** to fill empty sample windows with NaNs

## Write an expression
<a name="v12-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="v12-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 [Configure Grafana managed alert rules](v12-alerting-configure-grafanamanaged.md).

In the case of using an expression on multiple queries, the expression engine requires that all of the queries return an identical timestamp. For example, if using math to combine the result of multiple SQL queries which each use `SELECT NOW() AS "time"`, the expression will only work if all queries evaluate `NOW()` to an identical timestamp, which does not always happen. To resolve this, you can replace `NOW()` with an arbitrary time, such as `SELECT 1 AS "time"`, or any other valid UNIX timestamp.

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

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

Grafana lets 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](v12-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 **Grafana** 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="v12-panels-xform"></a>

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

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="v12-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="v12-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="v12-panels-xform-add"></a>

The following steps guide you in adding a transformation to data. This documentation does not include steps for each type of transformation.

**To add a transformation to a panel**

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

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

1. From the actions menu choose **Edit**.

1. Select the **Transform** tab.

1. Select 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="v12-panels-xform-debug"></a>

To see the input and the output result sets of the transformation, choose the debug (bug) icon on the right side of the transformation row. This will display the input data, and the result of the transformation as output.

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

## Disable a transformation
<a name="v12-panels-xform-disable"></a>

You can disable or hide a transformation by choosing the show (eye) icon on the top right of the transformation row. This disables the applied actions of that specific transformation and can help to identify issues when you change several transformations one after another.

## Filter a transformation
<a name="v12-panels-xform-filter"></a>

If your transformation uses more than one query, you can filter these, and apply the selected transformation to only one of the queries. To do this, choose the filter icon on the top right of the transformation row. This opens a dropdown with a list of queries used on the panel. From here, you can select the query you want to transform.

You can also filter by annotations (which includes exemplars) to apply transformations to them. When you do so, the list of fields changes to reflect those in the annotation or exemplar tooltip.

The filter icon is always displayed if your panel has more than one query or source of data (that is panel or annotation data), but it may not work if previous transformations for merging the queries' outputs are applied. This is because one transformation takes the output of the previous one.

## Delete a transformation
<a name="v12-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. Select the **Transform** tab.

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

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

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

You can perform the following transformations on your data.

## Add field from calculation
<a name="v12-panels-xform-funcs-add"></a>

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 operation** – Apply basic binary operations (for example, sum or multiply) on values in a single row from two selected fields.
  + **Unary operation** – Apply basic unary operations on values in a single row from a selected field. The available operations are:
    + **Absolute value (abs)** – Returns the absolute value of a given expression. It represents the distance from zero as a positive number.
    + **Natural exponential (exp)** – Returns *e* raised to the power of a given expression.
    + **Natural logarithm (ln)** – Returns the natural logarithm of a given expression.
    + **Floor (floor)** – Returns the largest integer less than or equal to a given expression.
    + **Ceiling (ceil)** – returns the smallest integer greater than or equal to a given expression.
  + **Cumulative functions** – Apply functions on teh current row and all preceding rows.
    + **Total** – Calculates the cumulative total up to and including the current row.
    + **Mean** – Calculates the mean up to and including the current row.
  + **Window functions** – Apply window functions. The window can either be *trailing* or *centered*. With a trailing window the current row will be the last row in the window. With a centered window, the window will be centered on the current row. For even windows sizes, the window will be centered between the current row and the previous row.
    + **Mean** – Calculates the moving mean or running average.
    + **** – Calculates the moving standard deviation.
    + **Variance** – Calculate the moving variance.
  + **Row index** – Insert a field with the row index.
+ **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. Select 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](v12-panels-calculation-types.md).
+ **Operation** – If you select **Binary operation** or **Unary operation** 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.
+ **As percentile** – If you select **Row index** mode, then the **As percentile** switch appears. This switch allows you to transform the row index as a percentage of the total number of rows.
+ **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.

**Note**  
**Cumulative functions** and **Window functions** are current in public preview. Grafana Labs offers limited support, and breaking changes might occur prior to the feature being made generally available.

## Concatenate fields
<a name="v12-panels-xform-funcs-concat"></a>

**Concatenate fields**

Use this transformation to combines all fields from all frames into one result.

For example, if you have separate queries retrieving temperature and uptime data (query A) and air quality index and error information (query b), applying the concatenate transformation yields a consolidated data frame with all relevant information in one view.

Consider these two following.

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

This transformation simplifies the process of merging data from different sources, providing a comprehensive view for analysis and visualization.

## Config from query results
<a name="v12-panels-xform-funcs-config"></a>

**Config from query results**

Use this transformation to select one query and extract standard options like **Min**, **Max**, **Unit** and **Thresholds** and apply them to other query results. This enables dynamic visualization configuration, based on the data returned by a specific query.

**Options**
+ **Config query** – Select the query that returns the data you want to use as configuration.
+ **Apply to** – Select the fields or series to which the configuration should be applied.
+ **Apply to options** – Specify a field type or use a field name regex, depending on your selection in **Apply to**.

**Field mapping table**

Below the configuration options, you'll find the field mapping table. This table lists all fields found in the data returned by the config query, along with the **Use as** and **Select** options. It provides control over mapping fields to config properties, and for multiple rows, it allows you to choose which value to select.

The following example shows an input query and a query used as field configuration.

*Input query*


| Time | Value | 
| --- | --- | 
| 1626178119127 | 10 | 
| 1626178119129 | 30 | 

*Config query*


| Time | Value | 
| --- | --- | 
| 1626178119127 | 100 | 
| 1626178119129 | 100 | 

*Output query (same as input, but now with config on the value field)*


| Time | Value (config: Max=100) | 
| --- | --- | 
| 1626178119127 | 10 | 
| 1626178119129 | 30 | 

Each field now has a maximum configuration option set. Options such as **Min**, **Max**, **Unit**, and **Thresholds** are part of teh field configuration. If set, they are used by the visualization instead of any options manually configured in the panel editor options pane.

**Value mappings**

You can also transform a query result into value mappings. With this option, every row in the configuration query result defines a single value mapping row. See the following example.

*Config query result*


| Value | Text | Color | 
| --- | --- | --- | 
| L | Low | blue | 
| M | Medium | green | 
| H | High | red | 

*In the field mapping, specify:*


| Field | Use as | Select | 
| --- | --- | --- | 
| Value | Value mappings / Value | All values | 
| Text | Value mappings / Text | All values | 
| Color | Value mappings / Color | All values | 

Grafana builds value mappings from your query result and applies them to the real data query results. You should see values being mapped and colored according to the config query results.

## Convert field type
<a name="v12-panels-xform-funcs-convert"></a>

Use this transformation to modify the field type of the specified field.

This transformation has the following options:
+ **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.
  + **Enum** – will make the values enums.
    + Will show a table to manage the enums.
  + **Other** – attempts to parse the values as json.

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


| Time | Mark | Value | 
| --- | --- | --- | 
| 2017-07-01 | above | 25 | 
| 2018-08-02 | below | 22 | 
| 2019-09-02 | below | 29 | 
| 2020-10-04 | above | 22 | 

The result:


| Time | Mark | Value | 
| --- | --- | --- | 
| 2017-01-01 00:00:00 | above | 25 | 
| 2018-01-01 00:00:00 | below | 22 | 
| 2019-01-01 00:00:00 | below | 29 | 
| 2020-01-01 00:00:00 | above | 22 | 

This transformation allows you to flexibly adapt your data types, ensuring compatibility and consistency in your visualizations.

## Extract Fields
<a name="v12-panels-xform-funcs-extract"></a>

Use this transformation to select a source of data and extract content from it in different formats. This transformation has the following fields:
+ **Source** – Select the field for the source of data.
+ **Format** – Choose one of the following:
  + **JSON** – Parse JSON content from the source.
  + **Key\$1value pairs** – Parse content in the format `a=b` or `c:d` from the source.
  + **Auto** – Discover fields automatically.
+ **Replace All Fields** – (Optional) Select this option to hide all other fields and display only your calculated field in the visualization.
+ **Keep Time** - (Optional) Available only if **Replace All Fields** is true. Keeps the time field in the output.

Consider the following dataset:

**Dataset Example**


| Timestamp | json\$1data | 
| --- | --- | 
| 1636678740000000000 | \$1"value": 1\$1 | 
| 1636678680000000000 | \$1"value": 5\$1 | 
| 1636678620000000000 | \$1"value": 12\$1 | 

You could prepare the data to be used by a [Time series panel](v12-panels-time-series.md) with this configuration:
+ Source: json\$1data
+ Format: JSON
  + Field: value
  + Alias: my\$1value
+ Replace all fields: true
+ Keep time: true

This will generate the following output:

**Transformed Data**


| Timestamp | my\$1value | 
| --- | --- | 
| 1636678740000000000 | 1 | 
| 1636678680000000000 | 5 | 
| 1636678620000000000 | 12 | 

With this transformation, you can extract and format data in various ways. You can customize the extraction format based on your specific data needs.

## Lookup fields from resource
<a name="v12-panels-xform-funcs-lookup"></a>

Use this transformation to enrich a field value by looking up additional fields from an external source.

This transformation has the following fields:
+ **Field** – Select a text field from your dataset.
+ **Lookup** – Choose from **Countries**, **USA States**, and **Airports**.

**Note**  
This transformation only supports spatial data.

For example, if you have this data:

**Dataset Example**


| Location | Values | 
| --- | --- | 
| AL | 0 | 
| AK | 10 | 
| Arizona | 5 | 
| Arkansas | 1 | 
| Somewhere | 5 | 

With this configuration:
+ Field: location
+ Lookup: USA States

You’ll get the following output:

**Transformed Data**


| Location | ID | Name | Lng | Lat | Values | 
| --- | --- | --- | --- | --- | --- | 
| AL | AL | Alabama | -80.891064 | 12.448457 | 0 | 
| AK | AK | Arkansas | -100.891064 | 24.448457 | 10 | 
| Arizona |  |  |  |  | 5 | 
| Arkansas |  |  |  |  | 1 | 
| Somewhere |  |  |  |  | 5 | 

This transformation lets you augment your data by fetching additional information from external sources, providing a more comprehensive dataset for analysis and visualization.

## Filter data by query refId
<a name="v12-panels-xform-funcs-queryrefid"></a>

Use this transformation to hide one or more queries in panels that have multiple queries.

Grafana displays the query identification letters in dark gray text. Choose 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 values
<a name="v12-panels-xform-funcs-values"></a>

Use this transformation to selectively filter data points directly within your visualization. This transformation provides options to include or exclude data based on one or more conditions applied to a selected field.

This transformation is very 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.

Additional 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 dataset:


| Time | Temperature | Altitude | 
| --- | --- | --- | 
| 2020-07-07 11:34:23 | 32 | 101 | 
| 2020-07-07 11:34:22 | 28 | 125 | 
| 2020-07-07 11:34:21 | 26 | 110 | 
| 2020-07-07 11:34:20 | 23 | 98 | 
| 2020-07-07 10:32:24 | 31 | 95 | 
| 2020-07-07 10:31:22 | 20 | 85 | 
| 2020-07-07 09:30:57 | 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:

**Transformed Data**


| Time | Temperature | Altitude | 
| --- | --- | --- | 
| 2020-07-07 11:34:22 | 28 | 125 | 
| 2020-07-07 11:34:21 | 26 | 110 | 
| 2020-07-07 11:34:20 | 23 | 98 | 
| 2020-07-07 10:31:22 | 20 | 85 | 
| 2020-07-07 09:30:57 | 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°C *AND* an altitude higher than 100. If we wanted to include the rows that have a temperature lower than 30°C *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.

This versatile data filtering transformation lets you to selectively include or exclude data points based on specific conditions. Customize the criteria to tailor your data presentation to meet your unique analytical needs.

## Filter fields by name
<a name="v12-panels-xform-funcs-name"></a>

Use this transformation to remove parts of your query results. There are three ways to filter field names:
+ Enter a regular expression.
+ Manually select included fields.
+ Use a dashboard variable.

*Use a regular expression*

When you filter using a regular expression, field names that match the regular expression are included. For example, using the regular expression `'prod.*'` would return only the fields that start with `prod`

The regular expression can include an interpolated dashboard variable using the `${variableName}` syntax.

*Manually select included fields*

Select or deselect field names to remove them from the result. If a regular expression is also included, fields that are matched by the expression are included, even if they're unchecked.

*Use a dashboard variable*

Select **From variable** to let you select a dashboard variable that's used to include fields. By setting up a dashboard variable with multiple choices, the same fields can be displayed across multiple visualizations.

This transformation provides flexibility in tailoring your query results to focus on the specific fields you need for effective analysis and visualization.

## Format string
<a name="v12-panels-xform-funcs-string"></a>

Use this transformation to customize the output of a string field. This transformation has the following fields:
+ **Upper case** – Formats the entire string in uppercase characters.
+ **Lower case** – Formats the entire string in lowercase characters.
+ **Sentence case** – Formats the first character of the string in uppercase.
+ **Title case** – Formats the first character of each word in the string in uppercase.
+ **Pascal case** – Formats the first character of each word in the string in uppercase and doesn’t include spaces between words.
+ **Camel case** – Formats the first character of each word in the string in uppercase, except the first word, and doesn’t include spaces between words.
+ **Snake case** – Formats all characters in the string in lowercase and uses underscores instead of spaces between words.
+ **Kebab case** – Formats all characters in the string in lowercase and uses dashes instead of spaces between words.
+ **Trim** – Removes all leading and trailing spaces from the string.
+ **Substring** – Returns a substring of the string, using the specified start and end positions.

This transformation provides a convenient way to standardize and tailor the presentation of string data for better visualization and analysis.

**Note**  
This transformation is currently in public preview. Grafana Labs offers limited support, and breaking changes might occur prior to the feature being made generally available.

## Format time
<a name="v12-panels-xform-funcs-time"></a>

Use this transformation to customize the output of a time field. Output can be formatted using [Moment.js format strings](https://momentjs.com/docs/#/displaying/). For example, if you want to display only the year of a time field, the format string 'YYYY' can be used to show the calendar year (for example, 1999 or 2012).

**Before Transformation:**


| Timestamp | Event | 
| --- | --- | 
| 1636678740000000000 | System Start | 
| 1636678680000000000 | User Login | 
| 1636678620000000000 | Data Updated | 

**After applying 'YYYY-MM-DD HH:mm:ss':**


| Timestamp | Event | 
| --- | --- | 
| 2021-11-12 14:25:40 | System Start | 
| 2021-11-12 14:24:40 | User Login | 
| 2021-11-12 14:23:40 | Data Updated | 

This transformation lets you tailor the time representation in your visualizations, providing flexibility and precision in displaying temporal data.

**Note**  
This transformation is available in workspaces compatbile with Grafana v12 as an alpha feature.

## Group by
<a name="v12-panels-xform-funcs-group"></a>

This transformation groups the data by a specified field (column) value and processes calculations on each group. Select 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.

## Grouping to matrix
<a name="v12-panels-xform-funcs-groupmatrix"></a>

Use this transformation to combine three fields—which are used as input for the **Column**, **Row**, and **Cell value** fields from the query output—and generate a matrix. The matrix is calculated as follows:

**Original data**


| Server ID | CPU Temperature | Server Status | 
| --- | --- | --- | 
| server 1 | 82 | OK | 
| server 2 | 88.6 | OK | 
| server 3 | 59.6 | Shutdown | 

We can generate a matrix using the values of `Server Status` as column names, the `Server ID` values as row names, and the `CPU Temperature` as content of each cell. The content of each cell will appear for the existing column (`Server Status`) and row combination (`Server ID`). For the rest of the cells, you can select which value to display between: **Null**, **True**, **False**, or **Empty**.

**Output**


| Server IDServer Status | OK | Shutdown | 
| --- | --- | --- | 
| server 1 | 82 |  | 
| server 2 | 88.6 |  | 
| server 3 |  | 59.6 | 

Use this transformation to construct a matrix by specifying fields from your query results. The matrix output reflects the relationships between the unique values in these fields. This helps you present complex relationships in a clear and structured matrix format.

## Group to nested table
<a name="v12-panels-xform-funcs-grouptable"></a>

Use this transformation to group the data by a specified field (column) value and process calculation on each group. Records are generated that share the same grouped field value, to be displayed in a nested table.

To calculate a statistic for a field, select the box next to the field and choose the **Calculate** option. This will add another selection box with statistics to be selected.

The following table shows sample 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 has two steps. First, specify one or more fields by which to group the data. This groups all the same values of those fields together, as if you sorted them For instance, if you group by the `Server ID` field, Grafana groups the data this way:


| Server ID | Data | 
| --- | --- | 
| Time | CPU Temperature | Server Status | 
| --- | --- | --- | 
| Time | CPU Temperature | Server Status | 
| --- | --- | --- | 
| Time | CPU Temperature | Server Status | 
| --- | --- | --- | 
| server 1 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/grafana/latest/userguide/v12-panels-xform-functions.html) | 
| server 2 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/grafana/latest/userguide/v12-panels-xform-functions.html) | 
| server 3 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/grafana/latest/userguide/v12-panels-xform-functions.html) | 
| 7/7/2020 11:34:20 AM | 80 | Shutdown | 
| 7/7/2020 9:28:06 AM | 80 | OK | 
| 7/7/2020 9:23:07 AM | 86 | OK | 
| 7/7/2020 10:32:20 AM | 90 | Overload | 
| 7/7/2020 9:30:05 AM | 88 | OK | 
| 7/7/2020 9:25:05 AM | 88 | OK | 
| 7/7/2020 11:34:20 AM | 62 | OK | 
| 7/7/2020 10:31:22 AM | 55 | OK | 
| 7/7/2020 9:30:57 AM | 62 | Rebooting | 

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


| Server ID | CPU Temperatute (mean) |  | 
| --- | --- | --- | 
| Time | Server Status | 
| --- | --- | 
| Time | Server Status | 
| --- | --- | 
| Time | Server Status | 
| --- | --- | 
| server 1 | 82 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/grafana/latest/userguide/v12-panels-xform-functions.html) | 
| server 2 | 88.6 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/grafana/latest/userguide/v12-panels-xform-functions.html) | 
| server 3 | 59.6 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/grafana/latest/userguide/v12-panels-xform-functions.html) | 
| 7/7/2020 11:34:20 AM | Shutdown | 
| 7/7/2020 9:28:06 AM | OK | 
| 7/7/2020 9:23:07 AM | OK | 
| 7/7/2020 10:32:20 AM | Overload | 
| 7/7/2020 9:30:05 AM | OK | 
| 7/7/2020 9:25:05 AM | OK | 
| 7/7/2020 11:34:20 AM | OK | 
| 7/7/2020 10:31:22 AM | OK | 
| 7/7/2020 9:30:57 AM | Rebooting | 

## Create heatmap
<a name="v12-panels-xform-funcs-heatmap"></a>

Use this transformation to prepare histogram data for visualizing trends over time. Similar to the heatmap visualization, this transformation converts histogram metrics into temporal buckets.

**X Bucket**

This setting determines how the x-axis is split into buckets.
+ **Size** – Specify a time interval in the input field. For example, a time range of `1h` creates cells one hour wide on the x-axis.
+ **Count** – For non-time-related series, use this option to define the number of elements in a bucket.

**Y Bucket**

This setting determines how the y-axis is split into buckets.
+ **Linear**
+ **Logarithmic** – Choose between log base 2 or log base 10.
+ **Symlog** – Uses a symmetrical logarithmic scale. Choose between log base 2 or log base 10, allowing for negative values.

Assume you have the following dataset:


| Timestamp | Value | 
| --- | --- | 
| 2023-01-01 12:00:00 | 5 | 
| 2023-01-01 12:15:00 | 10 | 
| 2023-01-01 12:30:00 | 15 | 
| 2023-01-01 12:45:00 | 8 | 
+ With X Bucket set to `Size: 15m` and Y Bucket as `Linear`, the histogram organizes values into time intervals of 15 minutes on the x-axis and linearly on the y-axis.
+ For X Bucket as `Count: 2` and Y Bucket as `Logarithmic (base 10)`, the histogram groups values into buckets of two on the x-axis and use a logarithmic scale on the y-axis.

## Histogram
<a name="v12-panels-xform-funcs-histogram"></a>

Use this transformation to generate a histogram based on input data, allowing you to visualize the distribution of values.
+ **Bucket size** – The range between the lowest and highest items in a bucket (xMin to xMax).
+ **Bucket offset** – The offset for non-zero-based buckets.
+ **Combine series** – Create a unified histogram using all available series.

**Original data**

Series 1:


| A | B | C | 
| --- | --- | --- | 
| 1 | 3 | 5 | 
| 2 | 4 | 6 | 
| 3 | 5 | 7 | 
| 4 | 6 | 8 | 
| 5 | 7 | 9 | 

Series 2:


| C | 
| --- | 
| 5 | 
| 6 | 
| 7 | 
| 8 | 
| 9 | 

**Output**


| xMin | xMax | A | B | C | C | 
| --- | --- | --- | --- | --- | --- | 
| 1 | 2 | 1 | 0 | 0 | 0 | 
| 2 | 3 | 1 | 0 | 0 | 0 | 
| 3 | 4 | 1 | 1 | 0 | 0 | 
| 4 | 5 | 1 | 1 | 0 | 0 | 
| 5 | 6 | 1 | 1 | 1 | 1 | 
| 6 | 7 | 0 | 1 | 1 | 1 | 
| 7 | 8 | 0 | 1 | 1 | 1 | 
| 8 | 9 | 0 | 0 | 1 | 1 | 
| 9 | 10 | 0 | 0 | 1 | 1 | 

Visualize the distribution of values using the generated histogram, providing insights into the data’s spread and density.

## Join by field
<a name="v12-panels-xform-funcs-joinfield"></a>

Use this transformation to merge multiple results into a single table, enabling the consolidation of data from different queries.

The 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 applying 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 | 

## Join by labels
<a name="v12-panels-xform-funcs-joinlabel"></a>

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 **Label** field.
+ **Join** – Select the label to join by between the labels available or common across all time series.
+ **Value** – The name for the output result.

**Example**

Input 1: `series1{what='Temp', cluster='A', job='J1'}`


| Time | Value | 
| --- | --- | 
| 1 | 10 | 
| 2 | 200 | 

Input 2: `series2{what='Temp', cluster='B', job='J1'}`


| Time | Value | 
| --- | --- | 
| 1 | 10 | 
| 2 | 200 | 

Input 3: `series3{what='Speed', cluster='B', job='J1'}`


| Time | Value | 
| --- | --- | 
| 22 | 22 | 
| 28 | 77 | 

Config:

```
value: 'what'
```

Output:


| cluster | job | Temp | Speed | 
| --- | --- | --- | --- | 
| A | J1 | 10 |  | 
| A | J1 | 200 |  | 
| B | J1 | 10 | 22 | 
| B | J1 | 200 | 77 | 

Combine and organize time series data effectively with this transformation for comprehensive insights.

## Labels to fields
<a name="v12-panels-xform-funcs-labelstofields"></a>

Use this transformation to convert time series results with labels or tags into a table, including each label's keys and values in the result. Display labels as either columns or row values for enhanced data visualization.

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.

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 | 

## Limit
<a name="v12-panels-xform-funcs-limit"></a>

Use this transformation to restrict the number of rows displayed, providing a more focused view of your data. This is particularly useful when dealing with large datasets.

The following is an example illustrating the impact of the **Limit** transformation on a response from a 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 | 

This transformation helps you tailor the visual presentation of your data to focus on the most relevant data.

## Merge series/tables
<a name="v12-panels-xform-funcs-merge"></a>

Use this transformation to combine the result from multiple queries into a single result, which is particularly useful when using the table panel visualization. The transformation merges values into the same row if shared fields contain the same data.

Here's an exampleillustration the impact of the **Merge series/tables** transformation on two queries returning table data:

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

This transformation combines values from Query A and Query B into a unified table, enhancingthe presentation for better insights.

## Organize fields by name
<a name="v12-panels-xform-funcs-organize"></a>

Use this transformation to rename, reorder, or hide fields returned by a single query in your panel. 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.

**Transforming fields**

Grafana displays a list of fields returned by the query. You can:
+ **Change field order** – Drag a field to a new location in the list.
+ **Hide or show a field** – Use the eye icon next to the field name to toggle the visibility of a field.
+ **Rename fields** – Type a new name into the **Rename** box.

**Example**

Given this initial query result:


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

You could apply a rename field override to create:


| Time | Sensor | Reading | 
| --- | --- | --- | 
| 2020-07-07 11:34:20 | Temperature | 25 | 
| 2020-07-07 11:34:20 | Humidity | 22 | 
| 2020-07-07 10:32:20 | Humidity | 29 | 

This transformation lets you tailor the display of query results, ensuring a clear and insightful representation of your data in Grafana.

## Partition by values
<a name="v12-panels-xform-funcs-partition"></a>

Use this transformation to streamline the process of graphing multiple series without the need for multiple queries with different `WHERE` clauses.

**Note**  
This function is available in workspaces compatible with Grafana version 9 and above.

This is particularly useful when using a metrics SQL table, as in this example:


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

With the *Partition by values* transformer, you can 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 | 

This transformation simplifies the process and enhances the flexibility of visualizing multiple series within the same time series visualization.

## Prepare times series
<a name="v12-panels-xform-funcs-preparetimeseries"></a>

Use this transformation to address issues when a data source returns time series data in a format that isn’t compatible with the desired visualization. This transformation allows you to convert time series data from between wide and long formats.

**Multi-frame time series**

Use this option to transform the time series data frame from the wide format to the long format. This is particularly helpful when your data source delivers time series information in a format that needs to be reshaped for optimal compatibility with your visualization.

*Example*

This input:


| Timestamp | Value1 | Value2 | 
| --- | --- | --- | 
| 2023-01-01 00:00:00 | 10 | 20 | 
| 2023-01-01 01:00:00 | 15 | 25 | 

Could be transformed to:


| Timestamp | Variable | Value | 
| --- | --- | --- | 
| 2023-01-01 00:00:00 | Value1 | 10 | 
| 2023-01-01 00:00:00 | Value2 | 20 | 
| 2023-01-01 01:00:00 | Value1 | 15 | 
| 2023-01-01 01:00:00 | Value2 | 25 | 

**Wide time series**

Use this option to transform the time series data frame from the long format to the wide format. This is particularly helpful when your data source delivers time series data in a long format and your visualization requires a wide format.

*Example*

This input:


| Timestamp | Variable | Value | 
| --- | --- | --- | 
| 2023-01-01 00:00:00 | Value1 | 10 | 
| 2023-01-01 00:00:00 | Value2 | 20 | 
| 2023-01-01 01:00:00 | Value1 | 15 | 
| 2023-01-01 01:00:00 | Value2 | 25 | 

Could be transformed to:


| Timestamp | Value1 | Value2 | 
| --- | --- | --- | 
| 2023-01-01 00:00:00 | 10 | 20 | 
| 2023-01-01 01:00:00 | 15 | 25 | 

## Reduce
<a name="v12-panels-xform-funcs-reduce"></a>

Use this transformation applies a calculation to each field in the data frame and return a single value. This transformation is particularly useful for consolidating mulitiple time series data into a more compact, summarized format. Time fields are removed when applying this transformation.

Consider the input:

Query A:


| Time | Temp | Uptime | 
| --- | --- | --- | 
| 2020-07-07 11:34:20 | 12.3 | 256122 | 
| 2020-07-07 11:24:20 | 15.4 | 1230233 | 

Query B:


| Time | AQI | Errors | 
| --- | --- | --- | 
| 2020-07-07 11:34:20 | 6.5 | 15 | 
| 2020-07-07 11:24:20 | 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 wouldbe:


| 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
<a name="v12-panels-xform-funcs-rename"></a>

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

This transformation lets you tailor your data to meet your visualization needs, making your dashboards more informative and user-friendly.

## Rows to fields
<a name="v12-panels-xform-funcs-row"></a>

Use this transformation to convert rows into separate fields. This can be useful because 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 configuration query. This table gives you control over what field should be mapped to each configuration property (the **Use as** 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) | 
| --- | --- | 
| 100 | 200 | 

The extra labels can now be used in the field display name to 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.

This transformation enables the conversion of rows into individual fields, facilitates dynamic field configuration, and maps additional fields to labels.

## Series to rows
<a name="v12-panels-xform-funcs-series"></a>

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 | 
| --- | --- | 
| 2020-07-07 11:34:20 | 25 | 
| 2020-07-07 10:31:22 | 22 | 
| 2020-07-07 09:30:05 | 19 | 

*Query B:*


| Time | Humidity | 
| --- | --- | 
| 2020-07-07 11:34:20 | 24 | 
| 2020-07-07 10:32:20 | 29 | 
| 2020-07-07 09:30:57 | 33 | 

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


| Time | Metric | Value | 
| --- | --- | --- | 
| 2020-07-07 11:34:20 | Temperature | 25 | 
| 2020-07-07 11:34:20 | Humidity | 22 | 
| 2020-07-07 10:32:20 | Humidity | 29 | 
| 2020-07-07 10:31:22 | Temperature | 22 | 
| 2020-07-07 09:30:57 | Humidity | 33 | 
| 2020-07-07 09:30:05 | Temperature | 19 | 

This transformation facilitates the consolidation of results from multiple time series queries, providing a streamlined and unified dataset for efficient analysis and visualization in a tabular format.

## Sort by
<a name="v12-panels-xform-funcs-sort"></a>

Use this transformation to sort each frame within a query result based on a specified field, making your data easier to understand and analyze. By configuring the desired field for sorting, you can control the order in which the data is presented in the table or visualization.

Use the **Reverse** switch to inversely order the values within the specified field. This functionality is particularly useful when you want to quickly toggle between ascending and descending order to suit your analytical needs.

For example, in a scenario where time-series data is retrieved from a data source, the **Sort by** transformation can be applied to arrange the data frames based on the timestamp, either in ascending or descending order, depending on the analytical requirements. This capability ensures that you can easily navigate and interpret time-series data, gaining valuable insights from the organized and visually coherent presentation.

## Spatial
<a name="v12-panels-xform-funcs-spatial"></a>

Use this transformation to apply spatial operations to query results.
+ **Action** – Select an action:
  + **Prepare spatial field** – Set a geometry field based on the results of other fields.
    + **Location mode** – Select a location mode (these options are shared by the **Calculate value** and **Transform** modes):
      + **Auto** – Automatically identify location data based on default field names.
      + **Coords** – Specify latitude and longitude fields.
      + **Geohash** – Specify a geohash field.
      + **Lookup** – Specify Gazetteer location fields.
  + **Calculate value** – Use the geometry to define a new field (heading/distance/area).
    + **Function** – Choose a mathematical operation to apply to the geometry:
      + **Heading** – Calculate the heading (direction) between two points.
      + **Area** – Calculate the area enclosed by a polygon defined by the geometry.
      + **Distance** – Calculate the distance between two points.
  + **Transform** – Apply spatial operations to the geometry.
    + **Operation** – Choose an operation to apply to the geometry:
      + **As line** – Create a single line feature with a vertex at each row.
      + **Line builder** – Create a line between two points.

This transformation allows you to manipulate and analyze geospatial data, enabling operations such as creating lines between points, calculating spatial properties, and more.

## Time series to table transform
<a name="v12-panels-xform-funcs-seriestotable"></a>

Use this transformation to convert time series results into a table, transforming a time series data frame into a **Trend** field. The **Trend** field can then be rendered using the [sparkline cell type](v12-panels-table.md#v12-panels-table-cell-type), generating an inline sparkline for each table row. If there are multiple time series queries, each will result in a separate table data frame. These can be joined using join or merge transforms to produce a single table with multiple sparklines per row.

For each generated **Trend** field value, a calculation function can be selected. The default is **Last non-null value**. This value is displayed next to the sparkline and used for sorting table rows.

## Regression analysis
<a name="v12-panels-xform-funcs-regression"></a>

Use this transformation to create a new data frame containing values predicted by a statistical model. This is useful for finding a trend in chaotic data. It works by fitting a mathematical function to the data, using either linear or polynomial regression. The data frame can then be used in a visualization to display a trendline.

There are two different models:
+  **Linear regression** – Fits a linear function to the data.
+  **Polynomial regression** – Fits a polynomial function to the data.

**Note**  
This transformation is currently in public preview. Grafana Labs offers limited support, and breaking changes might occur prior to the feature being made generally available.

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

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

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](v12-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.

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

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

The following table 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 values | Array with all values | 
| All unique values | Array with all unique values | 
| 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 | First value in a field | 
| First\$1 (not null) | First, not null value in a field (also excludes NaNs) | 
| Last | Last value in a field | 
| Last\$1 (not null) | Last, not null value in a field (also excludes NaNs) | 
| 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 | 

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

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

A Grafana panel is a visual representation of data that you can customize by defining a data source query, transforming and formatting data, and configuring visualization settings.

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
+ Configure repeating rows and panels

## Editing a panel
<a name="v12-panels-edit-a-panel"></a>

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

**To edit a panel**

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 in the top right corner.

1. Choose 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="v12-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 in a tooltip 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](v12-dash-variables.md) in the **Title** and **Description** field, but not [global variables](v12-dash-variable-add.md#v12-dash-variable-add-global).

## Viewing a panel JSON model
<a name="v12-panels-json-model"></a>

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

**To view a panel JSON model**

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. From the menu, select **Inspect > Panel JSON**.

1. In the **Select source** field, choose 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 data structure of the panel, including any transformations, field configurations, and override configurations that have been applied.

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

## Configuring repeating panels
<a name="v12-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. For more information about repeating panels, see [Creating dashboards](v12-dash-creating.md).

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

*Prequisites*
+ 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, choose **Panel options > Repeat options**.

1. Select a **direction**.
   + Choose **horizontal** to arrange panels side-by-side. Grafana adjusts the width of a repeated panel. 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="v12-panels-configure-standard-options"></a>

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

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

A complete list of field formatting options is included later in this topic.

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

**To configure standard options**

1. Open a dashboard. Hover over any part of the panel to display the actions menu at the top right corner of the dashboard.

1. From the actions menu, choose **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, select outside of the field option box you are editing or press **Enter**.

**Standard options definitions**

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**  
Grafana Labs is constantly working to add and expand options for all visualization, so all options might not be available for all visualizations.

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

Lets you choose what unit a field should use. Choose 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="v12-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 a custom unit that should go after the value.
+ **prefix:<prefix>** for a custom unit that should go before the value.
+ **time:<format>** For custom date time formats, type for example `time:YYYY-MM-DD`. See [format](https://momentjs.com/docs/#/displaying/) in the *Moment.js Documentation* for the format syntax and options.
+ **si:<base scale><unit characters>** for custom SI units. For example: `si: mF`. This 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="v12-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.

### Scale units
<a name="v12-panels-standard-options-scale-units"></a>

By default, Grafana automatically scales the unit based on the magnitude of the value. For example, if you have a value of 0.14 kW, Grafana will display it as 140 W. Another example is that 3000 kW will be displayed as three MW. If you want to disable this behavior, you can turn off the **Scale units** switch.

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

Lets you set the minimum value used in percentage threshold calculations. Leave blank to automatically calculate the minimum.

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

Lets you set the maximum value used in percentage threshold calculations. Leave blank to automatically calculate the maximum.

## Field min/max
<a name="v12-panels-standard-options-fieldminmax"></a>

By default the calculated min and max will be based on the minimum and maximum, in all series and fields. Turning field min/max on will calculate the min or max on each field individually, based on the minimum or maximum of that field.

## Decimals
<a name="v12-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="v12-panels-standard-options-displayname"></a>

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

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

Given a field with a name of `Temp`, and labels of `{"Loc"="PBI", "Sensor"="3"}`:


| 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="v12-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 scheme, 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 | 
| Shades of a color | Selects shades of 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 | 
| Classic palette (by series name) | Grafana will assign color based on the name of the series. Useful when the series names to be vsiualized depend on the available data. | 
| Green-Yellow-Red (by value) | Continuous color scheme | 
| Red-Yellow-Green (by value) | Continuous color scheme | 
| Blue-Yellow-Red (by value) | Continuous color scheme | 
| Yellow-Red (by value) | Continuous color scheme | 
| Blue-Purple (by value) | Continuous color scheme | 
| Yellow-Blue (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 red) | 
| Greens (by value) | Continuous color scheme (panel background color to green) | 
| Purple (by value) | Continuous color scheme (panel background color to purple) | 

## No value
<a name="v12-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 (-).

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

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

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

Legends are supported for the following visualizations:
+ [Bar chart](v12-panels-bar-chart.md)
+ [Candlestick](v12-panels-candlestick.md)
+ [Histogram](v12-panels-histogram.md)
+ [Pie chart](v12-panels-piechart.md)
+ [State timeline](v12-panels-state-timeline.md)
+ [Status history](v12-panels-status-history.md)
+ [Time series](v12-panels-time-series.md)
+ [Trend](v12-panels-trend.md)

[Geomaps](v12-panels-geomap.md) and [Heatmaps](v12-panels-heatmap.md) also have legends, but they only provide the choice to display or not display a legend, and don't support other legend options.

## Legend options
<a name="v12-panels-legend-options"></a>

You can find the following options under the **Legend** section in the panel edit pane.

**Note**  
Not all of the options listed apply to all visualizations with legends.

**Visibility**

Set whether the legend is displayed or not. Use the switch to toggle a legend on or off.

**Mode**

Set the format in which the legend is displayed. Choose from:
+ **List**
+ **Table**

When you format a legend as a table, other information about the legend, such as associated values or where it's located in the visualization, might be displayed as well.

**Placement**

Set where on the visualization a legend is displayed. Choose from:
+ **Bottom**
+ **Right**

**Width**

If you set the legend placement to **Right**, the **Width** option becomes available. Leave the field empty to allow Grafana to automatically set the legend width, or enter a vale in the field.

**Values**

You can add more context to a visualization by adding series data values or [calculations](v12-panels-calculation-types.md) to a legend. You can add as many values as you like. After you apply your changes, you can scroll the legend to see all values.

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

By default, Grafana sets the color of your series data, but you can change them through the panel legend.

**To change a series color**

1. Navigate to the panel you want to update.

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

1. Select a pre-set color in the **Colors** tab or set a custom color in the **Custom** tab, using the picker or RGB values.

1. Save the dashboard.

## Isolating series data in a visualization
<a name="v12-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 through the legend, which isolates the data you want to see. When you do this, Grafana automatically creates a new override in the **Override** tab.

**To isolate series data in a visualization**

1. Navigate to the panel you want to update.

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 back to an isolated series, press the **Ctrl** or **Command** key and select the label of the series you want to add.

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

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

## Sorting series
<a name="v12-panels-legend-sort"></a>

When you format a legend as a table and add values to it, you can sort the series in the table by those values.

**To sort series**

1. Navigate to the panel you want to update.

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

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

1. Scroll to the **Legend** section of the panel edit pane.

1. Under **Values**, select the value or calculation that you want to show.

   The legend now displays values.

1. Choose the calculation name header in the legend table to sort the values in the table in ascending or descending order.

**Note**  
This feature is only supported in these panels: bar chart, histogram, time series.

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

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

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 shows four servers, you can add a datalink to one or two of them. You can also link panels using data links.

The link itself is accessible in different ways depending on the visualization. For the time series visualization, for example, you choose a data point or line. For large area visualizations, like stat, gauge, or bar gauge, you can choose anywhere on the visualization to open the context menu.

If there is only one data link in the visualization, choosing anywhere on the visualization opens the link rather than the context menu.

**Supported visualizations**
+ Bar chart
+ Bar gauge
+ Candlestick
+ Canvas
+ Gauge
+ Geomap
+ Heatmap
+ Histogram
+ Pie chart
+ Stat
+ State timeline
+ Status history
+ Table
+ Time series
+ Trend

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

Variables in data links let you send people to a detailed dashboard with preserved data filters. For example, you could use variable to specify a label, time range, series, or variable selection.

To see a list of available variables, type `$` in the data link **URL** field.

You can also use template variables in your data links URLs, see [Variables](v12-dash-variables.md).

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

These variables allow you to include the current time range in the data link URL.
+ `__url_time_range` – current dashboard’s time range (i.e. `?from=now-6h&to=now`)
+ `$__from` – For more information, see [Global variables](v12-dash-variable-add.md#v12-dash-variable-add-global).
+ `$__to` – For more information, see [Global variables](v12-dash-variable-add.md#v12-dash-variable-add-global).

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

Series specific variables are available under `__series` namespace:
+ `__series.name` – series name to the URL

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

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

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

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

Using value-specific variable in data links can show different result depending on the set option of Tooltip mode.

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

To access values from other fields use:
+ `__data.fields[i]` – Value of field `i` (on the same row).
+ `__data.fields["NameOfField"]` – Value of field using name instead of index.
+ `__data.fields[i].labels.cluster` – Access the labels of another field.

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

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

`${var-myvar:queryparam}` – 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 `${__all_variables}`.

## Adding a data link
<a name="v12-panels-add-a-datalink"></a>

You can add data links to your panels.

1. Navigate to the panel to which you want to add the data link.

1. Hover over the panel to display the menu icon in the upper-right corner.

1. From the menu, choose **Edit** to open the panel editor.

1. In the **Panel edit** pane, scroll down to the **Data links** section and expand it.

1. Choose **Add link**.

1. In the dialog box that opens, enter a **Title**. This is a human-readable label for the link, which will be displayed in the UI.

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

   To add a data link variable, select the **URL** field and then enter `$` or press Ctrl\$1Space or Cmd\$1Space to see a list of available variables.

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

1. Choose **Save** to save changes and close the dialog box.

1. Save your changes to the dashboard.

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

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

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

Values mappings bypass the unit formatting set in the [Standard options](v12-panels-configure-standard-options.md) of the panel editor, like color or number of decimal places displayed. When value mappings are present in a panel, Grafana displays a summary of them in the **Value mappings** section of the panel editor.

**Supported visualizations**
+ Bar chart
+ Bar gauge
+ Candlestick
+ Canvas
+ Gauge
+ Geomap
+ Histogram
+ Pie chart
+ Stat
+ State timeline
+ Status history
+ Table
+ Time series
+ Trend

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

Grafana supports the following value mapping types:
+ **Value** – Maps specific values to a text and a color. For example, you can configure a value mapping so that all instances of the value `10` appear as `Perfection!` rather than the number. Use a **Value** mapping when you want to format a single value.
+ **Range** – Maps numerical ranges to text and a 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. Use **Range** mapping when you want to formate multiple continuous values.
+ **Regex** – Maps regular expressions to 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. Use the **Regex** mapping when you want to format the text and color of a regular expression value.
+ **Special** – Maps special values like `Null`, `NaN` (not a number), and Boolean values like `true` and `false` to a text and color. For example, you can configure a special value mapping so that `null` values appear as `N/A`. Use the **Special** mappiong when you want to format uncommon, Boolean, or empty value.

## Adding a value mapping
<a name="v12-panels-value-mappings-add"></a>

You can add value mappings to your panels.

**To add a value mapping**

1. Navigate to the panel you want to update.

1. Hover over any part of the panel to display a menu at the top right corner of the panel.

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

1. In the **Value mappings** section, choose **Add value mappings**.

1. Choose **Add a new mapping**, and then select one of the following:
   + **Value** – Enter a single value to match.
   + **Range** – Enter the beginning and ending values of a range to match.
   + **Regex** – Enter a regular expression pattern to match.
   + **Special** – Choose a special value to match.

1. (Optional) Enter display text.

1. (Optional) Set the color.

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

After you've added a mapping, the **Edit value mappings** button replaces the **Add value mappings** button. Choose the edit button to add or update mappings.

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

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

In dashboards, a threshold is a value or limit you set for a metric that's reflected visually when it's met or exceeded. Thresholds are one way you can conditionally style and color your visualizations based on query results.

You can use thresholds to:
+ Color grid lines or grid ares areas in a time-series visualization.
+ Color the background or value text in a stat visualization.
+ Define regions and region colors in a state timeline.
+ Color lines in a time-series visualization.
+ Color the gauge and threshold markers in a gauge.
+ Color markers in a geomap.
+ Color cell text or background in a table.

**Supported visualizations**
+ Bar chart
+ Bar gauge
+ Candlestick
+ Canvas
+ Gauge
+ Geomap
+ Histogram
+ Stat
+ State timeline
+ Status history
+ Table
+ Time series
+ Trend

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

On visualizations that support thresholds, Grafana has the following default threshold settings:
+ 80 = red
+ Base = green
+ Mode = Absolute
+ Show thresholds = Off (for some visualizations)

  For more information, see [Show thresholds](#v12-panels-thresholds-show).

## Thresholds options
<a name="v12-panels-thresholds-options"></a>

You can set the following options to further define how thresholds look.

### Thresholds value
<a name="v12-panels-thresholds-value"></a>

This number is the value that triggers the threshold. You can also set the color associated with the threshold in this field.

The **Base** value represents minus infinity. By default, it's set to the color green, which is generally the "good" color.

### Thresholds mode
<a name="v12-panels-thresholds-mode"></a>

There are two threshold modes:
+ **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.

### Show thresholds
<a name="v12-panels-thresholds-show"></a>

**Note**  
This option is only supported for the bar chart, candlestick, time series, and trend visualizations.

Set if and how thresholds are shown on the visualization with the following options.
+ **Off** – The thresholds are not shown.
+ **As lines** – The thresholds are shown as horizontal lines on the visualization.
+ **As lines (dashed)** – The thresholds are shown as dashed horizontal lines.
+ **As filled regions** – The thresholds are shown as horizontal regions.
+ **As filled regions and lines** – The thresholds are shown as horizontal regions separated by lines.
+ **As filled regions and lines (dashed)** – The thresholds are shown as horizontal regions separated by dashed lines.

## Adding a threshold
<a name="v12-panels-thresholds-add"></a>

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

**To add a threshold**

1. Navigate to the panel you want to update.

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

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

1. Scroll to the **Thresholds** section, or enter `Thresholds` in the search bar at the top of the panel edit pane.

1. Choose **\$1 Add threshold**.

1. Enter a new threshold value, or use the up and down arrows at the right side of the field to increase or decrease the value incrementally.

1. Click the colored circle to the left of the threshold value to open the color picker, where you can update the threshold color.

1. Under **Thresholds mode**, select either **Absolute** or **Percentage**.

1. Under **Show thresholds**, set how the threshold is displayed, or turn it off.

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

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

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

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="v12-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="v12-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% | 

## Adding a field override
<a name="v12-panels-overrides-add-a-field"></a>

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

**To add a field override**

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

1. In the panel options side pane, choose **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. This selects fields to override, but doesn't rename the fields; to do this, use the [Rename by regex transformation](v12-panels-xform-functions.md).
   + **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. Choose **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 choosing **Add override property**, or you can choose **Add override** and select a different field to add overrides to.

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

## Deleting a field override
<a name="v12-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.

**To delete a field override**

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. Choose the override you want to delete and then choose the associated trash icon.

## Viewing field overrides
<a name="v12-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.

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

## Editing a field override
<a name="v12-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.

**To edit a field override**

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 choosing the **X** next to the property.
   + Add an override properties by choosing **Add override property**.

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

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

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

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

**Note**  
If you are unsure which visualization to pick, Grafana can provide visualization suggestions based on the panel query. When you select a visualization, Grafana will show a preview with that visualization applied.
+ Graphs & charts
  + [Time series](v12-panels-time-series.md) is the default and main Graph visualization.
  + [State timeline](v12-panels-state-timeline.md) for state changes over time.
  + [Status history](v12-panels-status-history.md) for periodic state over time.
  + [Bar chart](v12-panels-bar-chart.md) shows any categorical data.
  + [Histogram](v12-panels-histogram.md) calculates and shows value distribution in a bar chart.
  + [Heatmap](v12-panels-heatmap.md) visualizes data in two dimensions, used typically for the magnitude of a phenomenon.
  + [Pie chart](v12-panels-piechart.md) is typically used where proportionality is important.
  + [Candlestick](v12-panels-candlestick.md) is typically for financial data where the focus is price/data movement.
  + [Gauge](v12-panels-gauge.md) is the traditional rounded visual showing how far a single metric is from a threshold.
  + [Trend](v12-panels-trend.md) for datasets that have a sequential, numeric x that is not time.
  + [XY Chart](v12-panels-xychart.md) provides a way to visualize arbitrary x and y values in a graph.
+ Stats & numbers
  + [Stat](v12-panels-stat.md) for big stats and optional sparkline.
  + [Bar gauge](v12-panels-bar-gauge.md) is a horizontal or vertical bar gauge.
+ Misc
  + [Table](v12-panels-table.md) is the main and only table visualization.
  + [Logs](v12-panels-logs.md) is the main visualization for logs.
  + [Node graph](v12-panels-node-graph.md) for directed graphs or networks.
  + [Traces](v12-panels-traces.md) is the main visualization for traces.
  + [Flame graph](v12-panels-flamegraph.md) is the main visualization for profiling.
  + [Geomap](v12-panels-geomap.md) helps you visualize geospatial data.
  + [Datagrid](v12-panels-datagrid.md) allows you to create and manipulate data, and acts as a data source for other panels.
+ Widgets
  + [Dashboard list](v12-panels-dashboard-list.md) can list dashboards.
  + [Alert list](v12-panels-alert-list.md) can list alerts.
  + [Text](v12-panels-text.md) can show markdown and html.
  + [News](v12-panels-news.md) can show RSS feeds.

## Get more
<a name="v12-panels-getmore"></a>

You can add more visualization types by installing panel plugins from the [Find plugins with the plugin catalog](grafana-plugins.md#plugin-catalog).

## Examples
<a name="v12-panels-examples"></a>

In the following sections you can find visualizations examples.

## Graphs
<a name="v12-panels-ex-graphs"></a>

For time based line, area, and bar charts, we recommend the default [time series](v12-panels-time-series.md) visualization.

![\[An image showing examples of times series visualizations in Grafana.\]](http://docs.aws.amazon.com/grafana/latest/userguide/images/viz/time_series_example.png)


For categorical data, use a [bar chart](v12-panels-bar-chart.md).

![\[An image showing examples of bar chart visualizations in Grafana.\]](http://docs.aws.amazon.com/grafana/latest/userguide/images/viz/barchart_example.png)


## Big numbers & stats
<a name="v12-panels-ex-numbers"></a>

A [stat](v12-panels-stat.md) visualization shows one large stat value with an optional graph sparkline. You can control the background or value color using thresholds or color scales.

![\[An image showing an example of a stat visualization in Grafana.\]](http://docs.aws.amazon.com/grafana/latest/userguide/images/viz/stat_panel_example.png)


## Gauge
<a name="v12-panels-ex-gauge"></a>

If you want to present a value as it relates to a min and max value, you have two options. First a standard radial [gauge](v12-panels-gauge.md):

![\[An image showing an example of a gauge visualization in Grafana.\]](http://docs.aws.amazon.com/grafana/latest/userguide/images/viz/gauge_example.png)


Secondly, Grafana also has a horizontal or vertical [bar gauge](v12-panels-bar-gauge.md) with three distinct display modes.

![\[An image showing an example of a gauge visualization in Grafana.\]](http://docs.aws.amazon.com/grafana/latest/userguide/images/viz/bar_gauge_example.png)


## Table
<a name="v12-panels-ex-table"></a>

To show data in a table layout, use a [table](v12-panels-table.md) visualization.

![\[An image showing an example of a table visualization in Grafana.\]](http://docs.aws.amazon.com/grafana/latest/userguide/images/viz/table_example.png)


## Pie chart
<a name="v12-panels-ex-piechart"></a>

To display reduced series, or values in a series, from one or more queries, as they relate to each other, use a [pie chart](v12-panels-piechart.md) visualization.

![\[An image showing an example of a pie chart visualization in Grafana.\]](http://docs.aws.amazon.com/grafana/latest/userguide/images/viz/pie_chart_example.png)


## Heatmaps
<a name="v12-panels-ex-heatmaps"></a>

To show value distribution over time, use a [heatmap](v12-panels-heatmap.md) visualization.

![\[An image showing an example of a heatmap visualization in Grafana.\]](http://docs.aws.amazon.com/grafana/latest/userguide/images/viz/heatmap_example.jpg)


## State timeline
<a name="v12-panels-ex-state"></a>

A [state timeline](v12-panels-state-timeline.md) shows discrete state changes over time. When used with time series, thresholds are used to turn numerical values into discrete state regions.

![\[An image showing an example of a state timeline visualization in Grafana.\]](http://docs.aws.amazon.com/grafana/latest/userguide/images/viz/state_timeline_example.png)


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

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

Use alert lists to display your alerts. You can configure the list to show current state. For more information about alerts, see [Alerts in Grafana version 12](v12-alerts.md).

Use these settings to refine your visualization.

## Options
<a name="v12-panels-alert-list-options"></a>
+ **Group mode** – Choose between **Default grouping** to show alert instances grouped by their alert rule, and **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
  + **Time (asc)** – Newest active alert instances first.
  + **Time (desc)** – Oldest active alert instances first.
+  **Alerts from this dashboard** – Show alerts only from the dashboard that the alert list is in.

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

These options allow you to limit alerts shown to only those that 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="v12-panels-alert-state-filter"></a>

Choose which alert states to display in this panel.
+ Alerting / Firing
+ Pending
+ No data
+ Normal
+ Error

# Annotations list
<a name="v12-panels-annotations"></a>

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

The Annotations list 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="v12-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="v12-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 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 visualization itself.

## Link behavior
<a name="v12-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
<a name="v12-panels-bar-chart"></a>

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

Bar charts allow you to graph categorical data.

![\[An image showing examples of bar chart visualizations in Grafana.\]](http://docs.aws.amazon.com/grafana/latest/userguide/images/viz/barchart_example.png)


## Supported data formats
<a name="v12-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="v12-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="v12-panels-bar-chart-options"></a>

Use these options to refine your visualization.

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

**Rotate x-axis tick labels**

 When the graph is vertically oriented, this setting rotates the labels under the bars. This setting is useful when bar chart labels are long and overlap.

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

**Group width**

Controls the width of groups.
+ `0 = Minimum width`
+ `1 = Maximum width`

**Bar width**

Controls the width of bars.
+ `0 = Minimum width`
+ `1 = Maximum width`

**Bar radius**

Controls the radius of the bars.
+ `0 = Minimum radius`
+ `0.5 = Maximum radius`

**Highlight full area on hover**

Controls if the entire surrounding area of the bar is highlighted when you hover over the bar.

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

**Text size**

Enter a value to change the size of the text on your bar chart.

## Legend options
<a name="v12-panels-bar-chart-legend"></a>

**Legend mode**

Use these settings to define how the legend appears in your visualization. For more information, see [Configure a legend](v12-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 values**

Choose series data values or standard calculations to show in the legend. You can have more than one. For more information, see [Configure a legend](v12-panels-configure-legend.md).

## Axis options
<a name="v12-panels-bar-chart-axis"></a>

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.

To selectively hide axes, [adding field overrides](v12-panels-configure-overrides.md) that targets specific fields.

**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 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 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. For more information, see [Configure standard options](v12-panels-configure-standard-options.md).

**Display multiple y-axes**

In some cases, you may want to display multiple y-axes. For example, if you have a dataset showing both temperature and humidity over time, you may want to show two y-axes with different units for these two series.

You can do this by [adding field overrides](v12-panels-configure-overrides.md). Follow the steps as many times as required to add as many y-axes as you need.

# Bar gauge
<a name="v12-panels-bar-gauge"></a>

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

Bar gauges simplify 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.

![\[An image showing an example of a bar gauge visualization in Grafana.\]](http://docs.aws.amazon.com/grafana/latest/userguide/images/viz/bar_gauge_example.png)


## Value options
<a name="v12-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](v12-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.

## Bar gauge options
<a name="v12-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.

**Value display**

Choose a value display mode.
+ **Value color** – Value color is determined by value.
+ **Text color** – Value color is the default text color.
+ **Hidden** – Values are hidden.

**Name placement**

Choose a name placement mode.

**Note**  
This option only applies when the orientation of the bar gauge is horizontal. When the bar gauge is in the vertical orientation, names are always placed at the bottom of each bar gauge.
+ **Auto** – Grafana determines the best placement.
+ **Top** – Names are placed on the top of each bar gauge.
+ **Left** – Names are placed to the left of each bar gauge.

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

**Bar size**

Choose a bar size mode.
+ **Auto** – Grafana determines the best bar gauge size.
+ **Manual** – Manually configure the bar gauge size.

**Min width**

Limit the minimum width of the bar column when the gauge is oriented vertically.

Automatically show x-axis scrollbar when there is a large amount of data.

**Note**  
This option only applies when bar size is set to manual.

**Min height**

Limit the minimum height of the bar row when the gauge is oriented horizontally.

Automatically show y-axis scrollbar when there is a large amount of data.

**Note**  
This option only applies when bar size is set to manual.

**Max height**

Limit the maximum height of the bar row when the gauge is oriented horizontally.

Automatically show y-axis scrollbar when there is a large amount of data.

**Note**  
This option only applies when bar size is set to manual.

# Candlestick
<a name="v12-panels-candlestick"></a>

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

The Candlestick visualization 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.

![\[An image showing an example of a candlestick visualization in Grafana.\]](http://docs.aws.amazon.com/grafana/latest/userguide/images/viz/candlestick-panel-example.png)


Candlestick visualizations build upon the foundation of the [Time series](v12-panels-time-series.md) and includes many common configuration settings.

## Mode
<a name="v12-panels-candlestick-mode"></a>

The mode options allow you to toggle which dimensions are used for the visualization.
+ **Candles** – Limit the panel dimensions to the open, high, low, and close dimensions used by candlestick visualizations.
+ **Volume** – Limit the panel dimension to the volume dimension.
+ **Both** – The default behavior for the candlestick panel. It includes both candlestick and volume visualizations.

## Candle style
<a name="v12-panels-candlestick-style"></a>
+ **Candles** – The default display style, creates candle-style visualizations between the open and close dimensions.
+ **OHLC Bars** – Display the four core dimensions open, high, low, and close values.

## Color strategy
<a name="v12-panels-candlestick-color"></a>
+ **Since Open** – 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** – An alternative display method where the color of the candle is based on the inter-period 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
<a name="v12-panels-candlestick-updown"></a>

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
<a name="v12-panels-candlestick-ohlc"></a>

The candlestick panel will attempt to map fields to the appropriate dimension.
+ **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)

**Note**  
The candlestick legend doesn't display these values.

To properly map these dimensions, the query results table from your data must include *at least* the following columns.
+ `timestamp`
+ `open`
+ `high`
+ `low`
+ `close`

If your data can't be mapped to these dimensions for some reason (for example, because the column names aren't the same), you can map them manually using the **Open**, **High**, **Low**, and **Close** fields under the **Candlestick** options in the panel editor.

## Additional fields
<a name="v12-panels-candlestick-other"></a>

**Additional fields**

The candlestick panel is based on the time series visualization. It can visualize additional data dimensions beyond open, high, low, close, and volume. The **Include** and **Ignore** options allow it 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](v12-panels-time-series.md).

# Canvas
<a name="v12-panels-canvas"></a>

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

Canvases combine the power of Grafana with the flexibility of custom elements. Canvases 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="v12-panels-canvas-elements"></a>

You can add these elements on your canvas. Adding multiple, and different kinds, of elements lets you customize a visualization in ways that are not possible with any other visualization.

**Metric value**

The metric value element lets you 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 panel. When in edit mode you can select which field data that you want to display.

**Text**

The text element lets you 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.

**Ellipse**

The ellipse element lets you add a basic ellipse to the canvas. An ellipse element can display text (both fixed and field data) and its background color can be changed based on data thresholds.

**Rectangle**

The rectangle element lets you to add a basic rectangle to the canvas. A rectangle elements can display text (both fixed and field data) and its background color can be changed based on data thresholds.

**Icon**

The icon element lets you add a supported icon to the canvas. Icons can have their color set based on thresholds or value mappings.

**Server**

The server element lets you easily represent a single server, a stack of servers, a database, or a terminal. Server elements support status color, bulb color, and a bulb blink rate, all configurable by fixed or field values.

**Button**

The button element lets you add a basic button to the canvas. Button elements support triggering basic, unauthenticated API calls. API settings are found in the button element editor. You can also pass template variables in the API editor.

**Note**  
Choosing a button will only trigger an API call when inline editing is disabled. See [Canvas editing](#v12-panels-canvas-editing).

## Connections
<a name="v12-panels-canvas-connections"></a>

When building a canvas, you can connect elements together to create more complex visualizations. You can create connections by dragging from the connection anchor of one element to the connection anchor of another element. You can also create connections to the background of the canvas. Connection anchors are displayed when you hover over an element and inline editing is turned on. To remove a connection, select the connection and then press `Delete` or `Backspace`.

You can set both the size and color of connections based on fixed or field values. To do so, enter into panel edit mode, select the connection, and modify the connection’s properties in the panel editor.

## Canvas editing
<a name="v12-panels-canvas-editing"></a>

**Inline editor**

You can edit your canvas inline while in the context of dashboard mode.

**Pan and zoom**

You and turn on panning and zooming in a canvas. This allows you to both create and navigate more complex designs.

**Note**  
Pan and zoom is currently in preview by Grafana Labs. Support is limited, and breaking changes might occur before general availability.

**Context menu**

The context menu lets you perform common tasks quickly and efficiently. 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 (or equivalent) 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="v12-panels-canvas-options"></a>

**Inline editing**

The inline editing toggle lets you lock or unlock the canvas panel. When turned off, the canvas panel becomes *locked*, freezing elements in place and preventing unintended modifications.

**Data links**

Canvases support [data links](v12-panels-configure-data-links.md). You can create a data link for a metric-value element and display it for all elements that use the field name by following these steps.

**To create a data link for an element**

1. Set an element to be tied to a field value.

1. Turn off the inline editing toggle.

1. Create an override for **Fields with name** and select the element field name from the list.

1. Choose the **\$1 Add override property** button.

1. Select **Datalinks > Datalinks** from the list.

1. Choose **\$1 Add link**, add a title and URL for the data link.

1. Hover over the element to display the data link tooltip.

1. Choose the element to be able to open the data link.

If multiple elements use the same field name, and you want to control which elements display the data link, you can create a unique field name using the [Add field from calculation](v12-panels-xform-functions.md#v12-panels-xform-funcs-add) transform. The alias you create in the transform will appear as a field you can use with an element.

# Dashboard list
<a name="v12-panels-dashboard-list"></a>

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

Dashboard lists allow 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.
+ **Include current time range** – Select this option to propagate the time range of the current dashboard to the dashboard links. When the user selects a link, the linked dashboard opens with the indicated time range already set.
+ **Include current template variable values** – Select this option to include template variables currently used as query parameters in a link. When the user selects a link, any matching templates in the linked dashboard are set to the values from the list. For more information, see [Dashboard URL variables](v12-dash-dashboard-url-variables.md).
+ **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 the 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.

# Datagrid
<a name="v12-panels-datagrid"></a>

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

**Note**  
The data grid visualization is currently in preview by Grafana Labs. Support is limited, and breaking changes might occur before general availability.

Datagrids offer you the ability to create, edit, and fine-tune data within Grafana. As such, this panel can act as a data source for other panels inside a dashboard.

![\[An image showing an example of a datagrid visualization in Grafana.\]](http://docs.aws.amazon.com/grafana/latest/userguide/images/viz/datagrid-panel-example.png)


Through it, you can manipulate data queried from any data source, you can start from a blank slate, or you can pull data from a dragged and dropped file. You can then use the panel as a simple tabular visualization, or you can modify the data—and even remove it altogether—to create a blank slate.

Editing the dataset changes the data source to use the built-in **Grafana** data source, replacing the old data source settings and related queries, while also copying the current dataset into the dashboard model.

You can then use the panel as a data source for other panels, by using the built-in **Dashboard** data source to pull the datagrid data. This provides an interactive dashboard experience, where you can modify the data and see the changes reflected in other panels.

For more information about the **Grafana** and **Dashboard** data sources, see [Special data sources](AMG-data-sources.md#AMG-data-sources-special).

## Context menu
<a name="v12-panels-datagrid-context"></a>

To provide a more streamlined experience, the datagrid has a context menu that can be accessed by right-clicking on a cell, column header, or row selector. Depending on the state of your datagrid, the context menu offers different options including the following.
+ Delete or clear all rows and columns.
+ Remove all existing data (rendering your datagrid blank).
+ Trigger search functionality, which allows you to find keywords within the dataset.

Deleting a row or column will remove the data from the datagrid, while clearing a row or column will only remove the data from the cells, leaving the row or column intact.

**Header menu**

You can also access a header menu by choosing the dropdown icon next to the header title. From here, you can not only delete or clear a column, but also rename it, freeze it, or convert the field type of the column.

## Selecting series
<a name="v12-panels-datagrid-selectseries"></a>

If there are multiple series, you can set the datagrid to display the preferred dataset using the **Select series** dropdown in the panel options.

## Using datagrids
<a name="v12-panels-datagrid-using"></a>

Datagrids offer various ways of interacting with your data. You can edit, move, clear, and remove rows and columns; use the built-in search functionality to find specific data; and convert field types or freeze horizontal scroll on a specific column.

**Adding data**

You can add data to a datagrid by creating a new column or row.

**To add a new column**

1. In an existing panel, choose the **\$1** button in the table header after the last column.

1. Add a name for the new column.

1. Select anywhere outside the field or press `Enter` to save the column.

Now you can add data in each cell.

To add a new row, choose a **\$1** button after the last row. The button is present in each cell after the last row, and choosing it triggers the creation of a new row while also activating the cell that you chose.

**Editing data**

You can move columns and rows as needed.

**To move a column**

1. Press and hold the header of the column that needs to be moved.

1. Drag the column to the desired location.

1. Release the column to finalize the move.

To move a row, select and hold the row selector from the number column situated on the far left side of the grid, and drag it to the desired location. Release the row to finalize the move.

**Selecting multiple cells**

You can select multiple cells by choosing a single cell, and dragging across others. This select can be used to copy the data from the selected cells or to delete them using the `Delete` key.

**Deleting or clearing multiple rows or columns**

To delete or clear multiple rows, you can do the following.

**To delete or clear multiple rows or columns**

1. Hover over the number column (to the left of the first column in the grid) to display row checkbox.

1. Select the checkboxes for the rows you want to work with. To select multiple consecutive rows, press and hold the `Shift` key while clicking the first and last row. To select non-consecutive rows, press and hold the `Ctrl` (or `Cmd`) key while clicking the desired rows.

1. Right-click (or equiavalent) to access the context menu.

1. Select **Delete rows** or **Clear rows**.

The same rules apply to columns by clicking the column headers.

To delete all rows, use the **Select all** checkbox at the top left corner of the datagrid. This select all rows and allows you to delete them using the context menu.

# Flame graph
<a name="v12-panels-flamegraph"></a>

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

Flame graphs let you visualize profiling data. Using this visualization, the profile can be represented as a flame graph, table, or both.

![\[An image showing an example of a flame graph visualization in Grafana.\]](http://docs.aws.amazon.com/grafana/latest/userguide/images/viz/flamegraph-panel-example.png)


## Flame graph mode
<a name="v12-panels-flamegraph-mode"></a>

A flame graph takes advantage of the hierarchical nature of profiling data. It condenses data into a format that allows you to easily see which code paths are consuming the most system resources, such as CPU time, allocated objects, or space when measuring memory. Each block in the flame graph represents a function call in a stack and its width represents its value.

Grayed-out sections are a set of functions that represent a relatively small value and they are collapsed together into one section for performance reasons.

You can hover over a specific function to view a tooltip that shows you additional data about that function, like the function's value, percentage of total value, and the number of samples with that function.

**Drop-down actions**

You can click a function to show a drop-down menu with additional actions: 
+ **Focus block** – When you choose **Focus block**, the block, or function, is set to 100% of the flame graph’s width and all its child functions are shown with their widths updated relative to the width of the parent function. This makes it easier to drill down into smaller parts ofthe flame graph.
+ **Copy function name** – When you choose **Copy function name**, the full name of the function that the block represents is copied.
+ **Sandwich view** – The sandwich view allows you to show the context of the clicked function. It shows all the function’s callers on the top and all the callees at the bottom. This shows the aggregated context of the function so if the function exists in multiple places in the flame graph, all the contexts are shown and aggregated in the sandwich view.

**Status bar**

 The status bar shows metadata about the flame graph and currently applied modifications, like what part of the graph is in focus or what function is shown in sandwich view. Click the **X** in the status bar pill to remove that modification.

## Toolbar
<a name="v12-panels-flamegraph-toolbar"></a>

**Search**

You can use the search field to find functions with a particular name. All the functions in the flame graph that match the search will remain colored while the rest of the functions are grayed-out.

**Color schema picker**

You can switch between coloring functions by their value or by their package name to visually tie functions from the same package together.

**Text align**

Align text either to the left or to the right to show more important parts of the function name when it does not fit into the block.

**Visualization picker**

You can choose to show only the flame graph, only table, or both at the same time.

## Top table mode
<a name="v12-panels-flamegraph-toptablemode"></a>

The top table shows the functions from the profile in table format. The table has three columns: symbols, self, and total. The table is sorted by self time by default, but can be reordered by total time or symbol name by clicking the column headers. Each row represents aggregated values for the given function if the function appears in multiple places in the profile.

There are also action buttons on the left for each row. The first button searches for the function name while second button shows the sandwich view of the function.

## Data API
<a name="v12-panels-flamegraph-dataapi"></a>

In order to render the flame graph, you must format the data frame data using a [nested set model](https://wikipedia.org/wiki/Nested_set_model).

A nested set model ensures each item of the flame graph is encoded just by its nesting level as an integer value, its metadata, and by its order in the data frame. This means that the order of items is significant and needs to be correct. The ordering is a depth-first traversal of the items in the flame graph which recreates the graph without needing variable-length values in the data frame like in a children’s array.

Required fields:


| Field name | Type | Description | 
| --- | --- | --- | 
| level | number | The nesting level of the item. In other words how many items are between this item and the top item of the flame graph. | 
| value | number | The absolute or cumulative value of the item. This translates to the width of the item in the graph. | 
| label | string | Label to be shown for the particular item. | 
| self | number | Self value which is usually the cumulative value of the item minus the sum of cumulative values of its immediate children. | 

# Gauge
<a name="v12-panels-gauge"></a>

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

Gauges are single-value visualizations that can repeat a gauge for every series, column or row.

![\[An image showing an example of a gauge visualization in Grafana.\]](http://docs.aws.amazon.com/grafana/latest/userguide/images/viz/gauge_example.png)


## Value options
<a name="v12-panels-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](v12-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
<a name="v12-panels-gauge-gauge"></a>

Adjust how the gauge is displayed.

**Orientation**

Choose a stacking direction.
+ **Auto** – Gauges display in rows and columns.
+ **Horizontal** – Gauges display top to bottom.
+ **Vertical** – Gauges display left to right.

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

**Gauge size**

Choose a guage size mode
+ **Auto** – Grafana determines the best gauge size.
+ **Manual** – Manually configure the gauge size.

**Min width**

Set the minimum width of vertically-oriented gauges.

If you set a minimum width, the x-axis scrollbar is automatically displayed when there is a large amount of data.

**Note**  
This option only applies when gauge size is set to manual.

**Min height**

Se the minimum height of horizontally-oriented gauges.

If you set a minimum height, the y-axis scrollbar is automatically displayed when there is a large amount of data.

**Note**  
This option only applies when gauge size is set to manual.

**Neutral**

Set the starting value from which every gauge will be filled.

## Text size
<a name="v12-panels-gauge-textsize"></a>

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
<a name="v12-panels-geomap"></a>

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

Geomaps allow 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.

**Note**  
You can add your own geospatial data on top of basemap layers provides by AWS. The basemap layers must all come from [https://tiles.maps.search-services.aws.a2z.com](https://tiles.maps.search-services.aws.a2z.com). 

![\[An image showing an example of a geomap visualization in Grafana.\]](http://docs.aws.amazon.com/grafana/latest/userguide/images/viz/geomap-panel-example.png)


## Map View
<a name="v12-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="v12-panels-geomap-layers"></a>

Geomaps support 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](#v12-panels-geomap-markers) renders a marker at each data point.
+ [Heatmap layer](#v12-panels-geomap-heatmap) visualizes a heatmap of the data.
+ [GeoJSON layer](#v12-panels-geomap-geojson) renders static data from a GeoJSON file.
+ [Night / Day layer (Alpha)](#v12-panels-geomap-nightday) renders a night or day region.
+ [Route layer (preview)](#v12-panels-geomap-route) render data points as a route.
+ [Photos layer (preview)](#v12-panels-geomap-photos) renders a photo at each data point.
+ [Network layer (preview)](#v12-panels-geomap-network) visualizes a network graph from the data.

There are also two experimental (or alpha) layer types.
+ **Icon at last point (alpha)** renders an icon at the last data point.
+ **Dynamic GeoJSON (alpha)** styles a GeoJSON file based on query results.

**Note**  
Layers marked *preview* or *alpha* in public preview. Grafana Labs offers limited support, and breaking changes might occur prior to the feature being made generally available.

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

Geomaps 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 getprompted 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="v12-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.
+ **Size** configures the size of the markers. The default is `Fixed size`, which makes all marker sizes the same regardless of the data; however, there is also an option to size the markers based on the data corresponding to selected field. `Min` and `Max` marker size has to be set such that the Marker layer can scale within this range.
+ **Symbol** allows you to choose the symbol, icon, or graphic to aid in providing additional visual context to your data. Choose from assets that are included with Grafana such as simple symbols or the Unicon library. You can also specify a URL containing an image asset. The image must be a scalable vector graphic (SVG).
+ **Symbol Vertical Align** configures the vertical alignment of the symbol relative to the data point. Note that the symbol's rotation angle is applies first around the data point, then the vertical alignment is applied relative to the rotation of the symbol.
+ **Symbol Horizontal Align** configures the horizontal alignment of the symbol relative to the data point. Note that the symbol's rotation angle is applies first around the data point, then the horizontal alignment is applied relative to the rotation of the symbol.
+ **Color** configures the color of the markers. The default `Fixed color` sets all markers to a specific color. There is also an option to have conditional colors depending on the selected field data point values and the color scheme set at the **Standard options** section.
+ **Fill opacity** configures the transparency of each marker.
+ **Rotation angle** configures the rotation angle of each marker. The default is **Fixed value**, which makes all markers rotate to the same angle regardless of the data; however, there is also an option to set the rotation of the markers based on data corresponding to a selected field.
+ **Text label** configures a text label for each marker.
+ **Show legend** lets you toggle the legend for the layers.
+ **Display tooltip** lets you toggle tooltips for the layer.

## Heatmap layer
<a name="v12-panels-geomap-heatmap"></a>

The heatmap layer clusters various data points to visualize locations with different densities.

![\[An image showing an example of heatmap using the geomap visualization in Grafana.\]](http://docs.aws.amazon.com/grafana/latest/userguide/images/viz/geomap-heatmap-example.png)


To add a heatmap layer:

Choose on the dropdown menu under Data Layer and select `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-1. 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.
+ **Opacity** configures the opacity of each cluster.
+ **Display tooltip** lets you toggle tooltips for the layer.

## GeoJSON layer
<a name="v12-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.
+ **Display tooltip** lets you toggle tooltips for the layer.

## Night / Day layer (Alpha)
<a name="v12-panels-geomap-nightday"></a>

The Night / Day layer displays night and day regions based on the current time range.

![\[An image showing an example of a night / day layer using the geomap visualization in Grafana.\]](http://docs.aws.amazon.com/grafana/latest/userguide/images/viz/geomap-day-night-example.png)


**Options**
+ **Show** toggles the time source from panel time range.
+ **Night region color** picks the color for the night region.
+ **Display sun** toggles sun icon.
+ **Opacity** from 0 (transparent) to 1 (opaque).
+ **Display tooltip** lets you toggle tooltips for the layer.

**Note**  
For more information, see [Extensions for OpenLayers - DayNight](https://viglino.github.io/ol-ext/examples/layer/map.daynight.html).

## Route layer (preview)
<a name="v12-panels-geomap-route"></a>

The Route layer renders data points as a route.

**Note**  
The Route layer is currently in public preview. Grafana Labs offers limited support, and breaking changes might occur prior to the feature being made generally available.

![\[An image showing an example of a route layer using the geomap visualization in Grafana.\]](http://docs.aws.amazon.com/grafana/latest/userguide/images/viz/geomap-route-layer-example.png)


**Options**
+ **Size** sets the route thickness. Fixed value by default. When field data is selected, you can set the Min and Max range in which field data can scale.
+ **Color** sets the route color. Set to fixed color by default, you can also tie the color to field data.
+ **Fill opacity** configures the opacity of the route.
+ **Text label** configures a text label for each route.
+ **Arrow** configures the arrow styling to display along the route, in order of data.
  + **None**
  + **Forward**
  + **Reverse**
+ **Display tooltip** lets you toggle tooltips for the layer.

**Note**  
For more information, see [Extensions for OpenLayers - Flow Line Style](http://viglino.github.io/ol-ext/examples/style/map.style.gpxline.html).

## Photos layer (preview)
<a name="v12-panels-geomap-photos"></a>

The Photos layer renders a photo at each data point.

**Note**  
The Photos layer is currently in public preview. Grafana Labs offers limited support, and breaking changes might occur prior to the feature being made generally available.

**Options**
+ **Image Source Field** lets you select a string field containing image data as a Base64 encoded image binary (`data:image/png;base64,...`).
+ **Kind** sets the frame style around the images. Choose from:
  + **Square**
  + **Circle**
  + **Anchored**
  + **Folio**
+ **Crop** toggles whether the images are cropped to fit.
+ **Shadow** toggles a box shadow behind the images.
+ **Border** sets the border size around images.
+ **Border color** sets the border color around images.
+ **Radius** sets the overall size of images in pixels.
+ **Display tooltip** lets you toggle tooltips for the layer.

**Note**  
For more information, see [Extensions for OpenLayers - Image Photo Style](http://viglino.github.io/ol-ext/examples/style/map.style.photo.html).

## Network layer (preview)
<a name="v12-panels-geomap-network"></a>

The Network layer renders a network graph. This layers supports the same data format supported by the node graph visualization, with the addition of geospatial data included in the nodes data. The geospatial data is used to locate and render the nodes on the map.

**Note**  
The Network layer is currently in public preview. Grafana Labs offers limited support, and breaking changes might occur prior to the feature being made generally available.

![\[An image showing examples of network visualizations within a geomap in Grafana.\]](http://docs.aws.amazon.com/grafana/latest/userguide/images/viz/geomap-network-layer-example.png)


**Note**  
The Network layer is currently in public preview. Grafana Labs offers limited support, and breaking changes might occur prior to the feature being made generally available.

**Options**
+ **Arrow** sets the arrow direction to display for each edge, with forward meaning source to target. Choose from:
  + **None**
  + **Forward**
  + **Reverse**
  + **Both**
+ **Show legend** lets you toggle the legend for the layer. The legend only supports node data.
+ **Display tooltip** lets you toggle tooltips for the layer.

**Node styles**
+ **Size** configures the size of the nodes. The default is **Fixed size**, which makes all node sizes the same regardless of the data; however, there is also an option to size the nodes based on data corresponding to a selected field. **Min** and **Max** node sizes have to be set such that the nodes can scale within this range.
+ **Color** configures the color of the nodes. The default is **Fixed color**, which sets all nodes to a specific color. There is also an option to have conditional colors depending on the selected field data point values and the color scheme set in the **Standard options** section.
+ **Symbol** lets you choose the symbol, icon, or graphic to aid in providing additional visual context to your data. Choose from assets that are included with Grafana, such as simple symbols 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 node.
+ **Rotation angle** configures the rotation angle of each node. The default is **Fixed value**, which makes all nodes rotate to the same angle regardless of the data; however, there is also an option to set the rotation of the nodes based on data corresponding to a selected field.
+ **Text label** configures a text label for each node.

**Edge styles**
+ **Size** configures the line width of the edges. The default is **Fixed size**, which makes all edge line widths the same regardless of the data; however, there is also an option to size the edges based on data corresponding to a selected field. **Min** and **Max** edge sizes have to be set such that the edges can scale within this range.
+ **Color** configures the color of the edges. The default is **Fixed color**, which sets all edges to a specific color. There is also an option to have conditional colors depending on the selected field data point values and the color scheme set in the **Standard options** section.
+ **Fill opacity** configures the transparency of each edge.
+ **Text label** configures a text label for each edge.

## CARTO layer
<a name="v12-panels-geomap-carto"></a>

CARTO layers are not supported in Amazon Managed Grafana.

## XYZ tile layer
<a name="v12-panels-geomap-xyz"></a>

XYZ tile layers are not supported in Amazon Managed Grafana.

## Open Street Map layer
<a name="v12-panels-geomap-osm"></a>

Open Street Map layers (other than the default basedmap) are not supported in Amazon Managed Grafana.

## ArcGIS layer
<a name="v12-panels-geomap-arcgis"></a>

ArcGIS layers are not supported in Amazon Managed Grafana.

## Map Controls
<a name="v12-panels-geomap-controls"></a>

The map controls section contains various options for map information and tool overlays.

**Zoom**

Options for 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.

# Heatmap
<a name="v12-panels-heatmap"></a>

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

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

![\[An image showing an example of a heatmap visualization in Grafana.\]](http://docs.aws.amazon.com/grafana/latest/userguide/images/viz/heatmap_example.jpg)


## Calculate from data
<a name="v12-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.
+ **symlog** – Symlog scale.

## Y Axes
<a name="v12-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.

**Display multiple y-axes**

In some cases, you may want to display multiple y-axes. For example, if you have a dataset showing both temperature and humidity over time, you may want to show two y-axes with different units for these two series.

You can do this by [adding field overrides](v12-panels-configure-overrides.md). Follow the steps as many times as required to add as many y-axes as you need.

## Colors
<a name="v12-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="v12-panels-heatmap-cell"></a>

Use these settings to refine your visualization.

## Additional display options
<a name="v12-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.
+ **Show color scale** – Show a color scale on the tooltip. The color scale represents the mapping between bucket value and color.

**Legend**

Choose whether you want to display the heatmap legend on the visualization.

**Exemplars**

Set the color used to show exemplar data.

# Histogram
<a name="v12-panels-histogram"></a>

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

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

![\[An image showing an example of a histogram visualization in Grafana.\]](http://docs.aws.amazon.com/grafana/latest/userguide/images/viz/histogram-example.png)


## Supported formats
<a name="v12-panels-histogram-formats"></a>

Histogram visualization supports time series and any table results with one or more numerical fields.

## Display options
<a name="v12-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**

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

## Legend options
<a name="v12-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. For more information about the legend, see [Configure a legend](v12-panels-configure-legend.md).

**Legend mode**

Use these settings to define 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](v12-panels-calculation-types.md).

**Legend calculations**

Choose which calculations to show in the legend. You can select more than one.

# Logs
<a name="v12-panels-logs"></a>

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

The 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="v12-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 [Log level](v12-explore-logs.md#v12-explore-log-level).

## Log details
<a name="v12-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
<a name="v12-panels-news"></a>

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

The news visualization displays an RSS feed. By default, it displays articles from the Grafana Labs blog, and users can change this by entering a different RSS feed URL.

Enter the URL of an RSS in the **Display** section. This visualization type does not accept any other queries, and users should not expect to be able to ilter or query the RSS feed data in any way using this visualization.

**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
<a name="v12-panels-node-graph"></a>

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

Node graphs can visualize directed graphs or networks. They use a directed force layout to effectively position the nodes, so they can help with displaying complex infrastructure maps, hierarchies, or run diagrams.

## Data requirements
<a name="v12-panels-node-graph-requirements"></a>

A node graph 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 with this graph. If you want to use this as a data source developer, see the section about data API.

A node graph 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="v12-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 representing 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="v12-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="v12-panels-node-graph-navigation"></a>

**Pan**

You can pan within the node graph by choosing outside of any node or edge and dragging the pointer.

**Zoom in or out**

You can zoom by using the buttons on the upper left corner of the node graph, or use a mouse wheel or other scroll input with the `Ctrl` (or `Cmd`) key.

**Explore 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 selectable 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 (either `˄` or `˅`) shows which stat is currently used for sorting and sorting direction.

Choose a node and then select 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="v12-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 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. | 
| color | string/number | Can be used to specify a single color instead of using the `arc__` fields to specify color sections. It can either be a string (it must be an acceptable HTML color string), or it can be a number, in which case the behavior depends on the `field.config.color.mode` setting. This can be used, for example, to create gradient colors controlled by a field value. | 
| icon | string | Name of the icon to show inside the node instead of the default stats. Only Grafana built in icons are allowed (see the available icons [here](https://developers.grafana.com/ui/latest/index.html?path=/story/docs-overview-icon--icons-overview)). | 
| nodeRadius | number | Radius value in pixels. Used to manage node size. | 
| highlighted | Boolean | Sets whether the node should be highlighted. Use, for example, to represent a specific path in the graph by highlighting several nodes and edges. Defaults to `false`. | 

# Pie chart
<a name="v12-panels-piechart"></a>

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

![\[An image showing an example of a pie chart visualization in Grafana.\]](http://docs.aws.amazon.com/grafana/latest/userguide/images/viz/pie_chart_example.png)


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="v12-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](v12-panels-calculation-types.md).

**Limit**

When displaying every value from a single series, this limits the number of values displayed.

**Fields**

Select at least one field 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="v12-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 options
<a name="v12-panels-piechart-legend"></a>

Use these settings to define how the legend appears in your visualization. For more information about the legend, refer to [Configure a legend](v12-panels-configure-legend.md).

**Legend visibility**

Use the **Visibility** toggle to show or hide the legend.

**Legend mode**

Set the display mode of the legend.
+ **List** – Displays the legend as a list. This is the default display mode of the legend.
+ **Table** – Displays the legend as a table.

**Legend placement**

Choose where to display the legend.
+ **Bottom** – Below the graph.
+ **Right** – To the right of the graph.

**Legend values**

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](v12-panels-configure-legend.md).

# Stat
<a name="v12-panels-stat"></a>

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

Stats show one large stat value with an optional graph sparkline. You can control the background or value color using thresholds or overrides.

![\[An image showing an example of a stat visualization in Grafana.\]](http://docs.aws.amazon.com/grafana/latest/userguide/images/viz/stat_panel_example.png)


By default, a Stat 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="v12-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="v12-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](v12-panels-calculation-types.md).
  + **Fields** – Select the fields display in the visualization.
+ **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 visualization.

## Stat styles
<a name="v12-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 visualization 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.

**Wide layout**

Set whether wide layout is enabled or not. Wide layout is enabled by default.
+ **On** – Wide layout is turned on.
+ **Off** – Wide layout is turned off.

**Note**  
This option is only applicable when **Text mode** is set to **Value and name**. When wide layout is turned on, the value and name are displayed side-by-side with the value on the right, if the panel is wide enough. When wide layout is turned off, the value is always rendered underneath the name.

**Color mode**

Select a color mode.
+ **None** – No color is applied to the value.
+ **Value** – Applies colors to the value and graph area.
+ **Background Gradient** – Applies color to the value, graph area, and background, with a slight background gradient.
+ **Background Solid** – Applies color to the value, graph area, and background, with a solid background color.

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

**Show percent change**

Set whether percent change is displayed or not. By default it is not shown.

**Note**  
This option is not applicable when the **Show** setting, under **Value options**, is set to **All values**.

## Text size
<a name="v12-panels-stat-textsize"></a>

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
<a name="v12-panels-state-timeline"></a>

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

State timelines show 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.

![\[An image showing an example of a state timeline visualizations in Grafana.\]](http://docs.aws.amazon.com/grafana/latest/userguide/images/viz/state_timeline_example.png)


## State timeline options
<a name="v12-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.

**Connect null values**

Choose how null values, which are gaps in the data, appear on the graph. Null values can be connected to form a continuous line or set to a threshold above which gaps in the data are no longer connected.
+ **Never** – Time series data points with gaps in the data are never connected.
+ **Always** – Time series data points with gaps in the data are always connected.
+ **Threshold** – Specify a threshold above which gaps in the data are no longer connected. This can be useful when the connected gaps in the data are of a known size or within a known range, and gaps outside this range should no longer be connected.

**Disconnect values**

Choose whether to set a threshold above which values in the data should be disconnected.
+ **Never** – Time series data points in the data are never disconnected.
+ **Threshold** – Specify a threshold above which values in the data are disconnected. This can be useful when desired values in the data are of a known size or within a known range, and values outside this range should no longer be connected.

## Value mappings
<a name="v12-panels-state-timeline-valuemap"></a>

To assign colors to boolean or string values, use [Configure value mappings](v12-panels-configure-value-mappings.md).

## Time series data with thresholds
<a name="v12-panels-state-timeline-threshold"></a>

The visualization 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="v12-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 define how the legend appears in your visualization. For more information about the legend, refer to [Configure a legend](v12-panels-configure-legend.md).
+ **List** – Displays the legend as a list. This is the default mode.
+ **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](v12-panels-calculation-types.md) to show in the legend. You can have more than one.

# Status history
<a name="v12-panels-status-history"></a>

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

Status histories show periodic states over time. Each field or series is rendered as a horizontal row. Boxes are rendered and centered around each value.

## Supported data
<a name="v12-panels-status-history-supporteddata"></a>

A status history 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="v12-panels-status-history-options"></a>

Use these options to refine the visualization.

**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 = maximum space and 0 = minimum space.

**Line width**

Controls line width of state regions.

**Fill opacity**

Controls the fill opacity of state regions.

## Value mappings
<a name="v12-panels-status-history-valuemap"></a>

To assign colors to boolean or string values, use [Configure value mappings](v12-panels-configure-value-mappings.md).

## Time series data with thresholds
<a name="v12-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="v12-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 define how the legend appears in your visualization. For more information about the legend, refer to [Configure a legend](v12-panels-configure-legend.md).
+ **List** – Displays the legend as a list. This is the default mode.
+ **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](v12-panels-calculation-types.md) to show in the legend. You can have more than one.

# Table
<a name="v12-panels-table"></a>

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

Tables are very flexible, supporting multiple modes for time series and for tables, annotation, and raw JSON data. This visualization also provides date formatting, value formatting, and coloring options.

![\[An image showing an example of a table visualization in Grafana.\]](http://docs.aws.amazon.com/grafana/latest/userguide/images/viz/table_example.png)


**Note**  
Annotations and alerts are not supported in tables.

## Sort column
<a name="v12-panels-table-sort"></a>

Choose a column title to change the sort order from default to descending to ascending. Each time you select the column, the sort order changes to the next option in the cycle. You can sort on multiple columns by holding the `shift` key when selecting additional columns.

## Table options
<a name="v12-panels-table-options"></a>

**Show header**

Show or hide column names imported from your data source.

## Column width
<a name="v12-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`, all the columns will be set to 100 pixels wide (the change takes place when you exit the field).

## Minimum column width
<a name="v12-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 set the minimum to `75`, all the columns will scale to no smaller than 75 pixels wide.

For small-screen devices, such as smartphones or tablets, you can reduce the default `150` pixel value to `50` to allow table based panels to render correctly in dashboards.

## Column alignment
<a name="v12-panels-table-alignment"></a>

Choose how Grafana should align cell contents.
+ Auto (default)
+ Left
+ Center
+ Right

## Cell type
<a name="v12-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.

Additionally, labels displayed alongside the gauges can be set to be colored by value, match the theme text color, or be hidden.
+ **Value color**
+ **Text color**
+ **Hidden**

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

**Sparkline**

Shows values rendered as a sparkline. Requires [time series to table](v12-panels-xform-functions.md#v12-panels-xform-funcs-series) data transform.

## Cell value inspect
<a name="v12-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="v12-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, see [Filter table columns](#v12-panels-table-filter).

## Pagination
<a name="v12-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="v12-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 (funnel) 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.

Select from several operators to display column values:
+ **Contains** – Matches a regex pattern (operator by default).
+ **Expression** – Evaluates a Boolean expression. The character `$` represents the column value in the expression (for example, `$ >= 10 ≈& $ <= 12`).
+ **Comparison operators** – You can use the typical comparison operators: `=`, `!=`, `<`, `<=`, `>`, `>=`.

Choose the checkbox above the **Ok** and **Cancel** buttons to add or remove all displayed values from the filter.

**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="v12-panels-table-footer"></a>

You can use the table footer to show [calculations](v12-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
<a name="v12-panels-text"></a>

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

Text visualizations enable 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
<a name="v12-panels-time-series"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 12.x**.  
For Grafana workspaces that support Grafana version 10.x, see [Working in Grafana version 10](using-grafana-v10.md).  
For Grafana workspaces that support Grafana version 9.x, see [Working in Grafana version 9](using-grafana-v9.md).  
For Grafana workspaces that support Grafana version 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

![\[An image showing examples of times series visualizations in Grafana.\]](http://docs.aws.amazon.com/grafana/latest/userguide/images/viz/time_series_example.png)


Time series visualizations are the default and primary way to visualize time series data as a graph. They can render series as lines, points, or bars. They're 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
](v12-time-series-panel-tooltip.md)
+ [

# Legend options
](v12-time-series-panel-legend.md)
+ [

# Graph styles
](v12-time-series-graph.md)
+ [

# Axis options
](v12-time-series-axis.md)
+ [

# Color options
](v12-time-series-color.md)

# Tooltip options
<a name="v12-time-series-panel-tooltip"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 12.x**.  
For Grafana workspaces that support Grafana version 10.x, see [Working in Grafana version 10](using-grafana-v10.md).  
For Grafana workspaces that support Grafana version 9.x, see [Working in Grafana version 9](using-grafana-v9.md).  
For Grafana workspaces that support Grafana version 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

Tooltip options control the information overlay that appears when you hover over data points in the graph.

**Tooltip mode**
+ **Single** – The hover tooltip shows only a single series, the one that you are hovering over.
+ **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.

# Legend options
<a name="v12-time-series-panel-legend"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 12.x**.  
For Grafana workspaces that support Grafana version 10.x, see [Working in Grafana version 10](using-grafana-v10.md).  
For Grafana workspaces that support Grafana version 9.x, see [Working in Grafana version 9](using-grafana-v9.md).  
For Grafana workspaces that support Grafana version 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

Legend options control the series names and statistics that appear under or to the right of the graph.

**Legend mode**

Use these settings to define how the legend appears in your visualization. For more information about the legend, see [Configure a legend](v12-panels-configure-legend.md).
+ **List** – Displays the legend as a list. This is the default display mode of a 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 [standards calculations](v12-panels-calculation-types.md) to show in the legend. You can have more than one.

# Graph styles
<a name="v12-time-series-graph"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 12.x**.  
For Grafana workspaces that support Grafana version 10.x, see [Working in Grafana version 10](using-grafana-v10.md).  
For Grafana workspaces that support Grafana version 9.x, see [Working in Grafana version 9](using-grafana-v9.md).  
For Grafana workspaces that support Grafana version 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

Use this option to define how to display your time series data. You can use overrides to combine multiple styles in the same graph.
+ **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
<a name="v12-time-series-graph-bar"></a>

Set the position of the bar relative to a data point.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:
+ ![\[An image showing a bar graph aligned before a point.\]](http://docs.aws.amazon.com/grafana/latest/userguide/images/viz/bar-alignment-before.png) **Before** – The bar is drawn before the point. The point is placed on the trailing corner of the bar.
+ ![\[An image showing a bar graph aligned around a point.\]](http://docs.aws.amazon.com/grafana/latest/userguide/images/viz/bar-alignment-center.png) **Center** – The bar is drawn around the point. The point is placed in the center of the bar. This is the default.
+ ![\[An image showing a bar graph aligned after a point.\]](http://docs.aws.amazon.com/grafana/latest/userguide/images/viz/bar-alignment-after.png) **After** – The bar is drawn after the point. the point is placed on the leading corner of the bar.

## Line width
<a name="v12-time-series-graph-linewidth"></a>

Line width is a slider that controls the thickness for series lines or the outline for bars.

## Fill opacity
<a name="v12-time-series-graph-fill"></a>

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
<a name="v12-time-series-graph-gradient"></a>

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](v12-panels-configure-standard-options.md#v12-panels-standard-options-color-scheme).

The gradient mode options are:
+ **None** – No gradient fill. This is the default setting.
+ **Opacity** – An opacity gradient where the opacity of the fill increases as the Y-axis values increase.
+ **Hue** – A subtle gradient that is based on the hue of the series color.
+ **Scheme** – A color gradient defined by your color scheme. This setting is used for the fill area and the line. For more information, see [Color options](v12-time-series-color.md).

The gradient appearance is influenced by the **Fill opacity** setting.

## Show points
<a name="v12-time-series-graph-showpoints"></a>

You can configure your visualization to add points to line or bars, with the following options.
+ **Auto** – Grafana determines whether to show points based on the density of the data. Points are shown when the density is low.
+ **Always** – Points are shown, regardless of the data density.
+ **Never** – Do not show points.

## Point size
<a name="v12-time-series-graph-pointsize"></a>

Sets the size of the points, from 1 to 40 pixels in diameter.

## Line interpolation
<a name="v12-time-series-graph-interpolation"></a>

Choose how Grafana interpolates the series line.

![\[An image showing different ways of drawing lines between points in Grafana.\]](http://docs.aws.amazon.com/grafana/latest/userguide/images/viz/line-interpolation.png)


The options are:
+ **Linear** – Points are joined by straight lines.
+ **Smooth** – Points are joined by curved lines that smooths transitions between points.
+ **Step before** – The line is displayed as steps between points. Points are rendered at the end of the step.
+ **Step after** – The line is displayed as steps between points. Points are rendered at the beginning of the step.

## Line style
<a name="v12-time-series-graph-linestyle"></a>

Set the style of the line. To change the color, use the standard color scheme field option.

The choices for line style are:
+ **Solid** – Display a solid line. This is the default setting.
+ **Dash** – Display a dashed line. When you choose this option, a list appears for you to select the length and gap (length, gap) for the line dashes. Dash spacing is set to 10, 10 by default.
+ **Dots** – Display dotted lines. When you choose this option, a list appears for you to select the gap length for the dot spacing. Dot spacing is set to 10 by default.

## Connect null values
<a name="v12-time-series-graph-null"></a>

Choose how null values, which are gaps in the data, appear on the graph. Null values can be connected to form a continuous line, or set to a threshold above which gaps in the data are no longer connected.

The choices for how to connect null values are:
+ **Never** – Time series data points with gaps in the data are never connected.
+ **Always** – Time series data points with gaps in the data are always connected.
+ **Threshold** – Specify a threshold above which gaps in the data are no longer connected. This can be useful when the connected gaps in the data are of a known size or within a known range, and gaps outside the range should no longer be connected.

## Disconnect values
<a name="v12-time-series-graph-disconnect"></a>

Choose whether to add a gap between values in the data that have times between them above a specified threshold.

The choices for disconnect values are are:
+ **Never** – Time series data points are never disconnected.
+ **Threshold** – Specify a threshold above which values in the data are disconnected. This can be useful when desired values in the data are of a known size or within a known range, and values outside this range should no longer be connected.

## Stack series
<a name="v12-time-series-graph-stack"></a>

*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 choices 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%.

**Stacking 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](v12-panels-configure-overrides.md).

**To stack series in groups**

1. Edit the panel and choose **Overrides**.

1. Create a field override for the **Stack series** option.

1. In stacking mode, select **Normal**.

1. Name the stacking group in which you want the series to appear.

   The stacking group name option is only available when you create an override.

## Fill below to
<a name="v12-time-series-graph-fillbelow"></a>

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="v12-time-series-axis"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 12.x**.  
For Grafana workspaces that support Grafana version 10.x, see [Working in Grafana version 10](using-grafana-v10.md).  
For Grafana workspaces that support Grafana version 9.x, see [Working in Grafana version 9](using-grafana-v9.md).  
For Grafana workspaces that support Grafana version 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

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 press `Enter`.

## Time zone
<a name="v12-time-series-axis-timezone"></a>

Set the desired time zones to display along the x-axis.

## Placement
<a name="v12-time-series-axis-placement"></a>

Select the placement of the Y-axis. The options are:
+ **Auto** – 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 axes.

To selectively hide axes, [add a field override](v12-panels-configure-overrides.md) that targets specific fields.

## Label
<a name="v12-time-series-axis-label"></a>

Set a y-axis text label. If you have more than one y-axis, then you can assign different labels using an override.

## Width
<a name="v12-time-series-axis-width"></a>

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.

## Show grid lines
<a name="v12-time-series-axis-gridlines"></a>

Set the axis grid line visibility.
+ **Auto** – Automatically show grid lines based on the density of the data.
+ **On** – Always show grid lines.
+ **Off** – Never show grid lines.

## Color
<a name="v12-time-series-axis-color"></a>

Set the color of the axis.
+ **Text** – Set the color based on theme text color.
+ **Series** – Set the color based on the series color.

## Show border
<a name="v12-time-series-axis-border"></a>

Set the axis border visibility.

## Scale
<a name="v12-time-series-axis-scale"></a>

Set how the y-axis values scale.
+ **Linear** – Divides the scale into equal parts.
+ **Logarithmic** – Use a logarithmic scale. When you select this option, a list appears for you to choose a binary (base 2) or common (base 10) logarithmic scale.
+ **Symlog** – Use a symmetrical logarithmic scale. When you select this option, a list appears for you to choose a binary (base 2) or common (base 10) logarithmic scale. The linear threshold option allows you to set the threshold at which the scale changes from linear to logarithmic.

## Centered zero
<a name="v12-time-series-axis-centered"></a>

Sets the y-axis to be centered on zero.

## Soft min and soft max
<a name="v12-time-series-axis-softminmax"></a>

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 can prevent small variations in the data from being magnified when it's mostly flat. In contrast, hard min and max values help prevent obscuring useful detail in the data by clipping intermittent spikes past a specific point.

To define hard limits of the y-axis, set standard min/max options. For more information, refer to [Configure standard options](v12-panels-configure-standard-options.md).

## Transform
<a name="v12-time-series-axis-transform"></a>

Use this option to transform the series values without affecting the values shown in the tooltip, context menus, or legend. 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.

**Note**  
The transform option is only available as an override.

## Display multiple y-axes
<a name="v12-time-series-axis-multiple"></a>

There are some cases where you want to display multiple y-axes. For example, if you have a dataset showing both temperature and humidity over time, you could show two y-axes with different units for these two series.

To display multiple y-axes, [add a field override](v12-panels-configure-overrides.md#v12-panels-overrides-add-a-field). Follow the steps as many times as required to add as many y-axes as you need.

# Color options
<a name="v12-time-series-color"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 12.x**.  
For Grafana workspaces that support Grafana version 10.x, see [Working in Grafana version 10](using-grafana-v10.md).  
For Grafana workspaces that support Grafana version 9.x, see [Working in Grafana version 9](using-grafana-v9.md).  
For Grafana workspaces that support Grafana version 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

By default, the graph uses the standard [Color scheme](v12-panels-configure-standard-options.md#v12-panels-standard-options-color-scheme) option to assign series colors. You can also use the legend to open the color picker by selecting 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
<a name="v12-time-series-color-classic"></a>

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
<a name="v12-time-series-color-single"></a>

Use this mode to specify a color. You can also select 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
<a name="v12-time-series-color-byvalue"></a>

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
<a name="v12-time-series-color-gradient"></a>

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
<a name="v12-panels-traces"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 12.x**.  
For Grafana workspaces that support Grafana version 10.x, see [Working in Grafana version 10](using-grafana-v10.md).  
For Grafana workspaces that support Grafana version 9.x, see [Working in Grafana version 9](using-grafana-v9.md).  
For Grafana workspaces that support Grafana version 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

Traces visualizations let you follow a request as it traverses the services in your infrastructure. The traces visualization displays traces data in a diagram that allows you to easily interpret it.

For more information about traces and how to use them, refer to the following documentation:
+ [Tracing in Explore](v12-explore-tracing.md)
+ [Tempo data source](tempo-data-source.md)
+ [Getting started with Tempo](https://grafana.com/docs/tempo/latest/getting-started/) in the *Grafana Labs Tempo Documentation*.

## Adding a panel with tracing visualizations
<a name="v12-panels-traces-add"></a>

Once you have tracing data available in your Grafana stack, you can add tracing panels to your Grafana dashboards.

Using a dashboard variable, `traceID`, lets you create a query to show specific traces for a given trace ID. For more information about dashboard variables, refer to the [Variables documentation](v12-dash-variables.md). 

**Prerequisites**

Before you begin, you need:
+ An Amazon Managed Grafana workspace.
+ A [Tempo data source](tempo-data-source.md) connected to your workspace.

To view and analyze traces data in a dashboard, you need to add the traces visualization to your dashboard and define a query using the panel editor. The query determines the data that is displayed in the visualization. For more information on the panel editor, refer to the [Panel editor documentation](v12-panels-editor-overview.md).

This procedure uses dashboard variables and templates to allow you to enter trace IDs which can then be visualized. You’ll use a variable called `traceId` and add it as a template query.

**To add a traces visualization query**

1. In your workspace, create a new dashboard or go to an existing dashboard where you’d like to add traces visualizations.

1. Choose **Add visualization** from a new dashboard or choose **Add Panel** on an existing dashboard.

1. Select the appropriate tracing data source.

1. In the top-right of the panel editor, choose the **Visualizations** tab, and select **Traces**.

1. Under the **Panel options**, enter a **Title** for your trace panel. For more information on the panel editor, see [Configure panel options](v12-panels-configure-panel-options.md).

1. In the query editor, select the **TraceQL** query type tab.

1.  Enter `${traceId}` in the TraceQL query field to create a dashboard variable. This variable is used as the template query.

1. Choose **Apply** in the panel editor to add the panel to the dashboard.

1. Go to the dashboard **Settings** and add a new variable called `traceId`, of variable type **Custom**, giving it a label, if required. Choose **Apply** to add the variable to the dashboard.

1. Verify that the panel works by using a valid trace ID for the data source used for the trace panel and editing the ID in the dashboard variable.

## Adding TraceQL with table visualizations
<a name="v12-panels-traces-traceql"></a>

While you can add a trace visualization to a dashboard, having to manually add trace IDs as a dashboard variable is cumbersome. It’s more useful to instead be able to use TraceQL queries to search for specific types of traces and then select appropriate traces from matching results.

**Prerequisites**

This procedure assumes you have completed the previous procedure.

**To add TraceQL with table visualizations**

1. In the same dashboard where you added the trace visualization, choose **Add panel** to add a new visualization panel.

1. Select the same trace data source you used in the previous section.

1. In the top-right of the panel editor, select the **Visualizations** tab, then choose **Table**.

1. In the query editor, choose the **TraceQL** tab.

1. Under the **Panel options**, enter a **Title** for your trace panel.

1. Add an appropriate TraceQL query to search for traces that you would like to visualize in the dashboard. For example, here is a simple, static query from a server called *my-server*.

   ```
   { .service.name = "my-server" && .http.status_code=500 }
   ```

   You can write the TraceQL query as a template query to take advantage of other dashboard variables, if they exist. This lets you create dynamic queries based on these variables.

When results are returned from a query, the results are rendered in the panel’s table.

The results in the traces visualization include links to the **Explore** page that renders the trace. You can add other links to traces in the table that fill in the `traceId` dashboard variable when selected, so that the trace is visualized in the same dashboard.

To create a set of data links in the panel, use the following procedure.

**To use a variable to add other links to traces**

1. In the right-side menu, under **Data links**, choose **Add link**.

1. Add a **Title** for the data link.

1. Find the path to the dashboard by looking in your browser’s address bar when the full dashboard is being rendered. Because this is a link to a dashboard in the same Grafana stack, only the path of the dashboard is required.

   For example, if your path is:

   ```
   https://g-example.grafana-workspace.us-east-1.amazonaws.com/d/1234abcd5/my-dashboard?orgId=1
   ```

   Then the path to the dashboard is:

   ```
   /d/1234abcd5/my-dashboard?orgId=1
   ```

1. In the **URL** field, make a self-reference to the dashboard that contains both of the panels. This self-reference uses the value of the selected trace in the table to fill in the dashboard variable. Use the path for the dashboard from the previous step and then fill in the value of `traceId` using the selected results from the TraceQL table. The trace ID is exposed using the `traceID` data field in the returned results, so use that as the value for the dashboard variable. For example:

   ```
   /d/1234abcd5/my-dashboard?orgId=1&var-traceId=${__data.fields["traceID"]}
   ```

1. Choose **Save** to save the data link.

1. Choose **Apply** from the panel editor to apply the panel to the dashboard.

1. Save the dashboard.

You should now see a list of matching traces in the table visualization. While selecting the **TraceID** or **SpanID** fields will give you the option to either open the **Explore** page to visualize the trace or following the data link, selecting any other field (such as `Start time`, `Name`, or `Duration`) automatically follows the data link, filling in the `traceId` dashboard variable, and then shows the relevant trace in the trace panel. 

# Trend
<a name="v12-panels-trend"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 12.x**.  
For Grafana workspaces that support Grafana version 10.x, see [Working in Grafana version 10](using-grafana-v10.md).  
For Grafana workspaces that support Grafana version 9.x, see [Working in Grafana version 9](using-grafana-v9.md).  
For Grafana workspaces that support Grafana version 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

Trend visualizations should be used for datasets that have a sequential, numeric X that is not time. Some examples are function graphs, rpm/torque curves, supply/demand relationships, and elevation or heart rate plots along a race course (with x as distance or duration from start).

Trend visualizations support all visual styles and options available in the [time series visualization](v12-panels-time-series.md) with the following exceptions:
+ No annotations or time regions
+ No shared cursor (or crosshair)
+ No multi-timezone x axis
+ No ability to change the dashboard time range via drag-selection

**X Field selection**

Use this option to select a field that contains increasing numeric values.

 For example, you could represent engine power and torque versus speed where speed is plotted on the x axis and power and torque are plotted on the y axes.

# XY Chart
<a name="v12-panels-xychart"></a>

XY charts provide a way to visualize arbitrary x and y values in a graph so that you can easily show the relationship between two variables. XY charts are typically used to create scatter plots. you can also use them to create bubble charts, where field values determine the size of each bubble.

![\[An image showing an example of an XY chart visualization in Grafana.\]](http://docs.aws.amazon.com/grafana/latest/userguide/images/viz/xy-chart-example.png)


## Supported data formats
<a name="v12-panels-xychart-formats"></a>

You can use any type of tabular data with at least two numeric fields in an XY chart. This type of visualization doesn't require time data.

## Panel options
<a name="v12-panels-xychart-paneloptions"></a>

In the **Panel options** section of the panel editor pane, you set basic options like the panel title and description. You can also configure repeating panels in this section. For more information, see [Configure panel options](v12-panels-configure-panel-options.md).

## XY chart options
<a name="v12-panels-xychart-options"></a>

**Series mapping**

Set how series data is mapped in the chart.
+ **Auto** – Automatically generates series from all available data frames (or datasets). You can filter to select only one frame.
+ **Manual** – Explicitly define the series by selecting from available data frames.

Depending on your series mapping selection, the **Frame**, **X-field**, and **Y-field** options differ. The Auto and Manual series mapping sections describe these different options.

**Auto series mapping options**

When you select **Auto** as your series mapping mode, the following options are preconfigured, but you can also define them yourself.
+ **Frame** – By default an XY chart displays all data frames. You can filter to select only one frame.
+ **X-field** – Select which field X represents. By default,t his is the first number field in each data frame.
+ **Y-field** – After the X-field is set, by default, all the remaining number fields in the data frame are designated as the Y-fields. You can use this option to explicitly choose which fields to use for Y.

  The series of the chart are generated from the Y-fields. To make changes to a series in an XY chart, make overrides to the Y-field. Any field you use in the Size field or Color field doesn't generate a series.

  You can also use overrides to exclude Y-fields individually. To do so, add an override with the following properties for each Y-field you want removed:
  + Override type: **Fields with name**
  + Override property: **Series > Hide in area**
  + Area: **Viz**

**Manual series mapping options**

When you select **Manual** as your series mode, you can add, edit, and delete series. To manage a series, select the **Series** field. To rename the series, select the series name.

In **Manual** mode, you must set the following options:
+ **Frame** – Select your data frame or dataset. You can add as many frames as you want.
+ **X-field** – Select which field X represents.
+ **Y-field** – Select which field Y represents.

**Size field**

Use this option to set which field's values control the size of point in the chart. This value is relative to the min and max of all the values in the data frame.

When you select this option, you can then set the min and max point size options.

**Color field**

Use this option to set which field's values control the color of the points in the chart. To use the color value options under the **Standard options**, you must set this field.

Typically, this option is used when you only have one series displayed in the chart.

**Show**

Set how values are represented in the visualization.
+ **Points** – Display values as points. When you select this option, the point size option is also displayed.
+ **Lines** – Add a line between values. When you select this option, the line style and line width options are also displayed.
+ **Both** – Display both points and lines.

**Point size**

Sets the size of all point in the chart, from one to 100 pixels in diameter. The default size is five pixels. You can set an override to set the pixel size by series (Y-field).

**Min/Max point size**

Use these optinos to control the minimum or maximum point size when you've set the **Size field** option. You can override these options for specific series.

**Line style**

Set the style of the line. To change the color, use the standard color scheme field option.
+ **Solid** – Display a solid line. This is the default setting.
+ **Dash** – Display a dashed line. When you choose this option, a drop-down list is displayed where you can select the length and gap setting for the line dashes. By default, the length and gap are set to `10, 10`.
+ **Dots** – Display dotted lines. When you choose this option, a drop-down list is displayed where you can select dot spacing. By default, the dot spacing is set to `0, 10` (the first number represents dot length, and is always zero).

**Line width**

Sets the width of the lines, in pixels.

## Tooltip options
<a name="v12-panels-xychart-tooltipoptions"></a>

Tooltip options control the information overlay that appears when you hover over data points in the graph.

**Tooltip mode**
+ **Single** – The hover tooltip shows only a single series, the one that you are hovering over.
+ **Hidden** – Do not display the tooltip when you interact with the visualization.

Use an override to hide individual series from the tooltip.

**Max height**

Set the maximum height of the tooltip box. The defautl is 600 pixels.

## Legend options
<a name="v12-panels-xychart-legendoptions"></a>

Legend options control the series names and statistics that appear under or to the right of the graph. For more information about the legend, see [Configure a legend](v12-panels-configure-legend.md).

**Visibility**

Toggle the switch to turn the legend on or off.

**Mode**

Use these settings to define how the legend appears in your visualization.
+ **List** – Displays the legend as a list. This is the default display mode of a legend.
+ **Table** – Displays the legend as a table.

**Placement**

Choose where to display the legend.
+ **Bottom** – Below the graph.
+ **Right** – To the right of the graph.

**Values**

Choose which of the [standards calculations](v12-panels-calculation-types.md) to show in the legend. You can have more than one.

**Width**

Control how wide the legend is when place to the right side of the visualization. This option is only displayed if you set the legend placement to **Right**.

## Axis options
<a name="v12-panels-xychart-axis"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 12.x**.  
For Grafana workspaces that support Grafana version 10.x, see [Working in Grafana version 10](using-grafana-v10.md).  
For Grafana workspaces that support Grafana version 9.x, see [Working in Grafana version 9](using-grafana-v9.md).  
For Grafana workspaces that support Grafana version 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

Options under the axis category change how the x- and y-axes are rendered. Some options don't take effect until you click outside of the field option box you are editing. You can also press `Enter`.

**Placement (y-axis)**

Select the placement of the Y-axis. The options are:
+ **Auto** – 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 axes.

To selectively hide axes, [add a field override](v12-panels-configure-overrides.md) that targets specific fields.

**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.

**Show grid lines**

Set the axis grid line visibility.
+ **Auto** – Automatically show grid lines based on the density of the data.
+ **On** – Always show grid lines.
+ **Off** – Never show grid lines.

**Color**

Set the color of the axis.
+ **Text** – Set the color based on theme text color.
+ **Series** – Set the color based on the series color.

**Show border**

Set the axis border visibility.

**Scale**

Set how the y-axis values scale.
+ **Linear** – Divides the scale into equal parts.
+ **Logarithmic** – Use a logarithmic scale. When you select this option, a list appears for you to choose a binary (base 2) or common (base 10) logarithmic scale.
+ **Symlog** – Use a symmetrical logarithmic scale. When you select this option, a list appears for you to choose a binary (base 2) or common (base 10) logarithmic scale. The linear threshold option allows you to set the threshold at which the scale changes from linear to logarithmic.

*Centered zero*

Sets the y-axis to be centered on zero.

**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 can prevent small variations in the data from being magnified when it's mostly flat. In contrast, hard min and max values help prevent obscuring useful detail in the data by clipping intermittent spikes past a specific point.

To define hard limits of the y-axis, set standard min/max options. For more information, refer to [Configure standard options](v12-panels-configure-standard-options.md).

**Transform**

Use this option to transform the series values without affecting the values shown in the tooltip, context menus, or legend. 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.

**Note**  
The transform option is only available as an override.

**Display multiple y-axes**

There are some cases where you want to display multiple y-axes. For example, if you have a dataset showing both temperature and humidity over time, you could show two y-axes with different units for these two series.

To display multiple y-axes, [add a field override](v12-panels-configure-overrides.md#v12-panels-overrides-add-a-field). Follow the steps as many times as required to add as many y-axes as you need.

## Standard options
<a name="v12-panels-xychart-standard"></a>

**Standard options** in the panel editor let you change how field data is displayed in your visualization. When you set a standard option, the change is applied to all fields or series. For more granular control over the display of fields, refer to [Configure field overrides](v12-panels-configure-overrides.md).

You can cusotmize the following standard options:
+ **Field min/max** – Enable **Field min/max** to have Grafana calculate the min or max of each field individually, based on the minimum or maximum value of the field.
+ **Color scheme** – Set single or multiple colors for your entire visualization.

For more information, see [Configure standard options](v12-panels-configure-standard-options.md).

## Data links
<a name="v12-panels-xychart-datalinks"></a>

Data links allow you to link to other panels, dashboards, and external resources while maintaining the context of the source panel. You can create links that include the series name or even the value under the cursor.

For each data link, set the following options:
+ **Title**
+ **URL**
+ **Open in new tab**

For more information, see [Configure data links](v12-panels-configure-data-links.md).

## Field overrides
<a name="v12-panels-xychart-fieldoverrides"></a>

Overrides allow you to customize visualization settings for specific fields or series. When you add an override rule, you can target a particular set of fields and define multiple options for how those fields are displayed.

Choose from one of the following override options:
+ **Fields with name** – Select a field from the list of all available fields.
+ **Fields with name matching regex** – Specify fields to override with a regular expression.
+ **Fields with type** – Select fields by type, such as string, numeric, or time.
+ **Fields returned by query** – Select all fields returned by a specific query.
+ **Fields with values** – Select all fields returned by your defined reducer condition, such as **Min**, **Max**, **Count**, or **Total**.

For more information, see [Configure field overrides](v12-panels-configure-overrides.md).

# Explore in Grafana version 12
<a name="v12-explore"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 12.x**.  
For Grafana workspaces that support Grafana version 10.x, see [Working in Grafana version 10](using-grafana-v10.md).  
For Grafana workspaces that support Grafana version 9.x, see [Working in Grafana version 9](using-grafana-v9.md).  
For Grafana workspaces that support Grafana version 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

Grafana’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.

This page will get you started exploring your data. The following topics give you more details on specific features and uses for Explore.
+ [Query management in Explore](v12-explore-manage.md)
+ [Logs in Explore](v12-explore-logs.md)
+ [Tracing in Explore](v12-explore-tracing.md)
+ [Correlations editor in Explore](v12-explore-correlations.md)
+ [Inspector in Explore](v12-explore-inspector.md)

## Start exploring
<a name="v12-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.

   You can also choose **Open advanced data source picker** to see more options, including adding a data source (for Admins only).

1. Write the querying using the query editor provided by the selected data source.

   For more details about queries, see [Query and transform data](v12-panels-query-xform.md).

1. Run the query using the button in the top right corner.

## Split and compare
<a name="v12-explore-compare"></a>

The split view provides an easy way to compare visualizations side-by-side or to look at related data together on one page.

**Top open the 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, choose the **Close Split** button.

## Content outline
<a name="v12-explore-outline"></a>

The content outline is a side navigation bar that keeps track of the queries and visualizations you created in Explore. It allows you to navigate between them quickly.

The content outline also works in a split view. When you are in split view, the content outline is generated for each pane.

**To open the content outline**

1. Select the **Outline** button in the top left corner of the **Explore** screen.

1. Select any panel icon in the content outline to navigate to that panel.

## Share Explore URLs
<a name="v12-explore-shareurl"></a>

When using Explore, the URL in the browser address bar updates as you make changes to the queries. You can share or bookmark this URL.

**Note**  
Explore may generate relatively long URLs. You can also generate and share a [shortened link](#v12-explore-share) if the URL is too long for your tools.

**Generating Explore URLs from external tools**

Because Explore URLs have a defined structure, you can build a URL from external tools and open it in Grafana. The url structure is:

```
http://<workspace_url>/explore?panes=<panes>&schemaVersion=<schema_version>&orgId=<org_id>
```

where:
+ `org_id` is the organization ID
+ `schema_version` is the schema version (should be set to the latest version, which is `1`.
+ `panes` is a url-encoded JSON object of panes, where each key is the pane ID and each value is an object matching the following schema:

  ```
  {
    datasource: string; // the pane's root datasource UID, or `-- Mixed --` for mixed datasources
    queries: {
      refId: string; // an alphanumeric identifier for this query, must be unique within the pane, i.e. "A", "B", "C", etc.
      datasource: {
        uid: string; // the query's datasource UID ie: "AD7864H6422"
        type: string; // the query's datasource type-id, i.e: "loki"
      }
      // ... any other datasource-specific query parameters
    }[]; // array of queries for this pane
    range: {
      from: string; // the start time, in milliseconds since epoch
      to: string; // the end time, in milliseconds since epoch
    }
  }
  ```
**Note**  
The `from` and `to` fields also accept relative ranges as described in the [Setting dashboard time range](v12-dash-using-dashboards.md#v12-dash-setting-dashboard-time-range) topic.

## Share shortened link
<a name="v12-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. If a link is used at least once, it won't get deleted.

**Sharing shortened links with absolute time**

Short links have two options: keeping relative time (for example, from two hours ago to the current time) or absolute time (for example, from 8am to 10am). Sharing a shortened link by default will copy the time range selected, relative or absolute. Choosing the dropdown button next to the share shortened link button and selecting one of the options under **Time-Sync URL Links** will allow you to create a short link with the absolute time, meaning anyone receiving the link will see the same data you are seeing, even if they open the link at another time. This option will not affect the time range selected in your Explore view.

# Query management in Explore
<a name="v12-explore-manage"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 12.x**.  
For Grafana workspaces that support Grafana version 10.x, see [Working in Grafana version 10](using-grafana-v10.md).  
For Grafana workspaces that support Grafana version 9.x, see [Working in Grafana version 9](using-grafana-v9.md).  
For Grafana workspaces that support Grafana version 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

You can manage the queries that you have created in Explore, including a history of queries that you have run, and queries that you have starred.

## Query history
<a name="v12-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
<a name="v12-explore-manage-history-view"></a>

Query history lets you view the history of your querying. For each individual query, you can:
+ Run the 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
<a name="v12-explore-manage-history-favorites"></a>

All queries that have been starred in the Query history tab are displayed in the Starred tab. This allows you to access your favorite queries faster and to reuse these queries without typing them from scratch.

## Sorting query history
<a name="v12-explore-manage-history-sort"></a>

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
<a name="v12-explore-manage-history-filter"></a>

You can filter your query history in Query history and Starred tab to a specific data source.

**To filter 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.

**Note**  
Queries ran using the Mixed data source will appear only when filtering for Mixed, and not when filtering by their individual 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 bottom handle.
+ Adjust the end date by dragging the top handle.

## Searching in query history
<a name="v12-explore-manage-history-search"></a>

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
<a name="v12-explore-manage-history-settings"></a>

You can customize the query history in the Settings tab. Options are described in the following table.


| 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.

# Logs in Explore
<a name="v12-explore-logs"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 12.x**.  
For Grafana workspaces that support Grafana version 10.x, see [Working in Grafana version 10](using-grafana-v10.md).  
For Grafana workspaces that support Grafana version 9.x, see [Working in Grafana version 9](using-grafana-v9.md).  
For Grafana workspaces that support Grafana version 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

Explore allows you to investigate your logs in different data sources, including:
+ [OpenSearch](using-opensearch-in-AMG.md)
+ [Amazon CloudWatch](using-amazon-cloudwatch-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 logs with other telemetry signals such as metrics, traces, or profiles, by viewing them side-by-side.

The results of log queries are displayed as individual log lines and as a graph showing the logs volume for the selected time period.

## Logs volume
<a name="v12-explore-logs-volume"></a>

When working with data sources that support a full range logs volume, Explore automatically displays a graph showing the log distribution for all the entered log queries. This feature is currently supported by OpenSearch and Loki data sources.

**Note**  
In Loki, this full range log volume is rendered by a metric query which can be expensive depending on the time range queried. This query can be particularly challenging to process for smaller Loki installations. To mitigate this, you can use a proxy like [nginx](https://www.nginx.com/) in front of Loki to set a custom timeout (for example, 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 the full range logs volume, the logs model calculates a time series by counting log rows and organizing them into buckets based on an automatically calculated time interval. The timestamp of the first log row is used to anchor the start of the logs volume in the results. The end of the time series is anchored to the time picker’s **To** range. This way, you can still analyze and visualize log data efficiently even when the data source doesn’t offer full range support.

## Logs
<a name="v12-explore-logs-overview"></a>

In the following sections, you will find detailed explanations of how to visualize and interact with individual logs in Explore.

## Logs navigation
<a name="v12-explore-logs-navigation"></a>

Logs navigation, at the right side of the log lines, can be used to easily request additional logs. You can do this by clicking the **Older logs** button at the bottom of the navigation. This is especially useful when you reach the line limit and you want to see more logs. Each request that is run from the navigation is then displayed in the navigation as separate page. Every page shows `from` and `to` timestamps of the incoming log lines. You can see previous results by clicking on each page. Explore caches the last five requests run from the logs navigation, so you’re not re-running the same queries when clicking on the pages, saving time and resources.

## Visualization options
<a name="v12-explore-log-visualization-options"></a>

 You can customize how logs are displayed and select which columns are shown. 


| Option | Description | 
| --- | --- | 
| 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 matches are done on the whole line except for date fields. Numbers matches are done on the line after stripping out numbers such as durations, IP addresses, and so on. Signature is the most aggressive deduplication as it strips all letters and numbers and matches on the remaining whitespace and punctuation. | 
| Display results order | You can change the order of received logs from the default descending order (newest first) to ascending order (oldest first). | 

## Download log lines
<a name="v12-explore-download-log-lines"></a>

To download log results in either `txt` or `json` format, use the **Download** button. This feature allows you to save the log data for further analysis or to share it with others in a convenient and accessible format.

## Log result meta information
<a name="v12-explore-log-result-meta-information"></a>

Above the received log lines you can find essential meta information, including:
+ **Number of received logs** – Indicates the total count of logs received for the current query or time range.
+ **Error** – Displays possible error in your log results.
+ **Common labels** – Shows common labels.
+ **Total bytes processed** – Represents the cumulative size of the log data processed in bytes.

**Note**  
The availability of certain meta information may depend on the data source, and as a result, you may only see some of these details for specific data sources.

## Escaping newlines
<a name="v12-explore-log-escaping-newlines"></a>

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.

**To automatically fix incorrectly escaped sequences that Explore has detected**

1. Choose **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 may not be accurate based on the input received. You can revert the replacements by selecting **Remove escaping**.

## Log level
<a name="v12-explore-log-level"></a>

For the logs where a `level` label is specified, we use the value of this label to determine the log level and update color of each log line accordingly. If the log doesn’t have specified level label, we try to find out if its content matches any of the supported expressions (see the following table for more information). The log level is always determined by the first match. In the case where Grafana is not able to infer a log level field, it will be visualized with an unknown log level.

**Note**  
If you use a Loki data source and the `level` is part of your log line, you can use parsers (JSON, logfmt, regex,..) to extract the level information into a level label that is used to determine the level value. This will allow the histogram to show the various log levels as separate bars.

**Supported log levels and mapping of log level abbreviation and expressions:** 


| Log level | Color | Supported expressions | 
| --- | --- | --- | 
| critical | purple | emerg, fatal, alert, crit, critical | 
| error | red | err, eror, error | 
| warning | yellow | warn, warning | 
| info | green | info, information, informational, notice | 
| debug | blue | dbug, debug | 
| trace | light blue | trace | 
| unknown | grey | \$1 | 

## Highlight searched words
<a name="v12-explore-highlight-searched-words"></a>

When your query includes specific words or expressions to search for, Explore will highlight these in the log lines for better visibility. This highlighting feature makes it easier to identify and focus on the relevant content in your logs.

**Note**  
The ability to highlight search words may vary depending on the data source. For some data sources, the highlighting of search words may not be available.

## Log details view
<a name="v12-explore-log-details-view"></a>

In Explore, each log line has an expandable section called *Log details* that can be opened by choosing the log line. The Log details view provides additional information and exploration options in the form of *Fields* and *Links* attached to the log lines, enabling a more robust interaction and analysis.

**Fields**

Within the Log details view, you can filter displayed fields in two ways: a positive filter (to focus on an specific field) and a negative filter (to exclude certain fields). These filters will update the corresponding query that produced the log line, adding equality and inequality expressions accordingly. If the data source has support, as is the case for Loki and OpenSearch, log details will check if the field is already present in the current query showing and active state (for positive filters only), allowing you to toggle it off the query, or changing the filter expression from positive to negative.

You can select a subset of fields to visualize in the logs list instead of the complete log line by clicking on the eye icon. Each field has a stats icon to display statistics in relation to all displayed logs.

**Links**

Grafana offers the functionality of data links or correlations, enabling you to convert any part of a log message into an internal or external link. These links can be used to navigate to related data or external resources, providing a seamless and convenient way to explore further information.

## Log context
<a name="v12-explore-log-context"></a>

Log context displays additional lines of context surrounding a log entry that matches a particular search query. This can be helpful in understanding the log entry’s context, and is similar to the `-C` parameter in the `grep` command.

You may encounter long lines of text that make it difficult to read and analyze the context around each log entry. This is where the **Wrap lines** toggle can come in handy. By enabling this toggle, Grafana will automatically wrap long lines of text so that they fit within the visible width of the viewer. This can make it easier to read and understand the log entries. 

 The **Open in split view** button allows you to execute the context query for a log entry in a split screen in the Explore view. Choosing this button will open a new Explore pane with the context query displayed alongside the log entry, making it easier to analyze and understand the surrounding context.

The log context query can also be opened in a new browser tab by pressing the `Ctrl` (or `Cmd`) key while choosing the button to open the context modal. When opened in a new tab, the previously selected filters are applied as well.

## Copy log line
<a name="v12-explore-copy-log-line"></a>

You can easily copy the content of a selected log line to your clipboard by choosing the **Copy log line** button.

## Copy link to log line
<a name="v12-explore-copy-link-to-log-line"></a>

Linking of log lines in Grafana allows you to quickly navigate to specific log entries for precise analysis. By choosing the **Copy shortlink** button for a log line, you can generate and copy a short URL that provides direct access to the exact log entry within an absolute time range. When you open the link, Grafana will automatically scroll to the corresponding log line and highlight it with a blue background, making it easy to identify and focus on the relevant information.

**Note**  
This is only supported in Loki and other data sources that provide an `id` field.

## Live tailing
<a name="v12-explore-log-live-tailing"></a>

To view real-time logs from supported data sources, you can leverage the Live tailing feature in Explore.

**To view logs in real-time with live tailing**

1. Choose the **Live** button in the Explore toolbar to switch to Live tail view.

1. While in Live tail view, new logs will appear from the bottom of the screen, and they will have a fading contrasting background, allowing you to easily track what’s new.

1. If you wish to pause the Live tailing and explore previous logs without any interruptions, you can do so by choosing the **Pause** button or simply scrolling through the logs view.

1. To clear the view and remove all logs from the display, choose the **Clear logs** button. This action will reset the log view and provide you with a clean slate to continue your log analysis.

1. To resume Live tailing and continue viewing real-time logs, choose the **Resume** button.

1. If you want to exit Live tailing and return to the standard Explore view, choose the **Stop** button.

Using the Live tailing feature, you can keep a close eye on the latest logs as they come in, making it easier to monitor real-time events and detect issues promptly.

**Logs sample**

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.

**Switch from metrics to logs**

 If you are coming from a metrics data source that implements `DataSourceWithQueryExportSupport` (such as Prometheus) to a logging data source that supports `DataSourceWithQueryImportSupport` (such as Loki), then it will keep the labels from your query that exist in the logs and use those to query the log streams.

For example, the following Prometheus query `grafana_alerting_active_alerts{job='grafana'}` after switching to the Loki data source, will change to `{job='grafana'}`. This will return a chunk of logs in the selected time range that can be grepped/text searched.

# Tracing in Explore
<a name="v12-explore-tracing"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 12.x**.  
For Grafana workspaces that support Grafana version 10.x, see [Working in Grafana version 10](using-grafana-v10.md).  
For Grafana workspaces that support Grafana version 9.x, see [Working in Grafana version 9](using-grafana-v9.md).  
For Grafana workspaces that support Grafana version 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

You can use Explore to visualize traces from tracing data sources.

The following data sources are supported.
+ [Tempo](tempo-data-source.md) (supported ingestion formats: OpenTelemetry, Jaeger, and Zipkin)
+ [Jaeger](jaeger-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.

## Query editor
<a name="v12-explore-trace-queryeditor"></a>

You can query and search tracing data using a data source's query editor.

Each data source can have its own query editor. The query editor for the Tempo data source is slightly different than the query editor for the Jaeger data source.

For information on querying each data source, refer to their documentation.
+ [Tempo](tempo-data-source.md)
+ [Jaeger](jaeger-data-source.md)
+ [AWS X-Ray](x-ray-data-source.md)
+ [Zipkin](zipkin-data-source.md)

## Trace View explanation
<a name="v12-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 the **Reset Selection** button which resets the zoom.

**Span filters**

Using span filters, you can filter your spans in teh trace timeline viewer. The more filters you add, the more specific are the filtered spans.

You can add one or more of the following filters:
+ Resource service name
+ Span name
+ Duration
+ Tags (which include tags, process tags, and log fields)

To show only the spans you have matched, choose the **Show matches only** toggle.

**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 the selected span.
+ Service name – Name of the service that 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**

Choosing 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.

**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.

Choose the document icon to open a split view in Explore with the configured data source and query relevant logs for the span.

**Trace to metrics**

**Note**  
This feature is currently in beta

You can navigate form a span in a trace view directly to metrics relevant for that span. This feature is available for Tempo, Jaeger, and Zipkin data sources. Refer to their relevant documentation for details on configuration.

**Trace to profiles**

Using Trace to profiles, you can use Grafana's ability to correlate different signales by adding the functionality to link between traces and profiles.

## Node graph
<a name="v12-explore-trace-node-graph"></a>

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.

## Service Graph view
<a name="v12-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 *Grafana Labs Tempo documentation*.

## Data API
<a name="v12-explore-trace-dataapi"></a>

This visualization needs a specific shape of the data to be returned from the data source in order to correctly display it.

The data source needs to return data frame and set `frame.meta.preferredVisualisationType = 'trace'`.

**Data frame structure**

Required fields;


| Field name | Type | Description | 
| --- | --- | --- | 
| traceID | string | Identifier for the entire trace. There should be only one trace in the data frame. | 
| spanID | string | Identifier for the current span. SpanIDs should be unique per trace. | 
| parentSpanID | string | SpanID of the parent span to create child parent relationship in the trace view. Can be undefined for root span without a parent. | 
| serviceName | string | Name of the service this span is part of. | 
| serviceTags | TraceKeyValuePair[] | List of tags relevant for the service. | 
| startTime | number | Start time of the span in millisecond epoch time. | 
| duration | number | Duration of the span in milliseconds. | 

 Optional fields: 


| Field name | Type | Description | 
| --- | --- | --- | 
| logs | TraceLog[] | List of logs associated with the current span. | 
| tags | TraceKeyValuePair[] | List of tags associated with the current span. | 
| warnings | string[] | List of warnings associated with the current span. | 
| stackTraces | string[] | List of stack traces associated with the current span. | 
| errorIconColor | string | Color of the error icon in case span is tagged with error: true. | 

For details about the types see [TraceSpanRow](https://github.com/grafana/grafana/blob/main/packages/grafana-data/src/types/trace.ts#L28), [TraceKeyValuePair](https://github.com/grafana/grafana/blob/main/packages/grafana-data/src/types/trace.ts#L4) and [TraceLog](https://github.com/grafana/grafana/blob/main/packages/grafana-data/src/types/trace.ts#L12) on GitHub.

# Correlations editor in Explore
<a name="v12-explore-correlations"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 12.x**.  
For Grafana workspaces that support Grafana version 10.x, see [Working in Grafana version 10](using-grafana-v10.md).  
For Grafana workspaces that support Grafana version 9.x, see [Working in Grafana version 9](using-grafana-v9.md).  
For Grafana workspaces that support Grafana version 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

Correlations allow users to build a link between any two data sources. For more information, including an overview of correlations, see [Correlations in Grafana version 12](v12-correlations.md).

## Creating a correlation
<a name="v12-explore-corr-create-a-correlation"></a>

You can create correlations from the Explore page.

**To create a correlation**

1. In your Amazon Managed Grafana workspace, navigate to the Explore page.

1. Select a data source that you would like to be the source for a new correlation.

1. Run a query producing data in a supported visualization.
**Note**  
Supported visualizations are [Logs](v12-panels-logs.md) and [Table](v12-panels-table.md).

1. Choose **\$1 Add** in the top toolbar and select **Add correlation** (you can also select **Correlations Editor** from the [Command Palette](v12-search.md#v12-search-palette).

   Explore is now in Correlations Editor mode indicated by a blue border and top bar. You can exit Correlations Editor by choosing **Exit** in the top bar.

1. You can now create the following new correlations for the visualization with links that are attached to the data that you can use to build a new query:
   + *Logs* – links are displayed next to field values inside log details for each log row.
   + *Table* – every table cell is a link.

1. Choose a link to add a new correlation. Links are associated with a field that is used as a result field of a correlation. For more details, see [Correlation configuration](v12-correlations-config.md).

1. In the split view that opens, use the right pane to set up the target query source of the correlation. For more details, see [Target query](v12-correlations-config.md#v12-correlations-config-target-query).

1. Build a target query using [variables syntax](v12-dash-variable-syntax.md) with variables from the list provided at the top of the pane. The list contains sample values from the selected data row.

1. Provide a label and description (optional). A label will be used as the name of the link inside the visualization and can contain variables.

1. Provide transformations (optional; see below for details).

1. Choose **Save** in the top toolbar to save the correlation and exit Correlations Editor mode. The link used to create the correlation is replaced with a data link in each row. When the link is selected, the query you defined will run in another pane, with the variables replaced dynamically with the values from the selected row.

## Transformations
<a name="v12-explore-corr-transformations"></a>

Transformations allow you to extract values that exist in a field with other data. For example, using a transformation, you can extract one portion of a log line to use in a correlation. For more details on transformations in correlations, see [Correlation Transformations](v12-correlations-config.md#v12-correlations-config-transformations).

After choosing one of the generated links in the editor mode, you can add transformations by selecting **Add transformation** in the **Transformations** dropdown menu.

**To use a transformation in a correlation**

1. Select a field to apply the transformation to. Select the portion of the field that you want to use for the transformation. For example, a log line. Once selected, the value of this field will be used to assist you in building the transformation.

1. Select the type of the transformation. See [Correlation Transformations](v12-correlations-config.md#v12-correlations-config-transformations) for the options and relevant settings. 

1. Based on your selection, you might see one or more variables populate, or you might need to provide more specifications in options that are displayed.

1. Select **Add transformation to correlation** to add the specified variables to the list of available variables.

**Note**  
For regular expressions in this dialog box, the `mapValue` referred to in other documentation is called `Variable Name` here. Grafana highlights any text that matches the expression in the field value. Use regular expression capture groups to select what portion of the match should be extracted. When a valid regular expression is provided, the variable and the value of that variable appear below the `Variable Name` field.

## Correlations examples
<a name="v12-explore-corr-examples"></a>

The following examples show how to create correlations using the Correlations Editor in Explore. If you’d like to follow these examples, make sure to set up a [test data source](testdata-data-source.md).

### Creating a text to graph correlation
<a name="v12-explore-corr-text-to-graph"></a>

This example shows how to create a correlation using Correlations Editor in Explore.

Correlations allow you to use results of one query to run a new query in any data source. In this example, you will run a query that renders tabular data. The data will be used to run a different query that yields a graph result.

To follow this example, make sure you have set up a [test data source](testdata-data-source.md).

**To create a text to graph correlation**

1. In Grafana, navigate to **Explore**.

1. Select the **test data source** from the dropdown menu at the top left of the page.

1. Choose **\$1 Add** in the dropdown menu to the right and select **Add correlation**.

1. Explore is now in Correlations Editor mode, indicated by a blue border.

1. Select the following scenario from the scenario dropdown menu: **CSV File**.

1. Select the file, **population\$1by\$1state.csv**. Each cell is a link that you can click on to begin creating a new correlation.

1. Click on any cell in the `State` column to create a new correlation that attaches a data link to that entry. For example, select `California`.

1. In the split view, select the same data source you selected in the left pane. The helper above the query editor contains all available variables you can use the target query. Variables contain all data fields (table columns) from the selected row.

1. In the **Scenario** menu, select **CSV Metric Values**. The `String Input` field in the Query editor provides variables with population values for each year: `${1980},${2000},${2020}`. This will generate a graph using variable values.

1. In the Query Editor **Alias** field, enter `${State}`.

   Run a query to see that it produces a graph using sample values from the variables.

1. Choose **Save** to save the correlation and exit the Correlations Editor.

   After the correlation is saved, Explore will rerun the query in the left pane. By clicking a state name, the query on the right is rerun with values from the row being inserted into the CSV, thus changing the graph. The query is rerun with updated values every time you click on a state name.

You can apply the same steps to any data source. Correlations allow you to create links in visualizations to run dynamic queries based on selected data. In this example we used data returned by a query to build a new query generating different visualization using the same data source. However, you can create correlations between any data sources to create custom exploration flows.

### Creating a logs to table correlation
<a name="v12-explore-corr-logs-to-table"></a>

In this example, you will create a correlation to demonstrate how to use transformations to extract values from the log line and another field.

To follow this example, make sure you have set up a [test data source](testdata-data-source.md).

**To create a logs to table correlation**

1. In Grafana, navigate to **Explore**.

1. Select the **test data source** from the dropdown menu at the top left of the page.

1. Choose **\$1 Add** in the dropdown menu to the right and select **Add correlation**.

1. Explore is now in Correlations Editor mode, indicated by a blue border.

1. In the **Scenario** menu, select **Logs**.

1. Expand a log line to see the correlation links. Select `Correlate with hostname`.

1. Explore opens in split view. Select the same data source you selected in the left pane. The helper above the query editor contains all available variables you can use the target query.

1. Expand the transformations section, and click **Add transformation**.

1. In the **Field** dropdown menu, select **message**. The log line shows up as example data.

1. Under **Type**, select **Logfmt**. This populates the list of variables.

1. Choose **Add transformation to correlation**.

1. Choose **Add transformation** again and under **Field**, select **hostname**.

1. Under **Type**, select **Regular expression**.

1. Under **Expression**, enter the following: `-([0-9]\*)`. This selects any numbers to the right of the dash.

1. Under **Variable Name**, enter the following: `hostNumber`. This populates the list of variables. 

1. Choose **Add transformation to correlation** to add it to the other variables.

1. In the data source editor, open the **Scenario** dropdown menu and select **CSV Content**.

1. In the text box below, provide the following and save the correlation:

   ```
   time,msg,hostNumber,status
   ${time},${msg},${hostNumber},${status}
   ```

   This closes the split view and reruns the left query. Expand any log line to see the correlation button. Chooseing the correlation button opens the split view with the `time` (a field), `msg` (extracted with *logfmt* from the log line), `host number` (extracted with *regex* from the `hostname`) and the `status` (extracted with *logfmt* from the log line).

# Inspector in Explore
<a name="v12-explore-inspector"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 12.x**.  
For Grafana workspaces that support Grafana version 10.x, see [Working in Grafana version 10](using-grafana-v10.md).  
For Grafana workspaces that support Grafana version 9.x, see [Working in Grafana version 9](using-grafana-v9.md).  
For Grafana workspaces that support Grafana version 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

The 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="v12-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="v12-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**

Grafana generates a CSV file in your default browser download location. You can open it in the viewer of your choice.

1. In the **Inspector** tab, get raw query results by following the instructions above.

1. Refine the query settings until you can see the raw data that you want to export.

1. Choose **Download CSV**.

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 generates a JSON file for the trace results in one of the supported formats: Jaeger, Zipkin, or OTLP formats.

1. Open the Inspector.

1. Inspect the log query results. Refine the results until you see the raw logs that you want to export.

1. Choose **Download logs**.

**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 displayed in read-only format.

**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.

# Correlations in Grafana version 12
<a name="v12-correlations"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 12.x**.  
For Grafana workspaces that support Grafana version 10.x, see [Working in Grafana version 10](using-grafana-v10.md).  
For Grafana workspaces that support Grafana version 9.x, see [Working in Grafana version 9](using-grafana-v9.md).  
For Grafana workspaces that support Grafana version 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

You can create interactive links for Explore visualizations to run queries related to presented data by setting up Correlations.

A correlation defines how data in one data source is used to query data in another data source. Some examples:
+ An application name returned in a logs data source can be used to query metrics related to that application in a metrics data source.
+ A user name returned by an SQL data source can be used to query logs related to that particular user in a logs data source.

Explore takes user-defined correlations to display links inside the visualizations. You can click on a link to run the related query and see results in Explore Split View.

Explore visualizations that currently support showing links based on correlations:
+ [Logs](v12-panels-logs.md)
+ [Table](v12-panels-table.md)

You can configure correlations using the **Administration > Plugins and data > Correlations** page in Grafana or directly in [Explore](v12-explore-correlations.md).

**Topics**
+ [

# Correlation configuration
](v12-correlations-config.md)
+ [

# Create a new correlation
](v12-correlations-create.md)

# Correlation configuration
<a name="v12-correlations-config"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 12.x**.  
For Grafana workspaces that support Grafana version 10.x, see [Working in Grafana version 10](using-grafana-v10.md).  
For Grafana workspaces that support Grafana version 9.x, see [Working in Grafana version 9](using-grafana-v9.md).  
For Grafana workspaces that support Grafana version 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

 Each correlation is configured with the following options: 

**Label**  
Link label, shown in the visualization.

**Description**  
Optional description.

**Source data source**  
The source of results that have links displayed.

**Results field**  
Defines where the link is shown in a visualization.

**Target query**  
The target query run when a link is clicked.

**Transformations**  
Optional manipulations to the source data included passed to the target query.

For details about creating a correlation, see [Create a correlation](v12-correlations-create.md).

## Source data source and result field
<a name="v12-correlations-config-source-and-result"></a>

Links are shown in Explore visualizations for the results from the correlation’s source data source. A link is assigned to one of the fields from the result provided in the correlation configuration (the results field). Each visualization displays fields with links in a different way. 

## Target query
<a name="v12-correlations-config-target-query"></a>

The target query is run when a link is clicked in the visualization. You can use the query editor of the selected target data source to specify the target query. Source data results can be accessed inside the target query with variables.

### Correlation Variables
<a name="v12-correlations-config-variables"></a>

You can use variables inside the target query to access the source data related to the query. Correlations use [Grafana variable syntax](v12-dash-variable-syntax.md). Variables are filled with values from the source results when the link is chosen. There are two types of variables you can use:
+ [Field variables](v12-panels-configure-data-links.md#v12-panels-data-link-variables) (to access field values and labels).
+ Correlation variables (to access field values and transformations).

Example: If source results contain a field called `employee`, the value of the field can be accessed with:
+ A field variable `${__data.fields.employee}`.
+ A correlation variable that maps the field value above to `${employee}`.

In addition to mapping field values to shorter variable names, more correlation variables can be created by applying transformations to existing fields.

Correlation creates a data link only if all variables have values in the selected data row. [Global variables](v12-dash-variable-add.md#v12-dash-variable-add-global) are the exception to this rule and are not required to be filled in from the returned data. These variables are interpolated automatically by data sources.

### Correlation Transformations
<a name="v12-correlations-config-transformations"></a>

Transformations provide a way to extract more variables out of field values. The output of transformations is a set of new variables that can be accessed as any other variable.

There are two types of transformations: logfmt and regular expression.

Each transformation uses a selected field value as the input. The output of a transformation is a set of new variables based on the type and options of the transformation.

### Logfmt transformation
<a name="v12-correlations-config-logfmt-transformation"></a>

The logfmt transformation deconstructs a field value containing text formatted with [logfmt key/value pairs](https://brandur.org/logfmt). Each pair becomes a variable with the key being the name of the variable.

The logfmt transformation only requires specifying the input field name if you would like the transformation to apply to a different field than the results field. Example output variables for `field = "host=srv001 endpoint=/test app=foo"`:


| name | value | 
| --- | --- | 
| host | srv001 | 
| endpoint | /test | 
| app | foo | 

### Regular expression transformation
<a name="v12-correlations-config-regular-expression-transformation"></a>

The regular expression transformation deconstructs a field value based on the provided regular expression.

Regular expression transformation options:

**field**  
Input field name

**expression**  
Regular expression. Named capture groups are mapped to variables matching the group name. If non-named matching groups are used a variable is created out of the first match. The value overrides the variable matching the input field or a new variable is created if mapValue is provided (see examples in the following table).

**mapValue**  
Used with simple regex groups without named matching groups. By default, the first match overrides the variable with the name of the field that is used as the input. To change that default behavior you can specify the mapValue property. The provided name is used to create a new variable. This can be useful if your target query requires both the exact value and a part of the value extracted with the transformation.

Example: Assuming the selected field name is `employee` and the field value is `John Doe`.

Various output variables based on expression and mapValue options:


| expression | mapValue | output variables | comment | 
| --- | --- | --- | --- | 
| /\$1w\$1 (\$1w\$1)/ | - | employee=Doe | No mapValue provided. The first matching is mapped to the existing field name variable (employee). | 
| /(\$1w\$1) (\$1w\$1)/ | name | name=John | The first matching is mapped to a new variable called name.  | 
| /(?\$1w\$1) (?\$1w\$1)/ | - | firstName=John, lastName=Doe | When named groups are used they are the names of the output variables and mapValue is ignored. | 
| /(?\$1w\$1) (?\$1w\$1)/ | name | firstName=John, lastName=Doe | Same as above | 

# Create a new correlation
<a name="v12-correlations-create"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 12.x**.  
For Grafana workspaces that support Grafana version 10.x, see [Working in Grafana version 10](using-grafana-v10.md).  
For Grafana workspaces that support Grafana version 9.x, see [Working in Grafana version 9](using-grafana-v9.md).  
For Grafana workspaces that support Grafana version 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

You can create correlations in the Explore correlations editor, or using the Grafana **Administration** page in your Amazon Managed Grafana workspace.

**Prerequisites**

You must have permission to add new correlations. Only users with write permissions to data sources can define new correlations.

## Creating a correlation in Explore’s correlations editor
<a name="v12-correlations-create-explore"></a>

You can create a correlation in the Explore correlation editor. For more details, see [Creating a correlation](v12-explore-correlations.md#v12-explore-corr-create-a-correlation).

## Creating a correlation in the Administration page
<a name="v12-correlations-create-administration"></a>

You can use the Grafana console **Administration** page to create a correlation.

**To create a correlation in the Administration page**

1. Go to the **Administration** section in Grafana.

1. Under **Plugins and data**, open the **Correlations** page.

1. Choose the **Add** button in the top right corner.

1. Provide a **label** for the correlation.

1. (Optional) Provide an **description**.

1. Go to the next page.

1. Provide **target data source**.

1. Provide **target query** using variables.

1. Go to the next page.

1. Provide **source data source**.

1. Provide **results field**.

1. Add transformations if you need variables that are not fields in the source data source.

1. Choose **Add** to add a new transformation.

1. Select the type of a transformation.

1. Configure transformation depending on the selected type.

1. Save the correlation.

You can edit a correlation in the same way, but when editing, you can't change the selected data sources.

# Alerts in Grafana version 12
<a name="v12-alerts"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 12.x**.  
For Grafana workspaces that support Grafana version 10.x, see [Working in Grafana version 10](using-grafana-v10.md).  
For Grafana workspaces that support Grafana version 9.x, see [Working in Grafana version 9](using-grafana-v9.md).  
For Grafana workspaces that support Grafana version 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

With Grafana v12, Amazon Managed Grafana includes access to an updated alerting system, *Grafana alerting*, that centralizes alerting information in a single, searchable view. Grafana alerting was introduced as an optional feature in Grafana v8, and GrafanaLabs has announced the removal of legacy alerting in version 11.

**Note**  
This documentation covers Grafana alerting. For information on legacy alerting, see [Classic dashboard alerts](old-alerts-overview.md).

Grafana Alerting allows you to learn about problems in your systems moments after they occur.

Monitor your incoming metrics data or log entries and set up your Alerting system to watch for specific events or circumstances and then send notifications when those things are found.

In this way, you eliminate the need for manual monitoring and provide a first line of defense against system outages or changes that could turn into major incidents.

Using Grafana Alerting, you create queries and expressions from multiple data sources — no matter where your data is stored — giving you the flexibility to combine your data and alert on your metrics and logs in new and unique ways. You can then create, manage, and take action on your alerts from a single, consolidated view, and improve your team’s ability to identify and resolve issues quickly.

With Mimir and Loki alert rules you can run alert expressions closer to your data and at massive scale, all managed by the Grafana UI you are already familiar with.

**Note**  
If you are migrating from an earlier version of Grafana, where you used the legacy Grafana alerting, you might find it helpful to see the [differences between the legacy alerting and the new Grafana alerting](v12-alerting-use-grafana-alerts.md#v12-alerting-diff-old-new).

## Key features and benefits
<a name="v12-alerting-key-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 rule. You do this by adding labels to your query to specify which component is being monitored and generate multiple alert instances for a single alert rule. For example, if you want to monitor each server in a cluster, a multi-dimensional alert will alert on each CPU, whereas a standard alert will alert on the overall server.

**Route 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.

**Silence alerts**

Silences stop notifications from getting created and last for only a specified window of time. Silences allow you to stop receiving persistent notifications from one or more alert 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**

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.

## Design your Alerting system
<a name="v12-alerting-design"></a>

Monitoring complex IT systems and understanding whether everything is up and running correctly is a difficult task. Setting up an effective alert management system is therefore essential to inform you when things are going wrong before they start to impact your business outcomes.

Designing and configuring an alert management set up that works takes time.

Here are some tips on how to create an effective alert management set up for your business:

**Which are the key metrics for your business that you want to monitor and alert on?**
+ Find events that are important to know about and not so trivial or frequent that recipients ignore them.
+ Alerts should only be created for big events that require immediate attention or intervention.
+ Consider quality over quantity.

**Which type of Alerting do you want to use?**
+ Choose between Grafana-managed Alerting or Grafana Mimir or Loki-managed Alerting; or both.

**How do you want to organize your alerts and notifications?**
+ Be selective about who you set to receive alerts. Consider sending them to whomever is on call or a specific Slack channel.
+ Automate as far as possible using the Alerting API or alerts as code (Terraform).

**How can you reduce alert fatigue?**
+ Avoid noisy, unnecessary alerts by using silences, mute timings, or pausing alert rule evaluation.
+ Continually tune your alert rules to review effectiveness. Remove alert rules to avoid duplication or ineffective alerts.
+ Think carefully about priority and severity levels.
+ Continually review your thresholds and evaluation rules.

## Grafana alerting limitations
<a name="v12-alerting-limitations"></a>
+ When aggregating rules from other systems, 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.

**Important**  
Amazon Managed Grafana has an alert evaluation timeout of 30 seconds. Queries made by alerts have a maximum duration of 30 seconds due to the high volume of queries the alert engine can generate. This timeout is not configurable. For more information, see [Amazon Managed Grafana service quotas](https://docs.aws.amazon.com/general/latest/gr/grafana-service.html#grafana-quotas) in the *AWS General Reference*.

**Topics**
+ [

## Key features and benefits
](#v12-alerting-key-features)
+ [

## Design your Alerting system
](#v12-alerting-design)
+ [

## Grafana alerting limitations
](#v12-alerting-limitations)
+ [

# Overview
](v12-alerting-overview.md)
+ [

# Set up Alerting
](v12-alerting-setup.md)
+ [

# Configure alerting
](v12-alerting-configure.md)
+ [

# Manage your alerts
](v12-alerting-manage.md)

# Overview
<a name="v12-alerting-overview"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 12.x**.  
For Grafana workspaces that support Grafana version 10.x, see [Working in Grafana version 10](using-grafana-v10.md).  
For Grafana workspaces that support Grafana version 9.x, see [Working in Grafana version 9](using-grafana-v9.md).  
For Grafana workspaces that support Grafana version 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

Whether you’re just starting out or you’re a more experienced user of Grafana Alerting, learn more about the fundamentals and available features that help you create, manage, and respond to alerts; and improve your team’s ability to resolve issues quickly.

## Principles
<a name="v12-alerting-overview-principles"></a>

In Prometheus-based alerting systems, you have an alert generator that creates alerts and an alert receiver that receives alerts. For example, Prometheus is an alert generator and is responsible for evaluating alert rules, while Alertmanager is an alert receiver and is responsible for grouping, inhibiting, silencing, and sending notifications about firing and resolved alerts.

Grafana Alerting is built on the Prometheus model of designing alerting systems. It has an internal alert generator responsible for scheduling and evaluating alert rules, as well as an internal alert receiver responsible for grouping, inhibiting, silencing, and sending notifications. Grafana doesn’t use Prometheus as its alert generator because Grafana Alerting needs to work with many other data sources in addition to Prometheus. However, it does use Alertmanager as its alert receiver.

Alerts are sent to the alert receiver where they are routed, grouped, inhibited, silenced and notified. In Grafana Alerting, the default alert receiver is the Alertmanager embedded inside Grafana, and is referred to as the Grafana Alertmanager. However, you can use other Alertmanagers too, and these are referred to as [External Alertmanagers](v12-alerting-setup-alertmanager.md).

## Fundamentals
<a name="v12-alerting-overview-fundamentals"></a>

The following provides an overview of the different parts of Grafana alerting.

### Alert rules
<a name="v12-alerting-overview-alert-rules"></a>

An alert rule is a set of criteria that determine when an alert should fire. It consists of one or more queries and expressions, a condition which needs to be met, an interval which determines how often the alert rule is evaluated, and a duration over which the condition must be met for an alert to fire.

Alert rules are evaluated over their interval, and each alert rule can have zero, one, or any number of alerts firing at a time. The state of the alert rule is determined by its most `severe` alert, which can be one of Normal, Pending, or Firing. For example, if at least one of an alert rule’s alerts are firing then the alert rule is also firing. The health of an alert rule is determined by the status of its most recent evaluation. These can be OK, Error, and NoData.

A very important feature of alert rules is that they support custom annotations and labels. These allow you to instrument alerts with additional metadata such as summaries and descriptions, and add additional labels to route alerts to specific notification policies.

### Alerts
<a name="v12-alerting-overview-alerts"></a>

Alerts are uniquely identified by sets of key/value pairs called Labels. Each key is a label name and each value is a label value. For example, one alert might have the labels `foo=bar` and another alert might have the labels `foo=baz`. An alert can have many labels such as `foo=bar,bar=baz` but it cannot have the same label twice such as `foo=bar,foo=baz`. Two alerts cannot have the same labels either, and if two alerts have the same labels such as `foo=bar,bar=baz` and `foo=bar,bar=baz` then one of the alerts will be discarded. Alerts are resolved when the condition in the alert rule is no longer met, or the alert rule is deleted.

In Grafana Managed Alerts, alerts can be in Normal, Pending, Alerting, No Data or Error states. In Data source Managed Alerts, such as Mimir and Loki, alerts can be in Normal, Pending and Alerting, but not NoData or Error.

### Contact points
<a name="v12-alerting-overview-contact-points"></a>

Contact points determine where notifications are sent. For example, you might have a contact point that sends notifications to an email address, to Slack, to an incident management system (IRM) such as Grafana OnCall or Pagerduty, or to a webhook.

The notifications that are sent from contact points can be customized using notification templates. You can use notification templates to change the title, message, and structure of the notification. Notification templates are not specific to individual integrations or contact points.

### Notification policies
<a name="v12-alerting-overview-notification-policies"></a>

Notification policies group alerts and then route them to contact points. They determine when notifications are sent, and how often notifications should be repeated.

Alerts are matched to notification policies using label matchers. These are human-readable expressions that assert if the alert’s labels exactly match, do not exactly match, contain, or do not contain some expected text. For example, the matcher `foo=bar` matches alerts with the label `foo=bar` while the matcher `foo=~[a-zA-Z]+` matches alerts with any label called foo with a value that matches the regular expression `[a-zA-Z]+`.

By default, an alert can only match one notification policy. However, with the `continue` feature alerts can be made to match any number of notification policies at the same time. For more information about notification policies, see [Notification Policies](v12-alerting-explore-notifications-policies-details.md).

### Silences and mute timings
<a name="v12-alerting-overview-silences-and-mute-timings"></a>

Silences and mute timings allow you to pause notifications for specific alerts or even entire notification policies. Use a silence to pause notifications on an ad-hoc basis, such as while working on a fix for an alert; and use mute timings to pause notifications at regular intervals, such as during regularly scheduled maintenance windows.

**Topics**
+ [

## Principles
](#v12-alerting-overview-principles)
+ [

## Fundamentals
](#v12-alerting-overview-fundamentals)
+ [

# Data sources and Grafana alerting
](v12-alerting-overview-datasources.md)
+ [

# Alerting on numeric data
](v12-alerting-overview-numeric.md)
+ [

# Labels and annotations
](v12-alerting-overview-labels.md)
+ [

# About alert rules
](v12-alerting-explore-rules.md)
+ [

# Alertmanager
](v12-alerting-explore-alertmanager.md)
+ [

# Contact points
](v12-alerting-explore-contacts.md)
+ [

# Notifications
](v12-alerting-explore-notifications.md)
+ [

# Alerting high availability
](v12-alerting-explore-high-availability.md)

# Data sources and Grafana alerting
<a name="v12-alerting-overview-datasources"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 12.x**.  
For Grafana workspaces that support Grafana version 10.x, see [Working in Grafana version 10](using-grafana-v10.md).  
For Grafana workspaces that support Grafana version 9.x, see [Working in Grafana version 9](using-grafana-v9.md).  
For Grafana workspaces that support Grafana version 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

There are a number of data sources that are compatible with Grafana Alerting. Each data source is supported by a plugin. Grafana alerting requires that data source plugins be *backend* plugins, in order to evaluate rules using the data source, because the evaluation engine runs on the backend. Plugins must also specify that they are compatible with Grafana alerting.

Data sources are added and updated over time. The following data sources are known to be compatible with Grafana alerting.
+ [Connect to an Amazon CloudWatch data source](using-amazon-cloudwatch-in-AMG.md)
+ [Connect to an Azure Monitor data source](using-azure-monitor-in-AMG.md)
+ [Connect to an Amazon OpenSearch Service data source](using-Amazon-OpenSearch-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 Amazon Managed Service for Prometheus and open-source Prometheus data sources](prometheus-data-source.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)

For more detailed information about data sources and data source plugins in Amazon Managed Grafana, see [Connect to data sources](AMG-data-sources.md).

# Alerting on numeric data
<a name="v12-alerting-overview-numeric"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 12.x**.  
For Grafana workspaces that support Grafana version 10.x, see [Working in Grafana version 10](using-grafana-v10.md).  
For Grafana workspaces that support Grafana version 9.x, see [Working in Grafana version 9](using-grafana-v9.md).  
For Grafana workspaces that support Grafana version 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

This topic 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
<a name="v12-alerting-numeric-tabular"></a>

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 a 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
<a name="v12-alerting-numeric-tabexample"></a>

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="v12-alerting-overview-labels"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 12.x**.  
For Grafana workspaces that support Grafana version 10.x, see [Working in Grafana version 10](using-grafana-v10.md).  
For Grafana workspaces that support Grafana version 9.x, see [Working in Grafana version 9](using-grafana-v9.md).  
For Grafana workspaces that support Grafana version 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

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](v12-alerting-overview-labels-templating.md) for how to do this). This kind of description would be more suitable as an annotation.

## Labels
<a name="v12-alerting-overview-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](v12-alerting-overview-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="v12-alerting-overview-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](v12-alerting-overview-labels-templating.md).

**Topics**
+ [

## Labels
](#v12-alerting-overview-labels-labels)
+ [

## Annotations
](#v12-alerting-overview-labels-annotations)
+ [

# How label matching works
](v12-alerting-overview-labels-matching.md)
+ [

# Labels in Grafana Alerting
](v12-alerting-overview-labels-alerting.md)
+ [

# Templating labels and annotations
](v12-alerting-overview-labels-templating.md)

# How label matching works
<a name="v12-alerting-overview-labels-matching"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 12.x**.  
For Grafana workspaces that support Grafana version 10.x, see [Working in Grafana version 10](using-grafana-v10.md).  
For Grafana workspaces that support Grafana version 9.x, see [Working in Grafana version 9](using-grafana-v9.md).  
For Grafana workspaces that support Grafana version 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

Use 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 matcher 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
<a name="v12-alerting-overview-labels-matching-ex"></a>

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.

## Exclude labels
<a name="v12-alerting-overview-labels-matching-exclude"></a>

You can also write label matchers to exclude labels.

Here is an example that shows how to exclude the label `team`. You can choose between any of these values to exclude the label.
+ `team=""`
+ `team!~.+`
+ `team=~^$`

# Labels in Grafana Alerting
<a name="v12-alerting-overview-labels-alerting"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 12.x**.  
For Grafana workspaces that support Grafana version 10.x, see [Working in Grafana version 10](using-grafana-v10.md).  
For Grafana workspaces that support Grafana version 9.x, see [Working in Grafana version 9](using-grafana-v9.md).  
For Grafana workspaces that support Grafana version 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

This topic 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](v12-alerting-configure.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
<a name="v12-alerting-overview-labels-alerting-external"></a>

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
<a name="v12-alerting-overview-labels-alerting-reserved"></a>

**Note**  
Labels prefixed with `grafana_` are reserved by Grafana for special use. If a manually configured label is added beginning with `grafana_` it will 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="v12-alerting-overview-labels-templating"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 12.x**.  
For Grafana workspaces that support Grafana version 10.x, see [Working in Grafana version 10](using-grafana-v10.md).  
For Grafana workspaces that support Grafana version 9.x, see [Working in Grafana version 9](using-grafana-v9.md).  
For Grafana workspaces that support Grafana version 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

You can use templates to include data from queries and expressions in labels and annotations. For example, you might want to set the severity label for an alert based on the value of the query, or use the instance label from the query in a summary annotation so you know which server is experiencing high CPU usage.

All templates should be written in [text/template](https://pkg.go.dev/text/template). Regardless of whether you are templating a label or an annotation, you should write each template inline inside the label or annotation that you are templating. This means you cannot share templates between labels and annotations, and instead you will need to copy templates wherever you want to use them.

Each template is evaluated whenever the alert rule is evaluated, and is evaluated for every alert separately. For example, if your alert rule has a templated summary annotation, and the alert rule has 10 firing alerts, then the template will be executed 10 times, once for each alert. You should try to avoid doing expensive computations in your templates as much as possible.

## Examples
<a name="v12-alerting-overview-labels-templating-examples"></a>

Rather than write a complete tutorial on text/template, the following examples attempt to show the most common use-cases we have seen for templates. You can use these examples verbatim, or adapt them as necessary for your use case. For more information about how to write text/template see the [text/template](https://pkg.go.dev/text/template) documentation.

**Print all labels, comma separated**

To print all labels, comma separated, print the `$labels` variable:

```
{{ $labels }}
```

For example, given an alert with the labels `alertname=High CPU usage`, `grafana_folder=CPU alerts` and `instance=server1`, this would print: 

```
alertname=High CPU usage, grafana_folder=CPU alerts, instance=server1
```

**Note**  
If you are using classic conditions then `$labels` will not contain any labels from the query. Refer to [the \$1labels variable](#v12-alerting-overview-labels-templating-the-labels-variable) for more information.

**Print all labels, one per line**

To print all labels, one per line, use a `range` to iterate over each key/value pair and print them individually. Here `$k` refers to the name and `$v` refers to the value of the current label: 

```
{{ range $k, $v := $labels -}}
{{ $k }}={{ $v }}
{{ end }}
```

For example, given an alert with the labels `alertname=High CPU usage`, `grafana_folder=CPU alerts` and `instance=server1`, this would print:

```
alertname=High CPU usage
grafana_folder=CPU alerts
instance=server1
```

**Note**  
If you are using classic conditions then `$labels` will not contain any labels from the query. Refer to [the \$1labels variable](#v12-alerting-overview-labels-templating-the-labels-variable) for more information.

**Print an individual label**

To print an individual label use the `index` function with the `$labels` variable: 

```
The host {{ index $labels "instance" }} has exceeded 80% CPU usage for the last 5 minutes
```

For example, given an alert with the label `instance=server1`, this would print:

```
The host server1 has exceeded 80% CPU usage for the last 5 minutes
```

**Note**  
If you are using classic conditions then `$labels` will not contain any labels from the query. Refer to [the \$1labels variable](#v12-alerting-overview-labels-templating-the-labels-variable) for more information.

**Print the value of a query**

To print the value of an instant query you can print its Ref ID using the `index` function and the `$values` variable: 

```
{{ index $values "A" }}
```

For example, given an instant query that returns the value 81.2345, this will print:

```
81.2345
```

To print the value of a range query you must first reduce it from a time series to an instant vector with a reduce expression. You can then print the result of the reduce expression by using its Ref ID instead. For example, if the reduce expression takes the average of A and has the Ref ID B you would write: 

```
{{ index $values "B" }}
```

**Print the humanized value of a query**

To print the humanized value of an instant query use the `humanize` function:

```
{{ humanize (index $values "A").Value }}
```

For example, given an instant query that returns the value 81.2345, this will print: 

```
81.234
```

To print the humanized value of a range query you must first reduce it from a time series to an instant vector with a reduce expression. You can then print the result of the reduce expression by using its Ref ID instead. For example, if the reduce expression takes the average of A and has the Ref ID B you would write: 

```
{{ humanize (index $values "B").Value }}
```

**Print the value of a query as a percentage**

To print the value of an instant query as a percentage use the `humanizePercentage` function:

```
{{ humanizePercentage (index $values "A").Value }}
```

This function expects the value to be a decimal number between 0 and 1. If the value is instead a decimal number between 0 and 100 you can divide it by 100 either in your query or using a math expression. If the query is a range query you must first reduce it from a time series to an instant vector with a reduce expression.

**Set a severity from the value of a query**

To set a severity label from the value of a query use an if statement and the greater than comparison function. Make sure to use decimals (`80.0`, `50.0`, `0.0`, etc) when doing comparisons against `$values` as text/template does not support type coercion. You can find a list of all the supported comparison functions [here](https://pkg.go.dev/text/template#hdr-Functions).

```
{{ if (gt $values.A.Value 80.0) -}}
high
{{ else if (gt $values.A.Value 50.0) -}}
medium
{{ else -}}
low
{{- end }}
```

**Print all labels from a classic condition**

You cannot use `$labels` to print labels from the query if you are using classic conditions, and must use `$values` instead. The reason for this is classic conditions discard these labels to enforce uni-dimensional behavior (at most one alert per alert rule). If classic conditions didn’t discard these labels, then queries that returned many time series would cause alerts to flap between firing and resolved constantly as the labels would change every time the alert rule was evaluated.

Instead, the `$values` variable contains the reduced values of all time series for all conditions that are firing. For example, if you have an alert rule with a query A that returns two time series, and a classic condition B with two conditions, then `$values` would contain `B0`, `B1`, `B2` and `B3`. If the classic condition B had just one condition, then `$values` would contain just `B0` and `B1`.

To print all labels of all firing time series use the following template (make sure to replace `B` in the regular expression with the Ref ID of the classic condition if it’s different): 

```
{{ range $k, $v := $values -}}
{{ if (match "B[0-9]+" $k) -}}
{{ $k }}: {{ $v.Labels }}{{ end }}
{{ end }}
```

For example, a classic condition for two time series exceeding a single condition would print: 

```
B0: instance=server1
B1: instance=server2
```

If the classic condition has two or more conditions, and a time series exceeds multiple conditions at the same time, then its labels will be duplicated for each condition that is exceeded: 

```
B0: instance=server1
B1: instance=server2
B2: instance=server1
B3: instance=server2
```

If you need to print unique labels you should consider changing your alert rules from uni-dimensional to multi-dimensional instead. You can do this by replacing your classic condition with reduce and math expressions.

**Print all values from a classic condition**

To print all values from a classic condition take the previous example and replace `$v.Labels` with `$v.Value`: 

```
{{ range $k, $v := $values -}}
{{ if (match "B[0-9]+" $k) -}}
{{ $k }}: {{ $v.Value }}{{ end }}
{{ end }}
```

For example, a classic condition for two time series exceeding a single condition would print: 

```
B0: 81.2345
B1: 84.5678
```

If the classic condition has two or more conditions, and a time series exceeds multiple conditions at the same time, then `$values` will contain the values of all conditions: 

```
B0: 81.2345
B1: 92.3456
B2: 84.5678
B3: 95.6789
```

## Variables
<a name="v12-alerting-overview-labels-templating-variables"></a>

The following variables are available to you when templating labels and annotations:

### The labels variable
<a name="v12-alerting-overview-labels-templating-the-labels-variable"></a>

The `$labels` variable contains all labels from the query. For example, suppose you have a query that returns CPU usage for all of your servers, and you have an alert rule that fires when any of your servers have exceeded 80% CPU usage for the last 5 minutes. You want to add a summary annotation to the alert that tells you which server is experiencing high CPU usage. With the `$labels` variable you can write a template that prints a human-readable sentence such as: 

```
CPU usage for {{ index $labels "instance" }} has exceeded 80% for the last 5 minutes
```

**Note**  
If you are using a classic condition then `$labels` will not contain any labels from the query. Classic conditions discard these labels in order to enforce uni-dimensional behavior (at most one alert per alert rule). If you want to use labels from the query in your template then follow the previous *Print all labels from a classic condition* example.

### The value variable
<a name="v12-alerting-overview-labels-templating-the-value-variable"></a>

The `$value` variable is a string containing the labels and values of all instant queries; threshold, reduce and math expressions, and classic conditions in the alert rule. It does not contain the results of range queries, as these can return anywhere from 10s to 10,000s of rows or metrics. If it did, for especially large queries a single alert could use 10s of MBs of memory and Grafana would run out of memory very quickly.

To print the `$value` variable in the summary you would write something like this: 

```
CPU usage for {{ index $labels "instance" }} has exceeded 80% for the last 5 minutes: {{ $value }}
```

And it would look something like this:

```
CPU usage for instance1 has exceeded 80% for the last 5 minutes: [ var='A' labels={instance=instance1} value=81.234 ]
```

Here `var='A'` refers to the instant query with Ref ID A, `labels={instance=instance1}` refers to the labels, and `value=81.234` refers to the average CPU usage over the last 5 minutes.

If you want to print just some of the string instead of the full string then use the `$values` variable. It contains the same information as `$value`, but in a structured table, and is much easier to use then writing a regular expression to match just the text you want.

### The values variable
<a name="v12-alerting-overview-labels-templating-the-values-variable"></a>

The `$values` variable is a table containing the labels and floating point values of all instant queries and expressions, indexed by their Ref IDs.

To print the value of the instant query with Ref ID A:

```
CPU usage for {{ index $labels "instance" }} has exceeded 80% for the last 5 minutes: {{ index $values "A" }}
```

For example, given an alert with the labels `instance=server1` and an instant query with the value `81.2345`, this would print:

```
CPU usage for instance1 has exceeded 80% for the last 5 minutes: 81.2345
```

If the query in Ref ID A is a range query rather than an instant query then add a reduce expression with Ref ID B and replace `(index $values "A")` with `(index $values "B")`:

```
CPU usage for {{ index $labels "instance" }} has exceeded 80% for the last 5 minutes: {{ index $values "B" }}
```

## Functions
<a name="v12-alerting-overview-labels-templating-functions"></a>

The following functions are available to you when templating 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.

```
{{define "x"}}{{.arg0}} {{.arg1}}{{end}}{{template "x" (args 1 "2")}}
```

```
1 2
```

**externalURL**

The `externalURL` function returns the external URL of the Grafana server.

```
{{ externalURL }}
```

```
https://example.com/grafana
```

**graphLink**

The `graphLink` function returns the path to the graphical view in [Explore in Grafana version 12](v12-explore.md) for the given expression and data source.

```
{{ 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.

```
{{ humanize 1000.0 }}
```

```
1k
```

**humanize1024**

The `humanize1024` works similar to `humanize` but uses 1024 as the base rather than 1000.

```
{{ humanize1024 1024.0 }}
```

```
1ki
```

**humanizeDuration**

The `humanizeDuration` function humanizes a duration in seconds.

```
{{ humanizeDuration 60.0 }}
```

```
1m 0s
```

**humanizePercentage**

The `humanizePercentage` function humanizes a ratio value to a percentage.

```
{{ humanizePercentage 0.2 }}
```

```
20%
```

**humanizeTimestamp**

The `humanizeTimestamp` function humanizes a Unix timestamp.

```
{{ humanizeTimestamp 1577836800.0 }}
```

```
2020-01-01 00:00:00 +0000 UTC
```

**match**

The `match` function matches the text against a regular expression pattern.

```
{{ match "a.*" "abc" }}
```

```
true
```

**pathPrefix**

The `pathPrefix` function returns the path of the Grafana server.

```
{{ pathPrefix }}
```

```
/grafana
```

**tableLink**

The `tableLink` function returns the path to the tabular view in [Explore in Grafana version 12](v12-explore.md) for the given expression and data source.

```
{{ 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.

```
{{ title "hello, world!" }}
```

```
Hello, World!
```

**toLower**

The `toLower` function returns all text in lowercase.

```
{{ toLower "Hello, world!" }}
```

```
hello, world!
```

**toUpper**

The `toUpper` function returns all text in uppercase.

```
{{ toUpper "Hello, world!" }}
```

```
HELLO, WORLD!
```

**reReplaceAll**

The `reReplaceAll` function replaces text matching the regular expression.

```
{{ reReplaceAll "localhost:(.*)" "example.com:$1" "localhost:8080" }}
```

```
example.com:8080
```

# About alert rules
<a name="v12-alerting-explore-rules"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 12.x**.  
For Grafana workspaces that support Grafana version 10.x, see [Working in Grafana version 10](using-grafana-v10.md).  
For Grafana workspaces that support Grafana version 9.x, see [Working in Grafana version 9](using-grafana-v9.md).  
For Grafana workspaces that support Grafana version 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

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 the duration over which the condition needs to be met to start firing.

While queries and expressions select the data set to evaluate, a *condition* sets the threshold that the data 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
](v12-alerting-explore-rules-types.md)
+ [

# Recording rules
](v12-alerting-explore-rule-recording.md)
+ [

# Queries and conditions
](v12-alerting-explore-rules-queries.md)
+ [

# Alert instances
](v12-alerting-rules-instances.md)
+ [

# Namespaces, folders and groups
](v12-alerting-rules-grouping.md)
+ [

# Alert rule evaluation
](v12-alerting-rules-evaluation.md)
+ [

# State and health of alerting rules
](v12-alerting-explore-state.md)
+ [

# Notification templating
](v12-alerting-rules-notification-templates.md)

# Alert rule types
<a name="v12-alerting-explore-rules-types"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 12.x**.  
For Grafana workspaces that support Grafana version 10.x, see [Working in Grafana version 10](using-grafana-v10.md).  
For Grafana workspaces that support Grafana version 9.x, see [Working in Grafana version 9](using-grafana-v9.md).  
For Grafana workspaces that support Grafana version 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

Grafana supports several alert rule types. Learn more about each of the alert rule types, how they work, and decide which one is best for your use case.

## Grafana managed rules
<a name="v12-alerting-explore-rule-types-grafana"></a>

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 multiple data sources, you can add [expressions](v12-panels-query-xform-expressions.md) to transform your data and express alert conditions.

In Grafana managed alerting:
+ Alert rules are created within Grafana, based on one or more data sources.
+ Alert rules are evaluated by the alert rule evaluation engine from within Grafana.
+ Alerts are delivered using the internal Grafana Alertmanager.

**Note**  
You can also configure alerts to be delivered using an external Alertmanager, or use both internal and external Alertmanagers. For more information, see [Add an external alertmanager](v12-alerting-setup-alertmanager.md).

## Data source managed rules
<a name="v12-alerting-explore-rule-types-datasource"></a>

To create data source managed alert rules 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.

In data source managed alerting:
+ Alert rules are created and stored within the data source itself.
+ Alert rules can only be created based on Prometheus data.
+ Alert rule evaluation and delivery is distributed across multiple nodes for high-availability and fault tolerance.

## Choose an alert rule type
<a name="v12-alerting-explore-rule-types-choose"></a>

When choosing which alert rule type to use, consider the following comparison between Grafana managed alert rules and data source managed alert rules.


| Feature | Grafana-managed alert rule | Loki/Mimir-managed alert rule | 
| --- | --- | --- | 
| Create alert rules based on data from any of our supported data sources | Yes | No: You can only create alert rules that are based on Prometheus data. The data source must have the Ruler API enabled.  | 
| Mix and match data sources | Yes | No | 
| Includes support for recording rules | No | Yes | 
| Add expressions to transform your data and set alert conditions | Yes | No | 
| Use images in alert notifications | Yes | No | 
| Scaling | More resource intensive, depend on the database, and are likely to suffer from transient errors. They only scale vertically. | Store alert rules within the data source itself and allow for “infinite” scaling. Generate and send alert notifications from the location of your data. | 
| Alert rule evaluation and delivery | Alert rule evaluation and delivery is done from within Grafana, using an external Alertmanager; or both. | Alert rule evaluation and alert delivery is distributed, meaning there is no single point of failure. | 

# Recording rules
<a name="v12-alerting-explore-rule-recording"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 12.x**.  
For Grafana workspaces that support Grafana version 10.x, see [Working in Grafana version 10](using-grafana-v10.md).  
For Grafana workspaces that support Grafana version 9.x, see [Working in Grafana version 9](using-grafana-v9.md).  
For Grafana workspaces that support Grafana version 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

*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.

Querying this new time series is faster, especially for dashboards since they query the same expression every time the dashboards refresh.

Read more about [recording rules](https://prometheus.io/docs/prometheus/latest/configuration/recording_rules/) in Prometheus.

# Queries and conditions
<a name="v12-alerting-explore-rules-queries"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 12.x**.  
For Grafana workspaces that support Grafana version 10.x, see [Working in Grafana version 10](using-grafana-v10.md).  
For Grafana workspaces that support Grafana version 9.x, see [Working in Grafana version 9](using-grafana-v9.md).  
For Grafana workspaces that support Grafana version 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

In Grafana, queries play a vital role in fetching and transforming data from supported data sources, which include databases like MySQL and PostgreSQL, time series databases like Prometheus, InfluxDB and Graphite, and services like OpenSearch, Amazon CloudWatch, Azure Monitor and Google Cloud Monitoring.

For more information on supported data sources, see [Data sources and Grafana alerting](v12-alerting-overview-datasources.md).

The process of executing a query involves defining the data source, specifying the desired data to retrieve, and applying relevant filters or transformations. Query languages or syntaxes specific to the chosen data source are utilized for constructing these queries.

In Alerting, you define a query to get the data you want to measure and a condition that needs to be met before an alert rule fires.

An alert rule consists of one or more queries and expressions that select the data you want to measure.

For more information on queries and expressions, see [Query and transform data](v12-panels-query-xform.md).

## Data source queries
<a name="v12-alerting-explore-rules-queries-data-source-queries"></a>

Queries in Grafana can be applied in various ways, depending on the data source and query language being used. 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.

Some common types of query components include: 

**Metrics or data fields** – Specify the specific metrics or data fields you want to retrieve, such as CPU usage, network traffic, or sensor readings.

**Time range** – Define the time range for which you want to fetch data, such as the last hour, a specific day, or a custom time range.

**Filters** – Apply filters to narrow down the data based on specific criteria, such as filtering data by a specific tag, host, or application.

**Aggregations** – Perform aggregations on the data to calculate metrics like averages, sums, or counts over a given time period.

**Grouping** – Group the data by specific dimensions or tags to create aggregated views or breakdowns.

**Note**  
Grafana does not support alert queries with template variables. More information is available [here](https://community.grafana.com/t/template-variables-are-not-supported-in-alert-queries-while-setting-up-alert/2514) in the Grafana Labs forums.

## Expression queries
<a name="v12-alerting-explore-rules-queries-expression-queries"></a>

In Grafana, an expression is used to perform calculations, transformations, or aggregations on the data source queried data. It allows you to create custom metrics or modify existing metrics based on mathematical operations, functions, or logical expressions.

By leveraging expression queries, users can perform tasks such as calculating the percentage change between two values, applying functions like logarithmic or trigonometric functions, aggregating data over specific time ranges or dimensions, and implementing conditional logic to handle different scenarios.

In Alerting, you can only use expressions for Grafana-managed alert rules. For each expression, you can choose from the math, reduce, and resample expressions. These are called multi-dimensional rules, because they generate a separate alert for each series.

You can also use a classic condition, which creates an alert rule that triggers a single alert when its condition is met. As a result, Grafana sends only a single alert even when alert conditions are met for multiple series.

**Note**  
Classic conditions exist mainly for compatibility reasons and should be avoided if possible.

**Reduce**

Aggregates time series values in the selected time range into a single value.

**Math**

Performs free-form math functions/operations on time series and number data. Can be used to preprocess time series data or to define an alert condition for number data.

**Resample**

Realigns a time range to a new set of timestamps, this is useful when comparing time series data from different data sources where the timestamps would otherwise not align.

**Threshold**

Checks if any time series data matches the threshold condition.

The threshold expression allows you to compare two single values. It returns `0` when the condition is false and `1` if the condition is true. The following threshold functions are available:
+ Is above (x > y)
+ Is below (x < y)
+ Is within range (x > y1 AND x < y2)
+ Is outside range (x < y1 AND x > y2)

**Classic condition**

Checks if any time series data matches the alert condition.

**Note**  
Classic condition expression queries always produce one alert instance only, no matter how many time series meet the condition. Classic conditions exist mainly for compatibility reasons and should be avoided if possible.

## Aggregations
<a name="v12-alerting-explore-rules-queries-aggregations"></a>

Grafana Alerting provides the following aggregation functions to enable you to further refine your query.

These functions are available for **Reduce** and **Classic condition** expressions only.


| Function | Expression | What it does | 
| --- | --- | --- | 
| avg | Reduce / Classic | Displays the average of the values | 
| min | Reduce / Classic | Displays the lowest value | 
| max | Reduce / Classic | Displays the highest value | 
| sum | Reduce / Classic | Displays the sum of all values | 
| count | Reduce / Classic | Counts the number of values in the result | 
| last | Reduce / Classic | Displays the last value | 
| median | Reduce / Classic | Displays the median value | 
| diff | Classic | Displays the difference between the newest and oldest value | 
| diff\$1abs | Classic | Displays the absolute value of diff | 
| percent\$1diff | Classic | Displays the percentage value of the difference between newest and oldest value | 
| percent\$1diff\$1abs | Classic | Displays the absolute value of percent\$1diff | 
| count\$1non\$1null | Classic | Displays a count of values in the result set that aren’t null | 

## Alert condition
<a name="v12-alerting-explore-rules-queries-alert-condition"></a>

An alert condition is the query or expression that determines whether the alert will fire or not depending on the value it yields. There can be only one condition which will determine the triggering of the alert.

After you have defined your queries and/or expressions, choose one of them as the alert rule condition.

When the queried data satisfies the defined condition, Grafana triggers the associated alert, which can be configured to send notifications through various channels like email, Slack, or PagerDuty. The notifications inform you about the condition being met, allowing you to take appropriate actions or investigate the underlying issue.

By default, the last expression added is used as the alert condition.

## Recovery threshold
<a name="v12-alerting-explore-rules-queries-recovery-threshold"></a>

To reduce the noise of flapping alerts, you can set a recovery threshold different to the alert threshold.

Flapping alerts occur when a metric hovers around the alert threshold condition and may lead to frequent state changes, resulting in too many notifications being generated.

Grafana-managed alert rules are evaluated for a specific interval of time. During each evaluation, the result of the query is checked against the threshold set in the alert rule. If the value of a metric is above the threshold, an alert rule fires and a notification is sent. When the value goes below the threshold and there is an active alert for this metric, the alert is resolved, and another notification is sent.

It can be tricky to create an alert rule for a noisy metric. That is, when the value of a metric continually goes above and below a threshold. This is called flapping and results in a series of firing - resolved - firing notifications and a noisy alert state history.

For example, if you have an alert for latency with a threshold of 1000ms and the number fluctuates around 1000 (say 980 ->1010 -> 990 -> 1020, and so on) then each of those will trigger a notification.

To solve this problem, you can set a (custom) recovery threshold, which basically means having two thresholds instead of one. An alert is triggered when the first threshold is crossed and is resolved only when the second threshold is crossed.

For example, you could set a threshold of 1000ms and a recovery threshold of 900ms. This way, an alert rule will only stop firing when it goes under 900ms and flapping is reduced.

# Alert instances
<a name="v12-alerting-rules-instances"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 12.x**.  
For Grafana workspaces that support Grafana version 10.x, see [Working in Grafana version 10](using-grafana-v10.md).  
For Grafana workspaces that support Grafana version 9.x, see [Working in Grafana version 9](using-grafana-v9.md).  
For Grafana workspaces that support Grafana version 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

Grafana 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 we are observing after the first evaluation, allowing a single rule to report the status of each CPU.

# Namespaces, folders and groups
<a name="v12-alerting-rules-grouping"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 12.x**.  
For Grafana workspaces that support Grafana version 10.x, see [Working in Grafana version 10](using-grafana-v10.md).  
For Grafana workspaces that support Grafana version 9.x, see [Working in Grafana version 9](using-grafana-v9.md).  
For Grafana workspaces that support Grafana version 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

Alerts can be organized using folders for Grafana managed rules and namespaces for Mimir, Loki, or Prometheus rules and group names.

**Namespaces and folders**

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.

A namespace contains one or more groups. The rules within a group are run sequentially at a regular interval. The default interval is one minute. You can rename Grafana Mimi or Loki rule namespaces and groups, and edit group evaluation intervals.

**Groups**

The rules within a group are run sequentially at a regular interval, meaning no rules will be evaluated at the same time, and in order of appearance. The default interval is one minute. You can rename Grafana Mimir or Loki rule namespaces or Loki rule namespaces and groups, and edit group evaluation intervals.

**Tip**  
If you want rules to be evaluated concurrently and with different intervals, consider storing them in different groups.

**Note**  
Grafana managed alert rules are evaluated concurrently instead of sequentially.

# Alert rule evaluation
<a name="v12-alerting-rules-evaluation"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 12.x**.  
For Grafana workspaces that support Grafana version 10.x, see [Working in Grafana version 10](using-grafana-v10.md).  
For Grafana workspaces that support Grafana version 9.x, see [Working in Grafana version 9](using-grafana-v9.md).  
For Grafana workspaces that support Grafana version 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

Use alert rule evaluation to determine how frequently an alert rule should be evaluated and how quickly it should change its state.

To do this, you need to make sure that your alert rule is in the right evaluation group and set a pending period time that works best for your use case.

## Evaluation group
<a name="v12-alerting-rules-evaluation-group"></a>

Every alert rule is part of an evaluation group. Each evaluation group contains an evaluation interval that determines how frequently the alert rule is checked.

**Data-source managed** alert rules within the same group are evaluated one after the other, while alert rules in different groups can be evaluated simultaneously. This feature is especially useful when you want to ensure that recording rules are evaluated before any alert rules.

**Grafana-managed** alert rules are evaluated at the same time, regardless of alert rule group. The default evaluation interval is set at 10 seconds, which means that Grafana-managed alert rules are evaluated every 10 seconds to the closest 10-second window on the clock, for example, 10:00:00, 10:00:10, 10:00:20, and so on. You can also configure your own evaluation interval, if required.

**Note**  
Evaluation groups and alerts grouping in notification policies are two separate things. Grouping in notification policies allows multiple alerts sharing the same labels to be sent in the same time message.

## Pending period
<a name="v12-alerting-rules-evaluation-pending-period"></a>

By setting a pending period, you can avoid unnecessary alerts for temporary problems.

In the pending period, you select the period in which an alert rule can be in breach of the condition until it fires.

**Example**

Imagine you have an alert rule evaluation interval set at every 30 seconds and the pending period to 90 seconds.

Evaluation will occur as follows:

[00:30] First evaluation - condition not met.

[01:00] Second evaluation - condition breached. Pending counter starts.**Alert starts pending.**

[01:30] Third evaluation - condition breached. Pending counter = 30s. **Pending state.**

[02:00] Fourth evaluation - condition breached. Pending counter = 60s **Pending state.**

[02:30] Fifth evaluation - condition breached. Pending counter = 90s. **Alert starts firing**

If the alert rule has a condition that needs to be in breach for a certain amount of time before it takes action, then its state changes as follows:
+ When the condition is first breached, the rule goes into a "pending" state.
+ The rule stays in the "pending" state until the condition has been broken for the required amount of time - pending period.
+ Once the required time has passed, the rule goes into a "firing" state.
+ If the condition is no longer broken during the pending period, the rule goes back to its normal state.

**Note**  
If you want to skip the pending state, you can simply set the pending period to 0. This effectively skips the pending period and your alert rule will start firing as soon as the condition is breached.

When an alert rule fires, alert instances are produced, which are then sent to the Alertmanager.

# State and health of alerting rules
<a name="v12-alerting-explore-state"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 12.x**.  
For Grafana workspaces that support Grafana version 10.x, see [Working in Grafana version 10](using-grafana-v10.md).  
For Grafana workspaces that support Grafana version 9.x, see [Working in Grafana version 9](using-grafana-v9.md).  
For Grafana workspaces that support Grafana version 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

The 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 one 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 one 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. | 

**Keep last state**

An alert rule can be configured to keep the last state when `NoData` or `Error` state is encountered. This will both prevent alerts from firing, and from resolving and re-firing. Just like normal evaluation, the alert rule will transition from `Pending` to `Firing` after the pending period has elapsed.

**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.

# Notification templating
<a name="v12-alerting-rules-notification-templates"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 12.x**.  
For Grafana workspaces that support Grafana version 10.x, see [Working in Grafana version 10](using-grafana-v10.md).  
For Grafana workspaces that support Grafana version 9.x, see [Working in Grafana version 9](using-grafana-v9.md).  
For Grafana workspaces that support Grafana version 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

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](v12-alerting-manage-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.

# Alertmanager
<a name="v12-alerting-explore-alertmanager"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 12.x**.  
For Grafana workspaces that support Grafana version 10.x, see [Working in Grafana version 10](using-grafana-v10.md).  
For Grafana workspaces that support Grafana version 9.x, see [Working in Grafana version 9](using-grafana-v9.md).  
For Grafana workspaces that support Grafana version 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

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.

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.

# Contact points
<a name="v12-alerting-explore-contacts"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 12.x**.  
For Grafana workspaces that support Grafana version 10.x, see [Working in Grafana version 10](using-grafana-v10.md).  
For Grafana workspaces that support Grafana version 9.x, see [Working in Grafana version 9](using-grafana-v9.md).  
For Grafana workspaces that support Grafana version 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

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 Pagerduty integration; an Amazon SNS and Slack integration; or a Pagerduty 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.

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 [Configure contact points](v12-alerting-configure-contactpoints.md) and [Customize notifications](v12-alerting-manage-notifications.md).

# Notifications
<a name="v12-alerting-explore-notifications"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 12.x**.  
For Grafana workspaces that support Grafana version 10.x, see [Working in Grafana version 10](using-grafana-v10.md).  
For Grafana workspaces that support Grafana version 9.x, see [Working in Grafana version 9](using-grafana-v9.md).  
For Grafana workspaces that support Grafana version 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

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](v12-alerting-explore-contacts.md), which define where to send your alert notifications. A contact point is a set of one or more integrations that are used to deliver 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.

## Alertmanagers
<a name="v12-alerting-explore-notifications-alertmanager"></a>

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="v12-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 default policy. There can be only one default policy and the default 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 nested policy can have its own nested policies, which allow for additional matching of alerts. An example of a nested 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 default policy. However, when the default policy receives an alert it looks at each nested policy and sends the alert to the first nested policy that matches the alert. If the nested policy has further nested policies, then it can attempt to match the alert against one of its nested policies. If no nested policies match the alert then the policy itself is the matching policy. If there are no nested policies, or no nested policies match the alert, then the default policy is the matching policy.

For more detailed information about notification policies, see [Notification policies](v12-alerting-explore-notifications-policies-details.md).

## Notification templates
<a name="v12-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.

For more detailed information about customizing notifications, see [Customize notifications](v12-alerting-manage-notifications.md).

## Silences
<a name="v12-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.

For more detailed information about using silences, see [Silencing alert notifications](v12-alerting-silences.md).

# Notification policies
<a name="v12-alerting-explore-notifications-policies-details"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 12.x**.  
For Grafana workspaces that support Grafana version 10.x, see [Working in Grafana version 10](using-grafana-v10.md).  
For Grafana workspaces that support Grafana version 9.x, see [Working in Grafana version 9](using-grafana-v9.md).  
For Grafana workspaces that support Grafana version 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

Notification policies provide you with a flexible way of routing alerts to various different receivers. Using label matchers, you can modify alert notification delivery without having to update every individual alert rule.

In this section, you will learn more about how notification policies work and are structured, so that you can make the most out of setting up your notification policies.

## Policy tree
<a name="v12-alerting-explore-notifications-policy-tree"></a>

Notification policies are *not* a list, but rather are structured according to a tree structure. This means that each policy can have child policies, and so on. The root of the notification policy tree is called the **Default notification policy**.

Each policy consists of a set of label matchers (0 or more) that specify which labels they are or aren’t interested in handling.

For more information about label matching, see [How label matching works](v12-alerting-overview-labels-matching.md).

**Note**  
If you haven’t configured any label matchers for your notification policy, your notification policy will match *all* alert instances. This may prevent child policies from being evaluated unless you have enabled **Continue matching siblings** on the notification policy.

## Routing
<a name="v12-alerting-explore-notifications-routing"></a>

To determine which notification policy will handle which alert instances, you have to start by looking at the existing set of notification policies, starting with the default notification policy.

If no policies other than the default policy are configured, the default policy will handle the alert instance.

If policies other than the default policy are defined, it will evaluate those notification policies in the order they are displayed.

If a notification policy has label matchers that match the labels of the alert instance, it will descend in to its child policies and, if there are any, will continue to look for any child policies that might have label matchers that further narrow down the set of labels, and so forth until no more child policies have been found.

If no child policies are defined in a notification policy or if none of the child policies have any label matchers that match the alert instance’s labels, the parent notification policy is used.

As soon as a matching policy is found, the system does not continue to look for other matching policies. If you want to continue to look for other policies that may match, enable **Continue matching siblings** on that particular policy.

Lastly, if none of the notification policies are selected the default notification policy is used.

### Routing example
<a name="v12-alerting-explore-notifications-routing-example"></a>

Here is an example of a relatively simple notification policy tree and some alert instances.

![\[An image showing a set of notification policies in a tree structure, and a set of alert instances with different labels to match to the policies.\]](http://docs.aws.amazon.com/grafana/latest/userguide/images/notification-routing.png)


Here’s a breakdown of how these policies are selected:

**Pod stuck in CrashLoop** does not have a `severity` label, so none of its child policies are matched. It does have a `team=operations` label, so the first policy is matched.

The `team=security` policy is not evaluated since we already found a match and **Continue matching siblings** was not configured for that policy.

**Disk Usage – 80%** has both a `team` and `severity` label, and matches a child policy of the operations team.

**Unauthorized log entry** has a `team` label but does not match the first policy (`team=operations`) since the values are not the same, so it will continue searching and match the `team=security` policy. It does not have any child policies, so the additional `severity=high` label is ignored.

## Inheritance
<a name="v12-alerting-explore-notifications-inheritance"></a>

In addition to child policies being a useful concept for routing alert instances, they also inherit properties from their parent policy. This also applies to any policies that are child policies of the default notification policy.

The following properties are inherited by child policies:
+ Contact point
+ Grouping options
+ Timing options
+ Mute timings

Each of these properties can be overwritten by an individual policy should you wish to override the inherited properties.

To inherit a contact point from the parent policy, leave it blank. To override the inherited grouping options, enable **Override grouping**. To override the inherited timing options, enable **Override general timings**.

### Inheritance example
<a name="v12-alerting-explore-notifications-inheritance-example"></a>

The example below shows how the notification policy tree from our previous example allows the child policies of the `team=operations` to inherit its contact point.

In this way, we can avoid having to specify the same contact point multiple times for each child policy.

![\[An image showing a set of notification policies in a tree structure, with contact points assigned to some of the policies, but with some child policies inheriting the contact points of their parents, rather than defining their own.\]](http://docs.aws.amazon.com/grafana/latest/userguide/images/notification-inheritance.png)


## Additional configuration options
<a name="v12-alerting-explore-notifications-additional-configuration-options"></a>

### Grouping
<a name="v12-alerting-explore-notifications-grouping"></a>

Grouping is an important feature of Grafana Alerting as it allows you to batch relevant alerts together into a smaller number of notifications. This is particularly important if notifications are delivered to first-responders, such as engineers on-call, where receiving lots of notifications in a short period of time can be overwhelming and in some cases can negatively impact a first-responders ability to respond to an incident. For example, consider a large outage where many of your systems are down. In this case, grouping can be the difference between receiving 1 phone call and 100 phone calls.

You choose how alerts are grouped together using the Group by option in a notification policy. By default, notification policies in Grafana group alerts together by alert rule using the `alertname` and `grafana_folder` labels (since alert names are not unique across multiple folders). Should you wish to group alerts by something other than the alert rule, change the grouping to any other combination of labels.

#### Disable grouping
<a name="v12-alerting-explore-notifications-disable-grouping"></a>

Should you wish to receive every alert as a separate notification, you can do so by grouping by a special label called `...`. This is useful when your alerts are being delivered to an automated system instead of a first-responder.

#### A single group for all alerts
<a name="v12-alerting-explore-notifications-a-single-group-for-all-alerts"></a>

Should you wish to receive all alerts together in a single notification, you can do so by leaving Group by empty.

### Timing options
<a name="v12-alerting-explore-notifications-timing-options"></a>

The timing options decide how often notifications are sent for each group of alerts. There are three timers that you need to know about: Group wait, Group interval, and Repeat interval.

#### Group wait
<a name="v12-alerting-explore-notifications-group-wait"></a>

Group wait is the amount of time Grafana waits before sending the first notification for a new group of alerts. The longer Group wait is the more time you have for other alerts to arrive. The shorter Group wait is the earlier the first notification will be sent, but at the risk of sending incomplete notifications. You should always choose a Group wait that makes the most sense for your use case.

**Default** 30 seconds

#### Group interval
<a name="v12-alerting-explore-notifications-group-interval"></a>

Once the first notification has been sent for a new group of alerts, Grafana starts the Group interval timer. This is the amount of time Grafana waits before sending notifications about changes to the group. For example, another firing alert might have just been added to the group while an existing alert might have resolved. If an alert was too late to be included in the first notification due to Group wait, it will be included in subsequent notifications after Group interval. Once Group interval has elapsed, Grafana resets the Group interval timer. This repeats until there are no more alerts in the group after which the group is deleted.

**Default** 5 minutes

#### Repeat interval
<a name="v12-alerting-explore-notifications-repeat-interval"></a>

Repeat interval decides how often notifications are repeated if the group has not changed since the last notification. You can think of these as reminders that some alerts are still firing. Repeat interval is closely related to Group interval, which means your Repeat interval must not only be greater than or equal to Group interval, but also must be a multiple of Group interval. If Repeat interval is not a multiple of Group interval it will be coerced into one. For example, if your Group interval is 5 minutes, and your Repeat interval is 9 minutes, the Repeat interval will be rounded up to the nearest multiple of 5 which is 10 minutes.

**Default** 4 hours

# Alerting high availability
<a name="v12-alerting-explore-high-availability"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 12.x**.  
For Grafana workspaces that support Grafana version 10.x, see [Working in Grafana version 10](using-grafana-v10.md).  
For Grafana workspaces that support Grafana version 9.x, see [Working in Grafana version 9](using-grafana-v9.md).  
For Grafana workspaces that support Grafana version 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

Amazon Managed Grafana is configured for high availability, including running multiple instances across multiple availability zones for each workspace that you create.

Grafana Alerting uses the Prometheus model of separating the evaluation of alert rules from the delivering of notifications. In this model the evaluation of alert rules is done in the alert generator and the delivering of notifications is done in the alert receiver. In Grafana Alerting, the alert generator is the Scheduler and the receiver is the Alertmanager.

With high availability configurations, all alert rules are evaluated on all instances. You can think of the evaluation of alert rules as being duplicated. This is how Grafana Alerting makes sure that as long as at least one Grafana instance is working, alert rules will still be evaluated and notifications for alerts will still be sent. You will see this duplication in state history, and is a good way to tell if you are using high availability.

# Set up Alerting
<a name="v12-alerting-setup"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 12.x**.  
For Grafana workspaces that support Grafana version 10.x, see [Working in Grafana version 10](using-grafana-v10.md).  
For Grafana workspaces that support Grafana version 9.x, see [Working in Grafana version 9](using-grafana-v9.md).  
For Grafana workspaces that support Grafana version 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

Configure the features and integrations that you need to create and manage your alerts.

**Prerequisites**

Before you set up alerting, you must do the following.
+ Configure your [data sources](AMG-data-sources.md).
+ Ensure that the data source you choose are compatible with and supported by [Grafana alerting](v12-alerting-overview-datasources.md).

**To set up alerting**

1. Configure [alert rules](v12-alerting-configure.md).
   + Create Grafana-managed or data-source managed alert rules and recording rules.

1. Configure [contact points](v12-alerting-configure-contactpoints.md).
   + Check the default contact point, and update the contact for your system.
   + Optionally, add new contact points and integrations.

1. Configure [notification policies](v12-alerting-explore-notifications-policies-details.md)
   + Check the default notification policy, and update for your system.
   + Optionally, add additional nested policies.
   + Optionally, add labels and label matchers to control alert routing.

The following topics give you more information about additional configuration options, including configuring external alert managers and routing Grafana-managed alerts outside of Grafana.

**Topics**
+ [

# Migrating classic dashboard alerts to Grafana alerting
](v12-alerting-use-grafana-alerts.md)
+ [

# Adding an external Alertmanager
](v12-alerting-setup-alertmanager.md)
+ [

# Provisioning Grafana Alerting resources
](v12-alerting-setup-provision.md)

# Migrating classic dashboard alerts to Grafana alerting
<a name="v12-alerting-use-grafana-alerts"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 12.x**.  
For Grafana workspaces that support Grafana version 10.x, see [Working in Grafana version 10](using-grafana-v10.md).  
For Grafana workspaces that support Grafana version 9.x, see [Working in Grafana version 9](using-grafana-v9.md).  
For Grafana workspaces that support Grafana version 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

Workspaces that choose not to use Grafana alerting use the [Classic dashboard alerts](old-alerts-overview.md). To switch to the new Grafana alerting, you must opt in to the feature. To see details about the differences between classic dashboard alerting and Grafana alerting, see [Grafana alerting vs legacy dashboard alerting](#v12-alerting-diff-old-new). GrafanaLabs has announced that classic dashboard alerts will be removed in version 11.

When you are using classic dashboard alerting, Amazon Managed Grafana shows you a preview of Grafana alerting where you can review and modify your upgraded alerts before finalizing the upgrade.

## Previewing Grafana alerts
<a name="v12-alerting-preview-grafana-alerts"></a>

You can preview your alerts in Grafana alerts before migrating. In the preview, you can make changes to the alerts that will change the migration.

**To preview your Grafana alerting migration**

1. Sign into your Grafana workspace.

1. From the left menu, choose **Alerting (legacy)** to view your current alerts.

1. From the left menu, choose **Alerting upgrade** to view your alerts in Grafana alerting.

   From this view, you can see what your alerts will look like after migration.

**Note**  
From this view, you can also make changes that will affect your migration. To undo any changes you make, choose **Reset upgrade** at the top right of the upgrade page.

When you are ready to upgrade your alerts, see the next section.

## Migrating to Grafana alerting system
<a name="v12-alerting-use-grafana-alerts-opt-in"></a>

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).

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="v12-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.

## Grafana alerting vs legacy dashboard alerting
<a name="v12-alerting-diff-old-new"></a>

Introduced in Grafana 8, Grafana alerting has several enhancements over legacy dashboard alerting.

### Multi-dimensional alerting
<a name="v12-alerts-diff-multi-dimensional"></a>

You can now create alerts that give you system-wide visibility with a single alerting rule. Generate multiple alert instances from a single alert rule. For example, you can create a rule to monitor the disk usage of multiple mount points on a single host. The evaluation engine returns multiple time series from a single query, with each time series identified by its label set.

### Create alerts outside of Dashboards
<a name="v12-alerts-diff-alerts-outside-of-dashboards"></a>

Unlike legacy dashboard alerts, Grafana alerts allow you to create queries and expressions that combine data from multiple sources in unique ways. You can still link dashboards and panels to alerting rules using their ID and quickly troubleshoot the system under observation.

Since unified alerts are no longer directly tied to panel queries, they do not include images or query values in the notification email. You can use customized notification templates to view query values.

### Create Loki and Grafana Mimir alerting rules
<a name="v12-alerts-diff-loki-mimir-alerting-rules"></a>

In Grafana Alerting, you can manage Loki and Grafana Mimir alerting rules using the same UI and API as your Grafana managed alerts.

### View and search for alerts from Prometheus compatible data sources
<a name="v12-alerts-diff-view-alerts-from-prometheus"></a>

Alerts for Prometheus compatible data sources are now listed under the Grafana alerts section. You can search for labels across multiple data sources to quickly find relevant alerts.

### Special alerts for alert state NoData and Error
<a name="v12-alerts-diff-special-alerts"></a>

Grafana Alerting introduced a new concept of the alert states. When evaluation of an alerting rule produces state NoData or Error, Grafana Alerting will generate special alerts that will have the following labels:
+ `alertname` with value DatasourceNoData or DatasourceError depending on the state.
+ `rulename` name of the alert rule the special alert belongs to.
+ `datasource_uid` will have the UID of the data source that caused the state.
+ All labels and annotations of the original alert rule

You can handle these alerts the same way as regular alerts by adding a silence, route to a contact point, and so on.

**Note**  
If the rule uses many data sources and one or many returns no data, the special alert will be created for each data source that caused the alert state.

# Adding an external Alertmanager
<a name="v12-alerting-setup-alertmanager"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 12.x**.  
For Grafana workspaces that support Grafana version 10.x, see [Working in Grafana version 10](using-grafana-v10.md).  
For Grafana workspaces that support Grafana version 9.x, see [Working in Grafana version 9](using-grafana-v9.md).  
For Grafana workspaces that support Grafana version 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

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.

**Note**  
You can't use Amazon Managed Service for Prometheus as an external Alertmanager.

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.

External alertmanagers are 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.

**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.

**To add an external Alertmanager**

1. Choose **Connections** from the main left menu.

1. Search for `Alertmanager`.

1. Choose the **Create a new data source** button.

1. 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. Choose **Save & test**.

# Provisioning Grafana Alerting resources
<a name="v12-alerting-setup-provision"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 12.x**.  
For Grafana workspaces that support Grafana version 10.x, see [Working in Grafana version 10](using-grafana-v10.md).  
For Grafana workspaces that support Grafana version 9.x, see [Working in Grafana version 9](using-grafana-v9.md).  
For Grafana workspaces that support Grafana version 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

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
](v12-alerting-setup-provision-terraform.md)
+ [

# Viewing provisioned alerting resources in Grafana
](v12-alerting-setup-provision-view.md)

# Create and manage alerting resources using Terraform
<a name="v12-alerting-setup-provision-terraform"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 12.x**.  
For Grafana workspaces that support Grafana version 10.x, see [Working in Grafana version 10](using-grafana-v10.md).  
For Grafana workspaces that support Grafana version 9.x, see [Working in Grafana version 9](using-grafana-v9.md).  
For Grafana workspaces that support Grafana version 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

Use 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="v12-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="v12-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="v12-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="v12-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 point details).

   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 is 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="v12-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="v12-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="v12-alerting-setup-provision-tf-rules"></a>

[Alert rules](v12-alerting-configure.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="v12-alerting-setup-provision-view"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 12.x**.  
For Grafana workspaces that support Grafana version 10.x, see [Working in Grafana version 10](using-grafana-v10.md).  
For Grafana workspaces that support Grafana version 9.x, see [Working in Grafana version 9](using-grafana-v9.md).  
For Grafana workspaces that support Grafana version 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

You can 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.

# Configure alerting
<a name="v12-alerting-configure"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 12.x**.  
For Grafana workspaces that support Grafana version 10.x, see [Working in Grafana version 10](using-grafana-v10.md).  
For Grafana workspaces that support Grafana version 9.x, see [Working in Grafana version 9](using-grafana-v9.md).  
For Grafana workspaces that support Grafana version 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

Configure the features and integrations that you need to create and manage your alerts.

**Topics**
+ [

# Configure Grafana managed alert rules
](v12-alerting-configure-grafanamanaged.md)
+ [

# Configure data source managed alert rules
](v12-alerting-configure-datasourcemanaged.md)
+ [

# Configure recording rules
](v12-alerting-configure-recordingrules.md)
+ [

# Configure contact points
](v12-alerting-configure-contactpoints.md)
+ [

# Configure notification policies
](v12-alerting-configure-notification-policies.md)

# Configure Grafana managed alert rules
<a name="v12-alerting-configure-grafanamanaged"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 12.x**.  
For Grafana workspaces that support Grafana version 10.x, see [Working in Grafana version 10](using-grafana-v10.md).  
For Grafana workspaces that support Grafana version 9.x, see [Working in Grafana version 9](using-grafana-v9.md).  
For Grafana workspaces that support Grafana version 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

Grafana-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. Using images in alert notifications is also supported. This is the only type of rule that allows alerting from multiple data sources in a single rule definition.

Multiple alert instances can be created as a result of one alert rule (also known as multi-dimensional alerting).

Grafana managed alert rules can only be edited or deleted by users with Edit permissions for the folder storing the rules.

If you delete an alerting resource created in the UI, you can no longer retrieve it. To make a backup of your configuration and to be able to restore deleted alerting resources, create your alerting resources using Terraform, or the Alerting API.

In the following procedures, we’ll go through the process of creating your Grafana-managed alert rules.

To create a Grafana-managed alert rule, use the in-workspace alert creation flow and follow these steps to help you.

**Set alert rule name**

1. Choose **Alerting** -> **Alert rules** -> **\$1 New alert rule**.

1. Enter a name to identify your alert rule.

   This name is displayed in the alert rule list. It is also the `alertname` label for every alert instance that is created from this rule.

Next, define a query to get the data you want to measure and a condition that needs to be met before an alert rule fires.

**To define the query and condition**

1. Select a data source.

1. From the **Options** dropdown, specify a [time range](v12-dash-using-dashboards.md#v12-dash-setting-dashboard-time-range).
**Note**  
Grafana Alerting only supports fixed relative time ranges, for example, `now-24hr: now`.  
It does not support absolute time ranges: `2021-12-02 00:00:00 to 2021-12-05 23:59:592` or semi-relative time ranges: `now/d to: now`.

1. Add a query.

   To add multiple [queries](v12-panels-query-xform.md#v12-panels-query-xform-add), choose **Add query**.

   All alert rules are managed by Grafana by default. If you want to switch to a data source-managed alert rule, click **Switch to data source-managed alert rule**.

1. Add one or more [expressions](v12-panels-query-xform-expressions.md).

   1. For each expression, select either **Classic condition** to create a single alert rule, or choose from the **Math**, **Reduce**, and **Resample** options to generate a separate alert for each series.
**Note**  
When using Prometheus, you can use an instant vector and built-in functions, so you don’t need to add additional expressions.

   1. Choose **Preview** to verify that the expression is successful.

1. [Optional] To add a recovery threshold, turn the **Custom recovery threshold** toggle on and fill in a value for when your alert rule should stop firing.

   You can only add one recovery threshold in a query and it must be the alert condition.

1. Choose **Set as alert condition** on the query or expression you want to set as your alert condition.

Use alert rule evaluation to determine how frequently an alert rule should be evaluated and how quickly it should change its state.

To do this, you need to make sure that your alert rule is in the right evaluation group and set a pending period time that works best for your use case.

**To set alert evaluation behavior**

1. Select a folder or choose **\$1 New folder**.

1. Select an evaluation group or click **\$1 New evaluation group**.

   If you are creating a new evaluation group, specify the interval for the group.

   All rules within the same group are evaluated concurrently over the same time interval.

1. Enter a pending period.

   The pending period is the period in which an alert rule can be in breach of the condition until it fires.

   Once a condition is met, the alert goes into the **Pending** state. If the condition remains active for the duration specified, the alert transitions to the **Firing** state, else it reverts to the **Normal** state.

1. Turn on pause alert notifications, if required.
**Note**  
Pause alert rule evaluation to prevent noisy alerting while tuning your alerts. Pausing stops alert rule evaluation and does not create any alert instances. This is different to mute timings, which stop notifications from being delivered, but still allow for alert rule evaluation and the creation of alert instances.  
You can pause alert rule evaluation to prevent noisy alerting while tuning your alerts. Pausing stops alert rule evaluation and does not create any alert instances. This is different to mute timings, which stop notifications from being delivered, but still allow for alert rule evaluation and the creation of alert instances.

1. In **Configure no data and error handling**, configure alerting behavior in the absence of data.

   Use the guidelines later in this section.

Add labels to your alert rules to set which notification policy should handle your firing alert instances.

All alert rules and instances, irrespective of their labels, match the default notification policy. If there are no nested policies, or no nested policies match the labels in the alert rule or alert instance, then the default notification policy is the matching policy.

**To configure notifications**

1. Add labels if you want to change the way your notifications are routed.

   Add custom labels by selecting existing key-value pairs from the drop down, or add new labels by entering the new key or value.

1. Preview your alert instance routing set up.

   Based on the labels added, alert instances are routed to the notification policies displayed.

   Expand each notification policy to view more details.

1. Choose **See details** to view alert routing details and a preview.

Add [annotations](v12-alerting-overview-labels.md#v12-alerting-overview-labels-annotations) to provide more context on the alert in your alert notification message.

Annotations add metadata to provide more information on the alert in your alert notification message. For example, add a **Summary** annotation to tell you which value caused the alert to fire or which server it happened on.

**To add annotations**

1. [Optional] Add a summary.

   Short summary of what happened and why.

1. [Optional] Add a description.

   Description of what the alert rule does.

1. [Optional] Add a Runbook URL.

   Webpage where you keep your runbook for the alert

1. [Optional] Add a custom annotation

1. [Optional] Add a dashboard and panel link.

   Links alerts to panels in a dashboard.

1. Choose **Save rule**.

**Single and multi-dimensional rule**

For Grafana managed alerts, you can create a rule with a classic condition or you can create a multi-dimensional rule.
+ **Rule with classic condition**

  Use the classic condition expression to create a rule that triggers 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.
+ **Multi-dimensional rule**

  To generate a separate alert for each series, create a multi-dimensional rule. Use `Math`, `Reduce`, or `Resample` expressions to create a multi-dimensional rule. For example:
  + 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](v12-alerting-overview-numeric.md)).
  + Add a `Math` expression with the condition for the rule. Not needed in case a query or a reduce expression already returns `0` if rule should not fire, or a positive number if it should fire. Some examples: `$B > 70` if it should fire in case value of B query/expression is more than 70. `$B < $C * 100` in case it should fire 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 [https://community.grafana.com/t/template-variables-are-not-supported-in-alert-queries-while-setting-up-alert/2514](https://community.grafana.com/t/template-variables-are-not-supported-in-alert-queries-while-setting-up-alert/2514).

**Configure no data and error handling**

Configure alerting behavior when your alert rule evaluation returns no data or an error.

**Note**  
Alert rules that are configured to fire when an evaluation returns no data or error only fire when the entire duration of the evaluation period has finished. This means that rather than immediately firing when the alert rule condition is breached, the alert rule waits until the time set as the **For** field has finished and then fires, reducing alert noise and allowing for temporary data availability issues.

If your alert rule evaluation returns no data, you can set the state on your alert rule to appear as follows:


| No Data | Description | 
| --- | --- | 
| No Data | Creates a new alert DatasourceNoData with the name and UID of the alert rule, and UID of the datasource that returned no data as labels. | 
| Alerting | Sets alert rule state to Alerting. The alert rule waits until the time set in the For field has finished before firing. | 
| Ok | Sets alert rule state to Normal. | 

If your evaluation returns an error, you can set the state on your alert rule to appear as follows:


| Error | Description | 
| --- | --- | 
| Error | Creates an alert instance DatasourceError with the name and UID of the alert rule, and UID of the datasource that returned no data as labels. | 
| Alerting | Sets alert rule state to Alerting. The alert rule waits until the time set in the For field has finished before firing. | 
| Ok | Sets alert rule state to Normal. | 

**Resolve stale alert instances**

An alert instance is considered stale if its dimension or series has disappeared from the query results entirely for two evaluation intervals.

Stale alert instances that are in the `Alerting`/`NoData`/`Error` states are automatically marked as `Resolved` and the `grafana_state_reason` annotation is added to the alert instance with the reason `MissingSeries`.

**Create alerts from panels**

Create alerts from any panel type. This means you can reuse the queries in the panel and create alerts based on them.

1. Navigate to a dashboard in the **Dashboards** section.

1. In the top right corner of the panel, choose the three dots (ellipses).

1. From the dropdown menu, select **More…** and then choose **New alert rule**.

This will open the alert rule form, allowing you to configure and create your alert based on the current panel’s query.

# Configure data source managed alert rules
<a name="v12-alerting-configure-datasourcemanaged"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 12.x**.  
For Grafana workspaces that support Grafana version 10.x, see [Working in Grafana version 10](using-grafana-v10.md).  
For Grafana workspaces that support Grafana version 9.x, see [Working in Grafana version 9](using-grafana-v9.md).  
For Grafana workspaces that support Grafana version 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

Create alert rules for an external Grafana Mimir or Loki instance that has ruler API enabled; these are called data source managed alert rules.

**Note**  
Alert rules for an external Grafana Mimir or Loki instance can be edited or deleted by users with Editor or Admin roles.  
If you delete an alerting resource created in the UI, you can no longer retrieve it. To make a backup of your configuration and to be able to restore deleted alerting resources, create your alerting resources using Terraform, or the Alerting API.

**Prerequisites**
+ Verify that you have write permission to the Prometheus or Loki data source. Otherwise, you will not be able to create or update Grafana Mimir managed alert 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 rule storage types.
  + **Grafana Mimir** - use the `/prometheus` prefix. The Prometheus data source supports both Grafana Mimir and Prometheus, and Grafana expects that both the [Query API](https://grafana.com/docs/mimir/latest/operators-guide/reference-http-api/#querier--query-frontend) and [Ruler API](https://grafana.com/docs/mimir/latest/operators-guide/reference-http-api/#ruler) are under the same URL. You cannot provide a separate URL for the Ruler API.

**Note**  
If you do not want to manage alert rules for a particular Loki or Prometheus data source, go to its settings and clear the **Manage alerts via alerting UI** checkbox.

In the following procedures, we’ll guide you through the process of creating your data source managed alert rules.

To create a data source-managed alert rule, use the in-workspace alert creation flow and follow these steps to help you.

**To set the alert rule name**

1. Choose **Alerting** -> **Alert rules** -> **\$1 New alert rule**.

1. Enter a name to identify your alert rule.

   This name is displayed in the alert rule list. It is also the `alertname` label for every alert instance that is created from this rule.

Define a query to get the data you want to measure and a condition that needs to be met before an alert rule fires.

**To define query and condition**

1. All alert rules are managed by Grafana by default. To switch to a data source managed alert rule, choose **Switch to data source-managed alert rule**.

1. Select a data source from the drop-down list.

   You can also choose **Open advanced data source picker** to see more options, including adding a data source (Admins only).

1. Enter a PromQL or LogQL query.

1. Choose **Preview alerts**.

Use alert rule evaluation to determine how frequently an alert rule should be evaluated and how quickly it should change its state.

**To set alert evaluation behavior**

1. Select a namespace or choose **\$1 New namespace**.

1. Select an evaluation group or choose **\$1 New evaluation group**.

   If you are creating a new evaluation group, specify the interval for the group.

   All rules within the same group are evaluated sequentially over the same time interval.

1. Enter a pending period.

   The pending period is the period in which an alert rule can be in breach of the condition until it fires.

   Once a condition is met, the alert goes into the `Pending` state. If the condition remains active for the duration specified, the alert transitions to the `Firing` state, else it reverts to the `Normal` state.

Add labels to your alert rules to set which notification policy should handle your firing alert instances.

All alert rules and instances, irrespective of their labels, match the default notification policy. If there are no nested policies, or no nested policies match the labels in the alert rule or alert instance, then the default notification policy is the matching policy.

**Configure notifications**
+ Add labels if you want to change the way your notifications are routed.

  Add custom labels by selecting existing key-value pairs from the drop down, or add new labels by entering the new key or value.

Add [annotations](v12-alerting-overview-labels.md#v12-alerting-overview-labels-annotations) to provide more context on the alert in your alert notifications.

Annotations add metadata to provide more information on the alert in your alert notifications. For example, add a `Summary` annotation to tell you which value caused the alert to fire or which server it happened on.

**To add annotations**

1. [Optional] Add a summary.

   Short summary of what happened and why.

1. [Optional] Add a description.

   Description of what the alert rule does.

1. [Optional] Add a Runbook URL.

   Webpage where you keep your runbook for the alert

1. [Optional] Add a custom annotation

1. [Optional] Add a dashboard and panel link.

   Links alerts to panels in a dashboard.

1. Choose **Save rule**.

# Configure recording rules
<a name="v12-alerting-configure-recordingrules"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 12.x**.  
For Grafana workspaces that support Grafana version 10.x, see [Working in Grafana version 10](using-grafana-v10.md).  
For Grafana workspaces that support Grafana version 9.x, see [Working in Grafana version 9](using-grafana-v9.md).  
For Grafana workspaces that support Grafana version 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

You can 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.

**Note**  
Recording rules are run as instance rules, and run every 10 seconds.

**Prerequisites**
+ Verify that you have write permissions to the Prometheus or Loki data source. You will be creating or updating alerting rules in your data source.
+ 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 `/prometheus` prefix. 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 create recording rules**

1. From your Grafana console, in the Grafana menu, choose **Alerting**, **Alert rules**.

1. Choose **New recording rule**.

1. Set rule name.

   The recording rule name must be a Prometheus metric name and contain no whitespace.

1. Define query
   + Select your Loki or Prometheus data source.
   + Enter a query.

1. Add namespace and group.
   + From the **Namespace** dropdown, select an existing rule namespace or add a new one. Namespaces can contain one or more rule groups and only have an organizational purpose.
   + From the **Group** dropdown, select an existing group within the selected namespace or add a new one. Newly created rules are appended to the end of the group. Rules within a group are run sequentially at a regular interval, with the same evaluation time.

1. Add labels.
   + Add custom labels selecting existing key-value pairs from the dropdown, or add new labels by entering the new key or value.

1. Choose **Save rule** to save the rule, or **Save rule and exit** to save the rule and go back to the Alerting page.

# Configure contact points
<a name="v12-alerting-configure-contactpoints"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 12.x**.  
For Grafana workspaces that support Grafana version 10.x, see [Working in Grafana version 10](using-grafana-v10.md).  
For Grafana workspaces that support Grafana version 9.x, see [Working in Grafana version 9](using-grafana-v9.md).  
For Grafana workspaces that support Grafana version 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

Use contact points to define how your contacts are notified when an alert rule fires.

**Note**  
You can create and edit contact points for Grafana managed alerts. Contact points for data source managed alerts are read-only.

## Working with contact points
<a name="v12-alerting-configure-contactpoints-working"></a>

The following procedures show how to add, edit, delete, and test a contact point.

**To add a contact point**

1. In the left-side menu, choose **Alerting**.

1. Choose **Contact points**.

1. From the **Choose Alertmanager** dropdown, select an Alertmanager. The Grafana Alertmanager is selected by default.

1. On the **Contact Points** tab, choose **\$1 Add contact point**.

1. Enter a **Name** for the contact point.

1. From **Integration**, choose a type, and fill out 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. To add another contact point integration, choose **Add contact point integration** and repeat the steps for each contact point type needed.

1. Save your changes.

**To edit a contact point**

1. In the left-side menu, choose **Alerting**.

1. Choose **Contact points** to see a list of existing contact points.

1. Select the contact point to edit, then choose **Edit**.

1. Update the contact point, and then save your changes.

You can delete contact points that are not in use by a notification policy.

**To delete a contact point**

1. In the left-side menu, choose **Alerting**.

1. Choose **Contact points** to open the list of existing contact points.

1. On the **Contact points**, select the contact point to delete, then choose **More**, **Delete**.

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.

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. In the left-side menu, choose **Alerting**.

1. Choose **Contact points** to open the list of existing contact points.

1. On the **Contact points**, select the contact point to test, then choose **Edit**. You can also create a new contact point if needed.

1. Choose **Test** to open the contact point testing dialog.

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.

## Configure contact point integrations
<a name="v12-alerting-configure-contactpoints-integration"></a>

Configure contact point integrations in Grafana to select your preferred communication channel for receiving notifications when your alert rules are firing. Each integration has its own configuration options and setup process. In most cases, this involves providing an API key or a Webhook URL.

Once configured, you can use integrations as part of your contact points to receive notifications whenever your alert changes its state. In this section, we’ll cover the basic steps to configure an integration, using PagerDuty as an example, so you can start receiving real-time alerts and stay on top of your monitoring data.

**List of supported integrations**

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` | 

**Configuring PagerDuty for alerting**

To set up PagerDuty, you must provide an integration key. Provide the following details.


| Setting | Description | 
| --- | --- | 
| Integration Key | Integration key for PagerDuty | 
| Severity | Level for dynamic notifications. Default is critical. | 
| Custom Details | Additional details about the event | 

The `CustomDetails` field is an object containing arbitrary key-value pairs. The user-defined details are merged with the ones used by default.

The default values for `CustomDetails` are:

```
{
	"firing":       `{{ template "__text_alert_list" .Alerts.Firing }}`,
	"resolved":     `{{ template "__text_alert_list" .Alerts.Resolved }}`,
	"num_firing":   `{{ .Alerts.Firing | len }}`,
	"num_resolved": `{{ .Alerts.Resolved | len }}`,
}
```

In case of duplicate keys, the user-defined details overwrite the default ones.

# Configure notification policies
<a name="v12-alerting-configure-notification-policies"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 12.x**.  
For Grafana workspaces that support Grafana version 10.x, see [Working in Grafana version 10](using-grafana-v10.md).  
For Grafana workspaces that support Grafana version 9.x, see [Working in Grafana version 9](using-grafana-v9.md).  
For Grafana workspaces that support Grafana version 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

Notification policies determine how alerts are routed to contact points.

Policies have a tree structure, where each policy can have one or more nested policies. Each policy, except for the default policy, can also match specific alert labels.

Each alert is evaluated by the default policy and subsequently by each nested policy.

If you enable the `Continue matching subsequent sibling nodes` option for a nested 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 default policy governs any alert that does not match a nested policy.

For more information on notification policies, see [Notifications](v12-alerting-explore-notifications.md).

The following procedures show you how to create and manage notification policies.

**To edit the default notification policy**

1. In the left-side menu, choose **Alerting**.

1. Choose **Notification policies**.

1. From the **Choose Alertmanager** dropdown, select the Alertmanager you want to edit.

1. In the **Default policy** section, choose **...**, **Edit**.

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 to group alerts by. If multiple alerts are matched for this policy, then they are grouped by these labels. A notification is sent per group. If the field is empty (the default), then all notifications are sent in a single group. Use a special label, `...` to group alerts by all labels (which effectively disables grouping).

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 create a new notification policy, you need to follow its tree structure. New policies created on the trunk of the tree (the default policy), are the tree branches. Each branch can have their own nested policies. This is why you will always be adding a new **nested** policy, either under the default policy, or under an already nested policy.

**To add a new nested policy**

1. In the left-side menu, choose **Alerting**.

1. Choose **Notification policies**.

1. From the **Choose Alertmanager** dropdown, select the Alertmanager you want to edit.

1. To add a top level specific policy, go to the Specific routing section (eitehr to the default policy, or to antoher existing policy in which you would like to add a new nested policy) and choose **\$1 New nested policy**.

1. In the matching labels section, add one or more rules for matching alert labels.

1. In the **Contact point** dropdown, select the contact point to send notifications to if an alert matches only this specific policy and not any of the nested policies.

1. Optionally, enable **Continue matching subsequent sibling nodes** to continue matching sibling policies even after the alert matched the current policy. When this option is enabled, you can get more than one notification for one alert.

1. Optionally, enable **Override grouping** to specify the same grouping as the default policy. If the option is not enabled, the default policy grouping is used.

1. Optionally, enable **Override general timings** to override the timing options configured in the group notification policy.

1. Choose **Save policy** to save your changes.

**To edit a nested policy**

1. In the left-side menu, choose **Alerting**.

1. Choose **Notification policies**.

1. Select the policy that you want to edit, then choose **...**, **Edit**.

1. Make any changes (as when adding a nested policy).

1. Save your changes.

**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. The policies that use that contact point will be highlighted in the user interface.
+ To search by label, enter a valid label matcher in the **Search by matchers** input 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.

# Manage your alerts
<a name="v12-alerting-manage"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 12.x**.  
For Grafana workspaces that support Grafana version 10.x, see [Working in Grafana version 10](using-grafana-v10.md).  
For Grafana workspaces that support Grafana version 9.x, see [Working in Grafana version 9](using-grafana-v9.md).  
For Grafana workspaces that support Grafana version 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

Once you have set up your alert rules, contact points, and notification policies, you can use Grafana alerting to manage your alerts in practice.

**Topics**
+ [

# Customize notifications
](v12-alerting-manage-notifications.md)
+ [

# Manage contact points
](v12-alerting-manage-contactpoints.md)
+ [

# Silencing alert notifications
](v12-alerting-silences.md)
+ [

# View and filter alert rules
](v12-alerting-manage-rules-viewfilter.md)
+ [

# Mute timings
](v12-alerting-manage-muting.md)
+ [

# View the state and health of alert rules
](v12-alerting-manage-rulestate.md)
+ [

# View and filter by alert groups
](v12-alerting-manage-viewfiltergroups.md)
+ [

# View notification errors
](v12-alerting-manage-viewnotificationerrors.md)

# Customize notifications
<a name="v12-alerting-manage-notifications"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 12.x**.  
For Grafana workspaces that support Grafana version 10.x, see [Working in Grafana version 10](using-grafana-v10.md).  
For Grafana workspaces that support Grafana version 9.x, see [Working in Grafana version 9](using-grafana-v9.md).  
For Grafana workspaces that support Grafana version 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

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 Amazon SNS 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
](v12-alerting-notifications-go-templating.md)
+ [

# Create notification templates
](v12-alerting-create-templates.md)
+ [

## Using notification templates
](#v12-alerting-use-notification-templates)
+ [

# Template reference
](v12-alerting-template-reference.md)

# Using Go’s templating language
<a name="v12-alerting-notifications-go-templating"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 12.x**.  
For Grafana workspaces that support Grafana version 10.x, see [Working in Grafana version 10](using-grafana-v10.md).  
For Grafana workspaces that support Grafana version 9.x, see [Working in Grafana version 9](using-grafana-v9.md).  
For Grafana workspaces that support Grafana version 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

You 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="v12-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](v12-alerting-create-templates.md), and all data and functions in the [Template reference](v12-alerting-template-reference.md).

## Opening and closing tags
<a name="v12-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="v12-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](#v12-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="v12-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="v12-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 }}
```

## The index functions
<a name="v12-go-index"></a>

To print a specific annotation or label use the `index` function.

```
{{ range .Alerts }}
The name of the alert is {{ index .Labels "alertname" }}
{{ end }}
```

## If statements
<a name="v12-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="v12-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="v12-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="v12-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="v12-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 }}
```

## Execute templates
<a name="v12-go-execute"></a>

You can execute 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="v12-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="v12-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="v12-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="v12-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="v12-alerting-create-templates"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 12.x**.  
For Grafana workspaces that support Grafana version 10.x, see [Working in Grafana version 10](using-grafana-v10.md).  
For Grafana workspaces that support Grafana version 9.x, see [Working in Grafana version 9](using-grafana-v9.md).  
For Grafana workspaces that support Grafana version 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

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="v12-alerting-creating-templates"></a>

**To create a notification template**

1. Choose **Alerting**, **Contact points**.

1. Choose the **Notification Templates** tab, and then **\$1 Add notification 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. Save your changes.

   `{{ 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. Choose **Alerting**, **Contact points**.

1. Choose the **Notification Templates** tab, and then **\$1 Add notification 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.

   Later sections show detailed examples for templates you might create.

1. Click Save.

## Preview notification templates
<a name="v12-alerting-preview-templates"></a>

Preview how your notification templates will look before using them in your contact points, helping you understand the result of the template you are creating as well as giving you a chance to fix any errors before saving the template.

**Note**  
Notification previews are only available for Grafana Alertmanager.

**To preview your notification templates**

1. Choose **Alerting**, **Contact points**.

1. Choose the **Notification Templates** tab, and then **\$1 Add notification template**, or edit an existing template.

1. Add or update your template content.

   Default data is provided and you can add or edit alert data to it as well as alert instances. You can add alert data directly in the Payload data window itself, or click **Select alert instances** or **Add custom alerts**.

1. [Optional] To add alert data from existing alert instances:

   1. Choose **Select alert instances**.

   1. Hover over the alert instances to view more information about each alert instance/

   1. Choose **Confirm** to add the alert instance to the payload.

1. [Optional] To add alert data using the Alert data editor, choose **Add custom data**:

   1. Add annotations, custom labels, or set a dashboard or panel.

   1. Toggle Firing or resolved, depending on whether you want to add firing or resolved alerts to your notification.

   1. Choose **Add alert data**.

   1. Choose **Refresh preview** to see what your template content will look like and the corresponding payload data.

   If there are any errors in your template, they are displayed in the Preview and you can correct them before saving.

1. Save your changes.

## Creating a template for the subject of message
<a name="v12-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="v12-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="v12-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. Execute the template from the title field in your contact point integration.

   ```
   {{ template "slack.title" . }}
   ```

## Creating a template for the content of a Slack message
<a name="v12-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.

**Note**  
This template is for Grafana managed alerts only. To use the template for data source managed alerts, delete the references to DashboardURL and SilenceURL. For more information about configuring Prometheus notifications, see the [Prometheus documentation on notifications](https://prometheus.io/docs/alerting/latest/notifications/).

```
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. Execute the template from the text body field in your contact point integration:

   ```
   {{ template "slack.message" . }}
   ```

## Template both email and Slack with shared templates
<a name="v12-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="v12-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 the **Contact points** tab to see a list of existing contact points.

1. Choose **New**. Alternately, you can edit an existing contact point by choosing the **Edit** icon.

1. Enter the templates you wish to use in a 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. Choose **Save contact point**.

# Template reference
<a name="v12-alerting-template-reference"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 12.x**.  
For Grafana workspaces that support Grafana version 10.x, see [Working in Grafana version 10](using-grafana-v10.md).  
For Grafana workspaces that support Grafana version 9.x, see [Working in Grafana version 9](using-grafana-v9.md).  
For Grafana workspaces that support Grafana version 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

This section provides reference information for creating your templates.

**Alert (type)**

The alert type contains the following data.


| Name | Kind | Description | Example | 
| --- | --- | --- | --- | 
|  Status  |  string  |  `firing` or `resolved`.  | \$1\$1 .Status \$1\$1 | 
|  Labels  |  KeyValue  |  A set of labels attached to the alert.  | \$1\$1 .Labels \$1\$1 | 
|  Annotations  |  KeyValue  |  A set of annotations attached to the alert.  | \$1\$1 .Annotations \$1\$1 | 
| Values | KeyValue | The values of all expressions, including Classic Conditions | \$1\$1 .Values \$1\$1 | 
|  StartsAt  |  time.Time  |  Time the alert started firing.  | \$1\$1 .StartsAt \$1\$1 | 
|  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.  | \$1\$1 .EndsAt \$1\$1 | 
|  GeneratorURL  |  string  |  A back link to Grafana or external Alertmanager.  | \$1\$1 .GeneratorURL \$1\$1 | 
|  SilenceURL  |  string  |  A link to silence the alert (with labels for this alert pre-filled). Only for Grafana managed alerts.  | \$1\$1 .SilenceURL\$1\$1 | 
|  DashboardURL  |  string  |  Link to grafana dashboard, if alert rule belongs to one. Only for Grafana managed alerts.  | \$1\$1 .DashboardURL \$1\$1 | 
|  PanelURL  |  string  |  Link to grafana dashboard panel, if alert rule belongs to one. Only for Grafana managed alerts.  | \$1\$1 .PanelURL \$1\$1 | 
|  Fingerprint  |  string  |  Fingerprint that can be used to identify the alert.  | \$1\$1 .Fingerprint \$1\$1 | 
|  ValueString  |  string  |  A string that contains the labels and value of each reduced expression in the alert.  | \$1\$1 .ValueString \$1\$1 | 

 **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 names  | `{{ .Names }}` | 
|  Values  |    |  []string  |  List of 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).

# Manage contact points
<a name="v12-alerting-manage-contactpoints"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 12.x**.  
For Grafana workspaces that support Grafana version 10.x, see [Working in Grafana version 10](using-grafana-v10.md).  
For Grafana workspaces that support Grafana version 9.x, see [Working in Grafana version 9](using-grafana-v9.md).  
For Grafana workspaces that support Grafana version 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

The **Contact points** list view lists all existing contact points and notification templates.

On the **Contact points** tab, you can:
+ Search for names and types of contact points and integrations.
+ View all existing contact points and integrations.
+ View how many notification policies each contact point is being used for, and navigate directly to the linked notification policies.
+ View the status of notification deliveries.
+ Export individual contact points or all contact points in JSON, YAML, or Terraform format.
+ Delete contact points that are not in use by a notification policy.

On the **Notification templates** tab, you can:
+ View, edit, copy, or delete existing notification templates.

# Silencing alert notifications
<a name="v12-alerting-silences"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 12.x**.  
For Grafana workspaces that support Grafana version 10.x, see [Working in Grafana version 10](using-grafana-v10.md).  
For Grafana workspaces that support Grafana version 9.x, see [Working in Grafana version 9](using-grafana-v9.md).  
For Grafana workspaces that support Grafana version 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

You can 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.

**Note**  
To suppress alert notifications at regular time intervals, for example, during regular maintenance periods, use [Mute timings](v12-alerting-manage-muting.md) rather than silences.

**To add a silence**

1. From your Grafana console, in the Grafana menu, choose **Alerting**.

1. Choose **Silences**.

1. Choose an Alertmanager from the **Alertmanager** dropdown.

1. Choose **Create 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.

1. 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 **Label** and **Value** fields, enter one or more *Matching Labels*. Matchers determine which rules the silence applies to. Any matching alerts (in firing state), will show in the **Affected alerts instances** field.

1. Optionally, add a **Comment** describing the silence.

1. Choose **Submit**.

**To edit a silence**

1. From your Grafana console, in the Grafana menu, choose **Alerting**.

1. Choose **Silences** to view the list of existing silences.

1. Find the silence you want to edit, then choose **Edit** (pen icon).

1. Make any desired changes, then choose **Submit** to save your changes.

You can edit an existing silence by choosing the **Edit** icon (pen).

**To create a URL link to a silence form**

When linking to a silence form, provide the default matching labels and comment via `matcher` and `comment` query parameters. The `matcher` parameter should be in the following format `[label][operator][value]` where the `operator` parameter can be one of the following: `=` (equals, not regex), `!=` (not equals, not regex), `=~` (equals, regex), `!~` (not equals, regex). The URL can contain many query parameters with the key `matcher`. For example, to link to silence form with matching labels `severity=critical` & `cluster!~europe-.*` and comment `Silence critical EU alerts`, create a URL `https://mygrafana/alerting/silence/new?matcher=severity%3Dcritical&matcher=cluster!~europe-*&comment=Silence%20critical%20EU%20alert`.

To link to a new silence page for an external Alertmanager, add an `alertmanager` query parameter

**To remove a silence**

1. From your Grafana console, in the Grafana menu, choose **Alerting**.

1. 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.

# View and filter alert rules
<a name="v12-alerting-manage-rules-viewfilter"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 12.x**.  
For Grafana workspaces that support Grafana version 10.x, see [Working in Grafana version 10](using-grafana-v10.md).  
For Grafana workspaces that support Grafana version 9.x, see [Working in Grafana version 9](using-grafana-v9.md).  
For Grafana workspaces that support Grafana version 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

The **Alerting** page lists alerting rules. By default, rules are grouped by types of data sources. The **Grafana** section lists rules managed by Grafana. Alert rules for Prometheus compatible data sources are also listed here. 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.

## View alert rules
<a name="v12-alerting-manage-rules-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 **Alerting**, **Alert rules**. By default, the list view is displayed.

1. In **View as**, you can toggle between the Grouped, List, and State views by choosing the option you prefer.

1. Expand the rule row to view the rule labels, annotations, data sources, the rule queries, and a list of alert instances resulting from the rule.

From this page, you can also make copies of an alert rule to help you reuse existing rules.

## Export alert rules
<a name="v12-alerting-manage-rules-export"></a>

You can export rules to YAML or JSON in the Grafana workspace.
+ Choose the **Export rule group** icon next to each alert rule group to export to YAML, JSON, or Terraform.
+ Choose **Export rules** to export all Grafana managed alert rules to YAML, JSON, or Terraform.
+ Choose **More**, **Modify export** next to each individual alert rule within a group to edit provisioned alert rules and export a modified version.

## View query definitions for provisioned alerts
<a name="v12-alerting-manage-rules-querydef"></a>

View read-only query definitions for provisioned alerts. Check quickly if your alert rule queries are correct, without diving into your "as-code" repository for rule definitions.

**Grouped view**

Grouped 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.

## Filtering alert rules
<a name="v12-alerting-manage-rules-filter"></a>

You can filter the alerting rules that appear on the **Alerting** page in several ways.

**To filter alert rules**

1. From **Select data sources**, select a data source.. You can see alert rules that query the selected data source.

1. In **Search by label**, enter search criteria using label selectors. For example, `environment=production;region=~US|EU,severity!=warning`.

1. From **Filter alerts by state**, select an alerting state you want to see. You can see alerting rules that match that state. Rules matching other states are hidden.

# Mute timings
<a name="v12-alerting-manage-muting"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 12.x**.  
For Grafana workspaces that support Grafana version 10.x, see [Working in Grafana version 10](using-grafana-v10.md).  
For Grafana workspaces that support Grafana version 9.x, see [Working in Grafana version 9](using-grafana-v9.md).  
For Grafana workspaces that support Grafana version 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

A 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 vs Silences
<a name="v12-alerting-manage-muting-compare"></a>

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. | 

## Adding a mute timing
<a name="v12-alerting-manage-muting-add"></a>

You can create mute timings in your Grafana workspace.

**To add a mute timing**

1. From your Grafana console, in the Grafana menu, choose **Alerting**.

1. Choose **Notification policies**, and then select the **Mute Timings** tab.

1. From the **Alertmanager** dropdown, select the Alertmanager you want to edit.

1. Choose the **\$1 Add mute timing** button.

1. Fill out the form to create a [time interval](#v12-alerting-manage-muting-interval) to match against for your mute timing.

1. Save your mute timing.

## Adding a mute timing to a notification policy
<a name="v12-alerting-manage-muting-add-notif"></a>

Once you have a mute timing, you use it by adding it to notification policy that you want to mute at regular intervals.

**To add a mute timing to a notification policy**

1. From your Grafana console, in the Grafana menu, choose **Alerting**.

1. Choose **Notification policies**, and then select the **Notification Policies** tab.

1. Select the notification policy you would like to add the mute timing to, and choose **...**, **Edit**.

1. From the **Mute timings** dropdown, select the mute timings you would like to add to the policy.

1. Save your changes.

## Time intervals
<a name="v12-alerting-manage-muting-interval"></a>

A time interval is a specific duration during which alerts are suppressed. The duration typically consists of a specific time range and the days of the week, month, or year. 

Support time interval options are:
+ **Time range** – The time inclusive of the start and exclusive of the end time (in UTC, if no location has been selected, otherwise local time.
+ **Location** – Sets the location for the timing—the time range is displayed in local time for the location.
+ **Days of the week** – The day or range of days of the week. For example, `monday:thursday`.
+ **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.
+ **Months** – The months of the year in either numerical of full calendar month name. For example, `1, may:august`.
+ **Years** – The year or years for the interval. For example, `2023:2024`.

Each of these elements can be a list, and at least one item in the element must be satisfied to be a match. Fields also support ranges, using `:`. For example, `monday:thursday`.

If a field is left blank, any moment of time will match the field. For an instant of to match a complete time intervale, all fields must match. A mute timing can contain multiple time intervals.

If you want to specify an exact duration, specify all the options needed for that duration. For example, if you want 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 the state and health of alert rules
<a name="v12-alerting-manage-rulestate"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 12.x**.  
For Grafana workspaces that support Grafana version 10.x, see [Working in Grafana version 10](using-grafana-v10.md).  
For Grafana workspaces that support Grafana version 9.x, see [Working in Grafana version 9](using-grafana-v9.md).  
For Grafana workspaces that support Grafana version 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

The state and health of alert rules gives you several key status indicators about your alerts.

There are three components:
+ [Alert rule state](#v12-alerting-manage-rulestate-state)
+ [Alert instance state](#v12-alerting-manage-rulestate-instance)
+ [Alert rule health](#v12-alerting-manage-rulestate-health)

Although related, each component conveys subtly different information.

**To view the state and health of your alert rules**

1. From your Grafana console, in the Grafana menu, choose **Alerting**.

1. Choose **Alert rules** to view the list of existing alerts.

1. Choose an alert rule to view its state and health.

## Alert rule state
<a name="v12-alerting-manage-rulestate-state"></a>

An alert rule can be in any 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 transition first to `pending` and then `firing`, thus it takes at least two evaluation cycles before an alert is fired.

## Alert instance state
<a name="v12-alerting-manage-rulestate-instance"></a>

An alert instance can be in any of the following states:


| State | Description | 
| --- | --- | 
| Normal | The state of an alert that is neither pending nor firing. Everything is working as expected. | 
| 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. | 
| No data | No data has been received for the configured time window. | 
| Alerting | An error occurred when attempting to evaluate an alerting rule. | 

## Keep last state
<a name="v12-alerting-manage-rulestate-keepstate"></a>

An alert rule can be configured to keep the last state when a `NoData` or `Error` state is encountered. This will both prevent alerts from firing, and from resolving and re-firing. Just like normal evaluation, the alert rule will transition from `pending` to `firing` after the pending period has elapsed.

## Alert rule health
<a name="v12-alerting-manage-rulestate-health"></a>

An alert rule can have one of the following health statuses.


| State | Description | 
| --- | --- | 
| Ok | No errors when evaluating the alert rule. | 
| Error | An error occurred when evaluating the alert rule. | 
| NoData | The absence of data in at least one time series returned during a rule evaluation. | 
| \$1status\$1, KeepLast | The rule would have received another status, but was configured to keep the last state of the alert rule. | 

## Special alerts for NoData and Error
<a name="v12-alerting-manage-rulestate-special"></a>

When evaluation of an alert rule produces the 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. | 

**Note**  
You will need to set the no data or error handling to `NoData` or `Error` in the alert rule, as described in the [Configure Grafana managed alert rules](v12-alerting-configure-grafanamanaged.md) topic, to generate the additional labels.

You can handle these alerts the same way as regular alerts, including adding silences, routing to a contact point, and so on.

# View and filter by alert groups
<a name="v12-alerting-manage-viewfiltergroups"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 12.x**.  
For Grafana workspaces that support Grafana version 10.x, see [Working in Grafana version 10](using-grafana-v10.md).  
For Grafana workspaces that support Grafana version 9.x, see [Working in Grafana version 9](using-grafana-v9.md).  
For Grafana workspaces that support Grafana version 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

Alert groups show grouped alerts from an Alertmanager instance. By default, alert rules are grouped by the label keys for the default 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. From your Grafana console, in the Grafana menu, choose **Alerting**.

1. Choose **Groups** to view existing groups.

1. From the **Alertmanager** dropdown, select an external Alertmanager as your data source.

1. From the **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`.

You can filter alerts by label or state of the alerts.

**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="v12-alerting-manage-viewnotificationerrors"></a>

****  
This documentation topic is designed for Grafana workspaces that support **Grafana version 12.x**.  
For Grafana workspaces that support Grafana version 10.x, see [Working in Grafana version 10](using-grafana-v10.md).  
For Grafana workspaces that support Grafana version 9.x, see [Working in Grafana version 9](using-grafana-v9.md).  
For Grafana workspaces that support Grafana version 8.x, see [Working in Grafana version 8](using-grafana-v8.md).

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. From the left menu, choose **Alerting** then **Contact points**.

   If any contact points are failing, a message at the right-hand corner of the workspace tells you that there are errors, and how many.

1. Select 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.