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

add metrics for provisioner usage #1872

Merged
merged 5 commits into from Jun 1, 2022
Merged

Conversation

tzneal
Copy link
Contributor

@tzneal tzneal commented Jun 1, 2022

1. Issue, if available:

Fixes #840

2. Description of changes:

This adds three metrics for provisioners

  • Limits
  • Usage
  • Usage Percentage (0-100)

3. How was this change tested?

Deploying to EKS

4. Does this change impact docs?

  • Yes, PR includes docs updates
  • Yes, issue opened: link to issue
  • [] No

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

This adds three metrics for provisioners
- Limits
- Usage
- Usage Percentage (0-100)
@tzneal tzneal requested a review from a team as a code owner June 1, 2022 02:39
@tzneal tzneal requested a review from njtran June 1, 2022 02:39
@netlify
Copy link

netlify bot commented Jun 1, 2022

Deploy Preview for karpenter-docs-prod ready!

Name Link
🔨 Latest commit 6168f49
🔍 Latest deploy log https://app.netlify.com/sites/karpenter-docs-prod/deploys/629784f45c787f00096f0b9f
😎 Deploy Preview https://deploy-preview-1872--karpenter-docs-prod.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@tzneal
Copy link
Contributor Author

tzneal commented Jun 1, 2022

The usage_pct metric is easy to wire up into Grafana for a gauge based vec that shows you if you are close to exceeding any limit on any provisioner. The other two metrics are just the limits & status, but reported to prometheus.

Screen Shot 2022-05-31 at 9 39 54 PM

New metrics docs can be seen at https://deploy-preview-1872--karpenter-docs-prod.netlify.app/preview/tasks/metrics/

@tzneal tzneal force-pushed the add-provisioner-metrics branch 2 times, most recently from 988fa28 to 7e08df4 Compare June 1, 2022 14:21
Copy link
Contributor

@bwagner5 bwagner5 left a comment

Choose a reason for hiding this comment

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

nice!


// metrics are all package global variables
var allMetrics []metricInfo
for _, pkg := range packages {
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be nice to have a Karpenter dry-run mode where we could just parse the metrics endpoint rather than making all these assumptions about the pkg structure.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, yeah, that could work too. I could go either way, parsing the source isn't too bad and we walk through all of the controller packages.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm fine with this approach for now. This is missing cloudprovider metrics: https://github.com/aws/karpenter/blob/main/pkg/cloudprovider/metrics/cloudprovider.go

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch, fixed.

Makefile Show resolved Hide resolved
Copy link
Contributor

@bwagner5 bwagner5 left a comment

Choose a reason for hiding this comment

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

lgtm

@tzneal tzneal merged commit 42ce207 into aws:main Jun 1, 2022
@tzneal tzneal deleted the add-provisioner-metrics branch June 1, 2022 15:45
hack/docs/metrics_gen_docs.go Show resolved Hide resolved
subSystemSortOrder["pods"] = 3
subSystemSortOrder["cloudprovider"] = 4
subSystemSortOrder["allocation_controller"] = 5
return func(i, j int) bool {
Copy link
Contributor

Choose a reason for hiding this comment

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

If the subsystem isn't one of the enum keys above, it'll show up as the first sorted, right? (Value of 0), can we make it the other way around?

}
}

func handleVariableDeclaration(v *ast.GenDecl) []metricInfo {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you comment this function so it's more readable to newcomers?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Emit Resource Limits in Metrics Controller
3 participants