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

feature: Adding metrics to syncer #141

Open
1 task done
vishnuchalla opened this issue Feb 27, 2023 · 9 comments
Open
1 task done

feature: Adding metrics to syncer #141

vishnuchalla opened this issue Feb 27, 2023 · 9 comments
Labels
kind/feature Categorizes issue or PR as related to a new feature.

Comments

@vishnuchalla
Copy link

Feature Description

As a follow up to this request: kcp-dev/kcp#2781. I am interested in picking up the task of adding metrics to syncer.

Proposed Solution

As a conclusion on discussion with @davidfestal, exploring on options similar to controllers runtime to integrate with syncer to publish metrics. Below are the some of the resources to explore.

Alternative Solutions

No response

Want to contribute?

  • I would like to work on this issue.

Additional Context

No response

@vishnuchalla vishnuchalla added the kind/feature Categorizes issue or PR as related to a new feature. label Feb 27, 2023
@ncdc
Copy link
Member

ncdc commented Feb 27, 2023

Do you have specific metrics you are thinking of adding?

@vishnuchalla
Copy link
Author

I am not sure at this moment. But I am looking for options to add metrics that are similar to the ones exposed by \metrics endpoint and primarily focusing on latencies for syncer.

@mjudeikis
Copy link
Contributor

Triage: Proposed 1-2 metrics for this before writing any code :)

@MikeSpreitzer
Copy link

MikeSpreitzer commented Feb 28, 2023

I have three metrics about the syncer that I would like to see.

  1. I would like to have a metric that we can look at to observe throughput. I assume that in each direction the syncer transports desired/reported state in chunks that each contain all it has to read/write about a single object. If so then I think it would be good to have a histogram vector of observations of chunk size. The vector would be indexed by APIGroup, APIVersion, and Resource or Kind (or, better yet, both!). The rate of change of the counts gives us message throughput, the rate of change of sum gives us data throughput, the sum gives us cumulative data volume transferred, and the buckets give us distribution of sizes in each vector element.
  2. I would also like to be able to observe trouble that the syncer has with requests to the apiserver to create/update/delete objects. A request can fail in various ways, including both (a) getting an HTTP response code that reports a problem and (b) suffering a disconnection that leaves the client unsure what happened at the server.
  3. I would also like to be able to observe latency. Recall the (usually hidden by kubectl get -o yaml) managedFields that reports on the latest write to each section of the object. How long from write at origin server to successful corresponding write to the other copy by the syncer?

@MikeSpreitzer
Copy link

For latencies, remember that kubernetes/kubernetes#110058 is not yet in kcp's fork of Kubernetes.

@vishnuchalla
Copy link
Author

vishnuchalla commented Mar 1, 2023

@davidfestal, @s-urbaniak, @MikeSpreitzer and @csams - I am fairly new to the syncer and metrics related code. I have been crawling over the code base and couldn't make much sense of the flow on how metrics are being published. I have looked at one of the previous code and took a look at the prometheus metrics package which is being used in some parts of our current kcp code. But still not sure on where to start with and get things into action.

Can you please suggest me on some resources or a plan of action items to start with (just to get a good hang of the codebase), so that they can help me get a better understanding on how to go about adding metrics to syncer and to test/verify if they are actually getting published?

Thanks in Advance,
Vishnu Challa

@s-urbaniak
Copy link

@vishnuchalla i don't know the internal details of the syncer but a good start wrt Kubernetes is https://github.com/kubernetes/community/blob/master/contributors/devel/sig-instrumentation/instrumentation.md, and generally Prometheus best practices https://prometheus.io/docs/practices/instrumentation/.

Generally, I would:

  1. Ensure the syncer has a /metrics endpoint available, your referenced front-proxy PR is a good starting point, although I would not encourage to use the legacy registry but instead, as outlined in https://github.com/kubernetes/enhancements/tree/master/keps/sig-instrumentation/1206-metrics-overhaul use dependency injection of the prometheus registry.
  2. Add new metrics to the syncer

@vishnuchalla
Copy link
Author

@vishnuchalla i don't know the internal details of the syncer but a good start wrt Kubernetes is https://github.com/kubernetes/community/blob/master/contributors/devel/sig-instrumentation/instrumentation.md, and generally Prometheus best practices https://prometheus.io/docs/practices/instrumentation/.

Generally, I would:

  1. Ensure the syncer has a /metrics endpoint available, your referenced front-proxy PR is a good starting point, although I would not encourage to use the legacy registry but instead, as outlined in https://github.com/kubernetes/enhancements/tree/master/keps/sig-instrumentation/1206-metrics-overhaul use dependency injection of the prometheus registry.
  2. Add new metrics to the syncer

Thanks for the suggestions. Will take a look.

@embik
Copy link
Member

embik commented Nov 29, 2023

/transfer-issue contrib-tmc

@kcp-ci-bot kcp-ci-bot transferred this issue from kcp-dev/kcp Nov 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature Categorizes issue or PR as related to a new feature.
Projects
Status: Next
Development

No branches or pull requests

6 participants