docs/sources/datasources/postgres/alerting/index.md
The PostgreSQL data source supports Grafana Alerting. You can create alert rules that evaluate time series queries against your PostgreSQL database and send notifications when conditions are met.
Only time series queries can be used in alert rule conditions.
time (native SQL date/time or UNIX epoch) and one or more numeric value columns.For details on writing time series queries, refer to Time series queries in the PostgreSQL query editor.
To create an alert rule that uses PostgreSQL:
time column and numeric value(s).For step-by-step guidance, refer to Create a Grafana-managed alert rule.
The following query returns a time series suitable for a threshold alert (e.g. alert when value exceeds a limit):
SELECT
$__timeGroupAlias("time_date_time", '5m'),
avg("value_double") AS value
FROM test_data
WHERE $__timeFilter("time_date_time")
GROUP BY time
ORDER BY time
Use condition types such as Is above or Is below in the alert rule to evaluate the series.
You can use template annotations and labels to include query results or metadata in alert notifications and labels.