Skip to content

Commit

Permalink
Merge pull request #10 from smartnews/spot-metrics
Browse files Browse the repository at this point in the history
chore: add hostname to spot int metrics
  • Loading branch information
Luke-Smartnews committed May 14, 2024
2 parents 0026970 + a7afc03 commit 1310e4d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pkg/controllers/interruption/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ func (c *Controller) handleNodeClaim(ctx context.Context, msg messages.Message,
if zone != "" && instanceType != "" {
c.unavailableOfferingsCache.MarkUnavailable(ctx, string(msg.Kind()), instanceType, zone, v1beta1.CapacityTypeSpot)
}
spotTotal.WithLabelValues(instanceType, zone).Inc()
spotTotal.WithLabelValues(instanceType, zone, nodeClaim.Status.NodeName, nodeClaim.Labels["karpenter.sh/nodepool"]).Inc()
// try to create a new nodeclaim immediately but ignore error if it fails
if err := c.createNodeClaim(ctx, nodeClaim); err != nil {
logging.FromContext(ctx).Errorf("[interruption handling]failed to create a new nodeclaim, %v", err)
Expand Down
4 changes: 3 additions & 1 deletion pkg/controllers/interruption/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ const (
terminationReasonLabel = "interruption"
instanceTypeLabel = "instance_type"
zoneLabel = "zone"
hostLabel = "node_name"
poolLabel = "node_pool"
)

var (
Expand Down Expand Up @@ -73,7 +75,7 @@ var (
Name: "spot_total",
Help: "Number of the spot interruption. Labeled by AZ, instance type",
},
[]string{instanceTypeLabel, zoneLabel},
[]string{instanceTypeLabel, zoneLabel, hostLabel, poolLabel},
)
)

Expand Down

0 comments on commit 1310e4d

Please sign in to comment.