0

大家,感谢您的关注,我有一个大问题,我的系统中有 1k 个客户端,我想使用 grafana 实时制作警报系统,它会向我发送警报,例如告诉我,如您在示例中看到的成功率低的客户。这是例如sql:

 with calculo_total as(
    select
     TIME_BUCKET(MINUTES(30), created_at) AS created_at,
      count( id) as num_total
    from
        sandbox.transactions_new t
    where
        (status_id = 2 or status_id = 3 or status_id = 4)  and   created_at > :startTime AND
  created_at < :stopTime
    GROUP BY
        TIME_BUCKET(MINUTES(30), created_at) )

select 
     TIME_BUCKET(MINUTES(30), t.created_at) AS created_at,
     (100*count (t.id))/c.num_total as porc_ok,
     
   from
        sandbox.transactions_new t
left join calculo_total c on c.created_at= TIME_BUCKET(MINUTES(30), t.created_at)
 where
        (t.status_id = 2 )  and   t.created_at > :startTime AND
  t.created_at < :stopTime
 

group by TIME_BUCKET(MINUTES(30), t.created_at), c.num_total

order by created_at desc

捕获警报:

[![警报配置][1]][1]

我在制作通用警报时没有问题,但我需要 grafana 独立于每个客户端评估每个警报,并告诉我哪个客户端产生警报。我知道我可以在查询中按 client_id 进行分组,但我认为这不是解决方案,因为正如您在图中看到的那样,他们不会评估每个 client_id。

这是图表,但我需要按 client_id 拆分,我知道我可以使用 where client_id='xxx' 进行 1k 个不同的查询,但这不是解决方案。

[![图][2]][2]

我调查了要放置一个变量,但是该选项有问题是您的数据库是例如作为rockset的签名插件。

谢谢和对不起我的英语。[1]:https ://i.stack.imgur.com/oHgSN.png [2]:https ://i.stack.imgur.com/xTniH.png

4

0 回答 0