DynamoDB query editor
This document explains how to use the DynamoDB query editor to query your DynamoDB tables using PartiQL, a SQL-compatible query language supported by DynamoDB.
Before you begin
- Configure the DynamoDB data source.
- Verify your IAM identity has
dynamodb:PartiQLSelectpermission on the tables you want to query.
Key concepts
If you’re new to DynamoDB or PartiQL, here are key terms used in this documentation:
Query editor overview
The DynamoDB query editor provides a full-featured code editor for writing PartiQL statements. The editor includes syntax highlighting and line numbers.
To run a query, press Ctrl+S (or Cmd+S on macOS) or click the play button in the top-left corner of the editor.
Result formats
The query editor automatically detects the result format based on your query:
Create a query
You can create table queries for raw data display or time-series queries for graphing data over time. Table names in PartiQL must be enclosed in double quotes (for example, "my-table").
Caution
A
SELECTstatement without a partition key in theWHEREclause results in a full table scan, which can consume significant read capacity and cause throttling. Always include a partition key filter when querying large tables. Refer to the PartiQL select statement reference for details.
Table queries
Table queries return data in a tabular format suitable for table panels, stat panels, and other non-time-series visualizations.
To create a table query:
- Select the DynamoDB data source.
- Enter a PartiQL
SELECTstatement in the editor. - Press
Ctrl+Sor click the play button to run the query.
Example:
SELECT * FROM "my-table"To select specific attributes:
SELECT orderId, customerName, orderTotal FROM "orders"Time-series queries
To display data as a time series, alias a datetime column AS time in your query. The plugin uses this column as the timestamp for each data point. Grafana interprets timestamp values without an explicit time zone as UTC.
Caution
The DynamoDB data source doesn’t support time-range macros such as
$__from,$__to, or$__timeFilter. You must use explicit values in time-basedWHEREclauses. Additionally, ensure the timestamp column’s data type in DynamoDB matches the comparison format in your query. For example, a numeric epoch value stored as a string type causes lexicographic comparison instead of numeric, leading to incorrect results. Refer to Troubleshooting for more details.
Note
The format detection uses a simple substring match for
as timein the query text. Avoid using the phraseas timein string literals or other contexts unless you intend time-series formatting.
To create a time-series query:
- Select the DynamoDB data source.
- Write a PartiQL query that aliases a datetime column
AS time. - Press
Ctrl+Sor click the play button to run the query.
Example:
SELECT log_time AS time, cpu_usage FROM "server-metrics"Multi-line time series
To create multi-line time series, your query must return at least three fields in the following order:
- A datetime field aliased
AS time. - A field to group by (this becomes the series label).
- One or more metric value fields.
Example:
SELECT log_time AS time, machine_group, avg(disk_free) AS avg_disk_free
FROM "server-logs"
GROUP BY machine_group, log_time
ORDER BY log_timeThis query produces one time-series line per unique machine_group value.
Query examples
The following examples demonstrate common query patterns with DynamoDB.
Retrieve all items from a table
SELECT * FROM "my-table"Filter by partition key
SELECT * FROM "orders" WHERE customerId = 'C001'Aggregate metrics over time
SELECT timestamp AS time, avg(temperature) AS avg_temp
FROM "sensor-data"
WHERE sensorId = 'S100'
GROUP BY timestamp
ORDER BY timestampCount items by category
SELECT category, count(*) AS total FROM "products" GROUP BY categoryQuery a secondary index
Use dot notation to query a global secondary index:
SELECT * FROM "orders"."customerIndex" WHERE customerId = 'C001'Filter with multiple conditions
SELECT orderId, orderTotal, status
FROM "orders"
WHERE customerId = 'C001' AND status IN ('pending', 'shipped')Known limitations
- Querying data from nested maps isn’t supported and returns null values.
- Any column except
timeis treated as a value column in time-series queries.
Next steps
- Refer to the PartiQL reference for DynamoDB for the full query language syntax.
- Use template variables in your queries.
- Set up alerting based on DynamoDB data.
- Add annotations to your dashboards.


