Skip to content

Commit

Permalink
expose metrics
Browse files Browse the repository at this point in the history
Signed-off-by: Eytan Avisror <[email protected]>
  • Loading branch information
Eytan Avisror authored and Eytan Avisror committed Jan 25, 2022
1 parent 09592cb commit ad167f1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions pkg/reaper/nodereaper/nodereaper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions pkg/reaper/podreaper/podreaper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -195,7 +196,6 @@ func (ctx *ReaperContext) reapPods(pods map[string]string) error {
}
}

ctx.exposeMetric(PodReaperResultMetricName, TerminatedPodReason, float64(ctx.ReapedPods))
return nil
}

Expand Down Expand Up @@ -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: %f, name: %s, pod: %s/%s>", value, metric)
log.Infof("metric push: Metric<value: %f, name: %s, reason: %s>", value, metric, reason)
return nil
}

Expand Down

0 comments on commit ad167f1

Please sign in to comment.