Skip to content

Commit d1b0364

Browse files
Merge branch 'master' into dashboard-utils
2 parents ad99fbe + 0033f1d commit d1b0364

File tree

1,627 files changed

+613982
-61960
lines changed

Some content is hidden

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

1,627 files changed

+613982
-61960
lines changed

.drone/drone.jsonnet

Lines changed: 0 additions & 26 deletions
This file was deleted.

.drone/drone.yml

Lines changed: 0 additions & 19 deletions
This file was deleted.

.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/build.yml

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
---
2+
name: Build
3+
4+
permissions:
5+
contents: read
6+
7+
on:
8+
push:
9+
branches:
10+
- main
11+
- master
12+
pull_request:
13+
14+
jobs:
15+
setup:
16+
name: Setup tools
17+
runs-on: ubuntu-latest
18+
outputs:
19+
cache-hit: ${{ steps.tools-cache.outputs.cache-hit }}
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v4
23+
with:
24+
fetch-depth: 0
25+
- name: Setup Go
26+
uses: actions/setup-go@v5
27+
with:
28+
go-version: 1.23
29+
- name: Tools cache
30+
id: tools-cache
31+
uses: actions/cache@v4
32+
with:
33+
path: |
34+
~/go/bin
35+
/usr/local/bin/promtool
36+
key: ${{ runner.os }}-tools-${{ hashFiles('Makefile') }}
37+
- name: Install CI dependencies
38+
if: steps.tools-cache.outputs.cache-hit != 'true'
39+
run: make install-ci-deps
40+
41+
lint-fmt:
42+
name: Lint and Format
43+
needs: setup
44+
runs-on: ubuntu-latest
45+
steps:
46+
- name: Checkout
47+
uses: actions/checkout@v4
48+
with:
49+
fetch-depth: 0
50+
- name: Setup Go
51+
uses: actions/setup-go@v5
52+
with:
53+
go-version: 1.23
54+
- name: Restore Tools cache
55+
uses: actions/cache@v4
56+
with:
57+
path: |
58+
~/go/bin
59+
/usr/local/bin/promtool
60+
key: ${{ runner.os }}-tools-${{ hashFiles('Makefile') }}
61+
- name: Lint and Format
62+
run: make lint-fmt
63+
64+
tests:
65+
name: Run Tests
66+
needs: setup
67+
runs-on: ubuntu-latest
68+
steps:
69+
- name: Checkout
70+
uses: actions/checkout@v4
71+
with:
72+
fetch-depth: 0
73+
- name: Setup Go
74+
uses: actions/setup-go@v5
75+
with:
76+
go-version: 1.23
77+
- name: Restore Tools cache
78+
uses: actions/cache@v4
79+
with:
80+
path: |
81+
~/go/bin
82+
/usr/local/bin/promtool
83+
key: ${{ runner.os }}-tools-${{ hashFiles('Makefile') }}
84+
- name: Run Tests
85+
run: make tests

.github/workflows/test-mixins.yml

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
---
2+
name: Mixin
3+
4+
permissions:
5+
contents: read
6+
7+
on:
8+
# To conserve resources we only run tests against main in PRs
9+
pull_request:
10+
branches:
11+
- master
12+
13+
jobs:
14+
setup:
15+
name: Setup tools
16+
runs-on: ubuntu-latest
17+
outputs:
18+
cache-hit: ${{ steps.tools-cache.outputs.cache-hit }}
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
with:
23+
fetch-depth: 0
24+
- name: Setup Go
25+
uses: actions/setup-go@v5
26+
with:
27+
go-version: 1.23
28+
- name: Tools cache
29+
id: tools-cache
30+
uses: actions/cache@v4
31+
with:
32+
path: |
33+
~/go/bin
34+
/usr/local/bin/promtool
35+
key: ${{ runner.os }}-tools-${{ hashFiles('Makefile') }}
36+
- name: Install CI dependencies
37+
if: steps.tools-cache.outputs.cache-hit != 'true'
38+
run: make install-ci-deps
39+
40+
check-for-changed-mixins:
41+
name: Check for changes
42+
needs: setup
43+
runs-on: ubuntu-latest
44+
outputs:
45+
changed-mixins: ${{ steps.changed-mixins.outputs.all_changed_files }}
46+
steps:
47+
- name: Checkout
48+
uses: actions/checkout@v4
49+
with:
50+
fetch-depth: 0
51+
- name: Get changed mixins
52+
id: changed-mixins
53+
uses: step-security/changed-files@3dbe17c78367e7d60f00d78ae6781a35be47b4a1 # v45.0.1
54+
with:
55+
dir_names: true
56+
dir_names_exclude_current_dir: true
57+
dir_names_max_depth: 1
58+
files: |
59+
**-mixin/
60+
**-observ-lib/
61+
matrix: true
62+
- name: List all changed mixins
63+
run: echo '${{ steps.changed-mixins.outputs.all_changed_files }}'
64+
65+
lint-mixin:
66+
name: Test mixin
67+
runs-on: ubuntu-latest
68+
permissions:
69+
issues: write
70+
contents: write
71+
pull-requests: write
72+
repository-projects: write
73+
timeout-minutes: 15
74+
needs: [setup, check-for-changed-mixins]
75+
strategy:
76+
matrix:
77+
mixin: ${{ fromJSON(needs.check-for-changed-mixins.outputs.changed-mixins) }}
78+
fail-fast: false
79+
services:
80+
grafana:
81+
image: grafana/grafana:11.4.0
82+
ports:
83+
- 3000:3000
84+
env:
85+
GF_AUTH_DISABLE_LOGIN_FORM: "true"
86+
GF_AUTH_ANONYMOUS_ENABLED: "true"
87+
GF_AUTH_ANONYMOUS_ORG_ROLE: "Admin"
88+
steps:
89+
- name: Checkout
90+
uses: actions/checkout@v4
91+
with:
92+
fetch-depth: 0
93+
- name: Setup Go
94+
uses: actions/setup-go@v5
95+
with:
96+
go-version: 1.23
97+
- name: Restore Tools cache
98+
uses: actions/cache@v4
99+
with:
100+
path: |
101+
~/go/bin
102+
/usr/local/bin/promtool
103+
key: ${{ runner.os }}-tools-${{ hashFiles('Makefile') }}
104+
- name: Install mixin dependencies
105+
working-directory: ./${{ matrix.mixin }}
106+
run: make build
107+
- name: Lint mixin
108+
working-directory: ./${{ matrix.mixin }}
109+
run: make lint
110+
- name: Check for unexpected changes in generated files
111+
working-directory: ./${{ matrix.mixin }}
112+
run: "make -B dashboards_out prometheus_alerts.yaml prometheus_rules.yaml && git diff --exit-code || ( echo 'Error: Generated files are not up to date. Run make and commit the local diff'; exit 1; )"
113+
- name: Wait for Grafana and validate dashboards
114+
working-directory: ./${{ matrix.mixin }}
115+
env:
116+
GRAFANA_URL: http://localhost:3000
117+
run: |
118+
# Wait for Grafana to be ready
119+
timeout 60s bash -c 'until curl -s http://localhost:3000/api/health | grep "ok"; do sleep 1; done'
120+
121+
# Try to deploy dashboards
122+
make deploy_dashboards
123+
- name: Run promtool test for rules
124+
working-directory: ./${{ matrix.mixin }}
125+
run: make test

.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

.scripts/.lint.base.merge.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
# This script merges the content of .lint.base.yaml file into all mixin dirs (as a .lint) file.
6+
7+
# Search for directories containing mixin.libsonnet files
8+
directories=$(find . -type f -name 'mixin.libsonnet' -exec dirname {} \;)
9+
10+
# Iterate through the found directories
11+
for dir in $directories; do
12+
lint_file="$dir/.lint"
13+
lint_base_file=".lint.base.yaml"
14+
15+
# Check if a .lint file exists in the directory
16+
if [ -f "$lint_file" ]; then
17+
# Merge .lint and .lint.base.yaml using yq
18+
yq eval-all 'select(fileIndex == 0) * select(fileIndex == 1)' "$lint_base_file" "$lint_file" > "$lint_file.tmp"
19+
20+
# Replace the original .lint file with the merged content
21+
mv "$lint_file.tmp" "$lint_file"
22+
echo "Merged $lint_file with $lint_base_file"
23+
else
24+
# If .lint file doesn't exist, create it with the content of .lint.base.yaml
25+
cp "$lint_base_file" "$lint_file"
26+
echo "Created $lint_file from $lint_base_file"
27+
fi
28+
done

.scripts/.lint.base.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
exclusions:
2+
panel-title-description-rule:
3+
reason: "mixtool upgrade made this rule stricter. TODO: Fix errors and remove the warning exclusion"
4+
panel-units-rule:
5+
reason: "mixtool upgrade made this rule stricter. TODO: Fix errors and remove the warning exclusion"
6+
template-datasource-rule:
7+
reason: "mixtool upgrade made this rule stricter. TODO: Fix errors and remove the warning exclusion"
8+
template-instance-rule:
9+
reason: "mixtool upgrade made this rule stricter. TODO: Fix errors and remove the warning exclusion"
10+
template-job-rule:
11+
reason: "mixtool upgrade made this rule stricter. TODO: Fix errors and remove the warning exclusion"
12+
template-on-time-change-reload-rule:
13+
reason: "mixtool upgrade made this rule stricter. TODO: Fix errors and remove the warning exclusion"
14+
target-instance-rule:
15+
reason: "mixtool upgrade made this rule stricter. TODO: Fix errors and remove the warning exclusion"
16+
target-job-rule:
17+
reason: "mixtool upgrade made this rule stricter. TODO: Fix errors and remove the warning exclusion"
18+
target-promql-rule:
19+
reason: "mixtool upgrade made this rule stricter. TODO: Fix errors and remove the warning exclusion"
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
# This script iterates over all .lint files and remove all no-op exclusions (that don't affect the linting result)
6+
7+
# Find all directories containing .lint files
8+
lint_dirs=$(find . -type f -name '.lint' -exec dirname {} \;)
9+
10+
for dir in $lint_dirs; do
11+
lint_file="$dir/.lint"
12+
lint_backup="$dir/.lint.bak"
13+
14+
# Get the keys of the "exclusions" map using yq
15+
exclusions_keys=$(yq eval '.exclusions | keys | .[]' "$lint_file")
16+
17+
for key in $exclusions_keys; do
18+
# Create a backup of the .lint file
19+
cp "$lint_file" "$lint_backup"
20+
21+
# Remove the current key from the "exclusions" map using yq
22+
yq eval "del(.exclusions.$key)" "$lint_file" -i
23+
24+
# Check if the mixtool lint command still works
25+
if mixtool lint -J "$dir/vendor" "$dir/mixin.libsonnet" &> /dev/null; then
26+
echo "Key '$key' removed successfully from $lint_file"
27+
else
28+
# Revert the .lint file to its original state
29+
cp "$lint_backup" "$lint_file"
30+
echo "Reverted $lint_file to its original state due to removal of key '$key'"
31+
fi
32+
33+
# Remove the backup file
34+
rm "$lint_backup"
35+
done
36+
done

.scripts/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Scripts
2+
3+
Collection of bash scripts that may be useful (or have been in the past) when managing this repository

0 commit comments

Comments
 (0)