From 5e83738d1dbd406fa4231e5624f6c10da73dc6f9 Mon Sep 17 00:00:00 2001 From: Vitaly Zhuravlev Date: Wed, 11 May 2022 19:19:45 +0400 Subject: [PATCH] Add Makefile and README --- prometheus/apache-http-mixin/Makefile | 34 ++++++++++++++++++++++++++ prometheus/apache-http-mixin/README.md | 33 +++++++++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 prometheus/apache-http-mixin/Makefile create mode 100644 prometheus/apache-http-mixin/README.md diff --git a/prometheus/apache-http-mixin/Makefile b/prometheus/apache-http-mixin/Makefile new file mode 100644 index 0000000..e8895a0 --- /dev/null +++ b/prometheus/apache-http-mixin/Makefile @@ -0,0 +1,34 @@ +JSONNET_FMT := jsonnetfmt -n 2 --max-blank-lines 1 --string-style s --comment-style s + +.PHONY: all +all: build dashboards_out prometheus_alerts.yaml + +vendor: jsonnetfile.json + jb install + +.PHONY: build +build: vendor + +.PHONY: fmt +fmt: + find . -name 'vendor' -prune -o -name '*.libsonnet' -print -o -name '*.jsonnet' -print | \ + xargs -n 1 -- $(JSONNET_FMT) -i + +.PHONY: lint +lint: build + find . -name 'vendor' -prune -o -name '*.libsonnet' -print -o -name '*.jsonnet' -print | \ + while read f; do \ + $(JSONNET_FMT) "$$f" | diff -u "$$f" -; \ + done + mixtool lint mixin.libsonnet + +dashboards_out: mixin.libsonnet config.libsonnet $(wildcard dashboards/*) + @mkdir -p dashboards_out + mixtool generate dashboards mixin.libsonnet -d dashboards_out + +prometheus_alerts.yaml: mixin.libsonnet alerts/*.libsonnet + mixtool generate alerts mixin.libsonnet -a prometheus_alerts.yaml + +.PHONY: clean +clean: + rm -rf dashboards_out prometheus_alerts.yaml diff --git a/prometheus/apache-http-mixin/README.md b/prometheus/apache-http-mixin/README.md new file mode 100644 index 0000000..08a6d76 --- /dev/null +++ b/prometheus/apache-http-mixin/README.md @@ -0,0 +1,33 @@ +# Apache HTTP server mixin + +Apache HTTP mixin is a set of configurable Grafana dashboards and alerts based on the metrics exported by the [Apache exporter](https://github.com/Lusitaniae/apache_exporter). + +![image](https://user-images.githubusercontent.com/14870891/167886371-92c60942-bbfa-43d2-ba16-ee13e629020a.png) + +Install tools before generating dashboards and alerts: + +```bash +go install github.com/jsonnet-bundler/jsonnet-bundler/cmd/jb@latest +go install github.com/monitoring-mixins/mixtool/cmd/mixtool@latest +``` + +For linting and formatting, you would also need `mixtool` and `jsonnetfmt` installed. If you +have a working Go development environment, it's easiest to run the following: + +```bash +go install github.com/google/go-jsonnet/cmd/jsonnetfmt@latest +``` + +The files in `dashboards_out` need to be imported +into your Grafana server. The exact details will be depending on your environment. + +`prometheus_alerts.yaml` needs to be imported into Prometheus. + +Edit `config.libsonnet` if required and then build JSON dashboard files for Grafana: + +```bash +make +``` + +For more advanced uses of mixins, see +https://github.com/monitoring-mixins/docs.