mirror of
https://github.com/samber/awesome-prometheus-alerts.git
synced 2026-06-21 00:47:18 +08:00
54 lines
1.9 KiB
YAML
54 lines
1.9 KiB
YAML
name: Promtool check
|
|
|
|
on:
|
|
pull_request:
|
|
push:
|
|
branches:
|
|
- master
|
|
|
|
jobs:
|
|
promtool-check:
|
|
name: Check alert rules syntax
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout Repo
|
|
uses: actions/checkout@v6
|
|
|
|
- name: Set up Ruby
|
|
uses: ruby/setup-ruby@v1
|
|
with:
|
|
ruby-version: 3.4
|
|
|
|
- name: Set up yq
|
|
uses: mikefarah/yq@v4
|
|
|
|
- name: Install liquid
|
|
run: gem install liquid-cli
|
|
|
|
- name: Build rule configuration
|
|
run: |
|
|
cat _data/rules.yml | yq -I 0 -o json > _data/rules.json
|
|
|
|
for service in $(cat _data/rules.json | jq -r '.groups[].services[] | @base64'); do
|
|
subdir=test/rules/$(echo ${service} | base64 --decode | jq -r '.name | ascii_downcase | split(" ") | join("-")')
|
|
mkdir -p "${subdir}"
|
|
|
|
# groupName=$(echo "{% assign groupName = name | split: ' ' %}{% capture groupNameCamelcase %}{% for word in groupName %}{{ word | capitalize }} {% endfor %}{% endcapture %} {{ groupNameCamelcase | remove: ' ' | remove: '-' }}" | liquid $(echo ${service} | base64 --decode | jq -r '.name | ascii_downcase | split(" ") | join("-")'))
|
|
|
|
for exporter in $(echo ${service} | base64 --decode | jq -r '.exporters[] | @base64'); do
|
|
exporterName=$(echo ${exporter} | base64 --decode | jq -r '.slug')
|
|
cat dist/template.yml | liquid "$(echo ${exporter} | base64 --decode)" > ${subdir}/${exporterName}.yml
|
|
echo ${subdir}/${exporterName}.yml
|
|
done
|
|
done
|
|
|
|
rm _data/rules.json
|
|
|
|
- name: Check Prometheus alert rules
|
|
uses: peimanja/promtool-github-actions@master
|
|
with:
|
|
promtool_actions_subcommand: 'rules'
|
|
promtool_actions_files: 'test/rules/*/*.yml'
|
|
promtool_actions_comment: true
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|