Files
claudeandClaude Opus 5.5 bba0d30f53 Add kube-state-metrics and CI runner alerts
Deploy kube-state-metrics v2.16.0 in the prometheus namespace with a
read-only ClusterRole limited to the resources it watches, scrape it, and
add an eom-ci alert group: runner not ready, runner container restarted,
runner pod replaced, runner evicted, node DiskPressure, and Gitea down.
The rules pass promtool unit tests, both as written and after rendering
through the Bitnami chart's tpl.

Refs DevOps/software-infrastructure#40

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 20:02:16 -05:00

120 lines
6.3 KiB
YAML
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Prometheus alerting rules for eom.dev, rendered into the chart's rules.yaml.
# The chart passes alertingRules through Helm's tpl, so every Prometheus template
# is wrapped as {{`{{ ... }}`}} to reach Prometheus unchanged. Ansible reads this
# file with lookup('file'), which it does not template.
# Disk and RAM thresholds are covered by Grafana-managed rules, so they're not repeated here.
groups:
- name: eom-availability
rules:
- alert: SiteDown
expr: probe_success{job="blackbox"} == 0 and (probe_http_status_code{job="blackbox"} == 0 or probe_http_status_code{job="blackbox"} >= 500)
for: 5m
labels:
severity: critical
annotations:
summary: '{{`{{ $labels.instance }}`}} is down'
description: 'The HTTPS probe of {{`{{ $labels.instance }}`}} has failed with a connection error or a 5xx for 5 minutes. 2xx/3xx/4xx count as up (logins and redirects).'
- alert: CertificateExpiringSoon
expr: (probe_ssl_earliest_cert_expiry{job="blackbox"} - time()) / 86400 < 14
for: 1h
labels:
severity: warning
annotations:
summary: 'TLS certificate for {{`{{ $labels.instance }}`}} expires in {{`{{ $value | printf "%.0f" }}`}} days'
description: 'cert-manager should have renewed it 30 days before expiry; check the Certificate and its CertificateRequest.'
- alert: ScrapeTargetDown
expr: up == 0
for: 15m
labels:
severity: warning
annotations:
summary: 'Prometheus cannot scrape {{`{{ $labels.instance }}`}} (job {{`{{ $labels.job }}`}})'
description: 'The exporter or the host itself is unreachable. Known on 2026-11-07: node_exporter on poweredge-r350 and alpha-control-plane, and the www and nextcloud exporters.'
- name: eom-hardware
rules:
- alert: GpuOverheating
expr: DCGM_FI_DEV_GPU_TEMP >= 85
for: 10m
labels:
severity: critical
annotations:
summary: '{{`{{ $labels.modelName }}`}} on {{`{{ $labels.Hostname }}`}} is at {{`{{ $value }}`}} °C'
description: 'The GPU has been at or above 85 °C for 10 minutes and is throttling (LocalAI slows 4–5x). Pause LocalAI agents or reduce load, and fix airflow over the card.'
- alert: HostOverheating
expr: max by (instance) (node_hwmon_temp_celsius) >= 85
for: 15m
labels:
severity: warning
annotations:
summary: '{{`{{ $labels.instance }}`}} sensor at {{`{{ $value }}`}} °C'
description: 'A hardware temperature sensor has been at or above 85 °C for 15 minutes.'
- alert: HostRebooted
expr: time() - node_boot_time_seconds < 900
labels:
severity: info
annotations:
summary: '{{`{{ $labels.instance }}`}} rebooted {{`{{ $value | humanizeDuration }}`}} ago'
description: 'Unexpected? Check the host and power logs. This alert clears 15 minutes after boot.'
# CI/CD 0, S7 (DevOps/software-infrastructure#40). Needs kube-state-metrics.
- name: eom-ci
rules:
- alert: GiteaRunnerNotReady
expr: >-
kube_statefulset_replicas{namespace="gitea", statefulset="gitea-actions-runner"}
- kube_statefulset_status_replicas_ready{namespace="gitea", statefulset="gitea-actions-runner"} > 0
for: 10m
labels:
severity: critical
annotations:
summary: 'The Gitea Actions runner has not been ready for 10 minutes'
description: 'No CI jobs can run. Check the pod with kubectl describe and its events (Pending, crash loop, or a missing node label). Runbook: docs/ci-cd/runner.md.'
- alert: GiteaRunnerRestarted
expr: >-
sum by (namespace, pod, container) (increase(kube_pod_container_status_restarts_total{namespace="gitea", pod=~"gitea-actions-runner-.*"}[15m])) > 0
labels:
severity: warning
annotations:
summary: 'Runner container {{`{{ $labels.container }}`}} restarted'
description: 'Jobs that were running on the runner were lost. Check the previous container log with kubectl logs --previous.'
- alert: GiteaRunnerPodReplaced
# A replaced pod keeps its name but gets a new uid, so it shows up as a
# second kube_pod_created series for the same pod name within the window.
expr: >-
count by (namespace, pod) (max_over_time(kube_pod_created{namespace="gitea", pod=~"gitea-actions-runner-.*"}[15m])) > 1
or
changes(kube_pod_created{namespace="gitea", pod=~"gitea-actions-runner-.*"}[15m]) > 0
labels:
severity: warning
annotations:
summary: 'The runner pod {{`{{ $labels.pod }}`}} was replaced'
description: 'The pod was deleted, evicted or rescheduled, and any running jobs were lost. Expected after a runner deploy; otherwise check the events and GiteaRunnerEvicted.'
- alert: GiteaRunnerEvicted
expr: >-
max by (namespace, pod) (max_over_time(kube_pod_status_reason{namespace="gitea", pod=~"gitea-actions-runner-.*", reason="Evicted"}[15m])) > 0
labels:
severity: critical
annotations:
summary: 'The runner pod {{`{{ $labels.pod }}`}} was evicted'
description: 'Usually the node ran short of disk or memory. Running jobs died without a step error. Check the node conditions and the runner Docker storage.'
- alert: NodeDiskPressure
expr: kube_node_status_condition{condition="DiskPressure", status="true"} == 1
for: 5m
labels:
severity: warning
annotations:
summary: '{{`{{ $labels.node }}`}} reports DiskPressure'
description: 'The kubelet will evict pods from this node until disk usage drops. Free space or move workloads.'
- alert: GiteaDown
expr: >-
kube_deployment_status_replicas_available{namespace="gitea", deployment="gitea"} < 1
or
absent(kube_deployment_status_replicas_available{namespace="gitea", deployment="gitea"})
for: 5m
labels:
severity: critical
annotations:
summary: 'Gitea has no available pod'
description: 'Git, the web UI, the API and CI are all down. SiteDown covers the public URL; this alert covers the pod itself.'