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 clustercache metrics #11789

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

cahillsf
Copy link
Member

@cahillsf cahillsf commented Feb 3, 2025

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Part of #11272

/area clustercache

@k8s-ci-robot
Copy link
Contributor

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. area/clustercache Issues or PRs related to the clustercachetracker cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Feb 3, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign vincepri for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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 the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Feb 3, 2025
@cahillsf cahillsf marked this pull request as ready for review February 3, 2025 23:28
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Feb 3, 2025
controllers/clustercache/cluster_accessor.go Outdated Show resolved Hide resolved
controllers/clustercache/cluster_accessor.go Outdated Show resolved Hide resolved
controllers/clustercache/cluster_accessor.go Outdated Show resolved Hide resolved
controllers/clustercache/metrics.go Outdated Show resolved Hide resolved
controllers/clustercache/metrics.go Show resolved Hide resolved
controllers/clustercache/metrics.go Show resolved Hide resolved
controllers/clustercache/metrics.go Outdated Show resolved Hide resolved
Name: "capi_clustercache_health_check",
Help: "Result of a single clustercache healthcheck.",
}, []string{
"cluster",
Copy link
Member

Choose a reason for hiding this comment

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

Do you know if there's some sort of standard/convention on how to encode namespace + name into metric labels?

If there is, would be nice to follow it to make it easier to correlate / join metrics

Copy link
Member Author

Choose a reason for hiding this comment

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

good point! will take a look into this

Copy link
Member Author

Choose a reason for hiding this comment

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

seems that namespace and then the object kind are common label keys. here's one specific example:
https://github.com/kubernetes/kubernetes/blob/5e0931336b54a9a0c38c37c7c1afe1ca41033c5f/pkg/kubelet/metrics/collectors/resource_metrics.go#L72-L77

in terms of CAPI setup, this might be a bit confusing since we are transforming pod metadata namespace as namespace from the metrics source:
https://github.com/kubernetes-sigs/cluster-api/blob/main/hack/observability/prometheus/values.yaml#L50-L52

and so in this case we would be sort of overloading the namespace key

maybe we should change that?

anyway, pushed up a change to address your most recent comments and at least start splitting name/namespace for the clusters rather than just using the .String() method

@cahillsf
Copy link
Member Author

cahillsf commented Feb 7, 2025

thanks for the review @sbueringer, everything except the label enhancement should be addressed (still have to look into this a bit)

healthChecksTotal = prometheus.NewCounterVec(
prometheus.CounterOpts{
Name: "capi_cluster_cache_health_checks_total",
Help: "Results of all clustercache healthchecks.",
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Help: "Results of all clustercache healthchecks.",
Help: "Results of all clustercache healthchecks.",

var (
healthCheck = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "capi_cluster_cache_health_check",
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Name: "capi_cluster_cache_health_check",
Name: "capi_cluster_cache_healthcheck",

Not sure, k/k is writing it like this (if yes, the same below)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/clustercache Issues or PRs related to the clustercachetracker cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants