feat(mixin): Add grafana mixins support for postgres exporter
Signed-off-by: Kaviraj <kavirajkanagaraj@gmail.com>
This commit is contained in:
parent
21f27a8e03
commit
51225e1733
|
@ -0,0 +1,3 @@
|
|||
/alerts.yaml
|
||||
/rules.yaml
|
||||
dashboards_out
|
|
@ -0,0 +1,23 @@
|
|||
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
|
|
@ -0,0 +1,26 @@
|
|||
# Postgres Mixin
|
||||
|
||||
_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 Postgres Mixin is a set of configurable, reusable, and extensible alerts and
|
||||
dashboards based on the metrics exported by the Postgres Exporter. The mixin creates
|
||||
recording and alerting rules for Prometheus and suitable dashboard descriptions
|
||||
for Grafana.
|
||||
|
||||
To use them, you need to have `mixtool` and `jsonnetfmt` installed. If you
|
||||
have a working Go development environment, it's easiest to run the following:
|
||||
```bash
|
||||
$ go get github.com/monitoring-mixins/mixtool/cmd/mixtool
|
||||
$ go get github.com/google/go-jsonnet/cmd/jsonnetfmt
|
||||
```
|
||||
|
||||
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:
|
||||
```bash
|
||||
$ make build
|
||||
```
|
||||
|
||||
For more advanced uses of mixins, see
|
||||
https://github.com/monitoring-mixins/docs.
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,3 @@
|
|||
module github.com/wrouesnel/postgres_exporter/postgres_mixin
|
||||
|
||||
go 1.15
|
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
grafanaDashboards: {
|
||||
'postgres-overview.json': (import 'dashboards/postgres-overview.json'),
|
||||
},
|
||||
|
||||
// Helper function to ensure that we don't override other rules, by forcing
|
||||
// the patching of the groups list, and not the overall rules object.
|
||||
local importRules(rules) = {
|
||||
groups+: std.native('parseYaml')(rules)[0].groups,
|
||||
},
|
||||
|
||||
prometheusAlerts+: importRules(importstr 'alerts/alerts.yaml'),
|
||||
}
|
Loading…
Reference in New Issue