Skip to content

Commit 6002df5

Browse files
bergquisttomwilkie
andauthored
Add monitoring mixing for Grafana (grafana#28285)
Co-authored-by: Tom Wilkie <[email protected]>
1 parent febdad4 commit 6002df5

File tree

9 files changed

+624
-0
lines changed

9 files changed

+624
-0
lines changed

grafana-mixin/.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
alerts.yaml
2+
rules.yaml
3+
dashboards_out

grafana-mixin/Makefile

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
JSONNET_FMT := jsonnetfmt -n 2 --max-blank-lines 2 --string-style s --comment-style s
2+
3+
all: fmt lint build clean
4+
5+
fmt:
6+
find . -name 'vendor' -prune -o -name '*.libsonnet' -print -o -name '*.jsonnet' -print | \
7+
xargs -n 1 -- $(JSONNET_FMT) -i
8+
9+
lint:
10+
find . -name 'vendor' -prune -o -name '*.libsonnet' -print -o -name '*.jsonnet' -print | \
11+
while read f; do \
12+
$(JSONNET_FMT) "$$f" | diff -u "$$f" -; \
13+
done
14+
15+
mixtool lint mixin.libsonnet
16+
17+
build:
18+
mixtool generate all mixin.libsonnet
19+
20+
clean:
21+
rm -rf dashboards_out alerts.yaml rules.yaml

grafana-mixin/README.md

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Grafana Mixin
2+
3+
_This is a work in progress. We aim for it to become a good role model for alerts
4+
and dashboards eventually, but it is not quite there yet._
5+
6+
The Grafana Mixin is a set of configurable, reusable, and extensible alerts and
7+
dashboards based on the metrics exported by Grafana. The mixin creates
8+
recording and alerting rules for Prometheus and suitable dashboard descriptions
9+
for Grafana.
10+
11+
To use them, you need to have `mixtool` and `jsonnetfmt` installed. If you
12+
have a working Go development environment, it's easiest to run the following:
13+
14+
```bash
15+
$ go get github.com/monitoring-mixins/mixtool/cmd/mixtool
16+
$ go get github.com/google/go-jsonnet/cmd/jsonnetfmt
17+
```
18+
19+
You can then build the Prometheus rules files `alerts.yaml` and
20+
`rules.yaml` and a directory `dashboard_out` with the JSON dashboard files
21+
for Grafana:
22+
23+
```bash
24+
$ make build
25+
```
26+
27+
For more advanced uses of mixins, see
28+
https://github.com/monitoring-mixins/docs.

grafana-mixin/alerts/alerts.yaml

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
groups:
2+
- name: GrafanaAlerts
3+
rules:
4+
- alert: GrafanaRequestsFailing
5+
for: 5m
6+
expr: |
7+
100 * namespace_job_handler_statuscode:http_request_total:rate5m{handler!~"/datasources/proxy/:id.*|/ds/query|/tsdb/query", statuscode=~"5.."}
8+
/
9+
namespace_job_handler_statuscode:http_request_total:rate5m{handler!~"/datasources/proxy/:id.*|/ds/query|/tsdb/query"}
10+
> 0.5
11+
labels:
12+
severity: 'critical'
13+
annotations:
14+
message: "'{{ $labels.namespace }}' / '{{ $labels.job }}' / '{{ $labels.handler }}' is experiencing {{ $value | humanize }}% errors"

0 commit comments

Comments
 (0)