kubernetes / kube-state-metrics

Add-on agent to generate and expose cluster-level metrics.
https://kubernetes.io/docs/concepts/cluster-administration/kube-state-metrics/
Apache License 2.0
5.21k stars 1.94k forks source link

registry_factory.go:685 Invalid syntax #2439

Open villanisaac-kr opened 6 days ago

villanisaac-kr commented 6 days ago

What happened:

After adding below metric. I was able to see the metric in Prometheus portal but the kube-state-metrics pod keeps throwing following error:
E0701 21:29:11.117845 1 registry_factory.go:685] "gotk_resource_status" err="[status,conditions]: []: strconv.ParseFloat: parsing \"Unknown\": invalid syntax".

#configuration
---
customResourceState:
    enabled: true
    config:
      spec:
        resources:
          - groupVersionKind:
              group: kustomize.toolkit.fluxcd.io
              version: v1
              kind: Kustomization
            metricNamePrefix: gotk
            metrics:
              - name: "resource_status"
                help: "The current state of a Flux Kustomization resource."
                each:
                  type: Gauge
                  gauge:
                    path: [status, conditions]
                    labelsFromPath:
                      type: ["type"]
                    valueFrom: ["status"]
                labelsFromPath:
                  name: [metadata, name]
                  exported_namespace: [metadata, namespace]
                  suspended: [spec, suspend]
                  prune: [spec, prune]
                  revision: [status, lastAppliedRevision]
                  source_name: [spec, sourceRef, name]

What you expected to happen:

I expect no errors in the logs after adding that configuration

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

Added the metric showed in the description

Anything else we need to know?: As I said before the metric works as expected but the logs are overflowing with the error described on "What happened?" section:

gotk_resource_status{container="kube-state-metrics", customresource_group="kustomize.toolkit.fluxcd.io", customresource_kind="Kustomization", customresource_version="v1", endpoint="http", exported_namespace="flux-system", instance="172.22.15.193:8080", job="kube-state-metrics", name="prometheus", namespace="monitoring", pod="kube-prometheus-stack-kube-state-metrics-5b7fb8dc6-j7tqn", prune="true", revision="main@sha1:cc6b5b452b9b09a964deaef0b4de59817fe5caed", service="kube-prometheus-stack-kube-state-metrics", source_name="flux-system", type="Ready"}

I followed this documentation: https://github.com/kubernetes/kube-state-metrics/blob/main/docs/metrics/extend/customresourcestate-metrics.md#example-for-status-conditions-on-kubernetes-controllers

Environment:

k8s-ci-robot commented 6 days ago

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](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes-sigs/prow](https://github.com/kubernetes-sigs/prow/issues/new?title=Prow%20issue:) repository.