Skip to content

Commit

Permalink
fixup! fixup! Use kube-scheduler's metrics instead of kube-state-metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
rexagod committed Jan 16, 2023
1 parent 758d714 commit 0a5f952
Show file tree
Hide file tree
Showing 11 changed files with 100 additions and 100 deletions.
8 changes: 4 additions & 4 deletions alerts/resource_alerts.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
} +
if $._config.showMultiCluster then {
expr: |||
sum(namespace_cpu:kube_pod_resource_requests:sum{%(ignoringOverprovisionedWorkloadSelector)s}) by (%(clusterLabel)s) - (sum(kube_node_status_allocatable{resource="cpu"}) by (%(clusterLabel)s) - max(kube_node_status_allocatable{resource="cpu"}) by (%(clusterLabel)s)) > 0
sum(namespace_cpu:kube_pod_resource_request:sum{%(ignoringOverprovisionedWorkloadSelector)s}) by (%(clusterLabel)s) - (sum(kube_node_status_allocatable{resource="cpu"}) by (%(clusterLabel)s) - max(kube_node_status_allocatable{resource="cpu"}) by (%(clusterLabel)s)) > 0
and
(sum(kube_node_status_allocatable{resource="cpu"}) by (%(clusterLabel)s) - max(kube_node_status_allocatable{resource="cpu"}) by (%(clusterLabel)s)) > 0
||| % $._config,
Expand All @@ -43,7 +43,7 @@
},
} else {
expr: |||
sum(namespace_cpu:kube_pod_resource_requests:sum{%(ignoringOverprovisionedWorkloadSelector)s}) - (sum(kube_node_status_allocatable{resource="cpu"}) - max(kube_node_status_allocatable{resource="cpu"})) > 0
sum(namespace_cpu:kube_pod_resource_request:sum{%(ignoringOverprovisionedWorkloadSelector)s}) - (sum(kube_node_status_allocatable{resource="cpu"}) - max(kube_node_status_allocatable{resource="cpu"})) > 0
and
(sum(kube_node_status_allocatable{resource="cpu"}) - max(kube_node_status_allocatable{resource="cpu"})) > 0
||| % $._config,
Expand All @@ -63,7 +63,7 @@
} +
if $._config.showMultiCluster then {
expr: |||
sum(namespace_memory:kube_pod_resource_requests:sum{%(ignoringOverprovisionedWorkloadSelector)s}) by (%(clusterLabel)s) - (sum(kube_node_status_allocatable{resource="memory"}) by (%(clusterLabel)s) - max(kube_node_status_allocatable{resource="memory"}) by (%(clusterLabel)s)) > 0
sum(namespace_memory:kube_pod_resource_request:sum{%(ignoringOverprovisionedWorkloadSelector)s}) by (%(clusterLabel)s) - (sum(kube_node_status_allocatable{resource="memory"}) by (%(clusterLabel)s) - max(kube_node_status_allocatable{resource="memory"}) by (%(clusterLabel)s)) > 0
and
(sum(kube_node_status_allocatable{resource="memory"}) by (%(clusterLabel)s) - max(kube_node_status_allocatable{resource="memory"}) by (%(clusterLabel)s)) > 0
||| % $._config,
Expand All @@ -73,7 +73,7 @@
} else
{
expr: |||
sum(namespace_memory:kube_pod_resource_requests:sum{%(ignoringOverprovisionedWorkloadSelector)s}) - (sum(kube_node_status_allocatable{resource="memory"}) - max(kube_node_status_allocatable{resource="memory"})) > 0
sum(namespace_memory:kube_pod_resource_request:sum{%(ignoringOverprovisionedWorkloadSelector)s}) - (sum(kube_node_status_allocatable{resource="memory"}) - max(kube_node_status_allocatable{resource="memory"})) > 0
and
(sum(kube_node_status_allocatable{resource="memory"}) - max(kube_node_status_allocatable{resource="memory"})) > 0
||| % $._config,
Expand Down
24 changes: 12 additions & 12 deletions dashboards/resources/cluster.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -144,23 +144,23 @@ local template = grafana.template;
)
.addPanel(
g.panel('CPU Requests Commitment') +
g.statPanel('sum(namespace_cpu:kube_pod_resource_requests:sum{%(clusterLabel)s="$cluster"}) / sum(kube_node_status_allocatable{%(kubeStateMetricsSelector)s,resource="cpu",%(clusterLabel)s="$cluster"})' % $._config)
g.statPanel('sum(namespace_cpu:kube_pod_resource_request:sum{%(clusterLabel)s="$cluster"}) / sum(kube_node_status_allocatable{%(kubeStateMetricsSelector)s,resource="cpu",%(clusterLabel)s="$cluster"})' % $._config)
)
.addPanel(
g.panel('CPU Limits Commitment') +
g.statPanel('sum(namespace_cpu:kube_pod_resource_limits:sum{%(clusterLabel)s="$cluster"}) / sum(kube_node_status_allocatable{%(kubeStateMetricsSelector)s,resource="cpu",%(clusterLabel)s="$cluster"})' % $._config)
g.statPanel('sum(namespace_cpu:kube_pod_resource_limit:sum{%(clusterLabel)s="$cluster"}) / sum(kube_node_status_allocatable{%(kubeStateMetricsSelector)s,resource="cpu",%(clusterLabel)s="$cluster"})' % $._config)
)
.addPanel(
g.panel('Memory Utilisation') +
g.statPanel('1 - sum(:node_memory_MemAvailable_bytes:sum{%(clusterLabel)s="$cluster"}) / sum(node_memory_MemTotal_bytes{%(nodeExporterSelector)s,%(clusterLabel)s="$cluster"})' % $._config)
)
.addPanel(
g.panel('Memory Requests Commitment') +
g.statPanel('sum(namespace_memory:kube_pod_resource_requests:sum{%(clusterLabel)s="$cluster"}) / sum(kube_node_status_allocatable{%(kubeStateMetricsSelector)s,resource="memory",%(clusterLabel)s="$cluster"})' % $._config)
g.statPanel('sum(namespace_memory:kube_pod_resource_request:sum{%(clusterLabel)s="$cluster"}) / sum(kube_node_status_allocatable{%(kubeStateMetricsSelector)s,resource="memory",%(clusterLabel)s="$cluster"})' % $._config)
)
.addPanel(
g.panel('Memory Limits Commitment') +
g.statPanel('sum(namespace_memory:kube_pod_resource_limits:sum{%(clusterLabel)s="$cluster"}) / sum(kube_node_status_allocatable{%(kubeStateMetricsSelector)s,resource="memory",%(clusterLabel)s="$cluster"})' % $._config)
g.statPanel('sum(namespace_memory:kube_pod_resource_limit:sum{%(clusterLabel)s="$cluster"}) / sum(kube_node_status_allocatable{%(kubeStateMetricsSelector)s,resource="memory",%(clusterLabel)s="$cluster"})' % $._config)
)
)
.addRow(
Expand All @@ -177,10 +177,10 @@ local template = grafana.template;
g.panel('CPU Quota') +
g.tablePanel(podWorkloadColumns + [
'sum(node_namespace_pod_container:container_cpu_usage_seconds_total:sum_irate{%(clusterLabel)s="$cluster"}) by (namespace)' % $._config,
'sum(namespace_cpu:kube_pod_resource_requests:sum{%(clusterLabel)s="$cluster"}) by (namespace)' % $._config,
'sum(node_namespace_pod_container:container_cpu_usage_seconds_total:sum_irate{%(clusterLabel)s="$cluster"}) by (namespace) / sum(namespace_cpu:kube_pod_resource_requests:sum{%(clusterLabel)s="$cluster"}) by (namespace)' % $._config,
'sum(namespace_cpu:kube_pod_resource_limits:sum{%(clusterLabel)s="$cluster"}) by (namespace)' % $._config,
'sum(node_namespace_pod_container:container_cpu_usage_seconds_total:sum_irate{%(clusterLabel)s="$cluster"}) by (namespace) / sum(namespace_cpu:kube_pod_resource_limits:sum{%(clusterLabel)s="$cluster"}) by (namespace)' % $._config,
'sum(namespace_cpu:kube_pod_resource_request:sum{%(clusterLabel)s="$cluster"}) by (namespace)' % $._config,
'sum(node_namespace_pod_container:container_cpu_usage_seconds_total:sum_irate{%(clusterLabel)s="$cluster"}) by (namespace) / sum(namespace_cpu:kube_pod_resource_request:sum{%(clusterLabel)s="$cluster"}) by (namespace)' % $._config,
'sum(namespace_cpu:kube_pod_resource_limit:sum{%(clusterLabel)s="$cluster"}) by (namespace)' % $._config,
'sum(node_namespace_pod_container:container_cpu_usage_seconds_total:sum_irate{%(clusterLabel)s="$cluster"}) by (namespace) / sum(namespace_cpu:kube_pod_resource_limit:sum{%(clusterLabel)s="$cluster"}) by (namespace)' % $._config,
], tableStyles {
'Value #C': { alias: 'CPU Usage' },
'Value #D': { alias: 'CPU Requests' },
Expand All @@ -207,10 +207,10 @@ local template = grafana.template;
g.tablePanel(podWorkloadColumns + [
// Not using container_memory_usage_bytes here because that includes page cache
'sum(container_memory_rss{%(cadvisorSelector)s, %(clusterLabel)s="$cluster", container!=""}) by (namespace)' % $._config,
'sum(namespace_memory:kube_pod_resource_requests:sum{%(clusterLabel)s="$cluster"}) by (namespace)' % $._config,
'sum(container_memory_rss{%(cadvisorSelector)s, %(clusterLabel)s="$cluster", container!=""}) by (namespace) / sum(namespace_memory:kube_pod_resource_requests:sum{%(clusterLabel)s="$cluster"}) by (namespace)' % $._config,
'sum(namespace_memory:kube_pod_resource_limits:sum{%(clusterLabel)s="$cluster"}) by (namespace)' % $._config,
'sum(container_memory_rss{%(cadvisorSelector)s, %(clusterLabel)s="$cluster", container!=""}) by (namespace) / sum(namespace_memory:kube_pod_resource_limits:sum{%(clusterLabel)s="$cluster"}) by (namespace)' % $._config,
'sum(namespace_memory:kube_pod_resource_request:sum{%(clusterLabel)s="$cluster"}) by (namespace)' % $._config,
'sum(container_memory_rss{%(cadvisorSelector)s, %(clusterLabel)s="$cluster", container!=""}) by (namespace) / sum(namespace_memory:kube_pod_resource_request:sum{%(clusterLabel)s="$cluster"}) by (namespace)' % $._config,
'sum(namespace_memory:kube_pod_resource_limit:sum{%(clusterLabel)s="$cluster"}) by (namespace)' % $._config,
'sum(container_memory_rss{%(cadvisorSelector)s, %(clusterLabel)s="$cluster", container!=""}) by (namespace) / sum(namespace_memory:kube_pod_resource_limit:sum{%(clusterLabel)s="$cluster"}) by (namespace)' % $._config,
], tableStyles {
'Value #C': { alias: 'Memory Usage', unit: 'bytes' },
'Value #D': { alias: 'Memory Requests', unit: 'bytes' },
Expand Down
24 changes: 12 additions & 12 deletions dashboards/resources/multi-cluster.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,23 @@ local g = import 'github.com/grafana/jsonnet-libs/grafana-builder/grafana.libson
)
.addPanel(
g.panel('CPU Requests Commitment') +
g.statPanel('sum(kube_pod_resource_requests{%(kubeSchedulerSelector)s, resource="cpu"}) / sum(kube_node_status_allocatable{%(kubeSchedulerSelector)s, resource="cpu"})' % $._config)
g.statPanel('sum(kube_pod_resource_request{%(kubeSchedulerSelector)s, resource="cpu"}) / sum(kube_node_status_allocatable{%(kubeSchedulerSelector)s, resource="cpu"})' % $._config)
)
.addPanel(
g.panel('CPU Limits Commitment') +
g.statPanel('sum(kube_pod_resource_limits{%(kubeSchedulerSelector)s, resource="cpu"}) / sum(kube_node_status_allocatable{%(kubeSchedulerSelector)s, resource="cpu"})' % $._config)
g.statPanel('sum(kube_pod_resource_limit{%(kubeSchedulerSelector)s, resource="cpu"}) / sum(kube_node_status_allocatable{%(kubeSchedulerSelector)s, resource="cpu"})' % $._config)
)
.addPanel(
g.panel('Memory Utilisation') +
g.statPanel('1 - sum(:node_memory_MemAvailable_bytes:sum) / sum(node_memory_MemTotal_bytes{%(nodeExporterSelector)s})' % $._config)
)
.addPanel(
g.panel('Memory Requests Commitment') +
g.statPanel('sum(kube_pod_resource_requests{%(kubeSchedulerSelector)s, resource="memory"}) / sum(kube_node_status_allocatable{%(kubeSchedulerSelector)s, resource="memory"})' % $._config)
g.statPanel('sum(kube_pod_resource_request{%(kubeSchedulerSelector)s, resource="memory"}) / sum(kube_node_status_allocatable{%(kubeSchedulerSelector)s, resource="memory"})' % $._config)
)
.addPanel(
g.panel('Memory Limits Commitment') +
g.statPanel('sum(kube_pod_resource_limits{%(kubeSchedulerSelector)s, resource="memory"}) / sum(kube_node_status_allocatable{%(kubeSchedulerSelector)s, resource="memory"})' % $._config)
g.statPanel('sum(kube_pod_resource_limit{%(kubeSchedulerSelector)s, resource="memory"}) / sum(kube_node_status_allocatable{%(kubeSchedulerSelector)s, resource="memory"})' % $._config)
)
)
.addRow(
Expand All @@ -59,10 +59,10 @@ local g = import 'github.com/grafana/jsonnet-libs/grafana-builder/grafana.libson
g.panel('CPU Quota') +
g.tablePanel([
'sum(node_namespace_pod_container:container_cpu_usage_seconds_total:sum_irate) by (%(clusterLabel)s)' % $._config,
'sum(kube_pod_resource_requests{%(kubeSchedulerSelector)s, resource="cpu"}) by (%(clusterLabel)s)' % $._config,
'sum(node_namespace_pod_container:container_cpu_usage_seconds_total:sum_irate) by (%(clusterLabel)s) / sum(kube_pod_resource_requests{%(kubeSchedulerSelector)s, resource="cpu"}) by (%(clusterLabel)s)' % $._config,
'sum(kube_pod_resource_limits{%(kubeSchedulerSelector)s, resource="cpu"}) by (%(clusterLabel)s)' % $._config,
'sum(node_namespace_pod_container:container_cpu_usage_seconds_total:sum_irate) by (%(clusterLabel)s) / sum(kube_pod_resource_limits{%(kubeSchedulerSelector)s, resource="cpu"}) by (%(clusterLabel)s)' % $._config,
'sum(kube_pod_resource_request{%(kubeSchedulerSelector)s, resource="cpu"}) by (%(clusterLabel)s)' % $._config,
'sum(node_namespace_pod_container:container_cpu_usage_seconds_total:sum_irate) by (%(clusterLabel)s) / sum(kube_pod_resource_request{%(kubeSchedulerSelector)s, resource="cpu"}) by (%(clusterLabel)s)' % $._config,
'sum(kube_pod_resource_limit{%(kubeSchedulerSelector)s, resource="cpu"}) by (%(clusterLabel)s)' % $._config,
'sum(node_namespace_pod_container:container_cpu_usage_seconds_total:sum_irate) by (%(clusterLabel)s) / sum(kube_pod_resource_limit{%(kubeSchedulerSelector)s, resource="cpu"}) by (%(clusterLabel)s)' % $._config,
], tableStyles {
'Value #A': { alias: 'CPU Usage' },
'Value #B': { alias: 'CPU Requests' },
Expand All @@ -88,10 +88,10 @@ local g = import 'github.com/grafana/jsonnet-libs/grafana-builder/grafana.libson
g.tablePanel([
// Not using container_memory_usage_bytes here because that includes page cache
'sum(container_memory_rss{%(cadvisorSelector)s, container!=""}) by (%(clusterLabel)s)' % $._config,
'sum(kube_pod_resource_requests{%(kubeSchedulerSelector)s, resource="memory"}) by (%(clusterLabel)s)' % $._config,
'sum(container_memory_rss{%(cadvisorSelector)s, container!=""}) by (%(clusterLabel)s) / sum(kube_pod_resource_requests{%(kubeSchedulerSelector)s, resource="memory"}) by (%(clusterLabel)s)' % $._config,
'sum(kube_pod_resource_limits{%(kubeSchedulerSelector)s, resource="memory"}) by (%(clusterLabel)s)' % $._config,
'sum(container_memory_rss{%(cadvisorSelector)s, container!=""}) by (%(clusterLabel)s) / sum(kube_pod_resource_limits{%(kubeSchedulerSelector)s, resource="memory"}) by (%(clusterLabel)s)' % $._config,
'sum(kube_pod_resource_request{%(kubeSchedulerSelector)s, resource="memory"}) by (%(clusterLabel)s)' % $._config,
'sum(container_memory_rss{%(cadvisorSelector)s, container!=""}) by (%(clusterLabel)s) / sum(kube_pod_resource_request{%(kubeSchedulerSelector)s, resource="memory"}) by (%(clusterLabel)s)' % $._config,
'sum(kube_pod_resource_limit{%(kubeSchedulerSelector)s, resource="memory"}) by (%(clusterLabel)s)' % $._config,
'sum(container_memory_rss{%(cadvisorSelector)s, container!=""}) by (%(clusterLabel)s) / sum(kube_pod_resource_limit{%(kubeSchedulerSelector)s, resource="memory"}) by (%(clusterLabel)s)' % $._config,
], tableStyles {
'Value #A': { alias: 'Memory Usage', unit: 'bytes' },
'Value #B': { alias: 'Memory Requests', unit: 'bytes' },
Expand Down
Loading

0 comments on commit 0a5f952

Please sign in to comment.