From 5c573e8c888bfc7ee2e72525ffde70531a29e801 Mon Sep 17 00:00:00 2001 From: Vincent Mercier Date: Wed, 22 Nov 2023 19:08:39 +0100 Subject: [PATCH] chore(documentation): Add Prometheus rules guide --- CONTRIBUTING.md | 11 +++++++++++ Makefile | 7 ++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2ed2f27..f3e20fd 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -18,6 +18,7 @@ We use : * [`pre-commit`](https://pre-commit.com) to have style consistency in runbooks. * [`markdownlint-cli2`](https://github.com/DavidAnson/markdownlint-cli2) for linting the Markdown document. If you think the linter is incorrect, look at [configuration](https://github.com/DavidAnson/markdownlint/blob/main/README.md#configuration) to ignore the line. +* [`promtool`](https://prometheus.io/docs/prometheus/latest/configuration/recording_rules/#syntax-checking-rules) to check Prometheus rules * Gitlab workflows to run tests ## Pull Request Checklist @@ -77,12 +78,20 @@ To have Hugo templates resolution, we recommend to edit pages using Hugo webserv ## Run tests +Requirements + +* `promtool` to run prometheus test (`brew install prometheus`) +* `kubeconform` (`brew install kubeconform`) + +Steps + `make all-tests` run all tests, but you can run them manually: ```bash make helm-test # Helm unit tests make kubeconform-test # Check Helm charts render valid Kubernetes manifests make runbook-test # Test runbooks +make prometheus-test # Test Prometheus alerts ``` Tests on SQL queries (files with `.sql` extension) are tested accross a PostgreSQL instance and need to be launched manually. @@ -146,6 +155,8 @@ Any runboks: message: "" ``` +1. Add [Prometheus unittest](https://prometheus.io/docs/prometheus/latest/configuration/unit_testing_rules/) in `chart/prometheus--alerts/prometheus_tests/.yml` + 1. Run tests ```bash diff --git a/Makefile b/Makefile index cf9b754..5c525c7 100644 --- a/Makefile +++ b/Makefile @@ -21,8 +21,13 @@ runbook-test: sql-test: PGHOST=localhost PGUSER=postgres PGPASSWORD=hackme PGDATABASE=test ./scripts/validate_sql_files.sh content $(PGDATABASE) +.PHONY: prometheus-test +prometheus-test: + ./scripts/check_prometheus_rules.sh charts/prometheus-rds-alerts + ./scripts/check_prometheus_rules.sh charts/prometheus-postgresql-alerts + .PHONY: all-tests -all-tests: helm-test kubeconform-test runbook-test sql-test +all-tests: helm-test kubeconform-test runbook-test sql-test prometheus-test .PHONY: helm-release helm-release: