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 total workers and active workers #1125

Merged
merged 1 commit into from Aug 18, 2020

Conversation

alvaroaleman
Copy link
Member

@alvaroaleman alvaroaleman commented Aug 11, 2020

Helps debugging issues around reconciliation duration. Right now its impossible to find out the number of workers from metrics and its also impossible to find out the number of active workers. The only thing we have is workqueue_unfinished_work_seconds which if big is probably not good but its not clearly indicating if we have one worker that takes longer, if all workers are blocked etc.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Aug 11, 2020
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: alvaroaleman

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Aug 11, 2020
@alvaroaleman
Copy link
Member Author

/assign @estroz

@alvaroaleman alvaroaleman changed the title ✨ Add metrics for total workers and available workers ✨ Add metrics for total workers and active workers Aug 11, 2020
@alvaroaleman
Copy link
Member Author

/retest

1 similar comment
@alvaroaleman
Copy link
Member Author

/retest

@@ -169,6 +169,7 @@ func (c *Controller) Start(stop <-chan struct{}) error {

// Launch workers to process resources
c.Log.Info("Starting workers", "worker count", c.MaxConcurrentReconciles)
ctrlmetrics.WorkerCount.WithLabelValues(c.Name).Set(float64(c.MaxConcurrentReconciles))
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 explain the logic behind collecting this metric?

Copy link
Member Author

Choose a reason for hiding this comment

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

  • It allows correlating other metrics to the number of workers, for example workqueue_depth
  • It allows calculating the available_workers

@alvaroaleman
Copy link
Member Author

@estroz PTAL

@estroz
Copy link
Contributor

estroz commented Aug 18, 2020

Without knowing too much about how metrics are collected this looks fine to me. However there are now 7 metrics collected for a controller. Will an increase in the number of metrics impact cluster resources significantly?

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 18, 2020
@estroz
Copy link
Contributor

estroz commented Aug 18, 2020

Cancel whenever

/hold

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 18, 2020
@alvaroaleman
Copy link
Member Author

Without knowing too much about how metrics are collected this looks fine to me. However there are now 7 metrics collected for a controller. Will an increase in the number of metrics impact cluster resources significantly?

No, the way this works is that only the current value of a metric is stored and Prometheus is expected to collect it. The thing to keep in mind is to not expose too many metrics which usually happens when using labels that have a yet-to-be-determined set of values, because every metric+label combinaation actually ends up being an unique metric in Prometheus: https://www.robustperception.io/cardinality-is-key

/hold cancel

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 18, 2020
@alvaroaleman
Copy link
Member Author

/retest

1 similar comment
@alvaroaleman
Copy link
Member Author

/retest

@k8s-ci-robot k8s-ci-robot merged commit af7f192 into kubernetes-sigs:master Aug 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants