Grafana Cloud Enterprise Open source
Last reviewed: July 28, 2026

Yugabyte alerting

The Yugabyte data source supports Grafana Alerting, which lets you define alert rules that evaluate SQL queries against YugabyteDB 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. Yugabyte 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.
  • Reduce to a single value: Add a Reduce expression to collapse a time series into a single number that the alert condition can evaluate.
  • Time filtering: Use the $__timeFilter(column) macro so the query only evaluates data within the alert’s evaluation window.
  • One series per alert instance: If the query returns multiple series, for example by adding a GROUP BY service column, Grafana creates a separate alert instance for each series. Return a single series unless you intend to alert on each series independently.

You can combine multiple queries (A, B, C) with Reduce and Math expressions to build complex alert conditions. Refer to Queries and conditions for details.

Create an alert rule

To create an alert rule using the Yugabyte data source:

  1. Navigate to Alerting > Alert rules in the left-side menu.
  2. Click New alert rule.
  3. Select the Yugabyte data source.
  4. Enter a SQL query that returns a numeric result.
  5. Add a Reduce expression to aggregate the query result, for example Last or Mean.
  6. Add a Threshold expression to define the alert condition, for example “is above 90”.
  7. Set the evaluation interval and pending period.
  8. Configure notification settings, including contact points and notification policies.
  9. Click Save rule and exit.

Alert query examples

The following examples show SQL queries suitable for alert rules.

Alert on error count

This query returns the number of errors over time for a specific service:

SQL
SELECT
  date_trunc('minute', created_at) AS time,
  count(*) AS errors
FROM logs
WHERE level = 'error' AND $__timeFilter(created_at)
GROUP BY time
ORDER BY time

Configure a Reduce expression with Last to get the most recent value, then add a Threshold expression set to “is above 100”.

Alert on average response time

This query returns average response time, which is useful for detecting latency degradation:

SQL
SELECT
  date_trunc('minute', created_at) AS time,
  avg(response_time) AS avg_response_time
FROM requests
WHERE service = 'checkout' AND $__timeFilter(created_at)
GROUP BY time
ORDER BY time

Configure a Reduce expression with Mean, then add a Threshold expression set to “is above 2000”.

Combine multiple queries

You can use multiple queries to compare values. For example, to alert when the error rate exceeds a percentage of total requests:

Query A – error count:

SQL
SELECT
  date_trunc('minute', created_at) AS time,
  count(*) AS errors
FROM logs
WHERE level = 'error' AND $__timeFilter(created_at)
GROUP BY time
ORDER BY time

Query B – total request count:

SQL
SELECT
  date_trunc('minute', created_at) AS time,
  count(*) AS requests
FROM logs
WHERE $__timeFilter(created_at)
GROUP BY time
ORDER BY time

Add 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% of requests.

Next steps