Skip to content

Commit

Permalink
Merge pull request grafana/cortex-jsonnet#331 from grafana/darrenjane…
Browse files Browse the repository at this point in the history
…czek/resources-dashboards-container-functions

Dashboards: defined container functions for common resources panels
  • Loading branch information
pracucci authored Jun 22, 2021
2 parents 6aba412 + 4399d9b commit 1be26db
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 72 deletions.
20 changes: 3 additions & 17 deletions jsonnet/mimir-mixin/dashboards/alertmanager-resources.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -52,30 +52,16 @@ local utils = import 'mixin-utils/utils.libsonnet';
.addRow(
$.row('Disk')
.addPanel(
$.panel('Writes') +
$.queryPanel(
'sum by(%s, %s, device) (rate(node_disk_written_bytes_total[$__rate_interval])) + %s' % [$._config.per_node_label, $._config.per_instance_label, $.filterNodeDiskContainer('alertmanager')],
'{{%s}} - {{device}}' % $._config.per_instance_label
) +
$.stack +
{ yaxes: $.yaxes('Bps') },
$.containerDiskWritesPanel('Writes', 'alertmanager'),
)
.addPanel(
$.panel('Reads') +
$.queryPanel(
'sum by(%s, %s, device) (rate(node_disk_read_bytes_total[$__rate_interval])) + %s' % [$._config.per_node_label, $._config.per_instance_label, $.filterNodeDiskContainer('alertmanager')],
'{{%s}} - {{device}}' % $._config.per_instance_label
) +
$.stack +
{ yaxes: $.yaxes('Bps') },
$.containerDiskReadsPanel('Reads', 'alertmanager'),
)
)
.addRow(
$.row('')
.addPanel(
$.panel('Disk Space Utilization') +
$.queryPanel('max by(persistentvolumeclaim) (kubelet_volume_stats_used_bytes{%s} / kubelet_volume_stats_capacity_bytes{%s}) and count by(persistentvolumeclaim) (kube_persistentvolumeclaim_labels{%s,label_name="alertmanager"})' % [$.namespaceMatcher(), $.namespaceMatcher(), $.namespaceMatcher()], '{{persistentvolumeclaim}}') +
{ yaxes: $.yaxes('percentunit') },
$.containerDiskSpaceUtilization('Disk Space Utilization', 'alertmanager'),
)
),
}
28 changes: 7 additions & 21 deletions jsonnet/mimir-mixin/dashboards/compactor-resources.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -28,27 +28,13 @@ local utils = import 'mixin-utils/utils.libsonnet';
.addRow(
$.row('Disk')
.addPanel(
$.panel('Disk Writes') +
$.queryPanel(
'sum by(%s, %s, device) (rate(node_disk_written_bytes_total[$__rate_interval])) + %s' % [$._config.per_node_label, $._config.per_instance_label, $.filterNodeDiskContainer('compactor')],
'{{%s}} - {{device}}' % $._config.per_instance_label
) +
$.stack +
{ yaxes: $.yaxes('Bps') },
)
.addPanel(
$.panel('Disk Reads') +
$.queryPanel(
'sum by(%s, %s, device) (rate(node_disk_read_bytes_total[$__rate_interval])) + %s' % [$._config.per_node_label, $._config.per_instance_label, $.filterNodeDiskContainer('compactor')],
'{{%s}} - {{device}}' % $._config.per_instance_label
) +
$.stack +
{ yaxes: $.yaxes('Bps') },
)
.addPanel(
$.panel('Disk Space Utilization') +
$.queryPanel('max by(persistentvolumeclaim) (kubelet_volume_stats_used_bytes{%s} / kubelet_volume_stats_capacity_bytes{%s}) and count by(persistentvolumeclaim) (kube_persistentvolumeclaim_labels{%s,label_name="compactor"})' % [$.namespaceMatcher(), $.namespaceMatcher(), $.namespaceMatcher()], '{{persistentvolumeclaim}}') +
{ yaxes: $.yaxes('percentunit') },
$.containerDiskWritesPanel('Disk Writes', 'compactor'),
)
.addPanel(
$.containerDiskReadsPanel('Disk Reads', 'compactor'),
)
.addPanel(
$.containerDiskSpaceUtilization('Disk Space Utilization', 'compactor'),
)
) + {
templating+: {
Expand Down
67 changes: 67 additions & 0 deletions jsonnet/mimir-mixin/dashboards/dashboard-utils.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,73 @@ local utils = import 'mixin-utils/utils.libsonnet';
containerNetworkTransmitBytesPanel(instanceName)::
$.containerNetworkPanel('Transmit Bandwidth', 'container_network_transmit_bytes_total', instanceName),

containerDiskWritesPanel(title, containerName)::
$.panel(title) +
$.queryPanel(
|||
sum by(%s, %s, device) (
rate(
node_disk_written_bytes_total[$__rate_interval]
)
)
+
%s
||| % [
$._config.per_node_label,
$._config.per_instance_label,
$.filterNodeDiskContainer(containerName),
],
'{{%s}} - {{device}}' % $._config.per_instance_label
) +
$.stack +
{ yaxes: $.yaxes('Bps') },

containerDiskReadsPanel(title, containerName)::
$.panel(title) +
$.queryPanel(
|||
sum by(%s, %s, device) (
rate(
node_disk_read_bytes_total[$__rate_interval]
)
) + %s
||| % [
$._config.per_node_label,
$._config.per_instance_label,
$.filterNodeDiskContainer(containerName),
],
'{{%s}} - {{device}}' % $._config.per_instance_label
) +
$.stack +
{ yaxes: $.yaxes('Bps') },

containerDiskSpaceUtilization(title, containerName)::
$.panel(title) +
$.queryPanel(
|||
max by(persistentvolumeclaim) (
kubelet_volume_stats_used_bytes{%(namespace)s} /
kubelet_volume_stats_capacity_bytes{%(namespace)s}
)
and
count by(persistentvolumeclaim) (
kube_persistentvolumeclaim_labels{
%(namespace)s,
%(label)s
}
)
||| % {
namespace: $.namespaceMatcher(),
label: $.containerLabelMatcher(containerName),
}, '{{persistentvolumeclaim}}'
) +
{ yaxes: $.yaxes('percentunit') },

containerLabelMatcher(containerName)::
if containerName == 'ingester'
then 'label_name=~"ingester.*"'
else 'label_name="%s"' % containerName,

goHeapInUsePanel(title, jobName)::
$.panel(title) +
$.queryPanel(
Expand Down
20 changes: 3 additions & 17 deletions jsonnet/mimir-mixin/dashboards/reads-resources.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -103,27 +103,13 @@ local utils = import 'mixin-utils/utils.libsonnet';
std.member($._config.storage_engine, 'blocks'),
$.row('')
.addPanel(
$.panel('Disk Writes') +
$.queryPanel(
'sum by(%s, %s, device) (rate(node_disk_written_bytes_total[$__rate_interval])) + %s' % [$._config.per_node_label, $._config.per_instance_label, $.filterNodeDiskContainer('store-gateway')],
'{{%s}} - {{device}}' % $._config.per_instance_label
) +
$.stack +
{ yaxes: $.yaxes('Bps') },
$.containerDiskWritesPanel('Disk Writes', 'store-gateway'),
)
.addPanel(
$.panel('Disk Reads') +
$.queryPanel(
'sum by(%s, %s, device) (rate(node_disk_read_bytes_total[$__rate_interval])) + %s' % [$._config.per_node_label, $._config.per_instance_label, $.filterNodeDiskContainer('store-gateway')],
'{{%s}} - {{device}}' % $._config.per_instance_label
) +
$.stack +
{ yaxes: $.yaxes('Bps') },
$.containerDiskReadsPanel('Disk Reads', 'store-gateway'),
)
.addPanel(
$.panel('Disk Space Utilization') +
$.queryPanel('max by(persistentvolumeclaim) (kubelet_volume_stats_used_bytes{%s} / kubelet_volume_stats_capacity_bytes{%s}) and count by(persistentvolumeclaim) (kube_persistentvolumeclaim_labels{%s,label_name="store-gateway"})' % [$.namespaceMatcher(), $.namespaceMatcher(), $.namespaceMatcher()], '{{persistentvolumeclaim}}') +
{ yaxes: $.yaxes('percentunit') },
$.containerDiskSpaceUtilization('Disk Space Utilization', 'store-gateway'),
)
) + {
templating+: {
Expand Down
20 changes: 3 additions & 17 deletions jsonnet/mimir-mixin/dashboards/writes-resources.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -56,27 +56,13 @@ local utils = import 'mixin-utils/utils.libsonnet';
.addRow(
$.row('')
.addPanel(
$.panel('Disk Writes') +
$.queryPanel(
'sum by(%s, %s, device) (rate(node_disk_written_bytes_total[$__rate_interval])) + %s' % [$._config.per_node_label, $._config.per_instance_label, $.filterNodeDiskContainer('ingester')],
'{{%s}} - {{device}}' % $._config.per_instance_label
) +
$.stack +
{ yaxes: $.yaxes('Bps') },
$.containerDiskWritesPanel('Disk Writes', 'ingester')
)
.addPanel(
$.panel('Disk Reads') +
$.queryPanel(
'sum by(%s, %s, device) (rate(node_disk_read_bytes_total[$__rate_interval])) + %s' % [$._config.per_node_label, $._config.per_instance_label, $.filterNodeDiskContainer('ingester')],
'{{%s}} - {{device}}' % $._config.per_instance_label
) +
$.stack +
{ yaxes: $.yaxes('Bps') },
$.containerDiskReadsPanel('Disk Reads', 'ingester')
)
.addPanel(
$.panel('Disk Space Utilization') +
$.queryPanel('max by(persistentvolumeclaim) (kubelet_volume_stats_used_bytes{%s} / kubelet_volume_stats_capacity_bytes{%s}) and count by(persistentvolumeclaim) (kube_persistentvolumeclaim_labels{%s,label_name=~"ingester.*"})' % [$.namespaceMatcher(), $.namespaceMatcher(), $.namespaceMatcher()], '{{persistentvolumeclaim}}') +
{ yaxes: $.yaxes('percentunit') },
$.containerDiskSpaceUtilization('Disk Space Utilization', 'ingester'),
)
)
+ {
Expand Down

0 comments on commit 1be26db

Please sign in to comment.