Skip to content

Commit

Permalink
revert: query formatting not related to PR goals
Browse files Browse the repository at this point in the history
  • Loading branch information
darrenjaneczek committed Jun 21, 2021
1 parent 1691d31 commit ecd2c34
Showing 1 changed file with 9 additions and 87 deletions.
96 changes: 9 additions & 87 deletions cortex-mixin/dashboards/dashboard-utils.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -126,35 +126,10 @@ local utils = import 'mixin-utils/utils.libsonnet';
},

containerCPUUsagePanel(title, containerName)::
local config = $._config {
namespaceMatcher: $.namespaceMatcher(),
containerName: containerName,
};
$.panel(title) +
$.queryPanel([
|||
sum by(%(per_instance_label)s) (
rate(
container_cpu_usage_seconds_total{
%(namespaceMatcher)s,
container="%(containerName)s"
}[$__rate_interval]
)
)
||| % config,
|||
min(
container_spec_cpu_quota{
%(namespaceMatcher)s,
container="%(containerName)s"
}
/
container_spec_cpu_period{
%(namespaceMatcher)s,
container="%(containerName)s"
}
)
||| % config,
'sum by(%s) (rate(container_cpu_usage_seconds_total{%s,container="%s"}[$__rate_interval]))' % [$._config.per_instance_label, $.namespaceMatcher(), containerName],
'min(container_spec_cpu_quota{%s,container="%s"} / container_spec_cpu_period{%s,container="%s"})' % [$.namespaceMatcher(), containerName, $.namespaceMatcher(), containerName],
], ['{{%s}}' % $._config.per_instance_label, 'limit']) +
{
seriesOverrides: [
Expand All @@ -169,39 +144,11 @@ local utils = import 'mixin-utils/utils.libsonnet';

containerMemoryWorkingSetPanel(title, containerName)::
$.panel(title) +
$.queryPanel(
[
// We use "max" instead of "sum" otherwise during a rolling update of a statefulset we will end up
// summing the memory of the old instance/pod (whose metric will be stale for 5m) to the new instance/pod.
|||
max by(%s) (
container_memory_working_set_bytes{
%s,
container="%s"
}
)
||| % [$._config.per_instance_label, $.namespaceMatcher(), containerName],
|||
min(
container_spec_memory_limit_bytes{
%s,
container="%s"
} > 0
)
||| % [$.namespaceMatcher(), containerName],
], ['{{%s}}' % $._config.per_instance_label, 'limit']
) +
{
seriesOverrides: [
{
alias: 'limit',
color: '#E02F44',
fill: 0,
},
],
yaxes: $.yaxes('bytes'),
tooltip: { sort: 2 }, // Sort descending.
},
$.queryPanel([
// We use "max" instead of "sum" otherwise during a rolling update of a statefulset we will end up
// summing the memory of the old instance/pod (whose metric will be stale for 5m) to the new instance/pod.
'max by(%s) (container_memory_working_set_bytes{%s,container="%s"})' % [$._config.per_instance_label, $.namespaceMatcher(), containerName],
'min(container_spec_memory_limit_bytes{%s,container="%s"} > 0)' % [$.namespaceMatcher(), containerName],

containerNetworkPanel(title, metric, instanceName)::
$.panel(title) +
Expand Down Expand Up @@ -452,31 +399,6 @@ local utils = import 'mixin-utils/utils.libsonnet';

filterNodeDiskContainer(containerName)::
|||
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
)
||| % [
$._config.per_instance_label,
$._config.per_node_label,
$._config.per_instance_label,
$.namespaceMatcher(),
containerName,
],
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)
||| % [$._config.per_instance_label, $._config.per_node_label, $._config.per_instance_label, $.namespaceMatcher(), containerName],
}

0 comments on commit ecd2c34

Please sign in to comment.