Skip to content

Commit a764783

Browse files
authored
Commonlib: add new panels (#1101)
* Add new panel utilization by core * Add status history for interfaces * Remove withAxisCenteredZero in network mirrored panels. This was removed to preserve space inside panels if out of the directions are not active. * Fix typo in CPU panel description
1 parent 1fa8fdb commit a764783

File tree

9 files changed

+115
-1
lines changed

9 files changed

+115
-1
lines changed

common-lib/common/panels.libsonnet

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@ local g = import './g.libsonnet';
99
},
1010
network: {
1111
timeSeries: import './panels/network/timeSeries/main.libsonnet',
12+
statusHistory: import './panels/network/statusHistory/main.libsonnet',
1213
},
1314
system: {
1415
stat: import './panels/system/stat/main.libsonnet',
1516
table: import './panels/system/table/main.libsonnet',
1617
statusHistory: import './panels/system/statusHistory/main.libsonnet',
18+
timeSeries: import './panels/system/timeSeries/main.libsonnet',
1719
},
1820
cpu: {
1921
stat: import './panels/cpu/stat/main.libsonnet',
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
local g = import '../../../g.libsonnet';
2+
local generic = import '../../generic/timeSeries/main.libsonnet';
3+
local base = import './base.libsonnet';
4+
base {
5+
new(
6+
title='CPU usage',
7+
targets,
8+
description=|||
9+
CPU utilization percent by core is a metric that indicates level of central processing unit (CPU) usage in a computer system.
10+
It represents the load placed on each CPU core or processors.
11+
|||
12+
):
13+
super.new(title, targets, description)
14+
+ self.stylize(),
15+
16+
stylize(allLayers=true):
17+
(if allLayers then super.stylize() else {})
18+
+ generic.percentage.stylize(allLayers=false)
19+
+ g.panel.timeSeries.fieldConfig.defaults.custom.withStacking({ mode: 'normal' }),
20+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
local g = import '../../../g.libsonnet';
2+
local base = import '../../generic/statusHistory/base.libsonnet';
3+
base {
4+
5+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
local g = import '../../../g.libsonnet';
2+
local base = import './base.libsonnet';
3+
local statusHistory = g.panel.statusHistory;
4+
base {
5+
new(title='Interface status', targets, description='Interfaces statuses'):
6+
super.new(title, targets, description),
7+
8+
stylize(allLayers=true):
9+
(if allLayers then super.stylize() else {})
10+
+ statusHistory.standardOptions.color.withMode('fixed')
11+
+ statusHistory.options.withShowValue('never')
12+
+ statusHistory.standardOptions.withMappings(
13+
{
14+
type: 'value',
15+
options: {
16+
'0': {
17+
text: 'Down',
18+
color: 'light-red',
19+
index: 0,
20+
},
21+
'1': {
22+
text: 'Up',
23+
color: 'light-green',
24+
index: 1,
25+
},
26+
},
27+
}
28+
),
29+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
interfaceStatus: import './interface_status.libsonnet',
3+
}

common-lib/common/panels/network/timeSeries/base.libsonnet

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ base {
1616

1717
withNegateOutPackets(regexp='/transmit|tx|out/'):
1818
defaults.custom.withAxisLabel('out(-) | in(+)')
19-
+ defaults.custom.withAxisCenteredZero(true)
19+
+ defaults.custom.withAxisCenteredZero(false)
2020
+ timeSeries.standardOptions.withOverrides(
2121
fieldOverride.byRegexp.new(regexp)
2222
+ fieldOverride.byRegexp.withPropertiesFromOptions(
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
local g = import '../../../g.libsonnet';
2+
local base = import '../../generic/timeSeries/base.libsonnet';
3+
local timeSeries = g.panel.timeSeries;
4+
local fieldOverride = g.panel.timeSeries.fieldOverride;
5+
local custom = timeSeries.fieldConfig.defaults.custom;
6+
local defaults = timeSeries.fieldConfig.defaults;
7+
local options = timeSeries.options;
8+
base {
9+
10+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
local g = import '../../../g.libsonnet';
2+
local generic = import '../../generic/timeSeries/main.libsonnet';
3+
local base = import './base.libsonnet';
4+
base {
5+
6+
new(
7+
title='Load average',
8+
loadTargets,
9+
cpuCountTarget,
10+
description=|||
11+
System load average over the previous 1, 5, and 15 minute ranges.
12+
13+
A measurement of how many processes are waiting for CPU cycles. The maximum number is the number of CPU cores for the node.
14+
|||
15+
):
16+
// validate inputs
17+
std.prune(
18+
{
19+
checks: [
20+
if !(std.objectHas(cpuCountTarget, 'legendFormat')) then error 'cpuCountTarget must have legendFormat"',
21+
],
22+
}
23+
)
24+
+
25+
local targets = loadTargets + [cpuCountTarget];
26+
super.new(title, targets, description)
27+
// call directly threshold styler (not called from super automatically)
28+
+ self.stylizeCpuCores(cpuCountTarget.legendFormat),
29+
30+
stylizeCpuCores(cpuCountName):
31+
generic.threshold.stylizeByRegexp(cpuCountName),
32+
33+
stylize(allLayers=true, cpuCountName=null):
34+
(if allLayers then super.stylize() else {})
35+
36+
+ g.panel.timeSeries.fieldConfig.defaults.custom.withFillOpacity(0)
37+
+ g.panel.timeSeries.standardOptions.withMin(0)
38+
+ g.panel.timeSeries.standardOptions.withUnit('short')
39+
// this is only called if cpuCountName provided
40+
+ (if cpuCountName != null then self.stylizeCpuCores(cpuCountName) else {}),
41+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
base: import './base.libsonnet',
3+
loadAverage: import './load_average.libsonnet',
4+
}

0 commit comments

Comments
 (0)