feat: initial alert rules

This commit is contained in:
2026-06-15 17:17:06 +02:00
parent eab99f7a00
commit b48ff0d8a1
7 changed files with 288 additions and 0 deletions
+33
View File
@@ -0,0 +1,33 @@
name: Deploy alert rules
on:
push:
branches: [main]
paths:
- 'rules/**'
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup kubectl
uses: azure/setup-kubectl@v3
with:
version: 'v1.29.0'
- name: Configure kubeconfig
run: |
mkdir -p $HOME/.kube
echo "${{ secrets.KUBECONFIG }}" | base64 -d > $HOME/.kube/config
chmod 600 $HOME/.kube/config
- name: Deploy rules
run: kubectl apply -f rules/ -n monitoring
- name: Verify
run: |
sleep 10
kubectl get prometheusrule -n monitoring
+33
View File
@@ -0,0 +1,33 @@
name: Validate alert rules
on:
pull_request:
paths:
- 'rules/**'
jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install promtool
run: |
PROM_VERSION="2.51.0"
wget -q https://github.com/prometheus/prometheus/releases/download/v${PROM_VERSION}/prometheus-${PROM_VERSION}.linux-amd64.tar.gz
tar xf prometheus-*.tar.gz
sudo mv prometheus-*/promtool /usr/local/bin/
- name: Validate rules
run: |
for f in rules/*.yaml; do
echo "→ Validation de $f"
python3 -c "
import yaml, sys
with open('$f') as fh:
doc = yaml.safe_load(fh)
groups = doc.get('spec', doc).get('groups', [])
print(yaml.dump({'groups': groups}))
" > /tmp/rules-flat.yaml
promtool check rules /tmp/rules-flat.yaml
done