Skip to content

Commit b4993cb

Browse files
authored
windows: Use instance label for hostname in hostname panel (#1353)
* windows: Use instance label for hostname in hostname panel * Fix NTP delay units (thanks to linter) * Add units to panels * Add none units to cpu count to pass linter * Update win mixin
1 parent ab84b9f commit b4993cb

File tree

7 files changed

+85
-78
lines changed

7 files changed

+85
-78
lines changed

common-lib/common/panels/cpu/stat/count.libsonnet

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

1717
stylize(allLayers=true):
1818
(if allLayers then super.stylize() else {})
19-
+ generic.info.stylize(allLayers=false),
19+
+ generic.info.stylize(allLayers=false)
20+
+ g.panel.stat.standardOptions.withUnit('none'),
2021

2122
}

windows-active-directory-mixin/mixin.libsonnet

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,13 @@ local alerts = import './alerts/alerts.libsonnet';
33
local g = import './g.libsonnet';
44
local var = g.dashboard.variable;
55
local activedirectorymixin =
6-
windowsobservlib.new(
7-
filteringSelector='job=~"integrations/windows_exporter"',
8-
uid='active-directory',
9-
groupLabels=['job'],
10-
instanceLabels=['instance'],
11-
)
6+
windowsobservlib.new()
127

138
{
149
config+: {
1510
enableADDashboard: true,
11+
groupLabels: ['job'],
12+
uid: 'active-directory',
1613
},
1714
}
1815

windows-mixin/mixin.libsonnet

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,7 @@ local winlib = import 'windows-observ-lib/main.libsonnet';
44
local config = (import 'config.libsonnet')._config;
55
{
66
local windows =
7-
winlib.new(
8-
dashboardNamePrefix=config.dashboardNamePrefix,
9-
uid=config.uid,
10-
filteringSelector=config.filteringSelector,
11-
)
7+
winlib.new()
128
+
139
{
1410
config+: config,
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
// any modular library should include as inputs:
3+
// 'dashboardNamePrefix' - Use as prefix for all Dashboards and (optional) rule groups
4+
// 'filteringSelector' - Static selector to apply to ALL dashboard variables of type query, panel queries, alerts and recording rules.
5+
// 'groupLabels' - one or more labels that can be used to identify 'group' of instances. In simple cases, can be 'job' or 'cluster'.
6+
// 'instanceLabels' - one or more labels that can be used to identify single entity of instances. In simple cases, can be 'instance' or 'pod'.
7+
// 'uid' - UID to prefix all dashboards original uids
8+
groupLabels: ['job'],
9+
instanceLabels: ['instance'],
10+
filteringSelector: 'job=~".*windows.*"',
11+
dashboardTags: ['windows'],
12+
uid: 'windows',
13+
dashboardNamePrefix: '',
14+
15+
// optional
16+
ignoreVolumes: 'HarddiskVolume.*',
17+
alertsCPUThresholdWarning: '90',
18+
alertMemoryUsageThresholdCritical: '90',
19+
alertDiskUsageThresholdCritical: '90',
20+
dashboardPeriod: 'now-1h',
21+
dashboardTimezone: 'default',
22+
dashboardRefresh: '1m',
23+
24+
// optional Windows AD
25+
alertsHighPendingReplicationOperations: 50, // count
26+
alertsHighReplicationSyncRequestFailures: 0, // count
27+
alertsHighPasswordChanges: 25, // count
28+
alertsMetricsDownJobName: 'integrations/windows_exporter',
29+
enableADDashboard: false,
30+
31+
// logs lib related
32+
enableLokiLogs: true,
33+
extraLogLabels: ['channel', 'source', 'keywords', 'level'],
34+
logsVolumeGroupBy: 'level',
35+
showLogsVolume: true,
36+
logsExtraFilters:
37+
|||
38+
| label_format timestamp="{{__timestamp__}}"
39+
| drop channel_extracted,source_extracted,computer_extracted,level_extracted,keywords_extracted
40+
| line_format `{{ if eq "[[instance]]" ".*" }}{{ alignLeft 25 .instance}}|{{end}}{{alignLeft 12 .channel }}| {{ alignLeft 25 .source}}| {{ .message }}`
41+
|||,
42+
}

windows-observ-lib/main.libsonnet

Lines changed: 7 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
local alerts = import './alerts.libsonnet';
2+
local config = import './config.libsonnet';
23
local dashboards = import './dashboards.libsonnet';
34
local datasources = import './datasources.libsonnet';
45
local g = import './g.libsonnet';
@@ -7,58 +8,10 @@ local targets = import './targets.libsonnet';
78
local commonlib = import 'common-lib/common/main.libsonnet';
89

910
{
10-
new(
11-
filteringSelector,
12-
groupLabels=['job'],
13-
instanceLabels=['instance'],
14-
dashboardNamePrefix='',
15-
dashboardTags=[uid],
16-
uid,
17-
): {
11+
new(): {
1812

1913
local this = self,
20-
config: {
21-
// any modular library should include as inputs:
22-
// 'dashboardNamePrefix' - Use as prefix for all Dashboards and (optional) rule groups
23-
// 'filteringSelector' - Static selector to apply to ALL dashboard variables of type query, panel queries, alerts and recording rules.
24-
// 'groupLabels' - one or more labels that can be used to identify 'group' of instances. In simple cases, can be 'job' or 'cluster'.
25-
// 'instanceLabels' - one or more labels that can be used to identify single entity of instances. In simple cases, can be 'instance' or 'pod'.
26-
// 'uid' - UID to prefix all dashboards original uids
27-
groupLabels: groupLabels,
28-
instanceLabels: instanceLabels,
29-
filteringSelector: filteringSelector,
30-
dashboardTags: dashboardTags,
31-
uid: uid,
32-
dashboardNamePrefix: dashboardNamePrefix,
33-
34-
// optional
35-
ignoreVolumes: 'HarddiskVolume.*',
36-
alertsCPUThresholdWarning: '90',
37-
alertMemoryUsageThresholdCritical: '90',
38-
alertDiskUsageThresholdCritical: '90',
39-
dashboardPeriod: 'now-1h',
40-
dashboardTimezone: 'default',
41-
dashboardRefresh: '1m',
42-
43-
// optional Windows AD
44-
alertsHighPendingReplicationOperations: 50, // count
45-
alertsHighReplicationSyncRequestFailures: 0, // count
46-
alertsHighPasswordChanges: 25, // count
47-
alertsMetricsDownJobName: 'integrations/windows_exporter',
48-
enableADDashboard: false,
49-
50-
// logs lib related
51-
enableLokiLogs: true,
52-
extraLogLabels: ['channel', 'source', 'keywords', 'level'],
53-
logsVolumeGroupBy: 'level',
54-
showLogsVolume: true,
55-
logsExtraFilters:
56-
|||
57-
| label_format timestamp="{{__timestamp__}}"
58-
| drop channel_extracted,source_extracted,computer_extracted,level_extracted,keywords_extracted
59-
| line_format `{{ if eq "[[instance]]" ".*" }}{{ alignLeft 25 .instance}}|{{end}}{{alignLeft 12 .channel }}| {{ alignLeft 25 .source}}| {{ .message }}`
60-
|||,
61-
},
14+
config: config,
6215
grafana: {
6316
variables: commonlib.variables.new(
6417
filteringSelector=this.config.filteringSelector,
@@ -74,7 +27,7 @@ local commonlib = import 'common-lib/common/main.libsonnet';
7427
reboot: commonlib.annotations.reboot.new(
7528
title='Reboot',
7629
target=this.grafana.targets.reboot,
77-
instanceLabels=std.join(',', instanceLabels),
30+
instanceLabels=std.join(',', this.config.instanceLabels),
7831
)
7932
+ commonlib.annotations.base.withTagKeys(std.join(',', this.config.groupLabels + this.config.instanceLabels)),
8033
}
@@ -124,5 +77,8 @@ local commonlib = import 'common-lib/common/main.libsonnet';
12477
},
12578

12679
},
80+
withConfigMixin(config): {
81+
config+: config,
82+
},
12783

12884
}

windows-observ-lib/mixin.libsonnet

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
local windowslib = import './main.libsonnet';
2+
{
3+
_config:: {},
4+
_windowsib::
5+
windowslib.new()
6+
+ windowslib.withConfigMixin(self._config),
7+
grafanaDashboards+:: self._windowsib.grafana.dashboards,
8+
prometheusAlerts+:: self._windowsib.prometheus.alerts,
9+
prometheusRules+:: self._windowsib.prometheus.recordingRules,
10+
}

windows-observ-lib/panels.libsonnet

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -187,22 +187,25 @@ local utils = commonlib.utils;
187187
188188
A high number of context switches or interrupts can indicate that the system is overloaded or that there are problems with specific devices or processes.
189189
|||
190-
),
190+
)
191+
+ g.panel.timeSeries.standardOptions.withUnit('short'),
191192
systemExceptions:
192193
commonlib.panels.generic.timeSeries.base.new(
193194
'System calls and exceptions',
194195
targets=[
195196
t.windowsSystemExceptions,
196197
t.windowsSystemCalls,
197198
],
198-
),
199+
)
200+
+ g.panel.timeSeries.standardOptions.withUnit('short'),
199201
systemThreads:
200202
commonlib.panels.generic.timeSeries.base.new(
201203
'System threads',
202204
targets=[
203205
t.windowsSystemThreads,
204206
],
205-
),
207+
)
208+
+ g.panel.timeSeries.standardOptions.withUnit('short'),
206209
timeNtpStatus:
207210
commonlib.panels.system.statusHistory.ntp.new(
208211
'NTP status',
@@ -224,7 +227,7 @@ local utils = commonlib.utils;
224227
Time offset: Absolute time offset between the system clock and the chosen time source, in seconds.
225228
|||
226229
)
227-
+ g.panel.timeSeries.standardOptions.withUnit('seconds')
230+
+ g.panel.timeSeries.standardOptions.withUnit('s')
228231
+ g.panel.timeSeries.standardOptions.withNoValue('No data. Please check that "time" collector is enabled.'),
229232
cpuCount: commonlib.panels.cpu.stat.count.new(targets=[t.cpuCount]),
230233
cpuUsageTs: commonlib.panels.cpu.timeSeries.utilization.new(targets=[t.cpuUsage]),
@@ -242,17 +245,19 @@ local utils = commonlib.utils;
242245
CPU usage by different modes.
243246
|||
244247
),
245-
cpuQueue: commonlib.panels.generic.timeSeries.base.new(
246-
'CPU average queue size',
247-
targets=[t.cpuQueue],
248-
description=|||
249-
The CPU average queue size in Windows, often referred to as the "Processor Queue Length" or "CPU Queue Length," is a metric that measures the number of threads or tasks waiting to be processed by the central processing unit (CPU) at a given moment.
250-
It is an essential performance indicator that reflects the workload and responsiveness of the CPU.
251-
When the CPU queue length is high, it indicates that there are more tasks in line for processing than the CPU can handle immediately.
248+
cpuQueue:
249+
commonlib.panels.generic.timeSeries.base.new(
250+
'CPU average queue size',
251+
targets=[t.cpuQueue],
252+
description=|||
253+
The CPU average queue size in Windows, often referred to as the "Processor Queue Length" or "CPU Queue Length," is a metric that measures the number of threads or tasks waiting to be processed by the central processing unit (CPU) at a given moment.
254+
It is an essential performance indicator that reflects the workload and responsiveness of the CPU.
255+
When the CPU queue length is high, it indicates that there are more tasks in line for processing than the CPU can handle immediately.
252256
253-
This can lead to system slowdowns, decreased responsiveness, and potential performance issues. High CPU queue lengths are often associated with CPU saturation, where the CPU is struggling to keep up with the demands placed on it.
254-
|||
255-
),
257+
This can lead to system slowdowns, decreased responsiveness, and potential performance issues. High CPU queue lengths are often associated with CPU saturation, where the CPU is struggling to keep up with the demands placed on it.
258+
|||
259+
)
260+
+ g.panel.timeSeries.standardOptions.withUnit('short'),
256261
memoryTotalBytes: commonlib.panels.memory.stat.total.new(targets=[t.memoryTotalBytes]),
257262
memoryPageTotalBytes:
258263
commonlib.panels.memory.stat.total.new(
@@ -363,7 +368,7 @@ local utils = commonlib.utils;
363368
targets=[t.osInfo],
364369
description="System's hostname."
365370
)
366-
{ options+: { reduceOptions+: { fields: '/^hostname$/' } } },
371+
{ options+: { reduceOptions+: { fields: '/^instance$/' } } },
367372
networkErrorsAndDroppedPerSec:
368373
commonlib.panels.network.timeSeries.errors.new(
369374
'Network errors and dropped packets',

0 commit comments

Comments
 (0)