Skip to content

Commit

Permalink
fixup! fixup! Prefer kube-scheduler's resource metrics to kube-state-…
Browse files Browse the repository at this point in the history
…metrics'

reintroduce dropped rules
  • Loading branch information
rexagod committed Sep 25, 2024
1 parent 86d83ae commit a27bcc3
Showing 1 changed file with 92 additions and 0 deletions.
92 changes: 92 additions & 0 deletions rules/apps.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,29 @@
{
name: 'k8s.rules.container_memory_requests',
rules: [
{
record: 'cluster:namespace:pod_memory:active:kube_pod_container_resource_requests',
expr: |||
kube_pod_container_resource_requests{resource="memory",%(kubeStateMetricsSelector)s} * on (namespace, pod, %(clusterLabel)s)
group_left() max by (namespace, pod, %(clusterLabel)s) (
(kube_pod_status_phase{phase=~"Pending|Running"} == 1)
)
||| % $._config,
},
{
record: 'namespace_memory:kube_pod_container_resource_requests:sum',
expr: |||
sum by (namespace, %(clusterLabel)s) (
sum by (namespace, pod, %(clusterLabel)s) (
max by (namespace, pod, container, %(clusterLabel)s) (
kube_pod_container_resource_requests{resource="memory",%(kubeStateMetricsSelector)s}
) * on(namespace, pod, %(clusterLabel)s) group_left() max by (namespace, pod, %(clusterLabel)s) (
kube_pod_status_phase{phase=~"Pending|Running"} == 1
)
)
)
||| % $._config,
},
{
record: 'cluster:namespace:pod_memory:active:kube_pod_resource_request_or_kube_pod_container_resource_requests',
expr: |||
Expand All @@ -106,6 +129,29 @@
{
name: 'k8s.rules.container_cpu_requests',
rules: [
{
record: 'cluster:namespace:pod_cpu:active:kube_pod_container_resource_requests',
expr: |||
kube_pod_container_resource_requests{resource="cpu",%(kubeStateMetricsSelector)s} * on (namespace, pod, %(clusterLabel)s)
group_left() max by (namespace, pod, %(clusterLabel)s) (
(kube_pod_status_phase{phase=~"Pending|Running"} == 1)
)
||| % $._config,
},
{
record: 'namespace_cpu:kube_pod_container_resource_requests:sum',
expr: |||
sum by (namespace, %(clusterLabel)s) (
sum by (namespace, pod, %(clusterLabel)s) (
max by (namespace, pod, container, %(clusterLabel)s) (
kube_pod_container_resource_requests{resource="cpu",%(kubeStateMetricsSelector)s}
) * on(namespace, pod, %(clusterLabel)s) group_left() max by (namespace, pod, %(clusterLabel)s) (
kube_pod_status_phase{phase=~"Pending|Running"} == 1
)
)
)
||| % $._config,
},
{
record: 'cluster:namespace:pod_cpu:active:kube_pod_resource_request_or_kube_pod_container_resource_requests',
expr: |||
Expand All @@ -129,6 +175,29 @@
{
name: 'k8s.rules.container_memory_limits',
rules: [
{
record: 'cluster:namespace:pod_memory:active:kube_pod_container_resource_limits',
expr: |||
kube_pod_container_resource_limits{resource="memory",%(kubeStateMetricsSelector)s} * on (namespace, pod, %(clusterLabel)s)
group_left() max by (namespace, pod, %(clusterLabel)s) (
(kube_pod_status_phase{phase=~"Pending|Running"} == 1)
)
||| % $._config,
},
{
record: 'namespace_memory:kube_pod_container_resource_limits:sum',
expr: |||
sum by (namespace, %(clusterLabel)s) (
sum by (namespace, pod, %(clusterLabel)s) (
max by (namespace, pod, container, %(clusterLabel)s) (
kube_pod_container_resource_limits{resource="memory",%(kubeStateMetricsSelector)s}
) * on(namespace, pod, %(clusterLabel)s) group_left() max by (namespace, pod, %(clusterLabel)s) (
kube_pod_status_phase{phase=~"Pending|Running"} == 1
)
)
)
||| % $._config,
},
{
record: 'cluster:namespace:pod_memory:active:kube_pod_resource_limit_or_kube_pod_container_resource_limits',
expr: |||
Expand All @@ -152,6 +221,29 @@
{
name: 'k8s.rules.container_cpu_limits',
rules: [
{
record: 'cluster:namespace:pod_cpu:active:kube_pod_container_resource_limits',
expr: |||
kube_pod_container_resource_limits{resource="cpu",%(kubeStateMetricsSelector)s} * on (namespace, pod, %(clusterLabel)s)
group_left() max by (namespace, pod, %(clusterLabel)s) (
(kube_pod_status_phase{phase=~"Pending|Running"} == 1)
)
||| % $._config,
},
{
record: 'namespace_cpu:kube_pod_container_resource_limits:sum',
expr: |||
sum by (namespace, %(clusterLabel)s) (
sum by (namespace, pod, %(clusterLabel)s) (
max by (namespace, pod, container, %(clusterLabel)s) (
kube_pod_container_resource_limits{resource="cpu",%(kubeStateMetricsSelector)s}
) * on(namespace, pod, %(clusterLabel)s) group_left() max by (namespace, pod, %(clusterLabel)s) (
kube_pod_status_phase{phase=~"Pending|Running"} == 1
)
)
)
||| % $._config,
},
{
record: 'cluster:namespace:pod_cpu:active:kube_pod_resource_limit_or_kube_pod_container_resource_limits',
expr: |||
Expand Down

0 comments on commit a27bcc3

Please sign in to comment.