DynamoDB alerting
The DynamoDB data source supports Grafana Alerting, which lets you define alert rules that evaluate PartiQL queries and trigger notifications when conditions are met. For general information about Grafana Alerting, refer to Alerting.
Before you begin
Query requirements for alerting
Alert rules evaluate query results to determine whether a condition is met. DynamoDB alert queries have the following requirements:
- Numeric results: The query must return at least one numeric column for Grafana to evaluate against a threshold or condition.
- Time-series format: For time-based alert conditions, alias a datetime column
AS timeso the plugin formats the result as a time series.
You can combine multiple queries (A, B, C) with Reduce and Math expressions to build complex alert conditions. Refer to Expression queries for details.
Caution
Alert queries run repeatedly on the configured evaluation interval. A
SELECTwithout a partition key in theWHEREclause results in a full table scan on every evaluation, which can rapidly consume read capacity and cause throttling. Always include a partition key filter in alert queries.
Note
The DynamoDB data source doesn’t support time-range macros such as
$__timeFilter. Alert queries must include explicit time filters or rely on DynamoDB’s data model to return only recent data. For details on timestamp formats and workarounds, refer to Dynamic time filtering doesn’t work.
Create an alert rule
To create an alert rule using the DynamoDB data source:
- Navigate to Alerting > Alert rules in the left-side menu.
- Click New alert rule.
- Select the DynamoDB data source.
- Enter a PartiQL query that returns a numeric result.
- Add a Reduce expression to aggregate the query result (for example, Last or Mean).
- Add a Threshold expression to define the alert condition (for example, “is above 90”).
- Set the evaluation interval and pending period.
- Configure notification settings (contact points and notification policies).
- Click Save rule and exit.
Alert query examples
The following examples show PartiQL queries suitable for alert rules.
Alert on error count
This query returns error counts over time for a specific application:
SELECT timestamp AS time, errorCount
FROM "application-metrics"
WHERE appId = 'my-app' AND metricType = 'errors'
ORDER BY timestamp DESCConfigure a Reduce expression with Last to get the most recent value, then add a Threshold expression set to “is above 100”.
Alert on response time
This query returns average response time, useful for detecting latency degradation:
SELECT timestamp AS time, avg(responseTime) AS avg_response_time
FROM "api-metrics"
WHERE serviceId = 'checkout'
GROUP BY timestamp
ORDER BY timestampConfigure a Reduce expression with Mean, then add a Threshold expression set to “is above 2000”.
Alert on low inventory
This query checks for products with stock below a threshold:
SELECT productId, stockCount
FROM "inventory"
WHERE warehouseId = 'warehouse-1' AND stockCount < 10Since this isn’t a time-series query, configure a Reduce expression with Min on the stockCount field, then add a Threshold expression set to “is below 5”.
Alert using multiple queries
You can use multiple queries to compare values. For example, to alert when error rate exceeds a percentage of total requests:
Query A – error count:
SELECT timestamp AS time, errorCount
FROM "application-metrics"
WHERE appId = 'my-app' AND metricType = 'errors'
ORDER BY timestamp DESCQuery B – total request count:
SELECT timestamp AS time, requestCount
FROM "application-metrics"
WHERE appId = 'my-app' AND metricType = 'requests'
ORDER BY timestamp DESCAdd Reduce expressions for each query using Last, then add a Math expression with the formula $A / $B * 100 to calculate the error percentage. Add a Threshold expression set to “is above 5” to alert when errors exceed 5%.
Next steps
- Refer to the full Grafana Alerting documentation for details on alert conditions, notification policies, and contact points.
- Learn how to write queries in the DynamoDB query editor.
- Troubleshoot DynamoDB data source issues if alerts aren’t firing as expected.


