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

Adhere to OTel-Prometheus standard for labels #2004

Merged
merged 1 commit into from Apr 26, 2023

Conversation

rexagod
Copy link
Member

@rexagod rexagod commented Feb 22, 2023

What this PR does / why we need it: Adhere to OTel-Prometheus standard for generated labels in CRS.

How does this change affect the cardinality of KSM: No change.


Additional info.: OSM has a hardcoded approach for doing this right now: https://github.com/openshift/openshift-state-metrics/blob/master/pkg/collectors/utils.go#L29


@@ -1,9 +1,9 @@
 # HELP kube_customresource_openshift_route_labels Kubernetes labels converted to Prometheus labels.
 # TYPE kube_customresource_openshift_route_labels info
-kube_customresource_openshift_route_labels{app.kubernetes.io/component="query-layer",app.kubernetes.io/instance="thanos-querier",app.kubernetes.io/name="thanos-query",app.kubernetes.io/part-of="openshift-monitoring",app.kubernetes.io/version="0.28.1",customresource_group="route.openshift.io",customresource_kind="Route",customresource_version="v1",namespace="openshift-monitoring",route="thanos-querier"} 1
+kube_customresource_openshift_route_labels{app_kubernetes_io_component="query-layer",app_kubernetes_io_instance="thanos-querier",app_kubernetes_io_name="thanos-query",app_kubernetes_io_part_of="openshift-monitoring",app_kubernetes_io_version="0.28.1",customresource_group="route.openshift.io",customresource_kind="Route",customresource_version="v1",namespace="openshift-monitoring",route="thanos-querier"} 1
 kube_customresource_openshift_route_labels{app="console",customresource_group="route.openshift.io",customresource_kind="Route",customresource_version="v1",namespace="openshift-console",route="console"} 1
 kube_customresource_openshift_route_labels{app="oauth-openshift",customresource_group="route.openshift.io",customresource_kind="Route",customresource_version="v1",namespace="openshift-authentication",route="oauth-openshift"} 1
-kube_customresource_openshift_route_labels{customresource_group="route.openshift.io",customresource_kind="Route",customresource_version="v1",ingress.openshift.io/canary="canary_controller",namespace="openshift-ingress-canary",route="canary"} 1
+kube_customresource_openshift_route_labels{customresource_group="route.openshift.io",customresource_kind="Route",customresource_version="v1",ingress_openshift_io_canary="canary_controller",namespace="openshift-ingress-canary",route="canary"} 1
 kube_customresource_openshift_route_labels{customresource_group="route.openshift.io",customresource_kind="Route",customresource_version="v1",namespace="openshift-console",route="downloads"} 1
 kube_customresource_openshift_route_labels{customresource_group="route.openshift.io",customresource_kind="Route",customresource_version="v1",namespace="openshift-monitoring",route="alertmanager-main"} 1
 kube_customresource_openshift_route_labels{customresource_group="route.openshift.io",customresource_kind="Route",customresource_version="v1",namespace="openshift-monitoring",route="prometheus-k8s"} 1

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Feb 22, 2023
@k8s-ci-robot k8s-ci-robot added needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Feb 22, 2023
@mrueg
Copy link
Member

mrueg commented Feb 22, 2023

As this is a breaking change to experimental _labels _annotations, we should either feature flag it or announce it visibly in a future changelog.

@logicalhan
Copy link
Member

/triage accepted
/assign @dgrisonnet

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Feb 23, 2023
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 14, 2023
Comment on lines 508 to 509
otelCompatPromLabelName := otelprom.NormalizeLabel(k)
result[otelCompatPromLabelName] = fmt.Sprintf("%v", v)
Copy link
Member

Choose a reason for hiding this comment

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

It would be great if we could reuse mapToPrometheusLabels here so that we don't duplicate the logic and make sure that both part of the code use the same normalization.

Copy link
Member Author

Choose a reason for hiding this comment

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

sanitizeLabelName felt a bit more "fitting" to me for this usecase, so I ended up using that here. LMK if you think otherwise and I'll change this accordingly.

@dgrisonnet
Copy link
Member

As this is a breaking change to experimental _labels _annotations, we should either feature flag it or announce it visibly in a future changelog.

Should we perhaps wait for the next major version? Just to make sure we don't break anyone on a minor.

@mrueg
Copy link
Member

mrueg commented Mar 16, 2023

As this is a breaking change to experimental _labels _annotations, we should either feature flag it or announce it visibly in a future changelog.

Should we perhaps wait for the next major version? Just to make sure we don't break anyone on a minor.

Since the _labels and _annotations metrics are experimental and not stable, I think it's fine to break them (we should just announce it visibly in the changelog).

@dgrisonnet
Copy link
Member

Sounds good 👍

@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Apr 14, 2023
@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Apr 14, 2023
@k8s-ci-robot k8s-ci-robot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Apr 14, 2023
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 14, 2023
go.mod Outdated Show resolved Hide resolved
@mrueg
Copy link
Member

mrueg commented Apr 23, 2023

/lgtm

thanks for your work on this @rexagod !

/hold

for others to review as well

@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 Apr 23, 2023
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 23, 2023
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mrueg, rexagod

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

@dgrisonnet
Copy link
Member

/unhold

@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 Apr 26, 2023
@k8s-ci-robot k8s-ci-robot merged commit b3157f7 into kubernetes:main Apr 26, 2023
11 checks passed
@rexagod rexagod mentioned this pull request May 23, 2023
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/L Denotes a PR that changes 100-499 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants