From 0dacb851d635b0abfa8cd3e6da34f53b2f6324f5 Mon Sep 17 00:00:00 2001 From: Martin Linkhorst Date: Tue, 18 May 2021 13:26:18 +0200 Subject: [PATCH] add namespace metadata to deleted pods metric --- chaoskube/chaoskube.go | 2 +- metrics/metrics.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/chaoskube/chaoskube.go b/chaoskube/chaoskube.go index ec3dfe76..1bb7a7ba 100644 --- a/chaoskube/chaoskube.go +++ b/chaoskube/chaoskube.go @@ -261,7 +261,7 @@ func (c *Chaoskube) DeletePod(ctx context.Context, victim v1.Pod) error { return err } - metrics.PodsDeletedTotal.Inc() + metrics.PodsDeletedTotal.WithLabelValues(victim.Namespace).Inc() ref, err := reference.GetReference(scheme.Scheme, &victim) if err != nil { diff --git a/metrics/metrics.go b/metrics/metrics.go index 052243a5..a38c2f76 100644 --- a/metrics/metrics.go +++ b/metrics/metrics.go @@ -7,11 +7,11 @@ import ( var ( // PodsDeletedTotal is the total number of deleted pods. - PodsDeletedTotal = promauto.NewCounter(prometheus.CounterOpts{ + PodsDeletedTotal = promauto.NewCounterVec(prometheus.CounterOpts{ Namespace: "chaoskube", Name: "pods_deleted_total", Help: "The total number of pods deleted", - }) + }, []string{"namespace"}) // IntervalsTotal is the total number of intervals, i.e. call to Run(). IntervalsTotal = promauto.NewCounter(prometheus.CounterOpts{ Namespace: "chaoskube",