mirror of
https://github.com/neondatabase/neon.git
synced 2025-12-27 16:12:56 +00:00
Fix some sql_exporter metrics for PG 17
Checkpointer related statistics moved from pg_stat_bgwriter to pg_stat_checkpointer, so we need to adjust our queries accordingly. Signed-off-by: Tristan Partin <tristan@neon.tech>
This commit is contained in:
@@ -1221,12 +1221,13 @@ RUN rm /usr/local/pgsql/lib/lib*.a
|
||||
#
|
||||
#########################################################################################
|
||||
FROM $REPOSITORY/$IMAGE:$TAG AS sql_exporter_preprocessor
|
||||
ARG PG_VERSION
|
||||
|
||||
USER nonroot
|
||||
|
||||
COPY --chown=nonroot compute compute
|
||||
|
||||
RUN make -C compute
|
||||
RUN make PG_VERSION="${PG_VERSION}" -C compute
|
||||
|
||||
#########################################################################################
|
||||
#
|
||||
|
||||
@@ -6,13 +6,15 @@ jsonnet_files = $(wildcard \
|
||||
all: neon_collector.yml neon_collector_autoscaling.yml sql_exporter.yml sql_exporter_autoscaling.yml
|
||||
|
||||
neon_collector.yml: $(jsonnet_files)
|
||||
JSONNET_PATH=etc jsonnet \
|
||||
JSONNET_PATH=jsonnet:etc jsonnet \
|
||||
--output-file etc/$@ \
|
||||
--ext-str pg_version=$(PG_VERSION) \
|
||||
etc/neon_collector.jsonnet
|
||||
|
||||
neon_collector_autoscaling.yml: $(jsonnet_files)
|
||||
JSONNET_PATH=etc jsonnet \
|
||||
JSONNET_PATH=jsonnet:etc jsonnet \
|
||||
--output-file etc/$@ \
|
||||
--ext-str pg_version=$(PG_VERSION) \
|
||||
etc/neon_collector_autoscaling.jsonnet
|
||||
|
||||
sql_exporter.yml: $(jsonnet_files)
|
||||
|
||||
1
compute/etc/sql_exporter/checkpoints_req.17.sql
Normal file
1
compute/etc/sql_exporter/checkpoints_req.17.sql
Normal file
@@ -0,0 +1 @@
|
||||
SELECT num_requested AS checkpoints_req FROM pg_stat_checkpointer;
|
||||
@@ -1,3 +1,8 @@
|
||||
local neon = import 'neon.libsonnet';
|
||||
|
||||
local pg_stat_bgwriter = importstr 'sql_exporter/checkpoints_req.sql';
|
||||
local pg_stat_checkpointer = importstr 'sql_exporter/checkpoints_req.17.sql';
|
||||
|
||||
{
|
||||
metric_name: 'checkpoints_req',
|
||||
type: 'gauge',
|
||||
@@ -6,5 +11,5 @@
|
||||
values: [
|
||||
'checkpoints_req',
|
||||
],
|
||||
query: importstr 'sql_exporter/checkpoints_req.sql',
|
||||
query: if neon.PG_MAJORVERSION_NUM < 17 then pg_stat_bgwriter else pg_stat_checkpointer,
|
||||
}
|
||||
|
||||
1
compute/etc/sql_exporter/checkpoints_timed.17.sql
Normal file
1
compute/etc/sql_exporter/checkpoints_timed.17.sql
Normal file
@@ -0,0 +1 @@
|
||||
SELECT num_timed AS checkpoints_timed FROM pg_stat_checkpointer;
|
||||
@@ -1,3 +1,8 @@
|
||||
local neon = import 'neon.libsonnet';
|
||||
|
||||
local pg_stat_bgwriter = importstr 'sql_exporter/checkpoints_req.sql';
|
||||
local pg_stat_checkpointer = importstr 'sql_exporter/checkpoints_req.17.sql';
|
||||
|
||||
{
|
||||
metric_name: 'checkpoints_timed',
|
||||
type: 'gauge',
|
||||
@@ -6,5 +11,5 @@
|
||||
values: [
|
||||
'checkpoints_timed',
|
||||
],
|
||||
query: importstr 'sql_exporter/checkpoints_timed.sql',
|
||||
query: if neon.PG_MAJORVERSION_NUM < 17 then pg_stat_bgwriter else pg_stat_checkpointer,
|
||||
}
|
||||
|
||||
16
compute/jsonnet/neon.libsonnet
Normal file
16
compute/jsonnet/neon.libsonnet
Normal file
@@ -0,0 +1,16 @@
|
||||
local MIN_SUPPORTED_VERSION = 14;
|
||||
local MAX_SUPPORTED_VERSION = 17;
|
||||
local SUPPORTED_VERSIONS = std.range(MIN_SUPPORTED_VERSION, MAX_SUPPORTED_VERSION);
|
||||
|
||||
# If we receive the pg_version with a leading "v", ditch it.
|
||||
local pg_version = std.strReplace(std.extVar('pg_version'), 'v', '');
|
||||
local pg_version_num = std.parseInt(pg_version);
|
||||
|
||||
assert std.setMember(pg_version_num, SUPPORTED_VERSIONS) :
|
||||
std.format('%s is an unsupported Postgres version: %s',
|
||||
[pg_version, std.toString(SUPPORTED_VERSIONS)]);
|
||||
|
||||
{
|
||||
PG_MAJORVERSION: pg_version,
|
||||
PG_MAJORVERSION_NUM: pg_version_num,
|
||||
}
|
||||
Reference in New Issue
Block a user