From ad167f139f6db4da970f487d7b81d528c21fe418 Mon Sep 17 00:00:00 2001 From: Eytan Avisror Date: Tue, 25 Jan 2022 17:54:20 -0500 Subject: [PATCH] expose metrics Signed-off-by: Eytan Avisror --- pkg/reaper/nodereaper/nodereaper.go | 6 ++++-- pkg/reaper/podreaper/podreaper.go | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/pkg/reaper/nodereaper/nodereaper.go b/pkg/reaper/nodereaper/nodereaper.go index bd4c017..19fcf2a 100644 --- a/pkg/reaper/nodereaper/nodereaper.go +++ b/pkg/reaper/nodereaper/nodereaper.go @@ -567,10 +567,11 @@ func (ctx *ReaperContext) reapOldNodes(w ReaperAwsAuth) error { if err != nil { return err } - ctx.exposeMetric(instance.NodeName, instance.InstanceID, terminationReasonHealthy, NodeReaperResultMetricName, 1) // Throttle deletion ctx.TerminatedInstances++ + ctx.exposeMetric(instance.NodeName, instance.InstanceID, terminationReasonHealthy, NodeReaperResultMetricName, float64(ctx.TerminatedInstances)) + log.Infof("starting deletion throttle wait -> %vs", ctx.AgeReapThrottle) time.Sleep(time.Second * time.Duration(ctx.AgeReapThrottle)) } else { @@ -627,9 +628,10 @@ func (ctx *ReaperContext) reapUnhealthyNodes(w ReaperAwsAuth) error { return err } - ctx.exposeMetric(instance.NodeName, instance.InstanceID, terminationReasonUnhealthy, NodeReaperResultMetricName, 1) // Throttle deletion ctx.TerminatedInstances++ + ctx.exposeMetric(instance.NodeName, instance.InstanceID, terminationReasonUnhealthy, NodeReaperResultMetricName, float64(ctx.TerminatedInstances)) + log.Infof("starting deletion throttle wait -> %vs", ctx.ReapThrottle) time.Sleep(time.Second * time.Duration(ctx.ReapThrottle)) } else { diff --git a/pkg/reaper/podreaper/podreaper.go b/pkg/reaper/podreaper/podreaper.go index 262d123..be2794a 100644 --- a/pkg/reaper/podreaper/podreaper.go +++ b/pkg/reaper/podreaper/podreaper.go @@ -104,6 +104,7 @@ func (ctx *ReaperContext) Reap() error { if err != nil { return errors.Wrap(err, "failed to reap failed pods") } + ctx.exposeMetric(PodReaperResultMetricName, TerminatedPodReason, float64(ctx.ReapedPods)) return nil } @@ -195,7 +196,6 @@ func (ctx *ReaperContext) reapPods(pods map[string]string) error { } } - ctx.exposeMetric(PodReaperResultMetricName, TerminatedPodReason, float64(ctx.ReapedPods)) return nil } @@ -389,7 +389,7 @@ func (ctx *ReaperContext) exposeMetric(metric, reason string, value float64) err if err := ctx.MetricsAPI.SetMetricValue(metric, tags, value); err != nil { return errors.Wrap(err, "failed to push metric") } - log.Infof("metric push: Metric", value, metric) + log.Infof("metric push: Metric", value, metric, reason) return nil }