-
Notifications
You must be signed in to change notification settings - Fork 456
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add compute_logical_snapshot_files_bytes metric
This metric exposes the size of all non-temporary logical snapshot files. Signed-off-by: Tristan Partin <[email protected]>
- Loading branch information
1 parent
5c23569
commit f5c4d98
Showing
4 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
compute/etc/sql_exporter/compute_logical_snapshots_bytes.16.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
SELECT | ||
(SELECT current_setting('neon.timeline_id')) AS timeline_id, | ||
-- Postgres creates temporary snapshot files of the form %X-%X.snap.%d.tmp. | ||
-- These temporary snapshot files are renamed to the actual snapshot files | ||
-- after they are completely built. We only WAL-log the completely built | ||
-- snapshot files | ||
(SELECT COALESCE(sum(size), 0) FROM pg_ls_logicalsnapdir() WHERE name LIKE '%.snap') AS logical_snapshots_bytes; |
17 changes: 17 additions & 0 deletions
17
compute/etc/sql_exporter/compute_logical_snapshots_bytes.libsonnet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
local neon = import 'neon.libsonnet'; | ||
|
||
local pg_ls_logicalsnapdir = importstr 'sql_exporter/compute_logical_snapshots_bytes.16.sql'; | ||
local pg_ls_dir = importstr 'sql_exporter/compute_logical_snapshots_bytes.sql'; | ||
|
||
{ | ||
metric_name: 'compute_logical_snapshots_bytes', | ||
type: 'gauge', | ||
help: 'Size of the pg_logical/snapshots directory, not including temporary files', | ||
key_labels: [ | ||
'timeline_id', | ||
], | ||
values: [ | ||
'logical_snapshots_bytes', | ||
], | ||
query: if neon.PG_MAJORVERSION_NUM < 16 then pg_ls_dir else pg_ls_logicalsnapdir, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
SELECT | ||
(SELECT setting FROM pg_settings WHERE name = 'neon.timeline_id') AS timeline_id, | ||
-- Postgres creates temporary snapshot files of the form %X-%X.snap.%d.tmp. | ||
-- These temporary snapshot files are renamed to the actual snapshot files | ||
-- after they are completely built. We only WAL-log the completely built | ||
-- snapshot files | ||
(SELECT COALESCE(sum((pg_stat_file('pg_logical/snapshots/' || name, missing_ok => true)).size), 0) | ||
FROM (SELECT pg_ls_dir('pg_logical/snapshots') AS name WHERE name LIKE '%.snap'); | ||
) AS logical_snapshots_bytes; |