Skip to content

Commit

Permalink
Add machine created/terminated counters (kubernetes-sigs#213)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathan-innis committed Feb 16, 2023
1 parent 6262bba commit 422e7fd
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 9 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/aws/karpenter-core

go 1.19
go 1.20

require (
github.com/Pallinder/go-randomdata v1.2.0
Expand Down
4 changes: 2 additions & 2 deletions hack/toolchain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ main() {

tools() {
go install github.com/google/go-licenses@v1.2.0
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.49.0
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.51.1
go install github.com/google/ko@v0.11.2
go install github.com/mikefarah/yq/v4@v4.24.5
go install github.com/norwoodj/helm-docs/cmd/helm-docs@v1.8.1
go install sigs.k8s.io/controller-runtime/tools/setup-envtest@v0.0.0-20220421205612-c162794a9b12
go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.11.2
go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.11.3
go install github.com/sigstore/cosign/cmd/cosign@v1.10.0
go install github.com/gohugoio/hugo@v0.97.3+extended
go install golang.org/x/vuln/cmd/govulncheck@v0.0.0-20220902211423-27dd78d2ca39
Expand Down
25 changes: 24 additions & 1 deletion pkg/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ import (
)

const (
nodeSubsystem = "nodes"
nodeSubsystem = "nodes"
machineSubsystem = "machines"
)

var (
Expand All @@ -46,6 +47,28 @@ var (
"reason",
},
)
MachinesCreatedCounter = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: Namespace,
Subsystem: machineSubsystem,
Name: "created",
Help: "Number of machines created in total by Karpenter. Labeled by reason the machine was created.",
},
[]string{
"reason",
},
)
MachinesTerminatedCounter = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: Namespace,
Subsystem: machineSubsystem,
Name: "terminated",
Help: "Number of machines terminated in total by Karpenter. Labeled by reason the machine was terminated.",
},
[]string{
"reason",
},
)
)

func MustRegister() {
Expand Down
5 changes: 0 additions & 5 deletions pkg/scheduling/requirement.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"math"
"math/rand"
"strconv"
"time"

"github.com/samber/lo"
v1 "k8s.io/api/core/v1"
Expand All @@ -28,10 +27,6 @@ import (
"github.com/aws/karpenter-core/pkg/apis/v1alpha5"
)

func init() {
rand.Seed(time.Now().UnixNano())
}

// Requirement is an efficient represenatation of v1.NodeSelectorRequirement
type Requirement struct {
Key string
Expand Down

0 comments on commit 422e7fd

Please sign in to comment.