Skip to content

Commit 70eb60f

Browse files
authored
Add Grafana validation for mixins (#1409)
* Update consul and minio * Add update-mixins target * Add validate dashboards check There is no validation against grafana schema when dashboards are generated. So let's try to import them into Grafana instance with grizzly to see if there are any issues. * Rename to test mixin * Fix minio * Update consul * Fix jaeger * Update minio * Fix for grizzly * Merge ci jobs
1 parent 74c19d2 commit 70eb60f

File tree

22 files changed

+2136
-12
lines changed

22 files changed

+2136
-12
lines changed

.github/workflows/lint-mixins.yml renamed to .github/workflows/test-mixins.yml

Lines changed: 22 additions & 2 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: Lint Mixin
49+
name: Test Mixin
5050
runs-on: ubuntu-latest
5151
permissions:
5252
issues: write
@@ -59,6 +59,15 @@ jobs:
5959
matrix:
6060
mixin: ${{ fromJSON(needs.check-for-changed-mixins.outputs.changed-mixins) }}
6161
fail-fast: false
62+
services:
63+
grafana:
64+
image: grafana/grafana:11.4.0
65+
ports:
66+
- 3000:3000
67+
env:
68+
GF_AUTH_DISABLE_LOGIN_FORM: "true"
69+
GF_AUTH_ANONYMOUS_ENABLED: "true"
70+
GF_AUTH_ANONYMOUS_ORG_ROLE: "Admin"
6271
steps:
6372
- name: Checkout
6473
uses: actions/checkout@v4
@@ -85,6 +94,17 @@ jobs:
8594
working-directory: ./${{ matrix.mixin }}
8695
run: "make && git diff --exit-code || ( echo 'Error: Generated files are not up to date. Run make and commit the local diff'; exit 1; )"
8796

88-
- name: Run promtool test
97+
- name: Wait for Grafana and validate dashboards
98+
working-directory: ./${{ matrix.mixin }}
99+
env:
100+
GRAFANA_URL: http://localhost:3000
101+
run: |
102+
# Wait for Grafana to be ready
103+
timeout 60s bash -c 'until curl -s http://localhost:3000/api/health | grep "ok"; do sleep 1; done'
104+
105+
# Try to deploy dashboards
106+
make deploy_dashboards
107+
108+
- name: Run promtool test for rules
89109
working-directory: ./${{ matrix.mixin }}
90110
run: make test

Makefile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ install-ci-deps: install-promtool
2323
go install github.com/google/go-jsonnet/cmd/[email protected]
2424
go install github.com/monitoring-mixins/mixtool/cmd/mixtool@main
2525
go install github.com/jsonnet-bundler/jsonnet-bundler/cmd/[email protected]
26+
go install github.com/grafana/grizzly/cmd/grr@latest
2627

2728
.PHONY: install-promtool
2829
install-promtool:
@@ -66,6 +67,14 @@ lint-mixins:
6667
done; \
6768
exit $$RESULT
6869

70+
update-mixins:
71+
@for d in $$(find . -maxdepth 1 -regex '.*-mixin\|.*-lib' -a -type d -print); do \
72+
if [ -e "$$d/jsonnetfile.json" ]; then \
73+
echo "Updating dependencies for $$d"; \
74+
pushd "$$d" >/dev/null && jb update && popd >/dev/null; \
75+
fi; \
76+
done
77+
6978
tests:
7079
pushd . && cd ./common-lib && make vendor && make tests
7180
pushd . && cd ./mixin-utils/test && make tests

Makefile_mixin

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ prometheus_rules.yaml: $(wildcard vendor/**/rules.yaml) $(wildcard vendor/**/rul
4545
.PHONY: test
4646
test:
4747
@if [ -f tests/prometheus_*.yaml ]; then \
48+
echo "Execute promtool tests:"; \
4849
promtool test rules tests/prometheus_*.yaml; \
4950
else \
5051
echo "No tests/prometheus_*.yaml files found, skipping promtool test."; \

consul-mixin/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include ../Makefile_mixin

consul-mixin/dashboards.libsonnet

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ local panel_settings = {
9292
g.queryPanel('sum(rate(consul_http_request{job=~"$job"}[$__rate_interval])) by (instance) / sum(rate(consul_http_request{job=~"$job"}[$__rate_interval])) by (instance)', 'Average') +
9393
{ yaxes: g.yaxes('ms') }
9494
)
95-
),
95+
) { editable: false },
96+
9697
},
98+
9799
}

0 commit comments

Comments
 (0)