I was wondering if it's possible to write a query to show the number of nodes in the cluster with a given cpu and memory configuration.
I have a metric kube_node_status_allocatable
available with different tags.
Metric 1 (cpu count on each node):
kube_node_status_allocatable{instance="ip1",node="host1",resource="cpu",unit="core"} 21
kube_node_status_allocatable{instance="ip2",node="host2",resource="cpu",unit="core"} 21
kube_node_status_allocatable{instance="ip3",node="host3",resource="cpu",unit="core"} 61
kube_node_status_allocatable{instance="ip4",node="host4",resource="cpu",unit="core"} 61
kube_node_status_allocatable{instance="ip5",node="host5",resource="cpu",unit="core"} 61
Metric 2 (memory count on each node)::
kube_node_status_allocatable{instance="ip1",node="host1",resource="memory",unit="gb"} 64
kube_node_status_allocatable{instance="ip2",node="host2",resource="memory",unit="gb"} 64
kube_node_status_allocatable{instance="ip3",node="host3",resource="memory",unit="gb"} 128
kube_node_status_allocatable{instance="ip4",node="host4",resource="memory",unit="gb"} 128
kube_node_status_allocatable{instance="ip5",node="host5",resource="memory",unit="gb"} 128
I want to output a metric that looks something like this:
{cpu=21, memory=64} 2
{cpu=61, memory=128} 3
So far I have been able to get number of nodes with a given configuration for one resource at a time.
i.e., number of nodes with different cpu configuration
count_values("node", kube_node_status_allocatable{resource="cpu"})
Above outputs:
{node=21} 2
{node=61} 3
Which roughly maps to configuration (cpu == 21 or 61) and the number of nodes with that configuration (2 or 3).
I can get a similar result for memory, but I am not sure how to join these two.