-
Notifications
You must be signed in to change notification settings - Fork 161
/
Copy pathmain.libsonnet
92 lines (87 loc) · 3.6 KB
/
main.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
local g = import './g.libsonnet';
local commonlib = import 'common-lib/common/main.libsonnet';
local jvmlib = import 'jvm-observ-lib/main.libsonnet';
local zookeeperlib = import 'zookeeper-observ-lib/main.libsonnet';
{
new(): {
local this = self,
config: import './config.libsonnet',
//include jvm lib
jvm::
jvmlib.new()
+ jvmlib.withConfigMixin(
{
filteringSelector: this.config.filteringSelector,
groupLabels: this.config.groupLabels,
instanceLabels: this.config.instanceLabels,
uid: this.config.uid,
dashboardNamePrefix: this.config.dashboardNamePrefix,
dashboardTags: this.config.dashboardTags,
metricsSource: this.config.jvmMetricsSource,
}
),
zookeeper::
zookeeperlib.new()
+ zookeeperlib.withConfigMixin(
{
filteringSelector: this.config.zookeeperfilteringSelector,
groupLabels: this.config.groupLabels,
instanceLabels: this.config.instanceLabels,
uid: this.config.uid,
dashboardNamePrefix: this.config.dashboardNamePrefix,
dashboardTags: this.config.dashboardTags,
metricsSource:
[]
+ (if std.member(this.config.metricsSource, 'prometheus') then ['prometheus'] else [])
+ (if std.member(this.config.metricsSource, 'grafanacloud') then ['grafanacloud'] else [])
+ (if std.member(this.config.metricsSource, 'bitnami') then ['prometheus'] else []),
}
),
signals:
{
[sig]: commonlib.signals.unmarshallJsonMulti(this.config.signals[sig], type=this.config.metricsSource)
for sig in std.objectFields(this.config.signals)
}
+ if this.config.zookeeperEnabled then { zookeeper: this.zookeeper.signals } else {},
grafana: {
panels: (import './panels/main.libsonnet').new(this.signals, this.config)
+ { jvm: this.jvm.grafana.panels }
+ if this.config.zookeeperEnabled then { zookeeper: this.zookeeper.grafana.panels } else {},
rows: (import './rows.libsonnet').new(this.grafana.panels, type=this.config.metricsSource)
+ { jvm: this.jvm.grafana.rows }
+ if this.config.zookeeperEnabled then { zookeeper: this.zookeeper.grafana.rows } else {},
// common links here
links: {
local link = g.dashboard.link,
otherDashboards:
link.dashboards.new('All Kafka dashboards', this.config.dashboardTags)
+ link.dashboards.options.withIncludeVars(true)
+ link.dashboards.options.withKeepTime(true)
+ link.dashboards.options.withAsDropdown(false),
},
dashboards: (import './dashboards.libsonnet').new(this)
+ if this.config.zookeeperEnabled then
{
'zookeeper-overview.json':
this.zookeeper.grafana.dashboards['zookeeper-overview.json']
+ g.dashboard.withLinks(this.grafana.links.otherDashboards),
}
else {},
},
prometheus: {
alerts: (import './alerts.libsonnet').new(this)
+ { groups+: this.jvm.prometheus.alerts.groups }
+ if this.config.zookeeperEnabled then { groups+: this.zookeeper.prometheus.alerts.groups } else {},
recordingRules: {},
},
asMonitoringMixin(): {
// _config+:: this.config,
grafanaDashboards+:: this.grafana.dashboards,
prometheusAlerts+:: this.prometheus.alerts,
prometheusRules+:: this.prometheus.recordingRules,
},
},
withConfigMixin(config): {
config+: config,
},
}