From d6b0ef6522731a8bf94ce6ea334b240a3477d3ab Mon Sep 17 00:00:00 2001 From: Alex Lebens Date: Fri, 26 Dec 2025 21:53:50 -0600 Subject: [PATCH] add namespace to alerts --- .../prometheus_rules/cluster-backends_waiting-warning.yaml | 2 +- .../cluster-database_deadlock_conflicts-warning.yaml | 2 +- .../cluster-last_failed_archive_time-warning.yaml | 2 +- .../cluster-long_running_transaction-warning.yaml | 2 +- .../prometheus_rules/cluster-pg_database_xid_age-warning.yaml | 2 +- .../cluster-replica_failing_replication-warning.yaml | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/charts/postgres-cluster/prometheus_rules/cluster-backends_waiting-warning.yaml b/charts/postgres-cluster/prometheus_rules/cluster-backends_waiting-warning.yaml index 762d121..3838cc9 100644 --- a/charts/postgres-cluster/prometheus_rules/cluster-backends_waiting-warning.yaml +++ b/charts/postgres-cluster/prometheus_rules/cluster-backends_waiting-warning.yaml @@ -7,7 +7,7 @@ annotations: Pod {{`{{`}} $labels.pod {{`}}`}} has been waiting for longer than 5 minutes expr: | - cnpg_backends_waiting_total > 300 + cnpg_backends_waiting_total{namespace="{{ .namespace }}"} > 300 for: 1m labels: severity: warning diff --git a/charts/postgres-cluster/prometheus_rules/cluster-database_deadlock_conflicts-warning.yaml b/charts/postgres-cluster/prometheus_rules/cluster-database_deadlock_conflicts-warning.yaml index ca934fa..bc99c16 100644 --- a/charts/postgres-cluster/prometheus_rules/cluster-database_deadlock_conflicts-warning.yaml +++ b/charts/postgres-cluster/prometheus_rules/cluster-database_deadlock_conflicts-warning.yaml @@ -7,7 +7,7 @@ annotations: There are over 10 deadlock conflicts in {{`{{`}} $labels.pod {{`}}`}} expr: | - cnpg_pg_stat_database_deadlocks > 10 + cnpg_pg_stat_database_deadlocks{namespace="{{ .namespace }}"} > 10 for: 1m labels: severity: warning diff --git a/charts/postgres-cluster/prometheus_rules/cluster-last_failed_archive_time-warning.yaml b/charts/postgres-cluster/prometheus_rules/cluster-last_failed_archive_time-warning.yaml index c26f10f..52ab0bd 100644 --- a/charts/postgres-cluster/prometheus_rules/cluster-last_failed_archive_time-warning.yaml +++ b/charts/postgres-cluster/prometheus_rules/cluster-last_failed_archive_time-warning.yaml @@ -6,7 +6,7 @@ annotations: description: |- Archiving failed for {{`{{`}} $labels.pod {{`}}`}} expr: | - (cnpg_pg_stat_archiver_last_failed_time - cnpg_pg_stat_archiver_last_archived_time) > 2 + (cnpg_pg_stat_archiver_last_failed_time{namespace="{{ .namespace }}"} - cnpg_pg_stat_archiver_last_archived_time{namespace="{{ .namespace }}"}) > 2 for: 1m labels: severity: warning diff --git a/charts/postgres-cluster/prometheus_rules/cluster-long_running_transaction-warning.yaml b/charts/postgres-cluster/prometheus_rules/cluster-long_running_transaction-warning.yaml index a41b85a..1bcdaf5 100644 --- a/charts/postgres-cluster/prometheus_rules/cluster-long_running_transaction-warning.yaml +++ b/charts/postgres-cluster/prometheus_rules/cluster-long_running_transaction-warning.yaml @@ -7,7 +7,7 @@ annotations: CloudNativePG Cluster Pod {{`{{`}} $labels.pod {{`}}`}} is taking more than 5 minutes (300 seconds) for a query. expr: |- - cnpg_backends_max_tx_duration_seconds > 300 + cnpg_backends_max_tx_duration_seconds{namespace="{{ .namespace }}"} > 300 for: 1m labels: severity: warning diff --git a/charts/postgres-cluster/prometheus_rules/cluster-pg_database_xid_age-warning.yaml b/charts/postgres-cluster/prometheus_rules/cluster-pg_database_xid_age-warning.yaml index 056b58f..eceba89 100644 --- a/charts/postgres-cluster/prometheus_rules/cluster-pg_database_xid_age-warning.yaml +++ b/charts/postgres-cluster/prometheus_rules/cluster-pg_database_xid_age-warning.yaml @@ -7,7 +7,7 @@ annotations: Over 300,000,000 transactions from frozen xid on pod {{`{{`}} $labels.pod {{`}}`}} expr: | - cnpg_pg_database_xid_age > 300000000 + cnpg_pg_database_xid_age{namespace="{{ .namespace }}"} > 300000000 for: 1m labels: severity: warning diff --git a/charts/postgres-cluster/prometheus_rules/cluster-replica_failing_replication-warning.yaml b/charts/postgres-cluster/prometheus_rules/cluster-replica_failing_replication-warning.yaml index 529f3b2..9d7d690 100644 --- a/charts/postgres-cluster/prometheus_rules/cluster-replica_failing_replication-warning.yaml +++ b/charts/postgres-cluster/prometheus_rules/cluster-replica_failing_replication-warning.yaml @@ -7,7 +7,7 @@ annotations: Replica {{`{{`}} $labels.pod {{`}}`}} is failing to replicate expr: | - cnpg_pg_replication_in_recovery > cnpg_pg_replication_is_wal_receiver_up + cnpg_pg_replication_in_recovery{namespace="{{ .namespace }}"} > cnpg_pg_replication_is_wal_receiver_up{namespace="{{ .namespace }}"} for: 1m labels: severity: warning