docs/sources/datasources/elasticsearch/alerting/index.md
You can use Grafana Alerting with Elasticsearch to create alerts based on your Elasticsearch data. This allows you to monitor metrics, detect anomalies, and receive notifications when specific conditions are met.
For general information about Grafana Alerting, refer to Grafana Alerting.
Before creating alerts with Elasticsearch, ensure you have:
Elasticsearch alerting works best with metrics queries that return time series data. To create a valid alert query:
Queries that return time series data allow Grafana to evaluate values over time and trigger alerts when thresholds are crossed.
| Query type | Alerting support | Notes |
|---|---|---|
| Metrics with Date histogram | ✅ Full support | Recommended for alerting |
| Metrics without Date histogram | ⚠️ Limited | May not evaluate correctly over time |
| Logs | ❌ Not supported | Use metrics queries instead |
| Raw data | ❌ Not supported | Use metrics queries instead |
| Raw document (deprecated) | ❌ Not supported | Deprecated since Grafana v10.1. Use metrics queries instead |
To create an alert rule using Elasticsearch:
For detailed instructions, refer to Create a Grafana-managed alert rule.
The following examples show common alerting scenarios with Elasticsearch.
Monitor the number of error-level log entries:
level:errorMonitor API response times:
type:api_requestresponse_timeDetect drops in active users:
* (all documents)user_idWhen using Elasticsearch with Grafana Alerting, be aware of the following limitations:
Alert queries cannot contain template variables. Grafana evaluates alert rules on the backend without dashboard context, so variables like $hostname or $environment won't be resolved.
If your dashboard query uses template variables, create a separate query for alerting with hard coded values.
Queries using the Logs metric type cannot be used for alerting. Convert your query to use metric aggregations with a Date histogram instead.
Complex queries with many nested aggregations may timeout or fail to evaluate. Simplify queries for alerting by:
Follow these best practices when creating Elasticsearch alerts: