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

CustomResource: no metrics if CRD apply after ksm starts #2296

Open
ZhangsongLee opened this issue Jan 4, 2024 · 7 comments
Open

CustomResource: no metrics if CRD apply after ksm starts #2296

ZhangsongLee opened this issue Jan 4, 2024 · 7 comments
Assignees
Labels
kind/bug Categorizes issue or PR as related to a bug. triage/accepted Indicates an issue or PR is ready to be actively worked on.

Comments

@ZhangsongLee
Copy link

ZhangsongLee commented Jan 4, 2024

What happened:

There is a issues when a CRD is not applied before starting ksm

  • no HELP or TYPE will get exported

What you expected to happen:

  • Not requiring a restart to expose the metrics

How to reproduce it (as minimally and precisely as possible):

  • Started KSM with configuration for the CRD
  • Sleep for 5min
  • Applied a CRD
  • Created a CR of the above CRD type
  • The metrics don't get exposed
  • Restart KSM
  • Metrics will get exposed

Used Configuration:

custom-resource-state-config.yaml: |
  spec:
    resources:
    - groupVersionKind:
        group: test.demo.io
        version: "v1alpha1"
        kind: crdtest
      labelsFromPath:
        namespace: [metadata, namespace]
      metrics:
        - name: "custom_request_cpu"
          help: "request cpu metrics"
          each:
            type: Gauge
            gauge:
              path: [status, custom, containers]
              labelsFromPath:
                container_name: ["containerName"]
              valueFrom: [cpu]

Anything else we need to know?:
I found a related issue #2142, this issue is before starting ksm, CRD already existed.

Environment:

  • kube-state-metrics commit: eac6d3b
  • Kubernetes version (use kubectl version): v1.26
@ZhangsongLee ZhangsongLee added the kind/bug Categorizes issue or PR as related to a bug. label Jan 4, 2024
@k8s-ci-robot k8s-ci-robot added the needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label Jan 4, 2024
@CatherineF-dev
Copy link
Contributor

Could you try KSM v2.8.2?

There are some big changes around CRD after v2.8.2.

@ZhangsongLee
Copy link
Author

But I used commit(eac6d3b) after v2.8.2

@CatherineF-dev
Copy link
Contributor

v2.8.2+ has some bugs, you can find them in issues.

I guess this might be related as well.

Is v2.8.2 working for you?

@ZhangsongLee
Copy link
Author

ZhangsongLee commented Jan 11, 2024

Unfortunately, v2.8.2 is not working :(

  • what is different from before is that#HELP #TYPEnow appears, but still no metrics
 # HELP kube_customresource_custom_request_cpu request cpu metrics
 # TYPE kube_customresource_custom_request_cpu gauge

@CatherineF-dev
Copy link
Contributor

CatherineF-dev commented Jan 11, 2024

This feature is working in my cluster.

Could you try examples here https://github.com/kubernetes/kube-state-metrics/blob/main/docs/customresourcestate-metrics.md?

I guess user configuration is not correct, you can add logs and rebuild KSM to debug. #2299

@dashpole
Copy link

/assign @CatherineF-dev
/triage accepted

@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 Jan 11, 2024
@CatherineF-dev
Copy link
Contributor

Hi @ZhangsongLee, is this issue resolved or not?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
Development

No branches or pull requests

4 participants