---
title: "Sentry template variables | Grafana Plugins documentation"
description: "Use template variables with the Sentry data source for dynamic, reusable dashboards."
---

> For a curated documentation index, see [llms.txt](/llms.txt). For the complete documentation index, see [llms-full.txt](/llms-full.txt).

# Sentry template variables

Use template variables to create dynamic, reusable dashboards that let you switch between Sentry projects, environments, and teams without editing queries.

## Before you begin

- [Configure the Sentry data source](/docs/plugins/grafana-sentry-datasource/latest/configure/).
- Understand [Grafana template variables](/docs/grafana/latest/dashboards/variables/).

## Supported variable types

The Sentry data source supports the following variable query types.

Expand table

| Variable query type | Display value       | Actual value     | Additional filters   |
|---------------------|---------------------|------------------|----------------------|
| **Projects**        | Project name and ID | Project ID       | Optional team slug   |
| **Environments**    | Environment name    | Environment name | Optional project IDs |
| **Teams**           | Team name and slug  | Team slug        | None                 |

## Create a query variable

To create a query variable using the Sentry data source:

1. Navigate to **Dashboard settings** &gt; **Variables**.
2. Click **Add variable**.
3. Select **Query** as the variable type.
4. Select the **Sentry** data source.
5. In **Query Type**, select the type of Sentry entity you want to list: **Projects**, **Environments**, or **Teams**.
6. Configure additional filters based on the selected query type:
   
   - **Projects:** Optionally select a **Team slug** to only list projects belonging to that team. The team selector shows all teams in your organization.
   - **Environments:** Optionally select one or more **Project IDs** to list environments for those projects. If no project is selected, environments from all projects are listed.
   - **Teams:** No additional configuration is needed.

## Use variables in queries

After creating template variables, you can use them in query editor fields. The **Projects** and **Environments** drop-downs in the query editor automatically include your dashboard variables as selectable options, prefixed with `var:`.

For example, if you create a variable named `project` that lists Sentry projects, you can select `var: ${project}` in the **Projects** field of any Sentry query to dynamically filter by the selected project.

## Variable examples

The following examples show common template variable configurations.

### Filter dashboards by project

Create a variable that lets users select which Sentry project to display data for:

1. Create a variable named `project` with **Query Type** set to **Projects**.
2. Set **Selection options** to **Multi-value** if you want users to select multiple projects.
3. In your dashboard queries, select `var: ${project}` in the **Projects** field.

### Cascading project and environment variables

Create linked variables where the environment list depends on the selected project:

1. Create a variable named `project` with **Query Type** set to **Projects**.
2. Create a second variable named `environment` with **Query Type** set to **Environments**.
3. In the `environment` variable configuration, select `var: ${project}` in the **Project ID** selector.
4. When a user changes the project, the environment list updates automatically.

### Filter projects by team

Create a variable scoped to a specific team’s projects:

1. Create a variable named `team` with **Query Type** set to **Teams**.
2. Create a second variable named `project` with **Query Type** set to **Projects**.
3. In the `project` variable configuration, select `var: ${team}` in the **Team slug** selector.
4. When a user selects a team, only that team’s projects appear in the project variable.

For more information about using variables in queries, refer to [Variable syntax](/docs/grafana/latest/dashboards/variables/variable-syntax/).
