Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions docs/victorialogs/vmalert.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,7 @@ for more details.

The `expr` query must contain [`stats` pipe](https://docs.victoriametrics.com/victorialogs/logsql/#stats-pipe) in order to calculate
some metric over the selected logs, and use this metric in alerting threshold. Use [`filter` pipe](https://docs.victoriametrics.com/victorialogs/logsql/#filter-pipe)
for filtering the calculated metric according to the needed threshold. For example, the following alerting rule fires
if the number of logs with the `error` or `warn` status in `env=prod` exceeds 10 during the last 5 minutes:
for filtering the calculated metric according to the needed threshold. For example, the following alerting rule fires if the number of `error` or `warn` logs on a single pod in `env=prod` exceeds 10 during the last 5 minutes:

```yaml
groups:
Expand All @@ -116,9 +115,9 @@ groups:
interval: 5m
rules:
- alert: HasMoreThan10ErrorLogs
expr: '{env=prod} status:in(error,warn) | stats count() as error_logs | filter error_logs:>10'
expr: '{env=prod} status:in(error,warn) | stats by (k8s.pod.name) count() as error_logs | filter error_logs:>10'
annotations:
description: 'Too big number of errors and warnings during the last 5 minutes: {{$value}}'
description: 'Too big number of errors and warnings on pod {{ index .Labels "k8s.pod.name" }} during the last 5 minutes: {{$value}}'
```

It is possible to group the calculated metrics by arbitrary log fields, by using [`stats by (...)` pipe](https://docs.victoriametrics.com/victorialogs/logsql/#stats-by-fields).
Expand Down