Skip to content

Commit

Permalink
add cloudprovider metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
tzneal committed Jun 1, 2022
1 parent 57196ce commit 6168f49
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -79,7 +79,7 @@ codegen: ## Generate code. Must be run if changes are made to ./pkg/apis/...
hack/boilerplate.sh

docgen: ## Generate docs
go run hack/docs/metrics_gen_docs.go pkg/controllers website/content/en/preview/tasks/metrics.md
go run hack/docs/metrics_gen_docs.go pkg/ website/content/en/preview/tasks/metrics.md

release: ## Generate release manifests and publish a versioned container image.
$(WITH_GOFLAGS) ./hack/release.sh
Expand Down
17 changes: 15 additions & 2 deletions hack/docs/metrics_gen_docs.go
Expand Up @@ -134,7 +134,8 @@ func bySubsystem(metrics []metricInfo) func(i int, j int) bool {
subSystemSortOrder["provisioner"] = 1
subSystemSortOrder["nodes"] = 2
subSystemSortOrder["pods"] = 3
subSystemSortOrder["allocation_controller"] = 4
subSystemSortOrder["cloudprovider"] = 4
subSystemSortOrder["allocation_controller"] = 5
return func(i, j int) bool {
lhs := metrics[i]
rhs := metrics[j]
Expand All @@ -157,7 +158,8 @@ func handleVariableDeclaration(v *ast.GenDecl) []metricInfo {
if !ok {
continue
}
if fmt.Sprintf("%s", ce.Fun.(*ast.SelectorExpr).X) != "prometheus" {
funcPkg := getFuncPackage(ce.Fun)
if funcPkg != "prometheus" {
continue
}
if len(ce.Args) != 2 {
Expand Down Expand Up @@ -201,3 +203,14 @@ func handleVariableDeclaration(v *ast.GenDecl) []metricInfo {
}
return metrics
}

func getFuncPackage(fun ast.Expr) string {
if sel, ok := fun.(*ast.SelectorExpr); ok {
return fmt.Sprintf("%s", sel.X)
}
if ident, ok := fun.(*ast.Ident); ok {
return ident.String()
}
log.Fatalf("unsupported func expression %T, %v", fun, fun)
return ""
}
5 changes: 5 additions & 0 deletions website/content/en/preview/tasks/metrics.md
Expand Up @@ -44,6 +44,11 @@ Node total pod requests are the resources requested by non-DaemonSet pods bound
### `karpenter_pods_state`
Pod state is the current state of pods. This metric can be used several ways as it is labeled by the pod name, namespace, owner, node, provisioner name, zone, architecture, capacity type, instance type and pod phase.

## Cloudprovider Metrics

### `karpenter_cloudprovider_duration_seconds`
Duration of cloud provider method calls. Labeled by the controller, method name and provider.

## Allocation_controller Metrics

### `karpenter_allocation_controller_bind_duration_seconds`
Expand Down

0 comments on commit 6168f49

Please sign in to comment.