Currently, alerts are triggered when the value of a column from a query exceeds, drops below, or equals a fixed value. It might also be useful if the alert threshold could be set dynamically to a value obtained from the query.

For example, one could add a column to a query called “threshold_value” that is XX% of the previous day’s value. Then, when defining the alert, one could set the alert threshold to be the value of the “threshold” column, rather than a fixed value.

I think this feature would make alerts more useful, as I often have cases where values fluctuate widely based on (e.g.) day of the week, so a fixed alert threshold doesn’t really work.

1 Like

This is a highly useful feature. Is it being implemented?

Always funny to come across feature requests for something you’ve been doing extensively for ages.

I do what’s been requested, but all within the query - with the query just reporting a final “Alert” or “Don’t Alert” to Redash.

Now the first thing I did when I discovered Redash in early 2018 was to modify the MySQL query runner so that it can call stored procedures - and in doing so, as a side effect I also gained the ability to put many SQL statments within one query. So when I look at the queries I perform now I use this extensively in almost ALL of them… and many look like:

select @threshold:=someValue from someTable where a={{a}} and b like "{{b}}";
select if(count(*) < @threshold, "Alert", "Normal") from otherTable where c=c;

or even:

create temporary table tmp select customer from someTable where a={{a}} and b like "{{b}}";
create temporary table results (customer int not null, result varchar(1024));
begin not atomic
  declare done int;
  declare cust int;
  declare continue handler for not found set done = 1;
  declare cur cursor for select customer from tmp;

  set done = 0;
  open cur;
  repeat fetch cur into c;
   if not done then
      insert into result values (c, (select if(somevar>0, "Alert", "Normal") from table where customer=c));
   end if;
 until done = 1 end repeat;
end;
select c.name, r.result from results r join customers c on r.customer=c.id;

You can write some really really powerful queries this way in redash!

The change I made to the MySQL query runner was merged into Redash in this change: https://github.com/getredash/redash/pull/3003 in May… so will hopefully be included in Redash 8 (or just install a dev build!).

1 Like