From 75886e04644d253e5f59d1d00443ff592c7b7d84 Mon Sep 17 00:00:00 2001 From: Simon Pasquier Date: Wed, 17 Jul 2019 17:02:31 +0200 Subject: [PATCH] cmd/promtool: fix panic with empty exp_labels Signed-off-by: Simon Pasquier --- cmd/promtool/unittest.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cmd/promtool/unittest.go b/cmd/promtool/unittest.go index 798cc40e1..cef51960a 100644 --- a/cmd/promtool/unittest.go +++ b/cmd/promtool/unittest.go @@ -286,6 +286,9 @@ func (tg *testGroup) test(mint, maxt time.Time, evalInterval time.Duration, grou for _, a := range testcase.ExpAlerts { // User gives only the labels from alerting rule, which doesn't // include this label (added by Prometheus during Eval). + if a.ExpLabels == nil { + a.ExpLabels = make(map[string]string) + } a.ExpLabels[labels.AlertName] = testcase.Alertname expAlerts = append(expAlerts, labelAndAnnotation{