mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
vmalert: always re-evaluate Annotations (#3119)
* vmalert: always re-evaluate Annotations Previously, Annotations were evaluated only: 1. On alert creating. 2. On alert's value change. This is premature optimization. It was assumed that since annotations could contain only text with alert's labels or value - there is no need in spending resources to re-compile Annotations. Later, template function `query` was added, which can execute arbitrary queries and return different results on every evaluation. So if it was used in annotations, it would be executed only on init or value change. Another case when optimization caused an issue - annotations hot reload. In this case, annotations of the active alert won't change even if Rule's annotations were changed. This fix enables Annotations re-evaluation on each iteration to resolve issues above. It would have some impact on performance, but it is unlikely it will be noticeable. Signed-off-by: hagen1778 <roman@victoriametrics.com> * vmalert: add tp Changelog Signed-off-by: hagen1778 <roman@victoriametrics.com> Signed-off-by: hagen1778 <roman@victoriametrics.com>
This commit is contained in:
parent
1c13cce5ed
commit
360b022603
2 changed files with 6 additions and 10 deletions
|
@ -324,16 +324,11 @@ func (ar *AlertingRule) Exec(ctx context.Context, ts time.Time, limit int) ([]pr
|
|||
a.ActiveAt = ts
|
||||
ar.logDebugf(ts, a, "INACTIVE => PENDING")
|
||||
}
|
||||
if a.Value != m.Values[0] {
|
||||
// update Value field with the latest value
|
||||
a.Value = m.Values[0]
|
||||
// and re-exec template since Value can be used
|
||||
// in annotations
|
||||
a.Annotations, err = a.ExecTemplate(qFn, ls.origin, ar.Annotations)
|
||||
if err != nil {
|
||||
curState.err = err
|
||||
return nil, curState.err
|
||||
}
|
||||
a.Value = m.Values[0]
|
||||
// re-exec template since Value or query can be used in annotations
|
||||
a.Annotations, err = a.ExecTemplate(qFn, ls.origin, ar.Annotations)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ The following tip changes can be tested by building VictoriaMetrics components f
|
|||
* BUGFIX: [VictoriaMetrics cluster](https://docs.victoriametrics.com/Cluster-VictoriaMetrics.html): properly calculate query results at `vmselect`. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/3067). The issue has been introduced in [v1.81.0](https://docs.victoriametrics.com/CHANGELOG.html#v1810).
|
||||
* BUGFIX: [VictoriaMetrics cluster](https://docs.victoriametrics.com/Cluster-VictoriaMetrics.html): log clear error when multiple identical `-storageNode` command-line flags are passed to `vmselect` or to `vminsert`. Previously these components were crashed with cryptic panic `metric ... is already registered` in this case. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/3076).
|
||||
* BUGFIX: [vmui](https://docs.victoriametrics.com/#vmui): fix `RangeError: Maximum call stack size exceeded` error when the query returns too many data points at `Table` view. See [this pull request](https://github.com/VictoriaMetrics/VictoriaMetrics/pull/3092/files).
|
||||
* BUGFIX: [vmalert](https://docs.victoriametrics.com/vmalert.html): re-evaluate alert's annotations on each execution. Previously, annotations were evaluated only on alert's value change. See [this PR](https://github.com/VictoriaMetrics/VictoriaMetrics/pull/3119) for details.
|
||||
|
||||
## [v1.81.2](https://github.com/VictoriaMetrics/VictoriaMetrics/releases/tag/v1.81.2)
|
||||
|
||||
|
|
Loading…
Reference in a new issue