Files
cozystack/packages/system
Andrei Kvapil 712c01419e fix(postgres-operator): correct PromQL syntax in CNPGClusterOffline alert (#1981)
## Summary
- Fix invalid PromQL expression in `CNPGClusterOffline` alert rule that
causes vmalert pods to crash
- Fix PromQL logic so the alert fires correctly when cluster is offline

## Problem
The `CNPGClusterOffline` alert in
`packages/system/postgres-operator/alerts/cnpg-default-alerts.yaml` had
two issues:

1. **Syntax error** - Extra closing parenthesis causing vmalert pods to
crash:
```promql
sum by (namespace, pod) (cnpg_collector_up)) OR on() vector(0) == 0
                                           ^^-- extra )
```

2. **Logic error** - After removing the extra parenthesis, the
expression still had incorrect logic:
```promql
sum by (namespace, pod) (cnpg_collector_up) OR on() vector(0) == 0
```
This evaluates as `cnpg_collector_up OR (vector(0) == 0)` which fires
when the cluster is **online** (wrong behavior).

## Solution
Fix both issues by properly wrapping the OR expression in parentheses:
```promql
(sum by (namespace, pod) (cnpg_collector_up) OR on() vector(0)) == 0
```

This correctly fires when `cnpg_collector_up` is 0 or absent (cluster
actually offline).

## Test plan
- [ ] Verify vmalert pods start successfully after applying the fix
- [ ] Verify the alert rule is properly loaded
- [ ] Verify alert only fires when CNPG cluster is actually offline

🤖 Generated with [Claude Code](https://claude.com/claude-code)
2026-02-05 20:25:20 +01:00
..
2026-02-02 12:34:58 +00:00
2026-01-20 07:50:59 +00:00
2026-02-04 14:53:28 +03:00
2026-01-20 03:24:32 +01:00
2026-02-02 12:34:58 +00:00
2026-02-02 12:34:58 +00:00
2026-02-02 12:34:58 +00:00
2026-01-20 03:24:32 +01:00
2026-01-15 23:32:41 +00:00
2026-01-20 03:24:32 +01:00
2026-01-20 03:24:32 +01:00
2026-02-02 12:34:58 +00:00