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 rest client request duration and size metrics #2217

Merged
merged 1 commit into from Mar 1, 2023

Conversation

sbueringer
Copy link
Member

@sbueringer sbueringer commented Mar 1, 2023

Signed-off-by: Stefan Büringer buringerst@vmware.com

This PR adds the following metrics:

  • rest_client_request_duration_seconds
  • rest_client_request_size_bytes
  • rest_client_response_size_bytes

As they are defined in component-base upstream: https://github.com/kubernetes/component-base/blob/master/metrics/prometheus/restclient/metrics.go

I think the cardinality should be fine as the host label intentionally only contains the "template url".

Example:

rest_client_request_duration_seconds_sum{host="https://172.18.0.3:6443/api/v1/namespaces/%7Bnamespace%7D/pods/%7Bname%7D?timeout=10s",verb="GET"} 0.002900856
rest_client_request_duration_seconds_count{host="https://172.18.0.3:6443/api/v1/namespaces/%7Bnamespace%7D/pods/%7Bname%7D?timeout=10s",verb="GET"} 1

More examples can be found under: https://storage.googleapis.com/kubernetes-jenkins/pr-logs/pull/kubernetes-sigs_cluster-api/8207/pull-cluster-api-e2e-main/1630798093588893696/artifacts/clusters/bootstrap/metrics/capi-system/capi-controller-manager/capi-controller-manager-9db79449b-vnfh8/metrics.txt
(please note that this file contains more rest_client metrics than I added in this PR)

@k8s-ci-robot k8s-ci-robot added 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. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Mar 1, 2023

requestResult = prometheus.NewCounterVec(
prometheus.CounterOpts{
Name: "rest_client_requests_total",
Copy link
Member Author

@sbueringer sbueringer Mar 1, 2023

Choose a reason for hiding this comment

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

Just aligned this to the way the metrics are defined just with name instead of subsystem + name here: https://github.com/kubernetes/component-base/blob/master/metrics/prometheus/restclient/metrics.go#L78

@@ -62,11 +61,44 @@ var (
Buckets: prometheus.ExponentialBuckets(0.001, 2, 10),
}, []string{"verb", "url"})
Copy link
Member Author

Choose a reason for hiding this comment

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

I wonder if we should drop RequestLatency in l.41-62 (in a separate PR) given:

	// Deprecated: This metric is deprecated for removal in a future release: using the URL as a
	// dimension results in cardinality explosion for some consumers. It was deprecated upstream
	// in k8s v1.14 and hidden in v1.17 via https://github.com/kubernetes/kubernetes/pull/83836.

Signed-off-by: Stefan Büringer buringerst@vmware.com
@sbueringer
Copy link
Member Author

/assign @vincepri @alvaroaleman

Copy link
Member

@vincepri vincepri left a comment

Choose a reason for hiding this comment

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

/approve
/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 1, 2023
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: sbueringer, vincepri

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:
  • OWNERS [sbueringer,vincepri]

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

@sbueringer
Copy link
Member Author

@vincepri Would it be possible to cherry-pick this PR into release-0.14?

No problem if we don't want to do it, would be just nice to be able to pick it up earlier

@k8s-ci-robot k8s-ci-robot merged commit 6229718 into kubernetes-sigs:main Mar 1, 2023
@sbueringer sbueringer deleted the pr-add-metrics branch March 1, 2023 15:32
@vincepri
Copy link
Member

vincepri commented Mar 1, 2023

/cherry-pick release-0.14

@k8s-infra-cherrypick-robot

@vincepri: new pull request created: #2218

In response to this:

/cherry-pick release-0.14

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

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/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.

None yet

5 participants