Skip to content

Commit

Permalink
Format dashboards & rules
Browse files Browse the repository at this point in the history
  • Loading branch information
povilasv committed Feb 24, 2020
1 parent 3cf851b commit 278b0cd
Show file tree
Hide file tree
Showing 9 changed files with 506 additions and 506 deletions.
2 changes: 1 addition & 1 deletion dashboards/resources.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
(import 'resources/node.libsonnet') +
(import 'resources/pod.libsonnet') +
(import 'resources/workload-namespace.libsonnet') +
(import 'resources/workload.libsonnet')
(import 'resources/workload.libsonnet')
500 changes: 250 additions & 250 deletions dashboards/resources/cluster.libsonnet

Large diffs are not rendered by default.

192 changes: 96 additions & 96 deletions dashboards/resources/multi-cluster.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -3,105 +3,105 @@ local grafana = import 'grafonnet/grafana.libsonnet';
local template = grafana.template;

{
grafanaDashboards+::
if $._config.showMultiCluster then {
'k8s-resources-multicluster.json':
local tableStyles = {
[$._config.clusterLabel]: {
alias: 'Cluster',
link: '%(prefix)s/d/%(uid)s/k8s-resources-cluster?var-datasource=$datasource&var-cluster=$__cell' % { prefix: $._config.grafanaK8s.linkPrefix, uid: std.md5('k8s-resources-cluster.json') },
},
};
grafanaDashboards+::
if $._config.showMultiCluster then {
'k8s-resources-multicluster.json':
local tableStyles = {
[$._config.clusterLabel]: {
alias: 'Cluster',
link: '%(prefix)s/d/%(uid)s/k8s-resources-cluster?var-datasource=$datasource&var-cluster=$__cell' % { prefix: $._config.grafanaK8s.linkPrefix, uid: std.md5('k8s-resources-cluster.json') },
},
};

g.dashboard(
'%(dashboardNamePrefix)sCompute Resources / Multi-Cluster' % $._config.grafanaK8s,
uid=($._config.grafanaDashboardIDs['k8s-resources-multicluster.json']),
).addRow(
(g.row('Headlines') +
{
height: '100px',
showTitle: false,
})
.addPanel(
g.panel('CPU Utilisation') +
g.statPanel('1 - avg(rate(node_cpu_seconds_total{mode="idle"}[1m]))' % $._config)
g.dashboard(
'%(dashboardNamePrefix)sCompute Resources / Multi-Cluster' % $._config.grafanaK8s,
uid=($._config.grafanaDashboardIDs['k8s-resources-multicluster.json']),
).addRow(
(g.row('Headlines') +
{
height: '100px',
showTitle: false,
})
.addPanel(
g.panel('CPU Utilisation') +
g.statPanel('1 - avg(rate(node_cpu_seconds_total{mode="idle"}[1m]))' % $._config)
)
.addPanel(
g.panel('CPU Requests Commitment') +
g.statPanel('sum(kube_pod_container_resource_requests_cpu_cores) / sum(kube_node_status_allocatable_cpu_cores)' % $._config)
)
.addPanel(
g.panel('CPU Limits Commitment') +
g.statPanel('sum(kube_pod_container_resource_limits_cpu_cores) / sum(kube_node_status_allocatable_cpu_cores)' % $._config)
)
.addPanel(
g.panel('Memory Utilisation') +
g.statPanel('1 - sum(:node_memory_MemAvailable_bytes:sum) / sum(kube_node_status_allocatable_memory_bytes)' % $._config)
)
.addPanel(
g.panel('Memory Requests Commitment') +
g.statPanel('sum(kube_pod_container_resource_requests_memory_bytes) / sum(kube_node_status_allocatable_memory_bytes)' % $._config)
)
.addPanel(
g.panel('Memory Limits Commitment') +
g.statPanel('sum(kube_pod_container_resource_limits_memory_bytes) / sum(kube_node_status_allocatable_memory_bytes)' % $._config)
)
)
.addPanel(
g.panel('CPU Requests Commitment') +
g.statPanel('sum(kube_pod_container_resource_requests_cpu_cores) / sum(kube_node_status_allocatable_cpu_cores)' % $._config)
.addRow(
g.row('CPU')
.addPanel(
g.panel('CPU Usage') +
g.queryPanel('sum(node_namespace_pod_container:container_cpu_usage_seconds_total:sum_rate) by (%(clusterLabel)s)' % $._config, '{{%(clusterLabel)s}}' % $._config)
+ { fill: 0, linewidth: 2 },
)
)
.addPanel(
g.panel('CPU Limits Commitment') +
g.statPanel('sum(kube_pod_container_resource_limits_cpu_cores) / sum(kube_node_status_allocatable_cpu_cores)' % $._config)
.addRow(
g.row('CPU Quota')
.addPanel(
g.panel('CPU Quota') +
g.tablePanel([
'sum(node_namespace_pod_container:container_cpu_usage_seconds_total:sum_rate) by (%(clusterLabel)s)' % $._config,
'sum(kube_pod_container_resource_requests_cpu_cores) by (%(clusterLabel)s)' % $._config,
'sum(node_namespace_pod_container:container_cpu_usage_seconds_total:sum_rate) by (%(clusterLabel)s) / sum(kube_pod_container_resource_requests_cpu_cores) by (%(clusterLabel)s)' % $._config,
'sum(kube_pod_container_resource_limits_cpu_cores) by (%(clusterLabel)s)' % $._config,
'sum(node_namespace_pod_container:container_cpu_usage_seconds_total:sum_rate) by (%(clusterLabel)s) / sum(kube_pod_container_resource_limits_cpu_cores) by (%(clusterLabel)s)' % $._config,
], tableStyles {
'Value #A': { alias: 'CPU Usage' },
'Value #B': { alias: 'CPU Requests' },
'Value #C': { alias: 'CPU Requests %', unit: 'percentunit' },
'Value #D': { alias: 'CPU Limits' },
'Value #E': { alias: 'CPU Limits %', unit: 'percentunit' },
})
)
)
.addPanel(
g.panel('Memory Utilisation') +
g.statPanel('1 - sum(:node_memory_MemAvailable_bytes:sum) / sum(kube_node_status_allocatable_memory_bytes)' % $._config)
)
.addPanel(
g.panel('Memory Requests Commitment') +
g.statPanel('sum(kube_pod_container_resource_requests_memory_bytes) / sum(kube_node_status_allocatable_memory_bytes)' % $._config)
)
.addPanel(
g.panel('Memory Limits Commitment') +
g.statPanel('sum(kube_pod_container_resource_limits_memory_bytes) / sum(kube_node_status_allocatable_memory_bytes)' % $._config)
)
)
.addRow(
g.row('CPU')
.addPanel(
g.panel('CPU Usage') +
g.queryPanel('sum(node_namespace_pod_container:container_cpu_usage_seconds_total:sum_rate) by (%(clusterLabel)s)' % $._config, '{{%(clusterLabel)s}}' % $._config)
+ { fill: 0, linewidth: 2 },
)
)
.addRow(
g.row('CPU Quota')
.addPanel(
g.panel('CPU Quota') +
g.tablePanel([
'sum(node_namespace_pod_container:container_cpu_usage_seconds_total:sum_rate) by (%(clusterLabel)s)' % $._config,
'sum(kube_pod_container_resource_requests_cpu_cores) by (%(clusterLabel)s)' % $._config,
'sum(node_namespace_pod_container:container_cpu_usage_seconds_total:sum_rate) by (%(clusterLabel)s) / sum(kube_pod_container_resource_requests_cpu_cores) by (%(clusterLabel)s)' % $._config,
'sum(kube_pod_container_resource_limits_cpu_cores) by (%(clusterLabel)s)' % $._config,
'sum(node_namespace_pod_container:container_cpu_usage_seconds_total:sum_rate) by (%(clusterLabel)s) / sum(kube_pod_container_resource_limits_cpu_cores) by (%(clusterLabel)s)' % $._config,
], tableStyles {
'Value #A': { alias: 'CPU Usage' },
'Value #B': { alias: 'CPU Requests' },
'Value #C': { alias: 'CPU Requests %', unit: 'percentunit' },
'Value #D': { alias: 'CPU Limits' },
'Value #E': { alias: 'CPU Limits %', unit: 'percentunit' },
})
)
)
.addRow(
g.row('Memory')
.addPanel(
g.panel('Memory Usage (w/o cache)') +
// Not using container_memory_usage_bytes here because that includes page cache
g.queryPanel('sum(container_memory_rss{container!=""}) by (%(clusterLabel)s)' % $._config, '{{%(clusterLabel)s}}' % $._config) +
{ fill: 0, linewidth: 2, yaxes: g.yaxes('bytes') },
)
)
.addRow(
g.row('Memory Requests')
.addPanel(
g.panel('Requests by Namespace') +
g.tablePanel([
.addRow(
g.row('Memory')
.addPanel(
g.panel('Memory Usage (w/o cache)') +
// Not using container_memory_usage_bytes here because that includes page cache
'sum(container_memory_rss{container!=""}) by (%(clusterLabel)s)' % $._config,
'sum(kube_pod_container_resource_requests_memory_bytes) by (%(clusterLabel)s)' % $._config,
'sum(container_memory_rss{container!=""}) by (%(clusterLabel)s) / sum(kube_pod_container_resource_requests_memory_bytes) by (%(clusterLabel)s)' % $._config,
'sum(kube_pod_container_resource_limits_memory_bytes) by (%(clusterLabel)s)' % $._config,
'sum(container_memory_rss{container!=""}) by (%(clusterLabel)s) / sum(kube_pod_container_resource_limits_memory_bytes) by (%(clusterLabel)s)' % $._config,
], tableStyles {
'Value #A': { alias: 'Memory Usage', unit: 'bytes' },
'Value #B': { alias: 'Memory Requests', unit: 'bytes' },
'Value #C': { alias: 'Memory Requests %', unit: 'percentunit' },
'Value #D': { alias: 'Memory Limits', unit: 'bytes' },
'Value #E': { alias: 'Memory Limits %', unit: 'percentunit' },
})
g.queryPanel('sum(container_memory_rss{container!=""}) by (%(clusterLabel)s)' % $._config, '{{%(clusterLabel)s}}' % $._config) +
{ fill: 0, linewidth: 2, yaxes: g.yaxes('bytes') },
)
)
) + { tags: $._config.grafanaK8s.dashboardTags },
} else {},
}
.addRow(
g.row('Memory Requests')
.addPanel(
g.panel('Requests by Namespace') +
g.tablePanel([
// Not using container_memory_usage_bytes here because that includes page cache
'sum(container_memory_rss{container!=""}) by (%(clusterLabel)s)' % $._config,
'sum(kube_pod_container_resource_requests_memory_bytes) by (%(clusterLabel)s)' % $._config,
'sum(container_memory_rss{container!=""}) by (%(clusterLabel)s) / sum(kube_pod_container_resource_requests_memory_bytes) by (%(clusterLabel)s)' % $._config,
'sum(kube_pod_container_resource_limits_memory_bytes) by (%(clusterLabel)s)' % $._config,
'sum(container_memory_rss{container!=""}) by (%(clusterLabel)s) / sum(kube_pod_container_resource_limits_memory_bytes) by (%(clusterLabel)s)' % $._config,
], tableStyles {
'Value #A': { alias: 'Memory Usage', unit: 'bytes' },
'Value #B': { alias: 'Memory Requests', unit: 'bytes' },
'Value #C': { alias: 'Memory Requests %', unit: 'percentunit' },
'Value #D': { alias: 'Memory Limits', unit: 'bytes' },
'Value #E': { alias: 'Memory Limits %', unit: 'percentunit' },
})
)
) + { tags: $._config.grafanaK8s.dashboardTags },
} else {},
}
56 changes: 28 additions & 28 deletions dashboards/resources/namespace.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,33 @@ local grafana = import 'grafonnet/grafana.libsonnet';
local template = grafana.template;

{
grafanaDashboards+:: {
local intervalTemplate =
template.new(
name='interval',
datasource='$datasource',
query='4h',
current='5m',
hide=2,
refresh=2,
includeAll=false,
sort=1
) + {
auto: false,
auto_count: 30,
auto_min: '10s',
skipUrlSync: false,
type: 'interval',
options: [
{
selected: true,
text: '4h',
value: '4h',
},
],
},
grafanaDashboards+:: {
local intervalTemplate =
template.new(
name='interval',
datasource='$datasource',
query='4h',
current='5m',
hide=2,
refresh=2,
includeAll=false,
sort=1
) + {
auto: false,
auto_count: 30,
auto_min: '10s',
skipUrlSync: false,
type: 'interval',
options: [
{
selected: true,
text: '4h',
value: '4h',
},
],
},

'k8s-resources-namespace.json':
'k8s-resources-namespace.json':
local tableStyles = {
pod: {
alias: 'Pod',
Expand Down Expand Up @@ -209,5 +209,5 @@ local template = grafana.template;
{ yaxes: g.yaxes('Bps') },
)
) + { tags: $._config.grafanaK8s.dashboardTags, templating+: { list+: [intervalTemplate] } },
}
}
},
}
56 changes: 28 additions & 28 deletions dashboards/resources/node.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,33 @@ local grafana = import 'grafonnet/grafana.libsonnet';
local template = grafana.template;

{
grafanaDashboards+:: {
local intervalTemplate =
template.new(
name='interval',
datasource='$datasource',
query='4h',
current='5m',
hide=2,
refresh=2,
includeAll=false,
sort=1
) + {
auto: false,
auto_count: 30,
auto_min: '10s',
skipUrlSync: false,
type: 'interval',
options: [
{
selected: true,
text: '4h',
value: '4h',
},
],
},
grafanaDashboards+:: {
local intervalTemplate =
template.new(
name='interval',
datasource='$datasource',
query='4h',
current='5m',
hide=2,
refresh=2,
includeAll=false,
sort=1
) + {
auto: false,
auto_count: 30,
auto_min: '10s',
skipUrlSync: false,
type: 'interval',
options: [
{
selected: true,
text: '4h',
value: '4h',
},
],
},

'k8s-resources-node.json':
'k8s-resources-node.json':
local tableStyles = {
pod: {
alias: 'Pod',
Expand Down Expand Up @@ -103,5 +103,5 @@ local template = grafana.template;
})
)
) + { tags: $._config.grafanaK8s.dashboardTags },
}
}
},
}
Loading

0 comments on commit 278b0cd

Please sign in to comment.