如何为记录的错误创建警报?

How to create alert for logged errors?

我在 Loki 中有一个日志消息流,我想在记录错误时创建一个警报。

这是我为警报编写的查询

sum by (app) (count_over_time({app="my-app"} | json | Level="Error" or Level="Critical" or Level="Fatal"[5m])) > 0

但是,当我尝试预览时,出现错误:

invalid format of evaluation results for the alert definition Failures: looks like time series data, only reduced data can be alerted on.

我应该怎么做才能让grafna开心?

您必须先减少查询并设置正确的警报条件。文档:https://grafana.com/docs/grafana/latest/alerting/unified-alerting/alerting-rules/create-grafana-managed-rule/):