From a9f76485dd966e7ec764677bd1ec59e41143ed4e Mon Sep 17 00:00:00 2001 From: Vitaly Zhuravlev Date: Wed, 11 May 2022 21:47:39 +0400 Subject: [PATCH] add make deploy --- prometheus/apache-http-mixin/Makefile | 18 ++++++++++++++++++ prometheus/apache-http-mixin/README.md | 15 ++++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/prometheus/apache-http-mixin/Makefile b/prometheus/apache-http-mixin/Makefile index e8895a0..f70705f 100644 --- a/prometheus/apache-http-mixin/Makefile +++ b/prometheus/apache-http-mixin/Makefile @@ -29,6 +29,24 @@ dashboards_out: mixin.libsonnet config.libsonnet $(wildcard dashboards/*) prometheus_alerts.yaml: mixin.libsonnet alerts/*.libsonnet mixtool generate alerts mixin.libsonnet -a prometheus_alerts.yaml + +.PHONY: deploy deploy_rules deploy_dashboards +deploy: deploy_rules deploy_dashboards + +deploy_dashboards: +ifdef GRAFANA_URL + grr apply mixin.libsonnet --target "Dashboard.*" --target "DashboardFolder.*" +else + $(warning GRAFANA_URL is not set, skipping grafana dashboards deployment) +endif + +deploy_rules: +ifdef CORTEX_ADDRESS + grr apply mixin.libsonnet --target "PrometheusRuleGroup.*" +else + $(warning CORTEX_ADDRESS is not set, skipping prometheus alerts deployment) +endif + .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 index 08a6d76..1df33fa 100644 --- a/prometheus/apache-http-mixin/README.md +++ b/prometheus/apache-http-mixin/README.md @@ -4,7 +4,7 @@ Apache HTTP mixin is a set of configurable Grafana dashboards and alerts based o ![image](https://user-images.githubusercontent.com/14870891/167886371-92c60942-bbfa-43d2-ba16-ee13e629020a.png) -Install tools before generating dashboards and alerts: +## Install tools ```bash go install github.com/jsonnet-bundler/jsonnet-bundler/cmd/jb@latest @@ -23,11 +23,24 @@ into your Grafana server. The exact details will be depending on your environme `prometheus_alerts.yaml` needs to be imported into Prometheus. +## Generate dashboards and alerts + Edit `config.libsonnet` if required and then build JSON dashboard files for Grafana: ```bash make ``` +## Import dashboards and alerts using Grizzly tool + +Install grizzly first: https://grafana.github.io/grizzly/installation/ + +Set env variables GRAFANA_URL and optionally CORTEX_ADDRESS (see for [details](https://grafana.github.io/grizzly/authentication/)). + +Then run to actually import the dashboards and alerts into Grafana instance: +```bash +make deploy +``` + For more advanced uses of mixins, see https://github.com/monitoring-mixins/docs.