Documentationbreadcrumb arrow Pluginsbreadcrumb arrow DynamoDBbreadcrumb arrow Template variables
Grafana Cloud Enterprise
Last reviewed: April 28, 2026

DynamoDB template variables

Use template variables to create dynamic, reusable dashboards that let you change query parameters without editing individual panels. For general information about template variables, refer to Templates and variables.

Before you begin

Supported variable types

The DynamoDB data source supports the following variable types:

Variable typeSupported
QueryYes
CustomYes
Data sourceYes

Create a query variable

The variable query editor uses the same PartiQL code editor as the main query editor.

To create a query variable:

  1. Navigate to Dashboard settings > Variables.
  2. Click Add variable.
  3. Select Query as the variable type.
  4. Select the DynamoDB data source.
  5. Enter a PartiQL query in the query editor.
  6. Click Run query to preview the values.

Caution

Variable queries run each time the variable is refreshed. A SELECT without a partition key in the WHERE clause results in a full table scan. Use targeted queries to avoid excessive read capacity consumption.

Query return format

The query editor determines variable values based on the number of columns your query returns:

Columns returnedBehavior
One columnEach value is used as both the display text and the variable value.
Two or more columnsThe first column is used as the variable value (ID), and the second column is used as the display text. Additional columns are ignored.

Single-column example

This query returns a list of unique customer IDs for use as variable values:

SQL
SELECT DISTINCT customerId FROM "orders"

Each customerId value becomes both the display text and the substituted value.

Two-column example

This query returns an ID and a human-readable name:

SQL
SELECT sensorId, sensorName FROM "sensors"

The variable drop-down displays sensorName values, but the selected sensorId is substituted into queries.

Use variables in queries

Reference template variables in your PartiQL queries using the $variable or ${variable} syntax. Single-value variables are substituted as-is, so you must include quotes around string values in your query:

SQL
SELECT * FROM "orders" WHERE customerId = '$customer'

Or with the braced syntax:

SQL
SELECT timestamp AS time, metric_value
FROM "metrics"
WHERE sensorId = '${sensor}'
ORDER BY timestamp

For numeric values, omit the quotes:

SQL
SELECT * FROM "orders" WHERE orderTotal > $threshold

Multi-value variables

When a variable allows multiple selections, the DynamoDB data source formats the values as a comma-separated, single-quoted list. For example, if a user selects A, B, and C, the variable expands to 'A','B','C'.

Use multi-value variables with the IN operator:

SQL
SELECT * FROM "orders" WHERE status IN ($status)

If the user selects pending and shipped, this expands to:

SQL
SELECT * FROM "orders" WHERE status IN ('pending','shipped')

Next steps