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

CustomResourceStateMetrics Wildcard in paths #2057

Closed
codysmithd opened this issue May 2, 2023 · 4 comments
Closed

CustomResourceStateMetrics Wildcard in paths #2057

codysmithd opened this issue May 2, 2023 · 4 comments
Labels
kind/feature Categorizes issue or PR as related to a new feature. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one.

Comments

@codysmithd
Copy link

What would you like to be added:
Ability to wildcard parts of paths for CustomResourceStateMetrics, in this case specifically a StateSet path, but could equally apply to other paths.

Example:

Custom Resource

status:
    foos:
    - name: "a"
      conditions:
      - type: "MetricForThis"
        color: "green"
    - name: "b"
    - name: "c" 
      conditions:
      - type: "MetricForThis"
        color: "yellow" 

We want to report a StateSet metric for the color of foos that have a condition of type "MetricForThis".

Config

metrics:
  - name: my_metric
    each:
      type: StateSet
    stateSet:
      labelName: color
      path: [status, foos, "[name=*]", "conditions", "[type=MetricForThis]", color]
      list: [green, yellow, red]

[name=*] means "any" name where the following path conditions still apply. To differentiate matching instances, the value of the wildcard is also applied as a label.

Metric output

my_metric{name="a", color="green"} 1
my_metric{name="a", color="yellow"} 0
my_metric{name="a", color="red"} 0

my_metric{name="c", color="green"} 0
my_metric{name="c", color="yellow"} 1
my_metric{name="c", color="red"} 0

Outside of the basic case presented here, ideally this would work with further levels nesting as well (multiple wildcards in the path).

@codysmithd codysmithd added the kind/feature Categorizes issue or PR as related to a new feature. label May 2, 2023
@k8s-ci-robot k8s-ci-robot added the needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label May 2, 2023
@k8s-ci-robot
Copy link
Contributor

This issue is currently awaiting triage.

If kube-state-metrics contributors determine this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

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.

@CatherineF-dev
Copy link
Contributor

CatherineF-dev commented May 8, 2023

Will it be covered by #1978?

Or you would like [status, foos, "[name=*]", "conditions", "[type=MetricForThis]", color] instead writing cel to extract these fields?

@logicalhan
Copy link
Member

I think we should cover this by CEL.

@codysmithd
Copy link
Author

Agreed, thank you!

@codysmithd codysmithd closed this as not planned Won't fix, can't repro, duplicate, stale May 8, 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. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one.
Projects
None yet
Development

No branches or pull requests

4 participants