forked from vitessio/vitess
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
vitess-mixin: add structure & first 2 dashboards
Signed-off-by: Guido Iaquinti <[email protected]>
- Loading branch information
Guido Iaquinti
committed
Dec 20, 2019
1 parent
c174b59
commit fdc7b22
Showing
17 changed files
with
1,217 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
*.yaml | ||
dashboards_out | ||
vendor | ||
jsonnetfile.lock.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
.PHONY: dashboards_out | ||
|
||
JSONNET_ARGS := -n 2 --max-blank-lines 2 --string-style s --comment-style s | ||
ifneq (,$(shell which jsonnetfmt)) | ||
JSONNET_FMT_CMD := jsonnetfmt | ||
else | ||
JSONNET_FMT_CMD := jsonnet | ||
JSONNET_FMT_ARGS := fmt $(JSONNET_ARGS) | ||
endif | ||
JSONNET_FMT := $(JSONNET_FMT_CMD) $(JSONNET_FMT_ARGS) | ||
|
||
all: fmt prometheus_alerts.yaml prometheus_rules.yaml dashboards_out lint test | ||
|
||
fmt: | ||
find . -name 'vendor' -prune -o -name '*.libsonnet' -print -o -name '*.jsonnet' -print | \ | ||
xargs -n 1 -- $(JSONNET_FMT) -i | ||
|
||
jsonnet_bundle_install: | ||
jb install | ||
|
||
prometheus_alerts.yaml: mixin.libsonnet lib/alerts.jsonnet alerts/*.libsonnet | ||
jsonnet -S lib/alerts.jsonnet > $@ | ||
|
||
prometheus_rules.yaml: mixin.libsonnet lib/rules.jsonnet rules/*.libsonnet | ||
jsonnet -S lib/rules.jsonnet > $@ | ||
|
||
dashboards_out: mixin.libsonnet lib/dashboards.jsonnet dashboards/*.libsonnet | ||
@mkdir -p dashboards_out | ||
jsonnet -J vendor -m dashboards_out lib/dashboards.jsonnet | ||
|
||
lint: prometheus_alerts.yaml prometheus_rules.yaml | ||
find . -name 'vendor' -prune -o -name '*.libsonnet' -print -o -name '*.jsonnet' -print | \ | ||
while read f; do \ | ||
$(JSONNET_FMT) "$$f" | diff -u "$$f" -; \ | ||
done | ||
|
||
promtool check rules prometheus_rules.yaml | ||
promtool check rules prometheus_alerts.yaml | ||
|
||
clean: | ||
rm -rf dashboards_out prometheus_alerts.yaml prometheus_rules.yaml | ||
|
||
test: prometheus_alerts.yaml prometheus_rules.yaml | ||
promtool test rules tests.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# (Alpha) Prometheus Monitoring Mixin for Vitess | ||
|
||
A set of Grafana dashboards and Prometheus alerts for Vitess. | ||
|
||
## Prerequisites | ||
|
||
1. Install `jsonnet-bundler`: | ||
* via `go`: `go get github.com/jsonnet-bundler/jsonnet-bundler/cmd/jb` | ||
* via `brew`: `brew install jsonnet` | ||
|
||
1. Install `promtool`: `go get github.com/prometheus/prometheus/cmd/promtool` | ||
|
||
## Generate config files | ||
|
||
You can manually generate the alerts, dashboards and rules files: | ||
|
||
``` | ||
$ make prometheus_alerts.yaml | ||
$ make prometheus_rules.yaml | ||
$ make dashboards_out | ||
``` | ||
|
||
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. | ||
|
||
## Running the tests (requires Docker) | ||
|
||
Build the mixins, run the tests: | ||
|
||
``` | ||
$ docker run -v $(pwd):/tmp --entrypoint "/bin/promtool" prom/prometheus:latest test rules /tmp/tests.yaml | ||
``` | ||
|
||
Generate the alerts, rules and dashboards: | ||
|
||
``` | ||
$ jsonnet -J vendor -S -e 'std.manifestYamlDoc((import "mixin.libsonnet").prometheusAlerts)' > alerts.yml | ||
$ jsonnet -J vendor -S -e 'std.manifestYamlDoc((import "mixin.libsonnet").prometheusRules)' >files/rules.yml | ||
$ jsonnet -J vendor -m files/dashboards -e '(import "mixin.libsonnet").grafanaDashboards' | ||
``` | ||
|
||
## Background | ||
|
||
* 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. | ||
* For more information about monitoring mixins, see this [design doc](https://docs.google.com/document/d/1A9xvzwqnFVSOZ5fD3blKODXfsat5fg6ZhnKu9LK3lB4/edit#). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
{ | ||
_config+:: { | ||
|
||
// Selectors are inserted between {} in Prometheus queries. | ||
regionSelector: 'region="$region"', | ||
vtctldSelector: 'job="vitess-vtctld"', | ||
vtgateSelector: 'job="vitess-vtgate"', | ||
vttabletSelector: 'job="vitess-vttablet"', | ||
vtworkerSelector: 'job="vitess-vtworker"', | ||
mysqlSelector: 'job="mysql"', | ||
|
||
// Datasource to use | ||
dataSource: 'Prometheus_Vitess', | ||
|
||
// Default config for the Grafana dashboards in the Vitess Mixin | ||
grafanaDashboardMetadataDefault: { | ||
dashboardNamePrefix: 'Vitess /', | ||
dashboardNameSuffix: '(auto-generated)', | ||
dashboardTags: ['vitess-mixin'], | ||
}, | ||
|
||
// Grafana dashboard IDs are necessary for stable links for dashboards | ||
grafanaDashboardMetadata: { | ||
cluster_overview: { | ||
uid: '0d0778047f5a64ff2ea084ec3e', | ||
title: '%(dashboardNamePrefix)s Cluster Overview %(dashboardNameSuffix)s' % $._config.grafanaDashboardMetadataDefault, | ||
description: 'Vitess cluster overview', | ||
dashboardTags: $._config.grafanaDashboardMetadataDefault.dashboardTags + ['overview', 'cluster'], | ||
}, | ||
keyspace_overview: { | ||
uid: 'ff33eceed7d2b1267dd286a099', | ||
title: '%(dashboardNamePrefix)s Keyspace Overview %(dashboardNameSuffix)s' % $._config.grafanaDashboardMetadataDefault, | ||
description: 'General keyspace overview', | ||
dashboardTags: $._config.grafanaDashboardMetadataDefault.dashboardTags + ['overview', 'keyspace'], | ||
}, | ||
}, | ||
|
||
}, | ||
} |
Oops, something went wrong.