Skip to content

Commit 820d253

Browse files
committed
fix: remove pg_stat_statements from Prometheus sink to prevent cardinality explosion
pg_stat_statements collected via pgwatch-prometheus was creating 30K+ series in VictoriaMetrics (one per queryid × 16 counter fields), causing query timeouts and excessive resource usage. This data is already handled by flask-pgss-api via the Postgres sink, making the Prometheus collection redundant. Changes: - Remove pg_stat_statements from the 'full' preset in pgwatch-prometheus metrics - Reduce pgwatch-prometheus CPU from 1.5 to 0.5 and RAM from 1024m to 512m (pg_stat_statements was the main CPU driver) - Update comments to document the architecture decision https://claude.ai/code/session_01SzJxzZNQjDQphaHyaX3RU7
1 parent 1e82023 commit 820d253

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

config/pgwatch-prometheus/metrics.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2532,7 +2532,8 @@ presets:
25322532
pg_stat_all_tables: 30
25332533
pg_class: 30
25342534
pg_stat_all_indexes: 30
2535-
pg_stat_statements: 30
2535+
# pg_stat_statements removed: handled by flask-pgss-api via Postgres sink
2536+
# Collecting per-queryid metrics here caused 30K+ series cardinality explosion
25362537
pg_stat_replication: 30
25372538
pg_stat_slru: 30
25382539
pg_statio_all_tables: 30

docker-compose.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
# Total allocation: ~5.1 vCPUs, ~7.6 GiB RAM (with headroom for host OS).
33
# CPU overcommitment is intentional - containers rarely hit limits simultaneously.
44
#
5-
# pgwatch-prometheus gets higher CPU (1.5) to handle pg_stat_statements load,
6-
# which was observed spiking to 150%+ under heavy query workloads.
5+
# pgwatch-prometheus gets higher CPU (1.5) to handle metric collection load.
6+
# Note: pg_stat_statements is NOT collected here (handled by flask-pgss-api
7+
# via the Postgres sink) to avoid cardinality explosion in VictoriaMetrics.
78

89
services:
910
# Config Initializer - Copies static configs from image to volume
@@ -139,8 +140,8 @@ services:
139140
build:
140141
context: ./pgwatch
141142
container_name: pgwatch-prometheus
142-
cpus: 1.5
143-
mem_limit: 1024m
143+
cpus: 0.5
144+
mem_limit: 512m
144145
command:
145146
[
146147
"--sources=/postgres_ai_configs/pgwatch-prometheus/sources.yml",

0 commit comments

Comments
 (0)