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 Custom Resource State mode to filter on resource labels #2348

Open
blezoray opened this issue Mar 22, 2024 · 1 comment
Open

Allow Custom Resource State mode to filter on resource labels #2348

blezoray opened this issue Mar 22, 2024 · 1 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.

Comments

@blezoray
Copy link

blezoray commented Mar 22, 2024

Hi,

I'm using KMS v2.11.0 with --custom-resource-state-only=true mode.
In my custom-resource-state-config-file, I would like to filter some resources (StatefulSet, Deployment, DeploymentConfig) with specific labels.
Something equivalent to:

$ kubectl get statefulsets.apps -A -l 'accounting'
NAMESPACE                        NAME                               READY   AGE
dbms-db                          myq-orange-mariadb                 1/1     106d
dbms-ops                         generic-graf-orange-grafana        1/1     35d
dbms-ops                         generic-prom-prometheus            1/1     21h
...

I try to configure my custom-resource-state-config-file like this but it doesn't return any metric.

  # StatefulSet.apps
  - metricNamePrefix: mpms
    groupVersionKind:
      group: apps
      version: v1
      kind: StatefulSet
      labels:
        accounting:
    labelsFromPath:
      name: [metadata, name]
      namespace: [metadata, namespace]
      accounting: [metadata, labels, accounting]
    metrics:
      - name: managedresources
        help: MPMS Managed Resources
        each:
          type: Gauge
          gauge:
            path: [status, conditions]
            labelsFromPath:
              type: [type]
            valueFrom: [status]

Here are the logs:

$ kubectl logs deployments/operators-accounting | grep -i stateful
I0322 07:56:59.035262       1 reflector.go:289] Starting reflector apps/v1, Kind=StatefulSet (0s) from pkg/mod/k8s.io/[email protected]/tools/cache/reflector.go:229
I0322 07:56:59.035288       1 reflector.go:325] Listing and watching apps/v1, Kind=StatefulSet from pkg/mod/k8s.io/[email protected]/tools/cache/reflector.go:229
I0322 07:56:59.234105       1 builder.go:282] "Active resources" activeStoreNames="apps/v1, Resource=statefulsets,cert-manager.io/v1, Resource=certificaterequests,cert-manager.io/v1, Resource=certificates,cert-manager.io/v1, Resource=clusterissuers,cert-manager.io/v1, Resource=issuers,core.strimzi.io/v1beta2, Resource=strimzipodsets,elasticsearch.k8s.elastic.co/v1, Resource=elasticsearches,enterprisesearch.k8s.elastic.co/v1, Resource=enterprisesearches,external-secrets.io/v1alpha1, Resource=pushsecrets,external-secrets.io/v1beta1, Resource=clusterexternalsecrets,external-secrets.io/v1beta1, Resource=clustersecretstores,external-secrets.io/v1beta1, Resource=externalsecrets,external-secrets.io/v1beta1, Resource=secretstores,kafka.strimzi.io/v1beta2, Resource=kafkabridges,kafka.strimzi.io/v1beta2, Resource=kafkaconnectors,kafka.strimzi.io/v1beta2, Resource=kafkaconnects,kafka.strimzi.io/v1beta2, Resource=kafkamirrormaker2s,kafka.strimzi.io/v1beta2, Resource=kafkamirrormakers,kafka.strimzi.io/v1beta2, Resource=kafkanodepools,kafka.strimzi.io/v1beta2, Resource=kafkarebalances,kafka.strimzi.io/v1beta2, Resource=kafkas,kafka.strimzi.io/v1beta2, Resource=kafkatopics,kafka.strimzi.io/v1beta2, Resource=kafkausers,kibana.k8s.elastic.co/v1, Resource=kibanas,kube-green.com/v1alpha1, Resource=sleepinfos,logstash.k8s.elastic.co/v1alpha1, Resource=logstashes,postgresql.cnpg.io/v1, Resource=clusters,postgresql.cnpg.io/v1, Resource=poolers,storage.tech.orange/v1alpha1, Resource=s3bucketclaims"
I0322 08:02:21.436082       1 reflector.go:790] pkg/mod/k8s.io/[email protected]/tools/cache/reflector.go:229: Watch close - apps/v1, Kind=StatefulSet total 6 items received
I0322 08:11:28.437911       1 reflector.go:790] pkg/mod/k8s.io/[email protected]/tools/cache/reflector.go:229: Watch close - apps/v1, Kind=StatefulSet total 10 items received
I0322 08:20:58.439071       1 reflector.go:790] pkg/mod/k8s.io/[email protected]/tools/cache/reflector.go:229: Watch close - apps/v1, Kind=StatefulSet total 11 items received
I0322 08:30:28.441079       1 reflector.go:790] pkg/mod/k8s.io/[email protected]/tools/cache/reflector.go:229: Watch close - apps/v1, Kind=StatefulSet total 10 items received

Is it supported ?

Rgds.

@blezoray blezoray added the kind/feature Categorizes issue or PR as related to a new feature. label Mar 22, 2024
@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.

@k8s-ci-robot k8s-ci-robot added the needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label Mar 22, 2024
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

2 participants