将Grafana配置为仅在查询匹配超过4分钟时发出警报

时间:2018-03-05 09:51:13

标签: mysql grafana

我有这样的Grafana指标:

SELECT
  UNIX_TIMESTAMP(time) as time_sec,
  sum(average_hashrate_eth) as value,
  'total hashrate' as metric
FROM status_rig
group by time;

发出如下警告:

WHEN last()

query(A, 5m, now) IS BELOW 800

如果此查询仅低于800超过4分钟,我该如何才能提醒?

感谢。

2 个答案:

答案 0 :(得分:1)

您只需更新警报配置即可使用:

当查询的max()(A,4m,现在)低于800时

答案 1 :(得分:0)

假设度量的时间频率为60秒,时间为DATETIME类型。

试试这个:

  SELECT
   UNIX_TIMESTAMP(time) as time_sec,
   SUM(case when average_hashrate_eth < 800 THEN 1 ELSE 0 END) as counter,
   SUM(average_hashrate_eth) as value,
   'total hashrate' as metric
  FROM status_rig
  WHERE time between (now()-interval 5 minute) and now()
  HAVING counter>=5;

如果价值保持在800以下,这将为您提供当前时间最后五分钟average_hashrate_eth的总和