Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add karpenter_pods_drained_total metric to track pod draining by reason #2044

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pkg/controllers/node/termination/terminator/eviction.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ func (q *Queue) Evict(ctx context.Context, key QueueKey) bool {
}
NodesEvictionRequestsTotal.Inc(map[string]string{CodeLabel: "200"})
q.recorder.Publish(terminatorevents.EvictPod(&corev1.Pod{ObjectMeta: metav1.ObjectMeta{Name: key.Name, Namespace: key.Namespace}}, evictionMessage))
PodsDrainedTotal.Inc(map[string]string{ReasonLabel: evictionMessage})
return true
}

Expand Down
13 changes: 13 additions & 0 deletions pkg/controllers/node/termination/terminator/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import (
const (
// CodeLabel for eviction request
CodeLabel = "code"
// ReasonLabel for pod draining
ReasonLabel = "reason"
)

var NodesEvictionRequestsTotal = opmetrics.NewPrometheusCounter(
Expand All @@ -39,3 +41,14 @@ var NodesEvictionRequestsTotal = opmetrics.NewPrometheusCounter(
},
[]string{CodeLabel},
)

var PodsDrainedTotal = opmetrics.NewPrometheusCounter(
crmetrics.Registry,
prometheus.CounterOpts{
Namespace: metrics.Namespace,
Subsystem: metrics.NodeSubsystem,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this needs to be in the metrics.PodsSubsystem -- as it stands right now this is called karpenter_nodes_pods_drained_total which doesn't sound right

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure

Name: "pods_drained_total",
Help: "The total number of pods drained during node termination by Karpenter, labeled by reason",
},
[]string{ReasonLabel},
)
Loading