Skip to content

Commit f9c8a99

Browse files
committed
chore: add markdown linter and formatter
1 parent de834e9 commit f9c8a99

File tree

10 files changed

+368
-178
lines changed

10 files changed

+368
-178
lines changed

.github/workflows/ci.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ jobs:
1818
run: make --always-make dashboards-lint
1919
- name: Jsonnet formatter
2020
run: make --always-make fmt && git diff --exit-code
21+
- name: Markdown formatter
22+
run: make --always-make markdownfmt && git diff --exit-code
23+
- name: Markdown linter
24+
run: make --always-make vale && git diff --exit-code
2125
- name: Jsonnet linter
2226
run: make --always-make jsonnet-lint
2327
- name: Unit tests

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ dashboards_out
44
vendor
55
jsonnetfile.lock.json
66
tmp
7+
.vale

.vale.ini

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
StylesPath = .vale/styles
2+
3+
MinAlertLevel = error
4+
5+
Packages = Readability, write-good, alex
6+
7+
[*]
8+
BasedOnStyles = Readability, write-good, alex

DESIGN.md

Lines changed: 39 additions & 113 deletions
Large diffs are not rendered by default.

Makefile

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@ JB_BIN=$(BIN_DIR)/jb
66
JSONNET_BIN=$(BIN_DIR)/jsonnet
77
JSONNETLINT_BIN=$(BIN_DIR)/jsonnet-lint
88
JSONNETFMT_BIN=$(BIN_DIR)/jsonnetfmt
9+
MD_FILES = $(shell find . \( -type d -name '.vale' -o -type d -name 'vendor' \) -prune -o -type f -name "*.md" -print)
10+
MARKDOWNFMT_BIN=$(BIN_DIR)/markdownfmt
11+
VALE_BIN=$(BIN_DIR)/vale
912
PROMTOOL_BIN=$(BIN_DIR)/promtool
10-
TOOLING=$(JB_BIN) $(JSONNETLINT_BIN) $(JSONNET_BIN) $(JSONNETFMT_BIN) $(PROMTOOL_BIN) $(GRAFANA_DASHBOARD_LINTER_BIN)
13+
TOOLING=$(JB_BIN) $(JSONNETLINT_BIN) $(JSONNET_BIN) $(JSONNETFMT_BIN) $(PROMTOOL_BIN) $(GRAFANA_DASHBOARD_LINTER_BIN) $(MARKDOWNFMT_BIN) $(VALE_BIN)
1114
JSONNETFMT_ARGS=-n 2 --max-blank-lines 2 --string-style s --comment-style s
1215
SRC_DIR ?=dashboards
1316
OUT_DIR ?=dashboards_out
@@ -22,10 +25,14 @@ $(JSONNET_VENDOR): $(JB_BIN) jsonnetfile.json
2225
$(JB_BIN) install
2326

2427
.PHONY: fmt
25-
fmt: $(JSONNETFMT_BIN)
26-
find . -name 'vendor' -prune -o -name '*.libsonnet' -print -o -name '*.jsonnet' -print | \
28+
fmt: $(JSONNETFMT_BIN) markdownfmt
29+
@find . -name 'vendor' -prune -o -name '*.libsonnet' -print -o -name '*.jsonnet' -print | \
2730
xargs -n 1 -- $(JSONNETFMT_BIN) $(JSONNETFMT_ARGS) -i
2831

32+
.PHONY: markdownfmt
33+
markdownfmt: $(MARKDOWNFMT_BIN)
34+
@for file in $(MD_FILES); do $(MARKDOWNFMT_BIN) -w -gofmt $$file; done
35+
2936
prometheus_alerts.yaml: $(JSONNET_BIN) mixin.libsonnet lib/alerts.jsonnet alerts/*.libsonnet
3037
@$(JSONNET_BIN) -J vendor -S lib/alerts.jsonnet > $@
3138

@@ -37,14 +44,13 @@ $(OUT_DIR): $(JSONNET_BIN) $(JSONNET_VENDOR) mixin.libsonnet lib/dashboards.json
3744
@$(JSONNET_BIN) -J vendor -m $(OUT_DIR) lib/dashboards.jsonnet
3845

3946
.PHONY: lint
40-
lint: jsonnet-lint alerts-lint dashboards-lint
47+
lint: jsonnet-lint alerts-lint dashboards-lint vale
4148

4249
.PHONY: jsonnet-lint
4350
jsonnet-lint: $(JSONNETLINT_BIN) $(JSONNET_VENDOR)
4451
@find . -name 'vendor' -prune -o -name '*.libsonnet' -print -o -name '*.jsonnet' -print | \
4552
xargs -n 1 -- $(JSONNETLINT_BIN) -J vendor
4653

47-
4854
.PHONY: alerts-lint
4955
alerts-lint: $(PROMTOOL_BIN) prometheus_alerts.yaml prometheus_rules.yaml
5056
@$(PROMTOOL_BIN) check rules prometheus_rules.yaml
@@ -59,6 +65,11 @@ dashboards-lint: $(GRAFANA_DASHBOARD_LINTER_BIN) $(OUT_DIR)/.lint
5965
@sed -i -e 's/$$interval:$$resolution/$$__rate_interval/g' $(OUT_DIR)/*.json
6066
@find $(OUT_DIR) -name '*.json' -print0 | xargs -n 1 -0 $(GRAFANA_DASHBOARD_LINTER_BIN) lint --strict
6167

68+
.PHONY: vale
69+
vale: $(VALE_BIN)
70+
@echo $(MD_FILES)
71+
@$(VALE_BIN) sync && \
72+
$(VALE_BIN) $(MD_FILES)
6273

6374
.PHONY: clean
6475
clean:

README.md

Lines changed: 33 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Prometheus Monitoring Mixin for Kubernetes
2+
23
[![ci](https://github.com/kubernetes-monitoring/kubernetes-mixin/actions/workflows/ci.yaml/badge.svg)](https://github.com/kubernetes-monitoring/kubernetes-mixin/actions/workflows/ci.yaml)
34

45
> NOTE: This project is *pre-release* stage. Flags, configuration, behaviour and design may change significantly in following releases.
@@ -7,24 +8,23 @@ A set of Grafana dashboards and Prometheus alerts for Kubernetes.
78

89
## Releases
910

10-
| Release branch | Kubernetes Compatibility | Prometheus Compatibility | Kube-state-metrics Compatibility |
11-
| -------------- | -------------------------- | ------------------------ | -------------------------------- |
12-
| release-0.1 | v1.13 and before | | |
13-
| release-0.2 | v1.14.1 and before | v2.11.0+ | |
14-
| release-0.3 | v1.17 and before | v2.11.0+ | |
15-
| release-0.4 | v1.18 | v2.11.0+ | |
16-
| release-0.5 | v1.19 | v2.11.0+ | |
17-
| release-0.6 | v1.19+ | v2.11.0+ | |
18-
| release-0.7 | v1.19+ | v2.11.0+ | v1.x |
19-
| release-0.8 | v1.20+ | v2.11.0+ | v2.0+ |
20-
| release-0.9 | v1.20+ | v2.11.0+ | v2.0+ |
21-
| release-0.10 | v1.20+ | v2.11.0+ | v2.0+ |
22-
| release-0.11 | v1.23+ | v2.11.0+ | v2.0+ |
23-
| release-0.12 | v1.23+ | v2.11.0+ | v2.0+ |
24-
| master | v1.26+ | v2.11.0+ | v2.0+ |
25-
26-
In Kubernetes 1.14 there was a major [metrics overhaul](https://github.com/kubernetes/enhancements/issues/1206) implemented.
27-
Therefore v0.1.x of this repository is the last release to support Kubernetes 1.13 and previous version on a best effort basis.
11+
| Release branch | Kubernetes Compatibility | Prometheus Compatibility | Kube-state-metrics Compatibility |
12+
|----------------|--------------------------|--------------------------|----------------------------------|
13+
| release-0.1 | v1.13 and before | | |
14+
| release-0.2 | v1.14.1 and before | v2.11.0+ | |
15+
| release-0.3 | v1.17 and before | v2.11.0+ | |
16+
| release-0.4 | v1.18 | v2.11.0+ | |
17+
| release-0.5 | v1.19 | v2.11.0+ | |
18+
| release-0.6 | v1.19+ | v2.11.0+ | |
19+
| release-0.7 | v1.19+ | v2.11.0+ | v1.x |
20+
| release-0.8 | v1.20+ | v2.11.0+ | v2.0+ |
21+
| release-0.9 | v1.20+ | v2.11.0+ | v2.0+ |
22+
| release-0.10 | v1.20+ | v2.11.0+ | v2.0+ |
23+
| release-0.11 | v1.23+ | v2.11.0+ | v2.0+ |
24+
| release-0.12 | v1.23+ | v2.11.0+ | v2.0+ |
25+
| master | v1.26+ | v2.11.0+ | v2.0+ |
26+
27+
In Kubernetes 1.14 there was a major [metrics overhaul](https://github.com/kubernetes/enhancements/issues/1206) implemented. Therefore v0.1.x of this repository is the last release to support Kubernetes 1.13 and previous version on a best effort basis.
2828

2929
Some alerts now use Prometheus filters made available in Prometheus 2.11.0, which makes this version of Prometheus a dependency.
3030

@@ -34,18 +34,16 @@ Warning: By default the expressions will generate *grafana 7.2+* compatible rule
3434

3535
## How to use
3636

37-
This mixin is designed to be vendored into the repo with your infrastructure config.
38-
To do this, use [jsonnet-bundler](https://github.com/jsonnet-bundler/jsonnet-bundler):
37+
This mixin is designed to be vendored into the repo with your infrastructure config. To do this, use [jsonnet-bundler](https://github.com/jsonnet-bundler/jsonnet-bundler):
3938

4039
You then have three options for deploying your dashboards
4140
1. Generate the config files and deploy them yourself
42-
1. Use ksonnet to deploy this mixin along with Prometheus and Grafana
43-
1. Use prometheus-operator to deploy this mixin (TODO)
41+
2. Use ksonnet to deploy this mixin along with Prometheus and Grafana
42+
3. Use prometheus-operator to deploy this mixin (TODO)
4443

4544
## Generate config files
4645

47-
You can manually generate the alerts, dashboards and rules files, but first you
48-
must install some tools:
46+
You can manually generate the alerts, dashboards and rules files, but first you must install some tools:
4947

5048
```
5149
$ go install github.com/jsonnet-bundler/jsonnet-bundler/cmd/jb@latest
@@ -68,13 +66,11 @@ $ make prometheus_rules.yaml
6866
$ make dashboards_out
6967
```
7068

71-
The `prometheus_alerts.yaml` and `prometheus_rules.yaml` file then need to passed
72-
to your Prometheus server, and the files in `dashboards_out` need to be imported
73-
into you Grafana server. The exact details will depending on how you deploy your
74-
monitoring stack to Kubernetes.
69+
The `prometheus_alerts.yaml` and `prometheus_rules.yaml` file then need to passed to your Prometheus server, and the files in `dashboards_out` need to be imported into you Grafana server. The exact details will depending on how you deploy your monitoring stack to Kubernetes.
7570

7671
### Dashboards for Windows Nodes
77-
There are separate dashboards for windows resources.
72+
73+
There exist separate dashboards for windows resources.
7874
1) Compute Resources / Cluster(Windows)
7975
2) Compute Resources / Namespace(Windows)
8076
3) Compute Resources / Pod(Windows)
@@ -91,10 +87,7 @@ make test
9187

9288
## Using with prometheus-ksonnet
9389

94-
Alternatively you can also use the mixin with
95-
[prometheus-ksonnet](https://github.com/kausalco/public/tree/master/prometheus-ksonnet),
96-
a [ksonnet](https://github.com/ksonnet/ksonnet) module to deploy a fully-fledged
97-
Prometheus-based monitoring system for Kubernetes:
90+
Alternatively you can also use the mixin with [prometheus-ksonnet](https://github.com/kausalco/public/tree/master/prometheus-ksonnet), a [ksonnet](https://github.com/ksonnet/ksonnet) module to deploy a fully-fledged Prometheus-based monitoring system for Kubernetes:
9891

9992
Make sure you have the ksonnet v0.8.0:
10093

@@ -115,8 +108,7 @@ $ cd <application name>
115108
$ ks env add default
116109
```
117110

118-
Grab the kubernetes-jsonnet module using and its dependencies, which include
119-
the kubernetes-mixin:
111+
Grab the kubernetes-jsonnet module using and its dependencies, which include the kubernetes-mixin:
120112

121113
```
122114
$ go get github.com/jsonnet-bundler/jsonnet-bundler/cmd/jb
@@ -158,9 +150,7 @@ Kubernetes-mixin can support dashboards across multiple clusters. You need eithe
158150

159151
## Customising the mixin
160152

161-
Kubernetes-mixin allows you to override the selectors used for various jobs,
162-
to match those used in your Prometheus set. You can also customize the dashboard
163-
names and add grafana tags.
153+
Kubernetes-mixin allows you to override the selectors used for various jobs, to match those used in your Prometheus set. You can also customize the dashboard names and add grafana tags.
164154

165155
In a new directory, add a file `mixin.libsonnet`:
166156

@@ -225,32 +215,32 @@ local utils = import 'lib/utils.libsonnet';
225215
}
226216
)
227217
```
218+
228219
Create new file: `lib/kubernetes_customised_alerts.jsonnet` with the following:
229220

230221
```jsonnet
231222
std.manifestYamlDoc((import '../kubernetes_mixin_override.libsonnet').prometheusAlerts)
232223
```
224+
233225
Running `jsonnet -S lib/kubernetes_customised_alerts.jsonnet` will build the alerts with your customisations.
234226

235227
Same result can be achieved by modyfying the existing `config.libsonnet` with the content of `kubernetes_mixin_override.libsonnet`.
236228

237229
## Background
238230

239231
### Alert Severities
232+
240233
While the community has not yet fully agreed on alert severities and their to be used, this repository assumes the following paradigms when setting the severities:
241234

242235
* Critical: An issue, that needs to page a person to take instant action
243236
* Warning: An issue, that needs to be worked on but in the regular work queue or for during office hours rather than paging the oncall
244237
* Info: Is meant to support a trouble shooting process by informing about a non-normal situation for one or more systems but not worth a page or ticket on its own.
245238

246-
247239
### Architecture and Technical Decisions
248240

249-
* For more motivation, see
250-
"[The RED Method: How to instrument your services](https://kccncna17.sched.com/event/CU8K/the-red-method-how-to-instrument-your-services-b-tom-wilkie-kausal?iframe=no&w=100%&sidebar=yes&bg=no)" talk from CloudNativeCon Austin.
241+
* For more motivation, see "[The RED Method: How to instrument your services](https://kccncna17.sched.com/event/CU8K/the-red-method-how-to-instrument-your-services-b-tom-wilkie-kausal?iframe=no&w=100%&sidebar=yes&bg=no)" talk from CloudNativeCon Austin.
251242
* For more information about monitoring mixins, see this [design doc](DESIGN.md).
252243

253244
## Note
254245

255-
You can use the external tool call [prom-metrics-check](https://github.com/ContainerSolutions/prom-metrics-check) to validate the created dashboards. This tool allows you to check if the metrics installed and used in Grafana dashboards exist in the Prometheus instance.
256-
Please have a look at https://github.com/ContainerSolutions/prom-metrics-check.
246+
You can use the external tool call [prom-metrics-check](https://github.com/ContainerSolutions/prom-metrics-check) to validate the created dashboards. This tool allows you to check if the metrics installed and used in Grafana dashboards exist in the Prometheus instance. Please have a look at https://github.com/ContainerSolutions/prom-metrics-check.

0 commit comments

Comments
 (0)