OpenSearch alerting
The OpenSearch data source supports Grafana’s unified alerting system. You can create alert rules that query OpenSearch data and trigger notifications when specified conditions are met. Alert queries are executed on the Grafana server through the backend plugin, not in the browser.
For more information about Grafana alerting, refer to the Grafana alerting documentation.
Before you begin
- Configure the OpenSearch data source.
- Familiarize yourself with Grafana alerting concepts.
Supported query types
Alerting works with queries that return numeric time-series data that can be evaluated against a threshold or condition. The following table describes alerting support for each query type:
Note
The default PPL format is Table. To use PPL queries with alerting, change the Format drop-down to Time series in the query editor.
Create an alert rule
To create an alert rule using OpenSearch data:
- Navigate to Alerting > Alert rules.
- Click New alert rule.
- Select the OpenSearch data source.
- Build a query that returns numeric time-series data (refer to the examples in the following section).
- Define the alert condition, for example, when the average value exceeds a threshold.
- Configure notification settings.
- Click Save rule and exit.
For detailed instructions, refer to Create alert rules.
Alert query examples
The following examples show queries that produce data compatible with alerting evaluation.
Lucene metric query
To alert on the average value of a numeric field, create a Lucene Metric query:
- Set Lucene Query Type to Metric.
- Enter a Lucene query to filter documents, for example
status:[500 TO 599]. - Select Average as the metric aggregation and choose a numeric field.
- Set the bucket aggregation to Date Histogram with an appropriate interval.
This produces a time series of average values that can be evaluated against a threshold condition, for example “alert when average response time exceeds 2000ms.”
PPL time-series query
To alert using a PPL query, set the Format to Time series and write a query that returns exactly two columns – a timestamp and a numeric value:
source = my_index | eval dateValue = timestamp(timestamp) | stats count(response) by dateValueThis produces a time series of response counts that can be evaluated against a threshold condition, for example “alert when count exceeds 1000 per interval.”
Note
If the PPL query returns more or fewer than two columns, or if the value column isn’t numeric, the query fails with an error such as “response should have 2 fields” or “found non-numerical value in value field.”


