Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions .github/workflows/validate-prometheus-alerts.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# SPDX-FileCopyrightText: 2026 SAP SE or an SAP affiliate company and cobaltcore-dev contributors
# SPDX-License-Identifier: Apache-2.0

name: Validate Prometheus Alerts

on:
workflow_dispatch:
pull_request:
paths:
- 'charts/openstack-hypervisor-operator/alerts/*.yaml'
- 'charts/openstack-hypervisor-operator/alerts/*.yml'

permissions:
contents: read

env:
PROMTOOL_VERSION: 3.8.0

defaults:
run:
shell: bash

concurrency:
group: validate-prometheus-alerts-${{ github.ref }}
cancel-in-progress: true

jobs:
validate-alerts:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v6

- name: Install promtool
run: |
set -euo pipefail
curl -sSfL "https://github.com/prometheus/prometheus/releases/download/v${PROMTOOL_VERSION}/prometheus-${PROMTOOL_VERSION}.linux-amd64.tar.gz" \
| tar xz --strip-components=1 "prometheus-${PROMTOOL_VERSION}.linux-amd64/promtool"
sudo install -m 0755 promtool /usr/local/bin/promtool
promtool --version

- name: Validate Prometheus alert rules
run: |
set -euo pipefail
shopt -s nullglob
files=(charts/openstack-hypervisor-operator/alerts/*.{yaml,yml})
if [ ${#files[@]} -eq 0 ]; then
echo "No Prometheus rule files found."
exit 1
fi
promtool check rules "${files[@]}"
60 changes: 60 additions & 0 deletions charts/openstack-hypervisor-operator/alerts/operator.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# SPDX-FileCopyrightText: 2025 SAP SE or an SAP affiliate company and cobaltcore-dev contributors
# SPDX-License-Identifier: Apache-2.0

groups:
- name: hypervisorOperator
rules:
- alert: HypervisorNotReady
expr: |
kube_customresource_hypervisor_condition{condition="Ready"} == 0
for: 10m
labels:
severity: critical
type: hypervisor_operator
annotations:
summary: "Hypervisor {{`{{ $labels.name }}`}} is not ready"
description: "The hypervisor {{`{{ $labels.name }}`}} in zone {{`{{ $labels.zone }}`}} has been in a non-ready state for more than 10 minutes."
Comment thread
fwiesel marked this conversation as resolved.
Outdated

- alert: HypervisorConditionDegraded
expr: |
kube_customresource_hypervisor_condition{condition!="Ready"} == 0
Comment thread
fwiesel marked this conversation as resolved.
Outdated
for: 10m
labels:
severity: warning
type: hypervisor_operator
annotations:
summary: "Hypervisor {{`{{ $labels.name }}`}} condition {{`{{ $labels.condition }}`}} is degraded"
description: "The hypervisor {{`{{ $labels.name }}`}} in zone {{`{{ $labels.zone }}`}} has condition {{`{{ $labels.condition }}`}} in a False state for more than 10 minutes. Reason: {{`{{ $labels.reason }}`}}."

- alert: HypervisorEvicted
expr: |
kube_customresource_hypervisor_evicted == 1
for: 2d
labels:
severity: warning
type: hypervisor_operator
annotations:
summary: "Hypervisor {{`{{ $labels.name }}`}} has been evicted"
description: "The hypervisor {{`{{ $labels.name }}`}} in zone {{`{{ $labels.zone }}`}} has been in an evicted state for more than 2 days."
Comment thread
fwiesel marked this conversation as resolved.
Outdated

- alert: HypervisorOperatorReconcileErrors
expr: |
rate(controller_runtime_reconcile_errors_total[5m]) > 0
for: 15m
labels:
severity: warning
type: hypervisor_operator
annotations:
summary: "Hypervisor operator controller {{`{{ $labels.controller }}`}} has persistent reconcile errors"
description: "The controller {{`{{ $labels.controller }}`}} has been producing reconciliation errors for more than 15 minutes."

- alert: HypervisorOperatorDown
expr: |
up{job=~".*hypervisor-operator.*"} == 0
for: 5m
labels:
severity: critical
type: hypervisor_operator
annotations:
summary: "Hypervisor operator is down"
description: "The hypervisor operator metrics endpoint has been unreachable for more than 5 minutes."
Loading
Loading