@@ -126,35 +126,10 @@ local utils = import 'mixin-utils/utils.libsonnet';
126126 },
127127
128128 containerCPUUsagePanel(title, containerName)::
129- local config = $._config {
130- namespaceMatcher: $.namespaceMatcher(),
131- containerName: containerName,
132- };
133129 $.panel(title) +
134130 $.queryPanel([
135- |||
136- sum by(%(per_instance_label)s) (
137- rate(
138- container_cpu_usage_seconds_total{
139- %(namespaceMatcher)s,
140- container="%(containerName)s"
141- }[$__rate_interval]
142- )
143- )
144- ||| % config,
145- |||
146- min(
147- container_spec_cpu_quota{
148- %(namespaceMatcher)s,
149- container="%(containerName)s"
150- }
151- /
152- container_spec_cpu_period{
153- %(namespaceMatcher)s,
154- container="%(containerName)s"
155- }
156- )
157- ||| % config,
131+ 'sum by(%s) (rate(container_cpu_usage_seconds_total{%s,container="%s"}[$__rate_interval]))' % [$._config.per_instance_label, $.namespaceMatcher(), containerName],
132+ 'min(container_spec_cpu_quota{%s,container="%s"} / container_spec_cpu_period{%s,container="%s"})' % [$.namespaceMatcher(), containerName, $.namespaceMatcher(), containerName],
158133 ], ['{{%s}}' % $._config.per_instance_label, 'limit' ]) +
159134 {
160135 seriesOverrides: [
@@ -169,39 +144,11 @@ local utils = import 'mixin-utils/utils.libsonnet';
169144
170145 containerMemoryWorkingSetPanel(title, containerName)::
171146 $.panel(title) +
172- $.queryPanel(
173- [
174- // We use "max" instead of "sum" otherwise during a rolling update of a statefulset we will end up
175- // summing the memory of the old instance/pod (whose metric will be stale for 5m) to the new instance/pod.
176- |||
177- max by(%s) (
178- container_memory_working_set_bytes{
179- %s,
180- container="%s"
181- }
182- )
183- ||| % [$._config.per_instance_label, $.namespaceMatcher(), containerName],
184- |||
185- min(
186- container_spec_memory_limit_bytes{
187- %s,
188- container="%s"
189- } > 0
190- )
191- ||| % [$.namespaceMatcher(), containerName],
192- ], ['{{%s}}' % $._config.per_instance_label, 'limit' ]
193- ) +
194- {
195- seriesOverrides: [
196- {
197- alias: 'limit' ,
198- color: '#E02F44' ,
199- fill: 0 ,
200- },
201- ],
202- yaxes: $.yaxes('bytes' ),
203- tooltip: { sort: 2 }, // Sort descending.
204- },
147+ $.queryPanel([
148+ // We use "max" instead of "sum" otherwise during a rolling update of a statefulset we will end up
149+ // summing the memory of the old instance/pod (whose metric will be stale for 5m) to the new instance/pod.
150+ 'max by(%s) (container_memory_working_set_bytes{%s,container="%s"})' % [$._config.per_instance_label, $.namespaceMatcher(), containerName],
151+ 'min(container_spec_memory_limit_bytes{%s,container="%s"} > 0)' % [$.namespaceMatcher(), containerName],
205152
206153 containerNetworkPanel(title, metric, instanceName)::
207154 $.panel(title) +
@@ -452,31 +399,6 @@ local utils = import 'mixin-utils/utils.libsonnet';
452399
453400 filterNodeDiskContainer(containerName)::
454401 |||
455- ignoring(%s) group_right() (
456- label_replace(
457- count by(
458- %s,
459- %s,
460- device
461- )
462- (
463- container_fs_writes_bytes_total{
464- %s,
465- container="%s",
466- device!~".*sda.*"
467- }
468- ),
469- "device",
470- "$1",
471- "device",
472- "/dev/(.*)"
473- ) * 0
474- )
475- ||| % [
476- $._config.per_instance_label,
477- $._config.per_node_label,
478- $._config.per_instance_label,
479- $.namespaceMatcher(),
480- containerName,
481- ],
402+ ignoring(%s) group_right() (label_replace(count by(%s, %s, device) (container_fs_writes_bytes_total{%s,container="%s",device!~".*sda.*"}), "device", "$1", "device", "/dev/(.*)") * 0)
403+ ||| % [$._config.per_instance_label, $._config.per_node_label, $._config.per_instance_label, $.namespaceMatcher(), containerName],
482404}
0 commit comments