Search code examples
.netgrafanagrafana-loki

How to create alert for logged errors?


I have a stream of log messages in Loki, and I want to create an alert if error is logged.

Here is the query I wrote for the alert

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

However, when I try to preview, I get the error:

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

What should I do to make grafna happy?


Solution

  • You have to reduce the query first and set the right alert condition. Documentation: https://grafana.com/docs/grafana/latest/alerting/unified-alerting/alerting-rules/create-grafana-managed-rule/):

    enter image description here