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

Export various stats about services in the metrics exported by this c… #1943

Merged

Conversation

mmamczur
Copy link
Contributor

…ontroller.

@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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Feb 10, 2023
@k8s-ci-robot
Copy link
Contributor

Hi @mmamczur. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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.

@k8s-ci-robot k8s-ci-robot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Feb 10, 2023
Comment on lines 191 to 192
IsStaticIPv4: service.Spec.LoadBalancerIP != "",
IsStaticIPv6: false,
Copy link
Member

Choose a reason for hiding this comment

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

@panslava is this assumption right? there are never StaticIPv6?

Copy link
Contributor

Choose a reason for hiding this comment

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

for now they are not supported in Google Cloud

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's add a todo to extend this field as soon as we support this

return string(*service.Spec.InternalTrafficPolicy)
}

func getPortsBucket(ports []v1.ServicePort) string {
Copy link
Member

Choose a reason for hiding this comment

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

prometheus histogram metrics only need to receive the data and it already. manages the bucket, do we need to export this as a string?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

so here we want to limit the number of possible values in the label and we decided on these specific 'bucket' ourselves. This is intended to limit the cardinality of the metric

@mmamczur mmamczur force-pushed the metrics_controller_attempt2 branch from 57194ba to f476884 Compare February 13, 2023 11:26
@mmamczur mmamczur marked this pull request as ready for review February 13, 2023 11:45
@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 13, 2023
@aojea
Copy link
Member

aojea commented Feb 13, 2023

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Feb 13, 2023
pkg/servicemetrics/servicemetrics.go Outdated Show resolved Hide resolved
pkg/servicemetrics/servicemetrics.go Outdated Show resolved Hide resolved
pkg/servicemetrics/servicemetrics.go Outdated Show resolved Hide resolved
Comment on lines 191 to 192
IsStaticIPv4: service.Spec.LoadBalancerIP != "",
IsStaticIPv6: false,
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's add a todo to extend this field as soon as we support this

pkg/servicemetrics/servicemetrics.go Outdated Show resolved Hide resolved
pkg/servicemetrics/servicemetrics.go Show resolved Hide resolved
pkg/servicemetrics/servicemetrics_test.go Outdated Show resolved Hide resolved
pkg/servicemetrics/servicemetrics_test.go Outdated Show resolved Hide resolved
pkg/servicemetrics/servicemetrics.go Outdated Show resolved Hide resolved
pkg/servicemetrics/servicemetrics_test.go Outdated Show resolved Hide resolved
@cezarygerard
Copy link
Contributor

Michał

overall LGTM from my side

please take from my comments whatever you find useful and we can commit soon
drop the comments that you find unuseful

thanks!

@mmamczur mmamczur force-pushed the metrics_controller_attempt2 branch 5 times, most recently from 309bac4 to ad346f4 Compare February 23, 2023 12:21
@mmamczur mmamczur force-pushed the metrics_controller_attempt2 branch from ad346f4 to 0e76ed7 Compare February 23, 2023 12:35
Copy link
Member

@swetharepakula swetharepakula left a comment

Choose a reason for hiding this comment

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

this mostly looks good to me. I would recommend customizing the buckets in prometheus if the goal is to reduce the cardinality and remove some of the logic necessary to maintain the buckets.

labelIPFamilies = "ip_families"
labelIPFamilyPolicy = "ip_family_policy"
labelIsStaticIPv4 = "is_static_ip_v4"
labelIsStaticIPv6 = "is_static_ip_v6"
Copy link
Member

Choose a reason for hiding this comment

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

do we want a labelIsStaticDualStack?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

LB that would have 2 static IPs?
is this possible? We could also set both these to true if we ever support a case like that

var (
serviceL4ProtocolStatsCount = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "service_l4_protocol_stats",
Copy link
Member

Choose a reason for hiding this comment

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

nit: Since these aren't all protocol labels, many configuration or config?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

something like service_l4_config_stats?


const (
// Names of the labels used by the service metrics.
labelType = "type"
Copy link
Member

Choose a reason for hiding this comment

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

what are the possible values for "type"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

in general this is the service type, so could be ClusterIP, NodePort etc with a caveat that instead of just having LoadBalancer we have special values for each varian of them, like LegacyXLB, RBSXLB etc
we considered having separate label but we wanted to limit the number of possible label value combinatons

@mmamczur
Copy link
Contributor Author

this mostly looks good to me. I would recommend customizing the buckets in prometheus if the goal is to reduce the cardinality and remove some of the logic necessary to maintain the buckets.

what do you mean about the buckets, can you have them for the label values (and not the metric value)?

@cezarygerard
Copy link
Contributor

@swetharepakula
There is a problem in changing the metric labels with bucketing information
into proper prometheus histograms

the metrics we want to export are type gauge, not cumulative, and they are exported every 10 minutes
there is no way we can create histogram of gauges in prometheus as of now

even if there was such metric type, to calculate bucketed gauges we would need to keep a slice of buckets in memory while iterating over services (thus duplicating prometheus)

also we can not use histogram_metric.Reset() before setting the histogram values from scratch every 10 minutes, as the scraping may happen just after we reset values and before we se new ones fully resulting is some funny values exported sometimes

@cezarygerard
Copy link
Contributor

/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 7, 2023
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: cezarygerard, mmamczur

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 the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 7, 2023
@k8s-ci-robot k8s-ci-robot merged commit b225097 into kubernetes:master Mar 7, 2023
@mmamczur mmamczur deleted the metrics_controller_attempt2 branch April 10, 2024 13:16
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. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants