Skip to content

Commit 362e410

Browse files
authored
Add Check for unexpected changes in generated files (#1407)
* Add Check for unexpected changes in generated files add kafka and snmp generated files * Fix kafka dashboards CI check * Add to docker-mixin * Add golang-observ-lib * Add jvm-observ-lib * Add windows * Add process lib * Add zookeeper * Add to csp-mixin check * Fix process-dashboards.json diff * Regenerate golang * Regenerate windows * Update ci * Update README * Update snmp Makefile * Add common Makefile * Add activemq * Add apache mixins * add confluent * Add docker-mixin * Add csp-mixin * Update goruntime * Update f5 * Update grafana-agent * Simplify Makefile to use common mixin Makefile * Add grafana-builder dependency * Add envoy * Add harbor * Add hass-mixin * Add influx * Add haproxy * Add istio * Add multiple mixins: IBM MQ, Istio, Jaeger, Jenkins, Jira, and JVM * Update kafka-mixin * Add multiple mixins: Couchbase, Discourse, Elasticsearch, GitLab, Kubescape, Memcached, Microsoft IIS, Minio, MongoDB (Atlas and standard), MSSQL, and NGINX * Add Spark mixin * Add multiple mixins: Node.js, Nomad, OpenLDAP, OpenSearch, OpenStack, OracleDB, PgBouncer, Presto, Python Runtime, RabbitMQ, Rclone, Redis (Enterprise and standard), Ruby, SAP HANA, and Spring Boot * Add multiple mixins: Supabase, Tensorflow, Traefik, Vault, Velero, Windows, WSO2 Enterprise and Streaming Integrators * add snmp-mixin * Remove unrelated links from snmp-mixin * set editable: false * Fix jvm * Update spring * make fmt camel * Fix redis mixin linter * Fix lint for golang * Update lint for kafka * update oracle * Update nomad * Update haproxy * update envoy * Update jaeger * update ceph linter * Fix for asterisk * Fix .lint * Update oracle * Fix cilium * Update install-ci-deps * Reset minio * Add .gitattributes * fix haproxy * Update gitattributes * Fix mixin format * Fix nomad lint * Fix .lint * Update makefile * fix typo in snmp * Update lint error message * Add newline * Update mixtool to main * Update snmp * Fix * Fix snmp
1 parent 158cec7 commit 362e410

File tree

638 files changed

+349628
-2134
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

638 files changed

+349628
-2134
lines changed

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
**/prometheus_rules_out/*.yaml linguist-generated=true
2+
**/dashboards_out/*.json linguist-generated=true

.github/workflows/lint-mixins.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646
run: echo '${{ steps.changed-mixins.outputs.all_changed_files }}'
4747

4848
lint-mixin:
49-
name: Run Mixtool
49+
name: Lint Mixin
5050
runs-on: ubuntu-latest
5151
permissions:
5252
issues: write
@@ -75,8 +75,13 @@ jobs:
7575

7676
- name: Install Mixin dependencies
7777
working-directory: ./${{ matrix.mixin }}
78-
run: jb install
78+
run: make build
7979

80-
- name: Lint Mixin
80+
- name: Lint Mixin with Mixtool
8181
working-directory: ./${{ matrix.mixin }}
8282
run: mixtool lint mixin.libsonnet
83+
84+
- name: Check for unexpected changes in generated files
85+
working-directory: ./${{ matrix.mixin }}
86+
run: "make && git diff --exit-code || ( echo 'Error: Generated files are not up to date. Run make and commit the local diff'; exit 1; )"
87+

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
.DS_Store
22
vendor
33
jsonnetfile.lock.json
4-
prometheus_alerts.yaml
5-
dashboards_out
64
*.zip

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ install-ci-deps:
55
go install github.com/google/go-jsonnet/cmd/[email protected]
66
go install github.com/google/go-jsonnet/cmd/[email protected]
77
go install github.com/google/go-jsonnet/cmd/[email protected]
8-
go install github.com/monitoring-mixins/mixtool/cmd/mixtool@a8984473edc33da685bd5f2138eab9cf6a0ff2b7
8+
go install github.com/monitoring-mixins/mixtool/cmd/mixtool@main
99
go install github.com/jsonnet-bundler/jsonnet-bundler/cmd/[email protected]
1010

1111
fmt:

Makefile_mixin

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
JSONNET_FMT := jsonnetfmt -n 2 --max-blank-lines 1 --string-style s --comment-style s
2+
3+
.PHONY: all
4+
all: build dashboards_out prometheus_alerts.yaml prometheus_rules.yaml
5+
6+
vendor: $(wildcard jsonnetfile.json)
7+
ifneq ("$(wildcard jsonnetfile.json)","")
8+
jb install
9+
endif
10+
11+
.PHONY: build
12+
build: vendor
13+
14+
.PHONY: fmt
15+
fmt:
16+
find . -name 'vendor' -prune -o -name '*.libsonnet' -print -o -name '*.jsonnet' -print | \
17+
xargs -n 1 -- $(JSONNET_FMT) -i
18+
19+
.PHONY: lint
20+
lint: build
21+
find . -name 'vendor' -prune -o -name '*.libsonnet' -print -o -name '*.jsonnet' -print | \
22+
while read f; do \
23+
$(JSONNET_FMT) "$$f" | diff -u "$$f" -; \
24+
done
25+
mixtool lint mixin.libsonnet
26+
27+
dashboards_out: mixin.libsonnet $(wildcard **/*.libsonnet) $(wildcard **/*.jsonnet) $(wildcard panels/*) $(wildcard signals/*)
28+
@mkdir -p dashboards_out
29+
mixtool generate dashboards mixin.libsonnet -d dashboards_out
30+
31+
prometheus_alerts.yaml: $(wildcard vendor/**/alerts.yaml) $(wildcard vendor/**/alerts.libsonnet) mixin.libsonnet $(wildcard alerts.libsonnet) $(wildcard signals/*) $(wildcard alerts/*)
32+
@mkdir -p prometheus_rules_out
33+
@if [ -f alerts.libsonnet -o -d alerts ]; then \
34+
mixtool generate alerts mixin.libsonnet -a prometheus_rules_out/prometheus_alerts.yaml; \
35+
else \
36+
touch prometheus_rules_out/prometheus_alerts.yaml; \
37+
fi
38+
prometheus_rules.yaml: $(wildcard vendor/**/rules.yaml) $(wildcard vendor/**/rules.libsonnet) mixin.libsonnet $(wildcard rules.libsonnet) $(wildcard signals/*) $(wildcard rules/*)
39+
@if [ -f rules.libsonnet -o -d rules ]; then \
40+
mixtool generate rules mixin.libsonnet -a prometheus_rules_out/prometheus_rules.yaml; \
41+
else \
42+
touch prometheus_rules_out/prometheus_rules.yaml; \
43+
fi
44+
45+
.PHONY: deploy deploy_rules deploy_dashboards
46+
deploy: deploy_rules deploy_dashboards
47+
48+
deploy_dashboards:
49+
ifdef GRAFANA_URL
50+
grr apply mixin.libsonnet --target "Dashboard.*" --target "DashboardFolder.*"
51+
else
52+
$(warning GRAFANA_URL is not set, skipping grafana dashboards deployment)
53+
endif
54+
55+
deploy_rules:
56+
ifdef CORTEX_ADDRESS
57+
grr apply mixin.libsonnet --target "PrometheusRuleGroup.*"
58+
else
59+
$(warning CORTEX_ADDRESS is not set, skipping prometheus alerts deployment)
60+
endif
61+
62+
.PHONY: clean
63+
clean:
64+
rm -rf dashboards_out prometheus_rules_out

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ More examples:
4646
[Signal](https://github.com/grafana/jsonnet-libs/tree/master/common-lib/common/signal#signal) is the experimental extension to observability libraries format to declare metrics (signals) and then render them as different grafana panel types (timeseries, stat, table, etc), or alert rules.
4747

4848
Examples:
49+
- [docker-mixin](docker-mixin/)
4950
- [kafka-observ-lib](kafka-observ-lib/)
5051
- [jvm-observ-lib](jvm-observ-lib/)
5152
- [snmp-observ-lib](snmp-observ-lib/)

aerospike-mixin/Makefile

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1 @@
1-
JSONNET_FMT := jsonnetfmt -n 2 --max-blank-lines 1 --string-style s --comment-style s
2-
3-
.PHONY: all
4-
all: build dashboards_out prometheus_alerts.yaml
5-
6-
vendor: jsonnetfile.json
7-
jb install
8-
9-
.PHONY: build
10-
build: vendor
11-
12-
.PHONY: fmt
13-
fmt:
14-
find . -name 'vendor' -prune -o -name '*.libsonnet' -print -o -name '*.jsonnet' -print | \
15-
xargs -n 1 -- $(JSONNET_FMT) -i
16-
17-
.PHONY: lint
18-
lint: build
19-
find . -name 'vendor' -prune -o -name '*.libsonnet' -print -o -name '*.jsonnet' -print | \
20-
while read f; do \
21-
$(JSONNET_FMT) "$$f" | diff -u "$$f" -; \
22-
done
23-
mixtool lint mixin.libsonnet
24-
25-
dashboards_out: mixin.libsonnet config.libsonnet $(wildcard dashboards/*)
26-
@mkdir -p dashboards_out
27-
mixtool generate dashboards mixin.libsonnet -d dashboards_out
28-
29-
prometheus_alerts.yaml: mixin.libsonnet alerts/*.libsonnet
30-
mixtool generate alerts mixin.libsonnet -a prometheus_alerts.yaml
31-
32-
.PHONY: clean
33-
clean:
34-
rm -rf dashboards_out prometheus_alerts.yaml
1+
include ../Makefile_mixin

0 commit comments

Comments
 (0)