The current settings metric SQL returns many configuration values as text.
Because pgwatch automatically converts SQL result sets into Prometheus metrics:
- text columns → labels
- numeric columns → metric values
this causes configuration parameters to be exported as labels instead of values.
Example (simplified SQL result):
name | setting
------------------+----------
lock_timeout | 100 (ms)
shared_buffers | 128MB
archive_mode | off
After automatic conversion, this becomes something like:
pgwatch_settings_server_version_num{
lock_timeout="100 (ms)",
shared_buffers="128MB",
archive_mode="off",
...
} 180000
This leads to:
- Cardinality explosion
- New time series on every config change
- Stale series accumulation
- Difficult aggregation
- Unintuitive promql query behavior
Proposed solution should use this trick:
select
name,
case vartype when
'integer' then setting::int
else
case setting when 'on' then 1 else 0 end
end
from pg_settings
where vartype in ('bool', 'integer')
The current
settingsmetric SQL returns many configuration values as text.Because pgwatch automatically converts SQL result sets into Prometheus metrics:
this causes configuration parameters to be exported as labels instead of values.
Example (simplified SQL result):
After automatic conversion, this becomes something like:
This leads to:
Proposed solution should use this trick: