-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use monitoring-mixins for dashboards and alerts
Monitoring-mixins ([1]) allow upstream collaboration on alerts and grafana dashboards and convergence on monitoring best practices through bundling mixins with the corresponding software. Downstream customization of alerts and dashboards may be done using jsonnet ([2]). Usage of jsonnet-bundler ([3]) gives a clear reference of where dashboards and alerts originated and which version is used through `.src/jsonnetfile.json` and `.src/jsonnetfile.lock.json`. [1] https://monitoring.mixins.dev/ [2] https://github.com/google/jsonnet [3] https://github.com/jsonnet-bundler/jsonnet-bundler Signed-off-by: Jan Horstmann <horstmann@osism.tech>
- Loading branch information
1 parent
396a8c1
commit 53e0e9d
Showing
29 changed files
with
5,997 additions
and
4,548 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.src/vendor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
From python:3.12-slim-bookworm | ||
|
||
ARG JB_VERSION=v0.6.0 | ||
|
||
ENV DEBIAN_FRONTEND=noninteractive | ||
|
||
RUN apt-get update \ | ||
&& apt-get install --no-install-recommends -y \ | ||
ca-certificates \ | ||
curl \ | ||
git \ | ||
jsonnet \ | ||
&& curl --location --output /usr/local/bin/jb https://github.com/jsonnet-bundler/jsonnet-bundler/releases/download/${JB_VERSION}/jb-linux-amd64 \ | ||
&& chmod +x /usr/local/bin/jb \ | ||
&& apt-get remove -y \ | ||
curl \ | ||
&& apt-get clean \ | ||
&& apt-get autoremove -y \ | ||
&& rm -rf \ | ||
/var/lib/apt/lists/* \ | ||
/var/tmp/* | ||
|
||
COPY files/mixins.py /mixins.py | ||
|
||
WORKDIR /srv/.src | ||
CMD ["/mixins.py"] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Containerfile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
#!/usr/local/bin/python3 | ||
|
||
import os | ||
import subprocess | ||
|
||
dashboards_out_prefix = "../grafana/dashboards" | ||
rules_out_prefix = "../prometheus" | ||
|
||
print("Installing dependencies...") | ||
try: | ||
out = subprocess.run(["/usr/local/bin/jb", "install"], capture_output=True) | ||
except subprocess.SubprocessError as e: | ||
print(e.stderr) | ||
raise e | ||
print(out.stdout.decode()) | ||
print(out.stderr.decode()) | ||
|
||
for path, _, filenames in os.walk("mixins"): | ||
for file in filenames: | ||
dashboards_out = os.path.join( | ||
dashboards_out_prefix, *os.path.normpath(path).split(os.sep)[1:] | ||
) | ||
if file.endswith(".libsonnet"): | ||
name = file.removesuffix(".libsonnet") | ||
print("Processing mixin " + name) | ||
print("Creating dashboard(s)...") | ||
os.makedirs(dashboards_out, exist_ok=True) | ||
try: | ||
subprocess.run( | ||
[ | ||
"jsonnet", | ||
"-J", | ||
"vendor", | ||
"-m", | ||
dashboards_out, | ||
"-e", | ||
'(import "' + os.path.join(path, file) + '").grafanaDashboards', | ||
] | ||
) | ||
except subprocess.SubprocessError as e: | ||
print(e.stderr) | ||
raise e | ||
for kind, suffix in [ | ||
("prometheusAlerts", ".rules"), | ||
("prometheusRules", ".rec.rules"), | ||
]: | ||
print("Creating " + kind + "...") | ||
prometheus_out = os.path.join(rules_out_prefix, name + suffix) | ||
with open(prometheus_out, "w") as f: | ||
try: | ||
subprocess.run( | ||
[ | ||
"jsonnet", | ||
"-J", | ||
"vendor", | ||
"-S", | ||
"-e", | ||
'std.manifestYamlDoc((import "' | ||
+ os.path.join(path, file) | ||
+ '").' | ||
+ kind | ||
+ ")", | ||
], | ||
stdout=f, | ||
) | ||
except subprocess.SubprocessError as e: | ||
print(e.stderr) | ||
raise e | ||
print(prometheus_out) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
{ | ||
"version": 1, | ||
"dependencies": [ | ||
{ | ||
"source": { | ||
"git": { | ||
"remote": "https://github.com/prometheus/alertmanager.git", | ||
"subdir": "doc/alertmanager-mixin" | ||
} | ||
}, | ||
"version": "main" | ||
}, | ||
{ | ||
"source": { | ||
"git": { | ||
"remote": "https://github.com/ceph/ceph.git", | ||
"subdir": "monitoring/ceph-mixin" | ||
} | ||
}, | ||
"version": "main" | ||
}, | ||
{ | ||
"source": { | ||
"git": { | ||
"remote": "https://github.com/prometheus/node_exporter.git", | ||
"subdir": "docs/node-mixin" | ||
} | ||
}, | ||
"version": "master" | ||
}, | ||
{ | ||
"source": { | ||
"git": { | ||
"remote": "https://github.com/prometheus/prometheus.git", | ||
"subdir": "documentation/prometheus-mixin" | ||
} | ||
}, | ||
"version": "main" | ||
} | ||
], | ||
"legacyImports": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
{ | ||
"version": 1, | ||
"dependencies": [ | ||
{ | ||
"source": { | ||
"git": { | ||
"remote": "https://github.com/ceph/ceph.git", | ||
"subdir": "monitoring/ceph-mixin" | ||
} | ||
}, | ||
"version": "14463aa7a493dc6903d18af960aac24e8ab8153b", | ||
"sum": "ZnyCIu25NBI6Q3Ru7QK1DHf7DBMEURSMQdEJXzCyIgA=" | ||
}, | ||
{ | ||
"source": { | ||
"git": { | ||
"remote": "https://github.com/grafana/grafonnet-lib.git", | ||
"subdir": "grafonnet" | ||
} | ||
}, | ||
"version": "a1d61cce1da59c71409b99b5c7568511fec661ea", | ||
"sum": "342u++/7rViR/zj2jeJOjshzglkZ1SY+hFNuyCBFMdc=" | ||
}, | ||
{ | ||
"source": { | ||
"git": { | ||
"remote": "https://github.com/grafana/grafonnet.git", | ||
"subdir": "gen/grafonnet-latest" | ||
} | ||
}, | ||
"version": "d20e609202733790caf5b554c9945d049f243ae3", | ||
"sum": "V9vAj21qJOc2DlMPDgB1eEjSQU4A+sAA4AXuJ6bd4xc=" | ||
}, | ||
{ | ||
"source": { | ||
"git": { | ||
"remote": "https://github.com/grafana/grafonnet.git", | ||
"subdir": "gen/grafonnet-v11.4.0" | ||
} | ||
}, | ||
"version": "d20e609202733790caf5b554c9945d049f243ae3", | ||
"sum": "aVAX09paQYNOoCSKVpuk1exVIyBoMt/C50QJI+Q/3nA=" | ||
}, | ||
{ | ||
"source": { | ||
"git": { | ||
"remote": "https://github.com/jsonnet-libs/docsonnet.git", | ||
"subdir": "doc-util" | ||
} | ||
}, | ||
"version": "6ac6c69685b8c29c54515448eaca583da2d88150", | ||
"sum": "BrAL/k23jq+xy9oA7TWIhUx07dsA/QLm3g7ktCwe//U=" | ||
}, | ||
{ | ||
"source": { | ||
"git": { | ||
"remote": "https://github.com/jsonnet-libs/xtd.git", | ||
"subdir": "" | ||
} | ||
}, | ||
"version": "1199b50e9d2ff53d4bb5fb2304ad1fb69d38e609", | ||
"sum": "LfbgcJbilu4uBdKYZSvmkoOTPwEAzg10L3/VqKAIWtA=" | ||
}, | ||
{ | ||
"source": { | ||
"git": { | ||
"remote": "https://github.com/prometheus/alertmanager.git", | ||
"subdir": "doc/alertmanager-mixin" | ||
} | ||
}, | ||
"version": "3b61ae81a7b859ae4e9ddd34c88d71b4c1691a9e", | ||
"sum": "Mf4h1BYLle2nrgjf/HXrBbl0Zk8N+xaoEM017o0BC+k=" | ||
}, | ||
{ | ||
"source": { | ||
"git": { | ||
"remote": "https://github.com/prometheus/node_exporter.git", | ||
"subdir": "docs/node-mixin" | ||
} | ||
}, | ||
"version": "8f9a914bee023a614f4eea1005baf2e112bbadb0", | ||
"sum": "xYj6VYFT/eafsbleNlC+Z2VfLy1CndyYrJs9BcTmnX8=" | ||
}, | ||
{ | ||
"source": { | ||
"git": { | ||
"remote": "https://github.com/prometheus/prometheus.git", | ||
"subdir": "documentation/prometheus-mixin" | ||
} | ||
}, | ||
"version": "d173c0b61c6658be00d5502c76c9226b7f643017", | ||
"sum": "CwaQpW66lHx+++sY2g4BgrUTEFZtlDnQzFjo0AlgfIg=" | ||
} | ||
], | ||
"legacyImports": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
local ceph = import "ceph-mixin/mixin.libsonnet"; | ||
|
||
ceph { | ||
prometheusRules+: {}, | ||
prometheusAlerts+: {}, | ||
grafanaDashboards+: {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
local alertmanager = import "alertmanager-mixin/mixin.libsonnet"; | ||
|
||
alertmanager { | ||
prometheusRules+: {}, | ||
prometheusAlerts+: {}, | ||
grafanaDashboards+: {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
local node = import "node-mixin/mixin.libsonnet"; | ||
|
||
node { | ||
prometheusRules+: {}, | ||
prometheusAlerts+: {}, | ||
grafanaDashboards+: { | ||
# Hide unused dashboards | ||
'nodes-darwin.json':: super['nodes-darwin.json'], | ||
'nodes-aix.json':: super['nodes-aix.json'] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
local prometheus = import "prometheus-mixin/mixin.libsonnet"; | ||
|
||
prometheus { | ||
prometheusRules+: {}, | ||
prometheusAlerts+: {}, | ||
grafanaDashboards+: {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.