From ddfabda152ce6b2e68e02c03589045d90d24c3ca Mon Sep 17 00:00:00 2001 From: beorn7 Date: Wed, 26 Jun 2019 15:30:55 +0200 Subject: [PATCH] Add Makefile and suitable jsonnet files This makes the mixins usable as abvertised. Signed-off-by: beorn7 --- documentation/prometheus-mixin/Makefile | 25 +++++++++++++++++++ documentation/prometheus-mixin/alerts.jsonnet | 1 + .../prometheus-mixin/dashboards.jsonnet | 6 +++++ 3 files changed, 32 insertions(+) create mode 100644 documentation/prometheus-mixin/Makefile create mode 100644 documentation/prometheus-mixin/alerts.jsonnet create mode 100644 documentation/prometheus-mixin/dashboards.jsonnet diff --git a/documentation/prometheus-mixin/Makefile b/documentation/prometheus-mixin/Makefile new file mode 100644 index 000000000..8319b5edf --- /dev/null +++ b/documentation/prometheus-mixin/Makefile @@ -0,0 +1,25 @@ +JSONNET_FMT := jsonnet fmt -n 2 --max-blank-lines 2 --string-style s --comment-style s + +all: fmt prometheus_alerts.yaml dashboards_out lint + +fmt: + find . -name 'vendor' -prune -o -name '*.libsonnet' -print -o -name '*.jsonnet' -print | \ + xargs -n 1 -- $(JSONNET_FMT) -i + +prometheus_alerts.yaml: mixin.libsonnet config.libsonnet alerts.libsonnet + jsonnet -S alerts.jsonnet > $@ + +dashboards_out: mixin.libsonnet config.libsonnet dashboards.libsonnet + @mkdir -p dashboards_out + jsonnet -J vendor -m dashboards_out dashboards.jsonnet + +lint: prometheus_alerts.yaml + find . -name 'vendor' -prune -o -name '*.libsonnet' -print -o -name '*.jsonnet' -print | \ + while read f; do \ + $(JSONNET_FMT) "$$f" | diff -u "$$f" -; \ + done + + promtool check rules prometheus_alerts.yaml + +clean: + rm -rf dashboards_out prometheus_alerts.yaml diff --git a/documentation/prometheus-mixin/alerts.jsonnet b/documentation/prometheus-mixin/alerts.jsonnet new file mode 100644 index 000000000..75e7c1b29 --- /dev/null +++ b/documentation/prometheus-mixin/alerts.jsonnet @@ -0,0 +1 @@ +std.manifestYamlDoc((import 'mixin.libsonnet').prometheusAlerts) diff --git a/documentation/prometheus-mixin/dashboards.jsonnet b/documentation/prometheus-mixin/dashboards.jsonnet new file mode 100644 index 000000000..fb102817c --- /dev/null +++ b/documentation/prometheus-mixin/dashboards.jsonnet @@ -0,0 +1,6 @@ +local dashboards = (import 'mixin.libsonnet').dashboards; + +{ + [name]: dashboards[name] + for name in std.objectFields(dashboards) +}