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

Allow labelFromKey field for all applicable types #1880

Merged
merged 5 commits into from
Nov 14, 2022

Conversation

rexagod
Copy link
Member

@rexagod rexagod commented Nov 3, 2022

Allow labelFromKey field for the following types:

  • Gauge: Done.
  • Info: Done.
  • StateSet: N/A (redundant use case, see doc changes for more info).

Fixes: #1871 and #1868.

How does this change affect the cardinality of KSM: Increases (we are adding labels from keys, which may increase cardinality).

@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. do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Nov 3, 2022
@k8s-ci-robot k8s-ci-robot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Nov 3, 2022
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. label Nov 3, 2022
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Nov 4, 2022
Allow `labelFromKey` field for the following types:
* Gauge: Done.
* Info: Done.
* StateSet: N/A (redundant use case, see doc changes for more info).

Signed-off-by: Pranshu Srivastava <rexagod@gmail.com>
@k8s-ci-robot k8s-ci-robot added 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 Nov 4, 2022
@rexagod
Copy link
Member Author

rexagod commented Nov 4, 2022

Input
kind: CustomResourceStateMetrics
spec:
  resources:
    - groupVersionKind:
        group: "apps"
        version: "v1"
        kind: "Deployment"
      labelsFromPath:
        name: [metadata, name]
      metrics:
        - name: "test_metrics"
          help: "metrics for debugging"
          each:
            type: Info
            info:
              path: [metadata, annotations]
              labelFromKey: test
Output
# HELP kube_crd_test_metrics metrics for debugging
# TYPE kube_crd_test_metrics gauge (<-- this is a bug, I've added a TODO for this)
kube_crd_test_metrics{group="apps",kind="Deployment",name="nginx-deployment",test="deployment.kubernetes.io/revision",version="v1"} 1
kube_crd_test_metrics{group="apps",kind="Deployment",name="nginx-deployment",test="test-a",version="v1"} 1
kube_crd_test_metrics{group="apps",kind="Deployment",name="nginx-deployment",test="test-b",version="v1"} 2
# HELP kube_crd_test_metrics metrics for debugging
# TYPE kube_crd_test_metrics gauge (<-- this is a bug, I've added a TODO for this)
kube_crd_test_metrics{group="apps",kind="Deployment",name="nginx-deployment",test="deployment.kubernetes.io/revision",version="v1"} 1
kube_crd_test_metrics{group="apps",kind="Deployment",name="nginx-deployment",test="test-a",version="v1"} 1
kube_crd_test_metrics{group="apps",kind="Deployment",name="nginx-deployment",test="test-b",version="v1"} 2

@rexagod rexagod marked this pull request as ready for review November 4, 2022 09:46
@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 Nov 4, 2022
@rexagod rexagod changed the title Allow labelFromKey field for all types Allow labelFromKey field for all applicable types Nov 4, 2022
@rexagod rexagod changed the title Allow labelFromKey field for all applicable types Allow labelFromKey field for all applicable types Nov 4, 2022
@rexagod
Copy link
Member Author

rexagod commented Nov 6, 2022

Ready for review.

@CatherineF-dev
Copy link
Contributor

Wondering if it's possible to have an E2E test for CRD metrics.

@mrueg
Copy link
Member

mrueg commented Nov 8, 2022

/lgtm
/hold
for @dgrisonnet @fpetkovski @logicalhan to have another look

@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 Nov 8, 2022
@k8s-ci-robot k8s-ci-robot added lgtm "Looks good to me", indicates that a PR is ready to be merged. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Nov 8, 2022
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 8, 2022
Copy link
Member

@logicalhan logicalhan left a comment

Choose a reason for hiding this comment

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

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 8, 2022
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed 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. labels Nov 9, 2022
@k8s-ci-robot k8s-ci-robot added 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 Nov 9, 2022
@rexagod rexagod requested review from dgrisonnet and removed request for fpetkovski November 10, 2022 16:19
@mrueg
Copy link
Member

mrueg commented Nov 14, 2022

/lgtm

/hold cancel

Thanks for your contribution @rexagod !

@k8s-ci-robot k8s-ci-robot added lgtm "Looks good to me", indicates that a PR is ready to be merged. and removed do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. labels Nov 14, 2022
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: logicalhan, 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

@k8s-ci-robot k8s-ci-robot merged commit b2c90e8 into kubernetes:master Nov 14, 2022
@rexagod rexagod mentioned this pull request Nov 16, 2022
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

labelFromKey is just for Gauge, other types (eg. Info) don't have the attribute
6 participants