Skip to content

CustomResourceStateMetrics Failing to Report Value #2601

Open
@kevarr

Description

What happened:

When creating CustomResourceStateMetrics to add a metric CRD resource annotations (similar to the example doing the same for VPA), KSM isn't exposing a metric value.

# HELP kube_customresource_application_annotations Kubernetes annotations converted to Prometheus labels.
# TYPE kube_customresource_application_annotations gauge
# HELP kube_configmap_annotations Kubernetes annotations converted to Prometheus labels.

What you expected to happen:

Custom metric with value exposed via KSM.

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

I'm using an ArgoCD Application CRD, but the same may be reproducible with any other CRD.

kind create cluster
helm install kube-state-metrics prometheus-community/kube-state-metrics --create-namespace -n kube-state-metrics -f defaults.yaml

Helm values I'm using..

defaults.yaml
    
    rbac:
      extraRules:
        - apiGroups:
            - "argoproj.io"
          resources:
            - "applications"
          verbs:
            - list
            - watch
    
    customResourceState:
      enabled: true
      config:
        kind: CustomResourceStateMetrics
        spec:
          resources:
            - groupVersionKind:
                group: argoproj.io
                kind: "Application"
                version: "v1alpha1"
              labelsFromPath:
                application: [metadata, name]
                namespace: [metadata, namespace]
              metrics:
                - name: "application_annotations"
                  help: "Kubernetes annotations converted to Prometheus labels."
                  each:
                    type: Gauge
                    gauge:
                      path: [metadata, annotations]
    
  

Anything else we need to know?:

Application manifest:

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  annotations:
    foo: bar
    test: testing
  name: guestbook
  namespace: argocd
spec:
  destination:
    namespace: default
    server: https://kubernetes.default.svc
  project: default
  source:
    path: guestbook
    repoURL: https://github.com/argoproj/argocd-example-apps.git

Thanks in advance! I'm assuming I'm missing something obvious but after staring at this for a while I'm out of ideas.

Environment:

  • kube-state-metrics version: v2.14.0
  • Kubernetes version (use kubectl version): v1.32.0
  • Cloud provider or hardware configuration: Kind cluster
  • Other info: N/A

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

kind/bugCategorizes issue or PR as related to a bug.triage/acceptedIndicates an issue or PR is ready to be actively worked on.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions