Skip to content

Add ccp_replication_slots to OTel metrics. #4167

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions internal/collector/eq_pg16_metrics.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# This list of queries configures an OTel SQL Query Receiver to read pgMonitor
# metrics from Postgres.
#
# https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/-/receiver/sqlqueryreceiver#metrics-queries
# https://github.com/CrunchyData/pgmonitor/blob/development/sql_exporter/common/crunchy_global_collector.yml

- sql: >
SELECT
s.slot_name
, s.active::int
, COALESCE(pg_wal_lsn_diff(CASE WHEN pg_is_in_recovery() THEN pg_last_wal_replay_lsn() ELSE pg_current_wal_insert_lsn() END, s.restart_lsn), 0) AS retained_bytes
, COALESCE(s.database, '')
, s.slot_type
, COALESCE(s.conflicting::int, 0)
, 0 AS failover
, 0 AS synced
FROM pg_catalog.pg_replication_slots s;
metrics:
- metric_name: ccp_replication_slots_active
value_column: active
description: Active state of slot. 1 = true. 0 = false.
attribute_columns: ["database", "slot_name", "slot_type"]
static_attributes:
server: "localhost:5432"
- metric_name: ccp_replication_slots_retained_bytes
value_column: retained_bytes
description: The amount of WAL (in bytes) being retained for this slot
attribute_columns: ["database", "slot_name", "slot_type"]
static_attributes:
server: "localhost:5432"
- metric_name: ccp_replication_slots_conflicting
value_column: conflicting
description: True if this logical slot conflicted with recovery (and so is now invalidated). When this column is true, check invalidation_reason column for the conflict reason. Always NULL for physical slots.
attribute_columns: ["database", "slot_name", "slot_type"]
static_attributes:
server: "localhost:5432"
- metric_name: ccp_replication_slots_failover
value_column: failover
description: True if this is a logical slot enabled to be synced to the standbys so that logical replication can be resumed from the new primary after failover. Always false for physical slots.
attribute_columns: ["database", "slot_name", "slot_type"]
static_attributes:
server: "localhost:5432"
- metric_name: ccp_replication_slots_synced
value_column: synced
description: True if this is a logical slot that was synced from a primary server. On a hot standby, the slots with the synced column marked as true can neither be used for logical decoding nor dropped manually. The value of this column has no meaning on the primary server; the column value on the primary is default false for all slots but may (if leftover from a promoted standby) also be true.
attribute_columns: ["database", "slot_name", "slot_type"]
static_attributes:
server: "localhost:5432"
1 change: 1 addition & 0 deletions internal/collector/generated/eq_pg16_metrics.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion internal/collector/generated/gte_pg17_metrics.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading