From 4a49577028bd3b8def52d53ee2f75992999bb768 Mon Sep 17 00:00:00 2001 From: Roman Khavronenko Date: Thu, 30 Mar 2023 14:57:00 +0200 Subject: [PATCH] vmalert: use `missingkey=zero` for templating (#4040) Replace empty labels with "" instead of "" during templating, as Prometheus does. See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/4012 Signed-off-by: hagen1778 --- app/vmalert/notifier/alert.go | 2 ++ docs/CHANGELOG.md | 1 + 2 files changed, 3 insertions(+) diff --git a/app/vmalert/notifier/alert.go b/app/vmalert/notifier/alert.go index 89dca7e17..9be76aeed 100644 --- a/app/vmalert/notifier/alert.go +++ b/app/vmalert/notifier/alert.go @@ -170,6 +170,8 @@ func templateAnnotation(dst io.Writer, text string, data tplData, tmpl *textTpl. if err != nil { return fmt.Errorf("error cloning template before parse annotation: %w", err) } + // Clone() doesn't copy tpl Options, so we set them manually + tpl = tpl.Option("missingkey=zero") tpl, err = tpl.Parse(text) if err != nil { return fmt.Errorf("error parsing annotation template: %w", err) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 051231031..ede415cbb 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -44,6 +44,7 @@ created by v1.90.0 or newer versions. The solution is to upgrade to v1.90.0 or n * BUGFIX: [MetricsQL](https://docs.victoriametrics.com/MetricsQL.html): properly convert [VictoriaMetrics historgram buckets](https://valyala.medium.com/improving-histogram-usability-for-prometheus-and-grafana-bc7e5df0e350) to Prometheus histogram buckets when VictoriaMetrics histogram contain zero buckets. Previously these buckets were ignored, and this could lead to missing Prometheus histogram buckets after the conversion. Thanks to @zklapow for [the fix](https://github.com/VictoriaMetrics/VictoriaMetrics/pull/4021). * BUGFIX: properly support comma-separated filters inside [retention filters](https://docs.victoriametrics.com/#retention-filters). See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/3915). * BUGFIX: verify response code when fetching configuration files via HTTP. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/4034). +* BUGFIX: [vmalert](https://docs.victoriametrics.com/vmalert.html): replace empty labels with "" instead of "" during templating, as Prometheus does. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/4012). ## [v1.89.1](https://github.com/VictoriaMetrics/VictoriaMetrics/releases/tag/v1.89.1)