This repository has been archived by the owner on Apr 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 169
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs/mixin: jsonnetify mixin to allow using common mixin tooling
Signed-off-by: Paweł Krupa (paulfantom) <pawel@krupa.net.pl>
- Loading branch information
1 parent
498cafd
commit 0a87098
Showing
11 changed files
with
108 additions
and
27 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
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
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
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,3 @@ | ||
/alerts.yaml | ||
/rules.yaml | ||
dashboards_out/ |
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 @@ | ||
# Those exclusions are needed due to usage of newer dashboard schema | ||
exclusions: | ||
template-datasource-rule: | ||
panel-datasource-rule: |
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,32 @@ | ||
JSONNET_FMT := jsonnetfmt -n 2 --max-blank-lines 2 --string-style s --comment-style s | ||
|
||
default: build | ||
|
||
all: fmt lint build clean | ||
|
||
fmt: | ||
find . -name 'vendor' -prune -o -name '*.libsonnet' -print -o -name '*.jsonnet' -print | \ | ||
xargs -n 1 -- $(JSONNET_FMT) -i | ||
|
||
lint: | ||
find . -name 'vendor' -prune -o -name '*.libsonnet' -print -o -name '*.jsonnet' -print | \ | ||
while read f; do \ | ||
$(JSONNET_FMT) "$$f" | diff -u "$$f" -; \ | ||
done | ||
|
||
mixtool lint mixin.libsonnet | ||
|
||
build: | ||
mixtool generate all mixin.libsonnet | ||
|
||
clean: | ||
rm -rf dashboards_out alerts.yaml rules.yaml | ||
|
||
test: build | ||
# If you don't have promtool, install it with | ||
# go install -a github.com/prometheus/prometheus/cmd/promtool@latest | ||
promtool check rules alerts.yaml | ||
|
||
# If you don't have gojsontoyaml, install it with | ||
# go install -a github.com/brancz/gojsontoyaml@latest | ||
gojsontoyaml -yamltojson < alerts/alerts.yaml | jq -e '.groups[].rules[].annotations | has("runbook_url")' |
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 |
---|---|---|
@@ -1,17 +1,38 @@ | ||
# Promscale Mixin | ||
|
||
This file contains instructions on how to use Promscale mixins. | ||
_This is a work in progress. We aim for it to become a good role model for alerts and dashboards eventually, but it is not quite there yet._ | ||
|
||
The Promscale Mixin is a set of configurable, reusable, and extensible alerts and dashboards based on the metrics exported by the Promscale. The mixin creates recording and alerting rules for Prometheus and suitable dashboard descriptions for Grafana. | ||
|
||
We recommend monitoring your Promscale deployments and include the mixins in this package | ||
as part of your alerting environment. | ||
|
||
## How to use | ||
## Using pre-built mixin | ||
|
||
### How to use | ||
Promscale alerts are defined [here](alerts/alerts.yaml). Copy the context into a file | ||
say `promscale_alerts.yaml`. | ||
|
||
## Configuring Prometheus | ||
### Configuring Prometheus | ||
In the Prometheus configuration file, add `promscale_alerts.yaml` under `rule_files` like | ||
```yaml | ||
rule_files: | ||
- promscale_alerts.yaml | ||
``` | ||
## Building mixin | ||
To build it, you need to have mixtool and jsonnetfmt installed. If you have a working Go development environment, it's easiest to run the following: | ||
```console | ||
$ go install github.com/monitoring-mixins/mixtool/cmd/mixtool@latest | ||
$ go install github.com/google/go-jsonnet/cmd/jsonnetfmt@latest | ||
``` | ||
|
||
You can then build the Prometheus rules files alerts.yaml and rules.yaml and a directory dashboard_out with the JSON dashboard files for Grafana: | ||
|
||
``` | ||
$ make build | ||
``` | ||
|
||
For more advanced uses of mixins, see https://github.com/monitoring-mixins/docs. |
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,5 @@ | ||
{ | ||
prometheusAlerts+:: { | ||
groups+: std.parseYaml(importstr 'alerts.yaml').groups, | ||
}, | ||
} |
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 @@ | ||
{ | ||
// This is left to allow possible customization in the future | ||
_config+:: {}, | ||
} |
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,10 @@ | ||
{ | ||
grafanaDashboards+:: { | ||
'apm-dependencies.json': (import 'apm-dependencies.json'), | ||
'apm-home.json': (import 'apm-home.json'), | ||
'apm-service-dependencies-downstream.json': (import 'apm-service-dependencies-downstream.json'), | ||
'apm-service-dependencies-upstream.json': (import 'apm-service-dependencies-upstream.json'), | ||
'apm-service-overview.json': (import 'apm-service-overview.json'), | ||
'promscale.json': (import 'promscale.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,3 @@ | ||
(import 'alerts/alerts.libsonnet') + | ||
(import 'dashboards/dashboards.libsonnet') + | ||
(import 'config.libsonnet') |