Skip to content
This repository was archived by the owner on Jun 9, 2020. It is now read-only.

Commit afda3f3

Browse files
committed
move site to cleaner theme with separated alerts and rules
1 parent 7caf7ea commit afda3f3

File tree

9 files changed

+228
-96
lines changed

9 files changed

+228
-96
lines changed

.gitmodules

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
[submodule "site/themes/cayman"]
2-
path = site/themes/cayman
3-
url = https://github.com/zwbetz-gh/cayman-hugo-theme.git
1+
[submodule "site/themes/ace-documentation"]
2+
path = site/themes/ace-documentation
3+
url = https://github.com/vantagedesign/ace-documentation.git

generate.sh

+40-19
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,12 @@ download_mixin() {
2626
cd "$curdir"
2727
}
2828

29-
# Prepare env
30-
rm -rf site/content/* $MANIFESTS $TMPDIR
29+
# remove generated manifests and temporary directory
30+
rm -rf $MANIFESTS $TMPDIR
31+
# remove generated site content
32+
find site/content/ ! -name '_index.md' -type f -exec rm -rf {} +
3133
mkdir -p $TMPDIR
3234

33-
# Create top-level index.md header
34-
INDEXFILE="site/content/_index.md"
35-
cp site/templates/_index_header.md.tmpl "$INDEXFILE"
36-
3735
# Generate manifests
3836
cat mixins.yaml | gojsontoyaml -yamltojson > $TMPDIR/mixins.json
3937

@@ -48,7 +46,7 @@ for mixin in $(cat $TMPDIR/mixins.json | jq -r '.mixins[].name'); do
4846
#set -u
4947

5048
mkdir -p "site/content/${mixin}"
51-
file="site/content/${mixin}/index.md"
49+
file="site/content/${mixin}/_index.md"
5250
# Create header
5351
if [ -n "$subdir" ]; then
5452
location="$repo/tree/master/$subdir"
@@ -62,29 +60,52 @@ title: $mixin
6260
6361
$text
6462
65-
Mixin available at [${repo#*//}]($location)
63+
{{< panel style="primary" title="Jsonnet source" >}}
64+
Mixin jsonnet code is available at [${repo#*//}]($location)
65+
{{< /panel >}}
6666
6767
EOF
68-
echo -e "\n## $mixin\n" >> $INDEXFILE
69-
7068
dir="$TOP/$MANIFESTS/$mixin"
69+
# Alerts
7170
if [ -s "$dir/alerts.yaml" ] && [ "$(stat -c%s "$dir/alerts.yaml")" -gt 20 ]; then
72-
echo -e "# Alerts\n\n[embedmd]:# (../../../$MANIFESTS/$mixin/alerts.yaml yaml)\n" >> $file
73-
echo "- [Alerts](/$mixin#alerts)" >> $INDEXFILE
71+
echo -e "## Alerts\n" >> $file
72+
echo -e '{{< panel style="info" >}}' >> $file
73+
echo -e "Complete list of pregenerated alerts is available [here](https://github.com/cloudalchemy/mixins/blob/master/manifests/$mixin/alerts.yaml)." >> $file
74+
echo -e '{{< /panel >}}\n' >> $file
75+
76+
for i in $(cat $dir/alerts.yaml | gojsontoyaml -yamltojson | jq -cr '[.groups[].rules] | flatten | .[] | @base64'); do
77+
var=$(echo "$i" | base64 --decode | gojsontoyaml);
78+
name=$(echo -e "$var" | grep 'alert' | awk -F ': ' '{print $2}')
79+
echo -e "### ${name}\n" >> $file
80+
echo -e '{{< code lang="yaml" >}}' >> $file
81+
echo -e "$var" >> $file
82+
echo -e '{{< /code >}}\n ' >> $file
83+
done
7484
fi
85+
86+
# Recording Rules
7587
if [ -s "$dir/rules.yaml" ] && [ "$(stat -c%s "$dir/rules.yaml")" -gt 20 ]; then
76-
echo -e "# Recording rules\n\n[embedmd]:# (../../../$MANIFESTS/$mixin/rules.yaml yaml)\n" >> $file
77-
echo "- [Recording Rules](/$mixin#recording-rules)" >> $INDEXFILE
88+
echo -e "## Recording rules\n" >> $file
89+
echo -e '{{< panel style="info" >}}' >> $file
90+
echo -e "Complete list of pregenerated recording rules is available [here](https://github.com/cloudalchemy/mixins/blob/master/manifests/$mixin/rules.yaml)." >> $file
91+
echo -e '{{< /panel >}}\n' >> $file
92+
93+
for i in $(cat $dir/rules.yaml | gojsontoyaml -yamltojson | jq -cr '[.groups[].rules] | flatten | .[] | @base64'); do
94+
var=$(echo "$i" | base64 --decode | gojsontoyaml);
95+
name=$(echo -e "$var" | grep 'record' | awk -F ': ' '{print $2}')
96+
echo -e "### ${name}\n" >> $file
97+
echo -e '{{< code lang="yaml" >}}' >> $file
98+
echo -e "$var" >> $file
99+
echo -e '{{< /code >}}\n ' >> $file
100+
done
78101
fi
102+
103+
# Dashboards
79104
if [ "$(ls -A "$dir/dashboards")" ]; then
80-
echo -e "# Dashboards\nFollowing dashboards are generated from mixins and hosted on github:\n\n" >> $file
105+
echo -e "## Dashboards\nFollowing dashboards are generated from mixins and hosted on github:\n\n" >> $file
81106
for dashboard in $dir/dashboards/*.json; do
82107
d=$(basename $dashboard)
83108
echo "- [${d%.*}](https://github.com/cloudalchemy/mixins/blob/master/manifests/$mixin/dashboards/$d)" >> $file
84109
done
85-
echo "- [Dashboards](/$mixin#dashboards)" >> $INDEXFILE
86110
fi
87111
done
88-
89-
# Embed alerts and rules into site files
90-
embedmd -w $(find site/content/ -name "*.md")

site/config.yaml

+13-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ baseURL: ""
44
languageCode: "en-us"
55
title: "Monitoring Mixins"
66

7-
theme: 'cayman'
7+
theme: 'ace-documentation'
88

99
# Google analytics
1010
# googleAnalytics: UA-123456789-1
@@ -17,12 +17,22 @@ params:
1717

1818
project_tagline: Combination of alerts, recording rules, and dashboards for prometheus exporters
1919

20+
disableSearch: true
21+
disableReadmoreNav: true
22+
23+
markup:
24+
highlight:
25+
style: monokailight
26+
2027
menu:
21-
nav:
28+
shortcuts:
2229
- name: Homepage
2330
url: /
2431
weight: 1
25-
- name: About
32+
- name: About mixins
2633
url: "https://github.com/monitoring-mixins/docs"
2734
weight: 2
35+
- name: "<i class='fab fa-github'></i>"
36+
url: "https://github.com/cloudalchemy/mixin"
37+
weight: 3
2838

site/content/_index.md

+128-34
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,153 @@
11
---
2-
title: Prometheus monitoring mixins
2+
title: Prometheus Monitoring Mixins
33
---
44

5+
A mixin is a set of Grafana dashboards and Prometheus rules and alerts, packaged together in a reuseable and extensible bundle.
6+
Mixins are written in [jsonnet](https://jsonnet.org/), and are typically installed and updated with [jsonnet-bundler](https://github.com/jsonnet-bundler/jsonnet-bundler).
57

6-
## prometheus
8+
For more information about mixins, see:
9+
* [Prometheus Monitoring Mixins Design Doc](https://docs.google.com/document/d/1A9xvzwqnFVSOZ5fD3blKODXfsat5fg6ZhnKu9LK3lB4/view). A [cached pdf](design.pdf) is included in monitoring mixins [documentation repository](https://github.com/monitoring-mixins/docs).
10+
* For more motivation, see
11+
"[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 2018. The KLUMPs system demo'd became the basis for the kubernetes-mixin.
12+
* "[Prometheus Monitoring Mixins: Using Jsonnet to Package Together Dashboards, Alerts and Exporters](https://www.youtube.com/watch?v=b7-DtFfsL6E)" talk from CloudNativeCon Copenhagen 2018.
13+
* "[Prometheus Monitoring Mixins: Using Jsonnet to Package Together Dashboards, Alerts and Exporters](https://promcon.io/2018-munich/talks/prometheus-monitoring-mixins/)" talk from PromCon 2018 (slightly updated).
714

8-
- [Alerts](/prometheus#alerts)
9-
- [Dashboards](/prometheus#dashboards)
15+
## How to use mixins.
1016

11-
## node-exporter
17+
Mixins are designed to be vendored into the repo with your infrastructure config.
18+
To do this, use [jsonnet-bundler](https://github.com/jsonnet-bundler/jsonnet-bundler):
1219

13-
- [Alerts](/node-exporter#alerts)
14-
- [Recording Rules](/node-exporter#recording-rules)
15-
- [Dashboards](/node-exporter#dashboards)
20+
You then have three options for deploying your dashboards
21+
1. Generate the config files and deploy them yourself.
22+
1. Use ksonnet to deploy this mixin along with Prometheus and Grafana.
23+
1. Use kube-prometheus to deploy this mixin.
1624

17-
## kubernetes
25+
## Generate config files
1826

19-
- [Alerts](/kubernetes#alerts)
20-
- [Recording Rules](/kubernetes#recording-rules)
21-
- [Dashboards](/kubernetes#dashboards)
27+
You can manually generate the alerts, dashboards and rules files, but first you
28+
must install some tools:
2229

23-
## kube-state-metrics
30+
```bash
31+
$ go get github.com/jsonnet-bundler/jsonnet-bundler/cmd/jb
2432

25-
- [Alerts](/kube-state-metrics#alerts)
33+
# macOS
34+
$ brew install jsonnet
2635

27-
## etcd
36+
# Archlinux AUR
37+
$ yay -S jsonnet
38+
```
2839

29-
- [Alerts](/etcd#alerts)
30-
- [Dashboards](/etcd#dashboards)
40+
Then, grab the mixin and its dependencies:
3141

32-
## ceph
42+
```bash
43+
$ git clone https://github.com/<mixin org>/<mixin repo>
44+
$ cd <mixin repo>
45+
$ jb install
46+
```
3347

34-
- [Alerts](/ceph#alerts)
35-
- [Recording Rules](/ceph#recording-rules)
48+
Finally, build the mixin:
3649

37-
## gluster
50+
```bash
51+
$ make prometheus_alerts.yaml
52+
$ make prometheus_rules.yaml
53+
$ make dashboards_out
54+
```
3855

39-
- [Alerts](/gluster#alerts)
40-
- [Recording Rules](/gluster#recording-rules)
41-
- [Dashboards](/gluster#dashboards)
56+
The `prometheus_alerts.yaml` and `prometheus_rules.yaml` file then need to passed
57+
to your Prometheus server, and the files in `dashboards_out` need to be imported
58+
into you Grafana server. The exact details will depending on how you deploy your
59+
monitoring stack to Kubernetes.
4260

43-
## consul
61+
## Using with prometheus-ksonnet
4462

45-
- [Alerts](/consul#alerts)
46-
- [Dashboards](/consul#dashboards)
63+
Alternatively you can also use the mixin with
64+
[prometheus-ksonnet](https://github.com/grafana/jsonnet-libs/tree/master/prometheus-ksonnet),
65+
a [ksonnet](https://github.com/ksonnet/ksonnet) module to deploy a fully-fledged
66+
Prometheus-based monitoring system for Kubernetes:
4767

48-
## jaeger
68+
Make sure you have the ksonnet v0.8.0:
4969

50-
- [Alerts](/jaeger#alerts)
70+
```bash
71+
$ brew install https://raw.githubusercontent.com/ksonnet/homebrew-tap/82ef24cb7b454d1857db40e38671426c18cd8820/ks.rb
72+
$ brew pin ks
73+
$ ks version
74+
ksonnet version: v0.8.0
75+
jsonnet version: v0.9.5
76+
client-go version: v1.6.8-beta.0+$Format:%h$
77+
```
5178

52-
## memcached
79+
In your config repo, if you don't have a ksonnet application, make a new one (will copy credentials from current context):
5380

54-
- [Dashboards](/memcached#dashboards)
81+
```bash
82+
$ ks init <application name>
83+
$ cd <application name>
84+
$ ks env add default
85+
```
5586

56-
## sealed-secrets
87+
Grab the kubernetes-jsonnet module using and its dependencies, which include
88+
the kubernetes-mixin:
5789

58-
- [Alerts](/sealed-secrets#alerts)
59-
- [Dashboards](/sealed-secrets#dashboards)
90+
```bash
91+
$ go get github.com/jsonnet-bundler/jsonnet-bundler/cmd/jb
92+
$ jb init
93+
$ jb install github.com/kausalco/public/prometheus-ksonnet
94+
95+
```
96+
97+
Assuming you want to run in the default namespace ('environment' in ksonnet parlance), add the follow to the file `environments/default/main.jsonnet`:
98+
99+
{{< code lang="as3" >}}
100+
local prometheus = import "prometheus-ksonnet/prometheus-ksonnet.libsonnet";
101+
102+
prometheus {
103+
_config+:: {
104+
namespace: "default",
105+
},
106+
}
107+
{{< /code >}}
108+
109+
Apply your config:
110+
111+
```bash
112+
$ ks apply default
113+
```
114+
115+
## Using kube-prometheus
116+
117+
See the kube-prometheus docs for [instructions on how to use mixins with kube-prometheus](https://github.com/coreos/kube-prometheus#kube-prometheus).
118+
119+
## Customising the mixin
120+
121+
Mixins typically allows you to override the selectors used for various jobs,
122+
to match those used in your Prometheus set.
123+
124+
This example uses the [kubernetes-mixin](https://github.com/kubernetes-monitoring/kubernetes-mixin).
125+
In a new directory, add a file `mixin.libsonnet`:
126+
127+
{{< code lang="as3" >}}
128+
local kubernetes = import "kubernetes-mixin/mixin.libsonnet";
129+
130+
kubernetes {
131+
_config+:: {
132+
kubeStateMetricsSelector: 'job="kube-state-metrics"',
133+
cadvisorSelector: 'job="kubernetes-cadvisor"',
134+
nodeExporterSelector: 'job="kubernetes-node-exporter"',
135+
kubeletSelector: 'job="kubernetes-kubelet"',
136+
},
137+
}
138+
{{< /code >}}
139+
140+
Then, install the kubernetes-mixin:
141+
142+
```bash
143+
$ jb init
144+
$ jb install github.com/kubernetes-monitoring/kubernetes-mixin
145+
```
146+
147+
Generate the alerts, rules and dashboards:
148+
149+
```bash
150+
$ jsonnet -J vendor -S -e 'std.manifestYamlDoc((import "mixin.libsonnet").prometheusAlerts)' > alerts.yml
151+
$ jsonnet -J vendor -S -e 'std.manifestYamlDoc((import "mixin.libsonnet").prometheusRules)' >files/rules.yml
152+
$ jsonnet -J vendor -m files/dashboards -e '(import "mixin.libsonnet").grafanaDashboards'
153+
```

site/layouts/_default/baseof.html

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<!DOCTYPE html>
2+
<html>
3+
{{- partial "head.html" . -}}
4+
<body>
5+
6+
{{- partial "header.html" . -}}
7+
8+
<div class="container-fluid">
9+
<div class="row">
10+
11+
<div class="docs-sidenav order-0 col-12 col-md-3 col-lg-2 col-xl-2 position-sticky border-right">
12+
{{- partial "menu.html" . -}}
13+
</div>
14+
15+
{{- if and (ne .Site.Params.toc false) (ne .Params.toc false) }}
16+
<div class="docs-toc large order-lg-2 order-md-0 order-xs-1 col-12 col-lg-3 col-xl-3 position-sticky border-left">
17+
{{- partial "tableofcontents.html" . -}}
18+
</div>
19+
<div class="main col-12 order-1 col-md-9 col-lg-9 col-xl-7 py-3">
20+
{{else}}
21+
<div class="main col-12 order-1 col-md-9 col-lg-10 col-xl-10 py-3">
22+
{{end}}
23+
24+
{{- block "main" . }}{{- end }}
25+
26+
<div class="row">
27+
{{- if and (ne .Site.Params.disableReadmoreNav true) (ne .Params.disableReadmoreNav true) -}}
28+
<div class="position-relative mx-auto col-lg-9">
29+
{{ partial "next-prev-page.html" . }}
30+
</div>
31+
{{- end -}}
32+
</div> <!-- /end of row -->
33+
34+
</div>
35+
36+
</div> <!-- /end of row -->
37+
38+
</div> <!-- /end of container -->
39+
40+
{{- partial "footer.html" . -}}
41+
42+
</body>
43+
</html>

site/layouts/_default/list.html

-19
This file was deleted.

0 commit comments

Comments
 (0)