Skip to content

Commit

Permalink
chore(documentation): Add Prometheus rules guide
Browse files Browse the repository at this point in the history
  • Loading branch information
vmercierfr committed Nov 22, 2023
1 parent 312fff8 commit 5c573e8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
11 changes: 11 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -146,6 +155,8 @@ Any runboks:
message: "<comprehensive description of the alert>"
```

1. Add [Prometheus unittest](https://prometheus.io/docs/prometheus/latest/configuration/unit_testing_rules/) in `chart/prometheus-<component>-alerts/prometheus_tests/<alertName>.yml`

1. Run tests

```bash
Expand Down
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 5c573e8

Please sign in to comment.