| aliases |
|
||||||
|---|---|---|---|---|---|---|---|
| description | Set up Grafana Alerting with the Amazon Athena data source. | ||||||
| keywords |
|
||||||
| labels |
|
||||||
| menuTitle | Alerting | ||||||
| title | Amazon Athena alerting | ||||||
| weight | 460 | ||||||
| last_reviewed | 2026-02-20 |
Use Grafana Alerting with the Amazon Athena data source to receive notifications when your data meets specific conditions. For example, you can create alerts that trigger when error counts exceed a threshold or when costs rise above a budget.
Before you set up alerting, ensure you have the following prerequisites.
- Configure the Amazon Athena data source.
- Understand how to use the Amazon Athena query editor.
- Understand Grafana Alerting concepts.
To create an alert rule using the Amazon Athena data source:
- Click Alerting in the left-side menu.
- Click Alert rules.
- Click New alert rule.
- Enter a name for the alert rule.
- Select the Amazon Athena data source.
- Write a SQL query that returns the numeric value you want to evaluate.
- Configure the alert condition by selecting a reducer (such as Last or Mean) and a threshold.
- Set the evaluation interval and pending period.
- Configure notification settings and click Save rule and exit.
Alert rule queries must return numeric data that Grafana can evaluate against a threshold. Follow these guidelines when writing queries for alert rules.
- Return a numeric value: The query must return at least one numeric column that Grafana can evaluate.
- Use time-series format: Select the Time series format in the query editor. The query needs a time column in ascending order and a numeric value column.
- Keep queries efficient: Alert queries run at the configured evaluation interval. Use filters, partitions, and narrow time ranges to reduce data scanned and query execution time.
- Use macros for time filtering: Use
$__timeFilter(column)to automatically filter data to the alert evaluation window.
The following query counts errors per minute, which can be evaluated against a threshold.
SELECT
$__timeGroup(time, '1m') AS time,
COUNT(*) AS error_count
FROM error_logs
WHERE $__timeFilter(time) AND level = 'ERROR'
GROUP BY 1
ORDER BY 1 ASCAmazon Athena queries run asynchronously, which means they may take longer to complete than queries from other data sources. Keep the following considerations in mind when configuring alert rules.
- Evaluation interval: Set an evaluation interval that accounts for Athena query execution time. Queries that scan large amounts of data may take several seconds or longer to complete.
- Query result reuse: Enable query result reuse to reduce costs and query time for alert queries that run frequently. This requires Athena engine version 3.
- Data scan costs: Each alert evaluation runs a query against Athena, which incurs costs based on data scanned. Use partitioned tables and add
WHEREclause filters to minimize the amount of data scanned per evaluation. - Query caching: Enable query caching to reduce the number of queries sent to Athena (available in Grafana Enterprise and Grafana Cloud).