diff --git a/k8s/monitoring/alerts-postgres.yaml b/k8s/monitoring/alerts-postgres.yaml new file mode 100644 index 0000000..1d5bc40 --- /dev/null +++ b/k8s/monitoring/alerts-postgres.yaml @@ -0,0 +1,20 @@ +apiVersion: monitoring.coreos.com/v1 +kind: PrometheusRule +metadata: + labels: + prometheus: k8s + role: alert-rules + name: postgres-operator-alerts + namespace: monitoring +spec: + groups: + - name: postgres-operator + rules: + - alert: PatroniHasNoLeader + expr: (max by (scope) (patroni_master) < 1) and (max by (scope) (patroni_standby_leader) < 1) + for: 0m + labels: + severity: critical + annotations: + summary: Patroni has no Leader (instance {{ $labels.instance }}) + description: "A leader node (neither primary nor standby) cannot be found inside the cluster {{ $labels.scope }}\n VALUE = {{ $value }}\n LABELS = {{ $labels }}" diff --git a/k8s/monitoring/kustomization.yaml b/k8s/monitoring/kustomization.yaml index c2061ad..750eaf8 100644 --- a/k8s/monitoring/kustomization.yaml +++ b/k8s/monitoring/kustomization.yaml @@ -2,6 +2,7 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization namespace: monitoring resources: + - alerts-postgres.yaml - promtail.yaml - ingresses.yaml - secrets.yaml