Alerting based on a Math expression

  • What Grafana version and what operating system are you using?
    8.3.3 web hosted

  • What are you trying to achieve?
    Fire alerts based on a Math expression

  • How are you trying to achieve it?
    I have 2 SQL queries and I’d like to create alerts that depend on both queries. Both SQL queries are formatted as table.
    Query A:

SELECT
  count(order_id)
FROM
  order
WHERE
  $__timeFilter(created_at)
AND
  product = 'Product1'

Query B:

SELECT
  count(id)
FROM
  product
WHERE
  id = 'Product1'
AND
  disabled = 'false'

I have added a Math expression C:
$B == 1 && $A > 0 because I’d like to fire alerts when Product1 is not disabled and no orders were created for Product1 in the given time frame.

  • What happened?
    I run the queries and expression C returns 0. Alerts do not fire.

  • What did you expect to happen?
    As I understand, Math expression will always return 0 or 1. In case of 0, alerts should fire, in case of 1, they do not. Yet, they do not fire either way. What am I doing wrong?

  • Did you follow any online instructions? If so, what is the URL?
    Expressions | Grafana Labs