-
Notifications
You must be signed in to change notification settings - Fork 163
/
dashboards.libsonnet
192 lines (188 loc) · 8.73 KB
/
dashboards.libsonnet
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
local g = import './g.libsonnet';
local commonlib = import 'common-lib/common/main.libsonnet';
local logslib = import 'github.com/grafana/jsonnet-libs/logs-lib/logs/main.libsonnet';
{
local root = self,
new(this):
local prefix = this.config.dashboardNamePrefix;
local links = this.grafana.links;
local tags = this.config.dashboardTags;
local uid = g.util.string.slugify(this.config.uid);
local vars = this.grafana.variables;
local annotations = this.grafana.annotations;
local refresh = this.config.dashboardRefresh;
local period = this.config.dashboardPeriod;
local timezone = this.config.dashboardTimezone;
local panels = this.grafana.panels;
local stat = g.panel.stat;
{
fleet:
local title = prefix + 'Windows fleet overview';
g.dashboard.new(title)
+ g.dashboard.withPanels(
g.util.grid.wrapPanels(
[
// g.panel.row.new("Overview"),
panels.fleetOverviewTable { gridPos+: { w: 24, h: 16 } },
panels.cpuUsageTopk { gridPos+: { w: 24 } },
panels.memoryUsageTopKPercent { gridPos+: { w: 24 } },
panels.diskIOutilPercentTopK { gridPos+: { w: 12 } },
panels.diskUsagePercentTopK { gridPos+: { w: 12 } },
panels.networkErrorsAndDroppedPerSecTopK { gridPos+: { w: 24 } },
], 12, 7
)
)
// hide link to self
+ root.applyCommon(vars.multiInstance, uid + '-fleet', tags, links { backToFleet+:: {}, backToOverview+:: {} }, annotations, timezone, refresh, period),
overview: g.dashboard.new(prefix + 'Windows overview')
+ g.dashboard.withPanels(
g.util.grid.wrapPanels(
[
g.panel.row.new('Overview'),
panels.uptime,
panels.hostname,
panels.osVersion,
panels.osInfo,
panels.cpuCount,
panels.memoryTotalBytes,
panels.memoryPageTotalBytes,
panels.diskTotalC,
g.panel.row.new('CPU'),
panels.cpuUsageStat { gridPos+: { w: 6, h: 6 } },
panels.cpuUsageTs { gridPos+: { w: 18, h: 6 } },
g.panel.row.new('Memory'),
panels.memoryUsageStatPercent { gridPos+: { w: 6, h: 6 } },
panels.memoryUsageTsBytes { gridPos+: { w: 18, h: 6 } },
g.panel.row.new('Disk'),
panels.diskIOBytesPerSec { gridPos+: { w: 12, h: 8 } },
panels.diskUsage { gridPos+: { w: 12, h: 8 } },
g.panel.row.new('Network'),
panels.networkUsagePerSec { gridPos+: { w: 12, h: 8 } },
panels.networkErrorsAndDroppedPerSec { gridPos+: { w: 12, h: 8 } },
], 6, 2
)
)
+ root.applyCommon(vars.singleInstance, uid + '-overview', tags, links { backToOverview+:: {} }, annotations, timezone, refresh, period),
// add TODO advanced memory dashboard (must enable memory collector)
// memory:
system: g.dashboard.new(prefix + 'Windows CPU and system')
+ g.dashboard.withPanels(
g.util.grid.wrapPanels(
[
g.panel.row.new('System'),
panels.cpuUsageStat { gridPos+: { w: 6, h: 6 } },
panels.cpuUsageTs { gridPos+: { w: 9, h: 6 } },
panels.cpuUsageByMode { gridPos+: { w: 9, h: 6 } },
panels.cpuQueue,
panels.systemContextSwitchesAndInterrupts,
// panels.systemThreads,
// panels.systemExceptions,
g.panel.row.new('Time'),
panels.osTimezone { gridPos+: { w: 3, h: 4 } },
panels.timeNtpStatus { gridPos+: { x: 0, y: 0, w: 21, h: 4 } },
panels.timeNtpDelay { gridPos+: { w: 24, h: 7 } },
], 12, 7
)
)
+ root.applyCommon(vars.singleInstance, uid + '-system', tags, links, annotations, timezone, refresh, period),
disks: g.dashboard.new(prefix + 'Windows disks and filesystems')
+ g.dashboard.withPanels(
g.util.grid.wrapPanels(
[
g.panel.row.new('Disk'),
panels.diskFreeTs,
panels.diskUsage,
panels.diskIOBytesPerSec,
panels.diskIOps,
panels.diskIOWaitTime,
panels.diskQueue,
], 12, 8
)
)
+ root.applyCommon(vars.singleInstance, uid + '-disks', tags, links, annotations, timezone, refresh, period),
}
+
(if this.config.enableLokiLogs then
{
logs:
logslib.new(
prefix + 'Windows logs',
datasourceName=this.grafana.variables.datasources.loki.name,
datasourceRegex=this.grafana.variables.datasources.loki.regex,
filterSelector=this.config.filteringSelector,
labels=this.config.groupLabels + this.config.instanceLabels + this.config.extraLogLabels,
formatParser='json',
showLogsVolume=this.config.showLogsVolume,
logsVolumeGroupBy=this.config.logsVolumeGroupBy,
extraFilters=this.config.logsExtraFilters
)
{
dashboards+:
{
logs+:
// reference to self, already generated variables, to keep them, but apply other common data in applyCommon
root.applyCommon(super.logs.templating.list, uid=uid + '-logs', tags=tags, links=links, annotations=annotations, timezone=timezone, refresh=refresh, period=period),
},
panels+:
{
// modify log panel
logs+:
g.panel.logs.options.withEnableLogDetails(true)
+ g.panel.logs.options.withShowTime(false)
+ g.panel.logs.options.withWrapLogMessage(false),
},
variables+: {
// add prometheus datasource for annotations processing
toArray+: [
this.grafana.variables.datasources.prometheus { hide: 2 },
],
},
}.dashboards.logs,
} else {})
+
(if this.config.enableADDashboard then
{
local adVariables = commonlib.variables.new(
this.config.filteringSelector,
this.config.groupLabels,
this.config.instanceLabels,
varMetric='windows_ad_directory_service_threads',
enableLokiLogs=this.config.enableLokiLogs,
// override to null to force more precise alert's panel filter
customAllValue=null,
),
activedirectory:
local title = prefix + 'Windows Active Directory overview';
g.dashboard.new(title)
+ g.dashboard.withPanels(
g.util.grid.wrapPanels(
[
panels.replicationPendingOperations { gridPos+: { w: 6, h: 3 } },
panels.directoryServiceThreads { gridPos+: { w: 6, h: 3 } },
panels.alertsPanel { gridPos+: { w: 12, h: 6 } },
panels.replicationPendingSynchronizations { gridPos+: { w: 12, h: 3 } },
panels.ldapBindRequests { gridPos+: { w: 12 } },
panels.ldapOperations { gridPos+: { w: 12, h: 6 } },
panels.bindOperationsOverview { gridPos+: { w: 24 } },
panels.intrasiteReplicationTraffic { gridPos+: { w: 12 } },
panels.intersiteReplicationTraffic { gridPos+: { w: 12 } },
panels.inboundReplicationUpdates { gridPos+: { w: 24 } },
panels.databaseOperationsOverview { gridPos+: { w: 12 } },
panels.databaseOperations { gridPos+: { w: 12 } },
], 12, 6
)
)
+ root.applyCommon(vars.multiInstance, uid, tags, links, annotations, timezone, refresh, period)
//override variables
+ g.dashboard.withVariables(adVariables.multiInstance),
} else {}),
applyCommon(vars, uid, tags, links, annotations, timezone, refresh, period):
g.dashboard.withTags(tags)
+ g.dashboard.withUid(uid)
+ g.dashboard.withLinks(std.objectValues(links))
+ g.dashboard.withTimezone(timezone)
+ g.dashboard.withRefresh(refresh)
+ g.dashboard.time.withFrom(period)
+ g.dashboard.withVariables(vars)
+ g.dashboard.withAnnotations(std.objectValues(annotations)),
}