Open diranged opened 8 months ago
There is an API server metric called 'apiserver_storage_objects' that should give you counts already.
/close
@dgrisonnet: Closing this issue.
/reopen
This feature is under consideration.
@dgrisonnet: Reopened this issue.
/triage accepted
Hello, I'm also interested in having a Count feature. I have CRDs with multiples status conditions:
status:
conditions:
- status: "True"
type: Synced
- status: "True"
type: Ready
I would like to count the number of CRD with specific conditions. The metric result is the number of K8s ressource with the label condition:
# HELP kube_customresource_MyCRD_count_condition_true Count of resource with a true condition
# TYPE kube_customresource_MyCRD_ready gauge
kube_customresource_MyCRD_count_condition_true{type="Ready"} 12
kube_customresource_MyCRD_count_condition_true{type="Synced"} 6
# HELP kube_customresource_MyCRD_count_condition_false Count of resource with a false condition
# TYPE kube_customresource_MyCRD_ready gauge
kube_customresource_MyCRD_count_condition_false{type="Ready"} 0
kube_customresource_MyCRD_count_condition_false{type="Synced"} 1
For the moment I have only been able to create one metric duplicate for each individual K8s resource. I want to group by this metrics into only one line: Output of kube-state-metrics:8080/metrics:
kube_customresource_test_status{customresource_group="****",customresource_kind="***",customresource_version="***",type="Ready"} 1
kube_customresource_test_status{customresource_group="***",customresource_kind="***",customresource_version="***",type="Synced"} 1
kube_customresource_test_status{customresource_group="****",customresource_kind="***",customresource_version="***",type="Ready"} 1
kube_customresource_test_status{customresource_group="***",customresource_kind="***",customresource_version="***",type="Synced"} 1
kube_customresource_test_status{customresource_group="****",customresource_kind="***",customresource_version="***",type="Ready"} 1
kube_customresource_test_status{customresource_group="***",customresource_kind="***",customresource_version="***",type="Synced"} 0
The metric is duplicate three time, because I have three objets.
Hello, I'm also interested in having a Count feature. I have CRDs with multiples status conditions:
status: conditions: - status: "True" type: Synced - status: "True" type: Ready
I would like to count the number of CRD with specific conditions. The metric result is the number of K8s ressource with the label condition:
# HELP kube_customresource_MyCRD_count_condition_true Count of resource with a true condition # TYPE kube_customresource_MyCRD_ready gauge kube_customresource_MyCRD_count_condition_true{type="Ready"} 12 kube_customresource_MyCRD_count_condition_true{type="Synced"} 6
# HELP kube_customresource_MyCRD_count_condition_false Count of resource with a false condition # TYPE kube_customresource_MyCRD_ready gauge kube_customresource_MyCRD_count_condition_false{type="Ready"} 0 kube_customresource_MyCRD_count_condition_false{type="Synced"} 1
For the moment I have only been able to create one metric duplicate for each individual K8s resource. I want to group by this metrics into only one line: Output of kube-state-metrics:8080/metrics:
kube_customresource_test_status{customresource_group="****",customresource_kind="***",customresource_version="***",type="Ready"} 1 kube_customresource_test_status{customresource_group="***",customresource_kind="***",customresource_version="***",type="Synced"} 1 kube_customresource_test_status{customresource_group="****",customresource_kind="***",customresource_version="***",type="Ready"} 1 kube_customresource_test_status{customresource_group="***",customresource_kind="***",customresource_version="***",type="Synced"} 1 kube_customresource_test_status{customresource_group="****",customresource_kind="***",customresource_version="***",type="Ready"} 1 kube_customresource_test_status{customresource_group="***",customresource_kind="***",customresource_version="***",type="Synced"} 0
The metric is duplicate three time, because I have three objets.
How did you get this to do counting? What was your each condition
What would you like to be added:
I'd like to see a way for us to count Custom Resources in an absolute way - just the count of the resources, split up by whatever labels we've selected.
Why is this needed:
Currently the https://github.com/kubernetes/kube-state-metrics/blob/main/docs/customresourcestate-metrics.md code allows us to query values from individual CRs and then report back those values as custom metrics. This is problematic if you have a CR that has a high cardinality rate (
kyverno.io/UpdatRequest
orCertificateSigningRequests
for example) and you only care about the absolute count of them.Describe the solution you'd like
Right now there is the
StateSet
,Gauge
andInfo
type of metric configuration. I'd like to seeCount
added.