|
| 1 | +# This list of queries configures an OTel SQL Query Receiver to read pgMonitor |
| 2 | +# metrics from Postgres. |
| 3 | +# |
| 4 | +# https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/-/receiver/sqlqueryreceiver#metrics-queries |
| 5 | +# https://github.com/CrunchyData/pgmonitor/blob/development/sql_exporter/common/crunchy_global_collector.yml |
| 6 | + |
| 7 | + - sql: > |
| 8 | + SELECT |
| 9 | + s.slot_name |
| 10 | + , s.active::int |
| 11 | + , 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 |
| 12 | + , COALESCE(s.database, '') |
| 13 | + , s.slot_type |
| 14 | + , COALESCE(s.conflicting::int, 0) |
| 15 | + , 0 AS failover |
| 16 | + , 0 AS synced |
| 17 | + FROM pg_catalog.pg_replication_slots s; |
| 18 | + metrics: |
| 19 | + - metric_name: ccp_replication_slots_active |
| 20 | + value_column: active |
| 21 | + description: Active state of slot. 1 = true. 0 = false. |
| 22 | + attribute_columns: ["database", "slot_name", "slot_type"] |
| 23 | + static_attributes: |
| 24 | + server: "localhost:5432" |
| 25 | + - metric_name: ccp_replication_slots_retained_bytes |
| 26 | + value_column: retained_bytes |
| 27 | + description: The amount of WAL (in bytes) being retained for this slot |
| 28 | + attribute_columns: ["database", "slot_name", "slot_type"] |
| 29 | + static_attributes: |
| 30 | + server: "localhost:5432" |
| 31 | + - metric_name: ccp_replication_slots_conflicting |
| 32 | + value_column: conflicting |
| 33 | + 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. |
| 34 | + attribute_columns: ["database", "slot_name", "slot_type"] |
| 35 | + static_attributes: |
| 36 | + server: "localhost:5432" |
| 37 | + - metric_name: ccp_replication_slots_failover |
| 38 | + value_column: failover |
| 39 | + 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. |
| 40 | + attribute_columns: ["database", "slot_name", "slot_type"] |
| 41 | + static_attributes: |
| 42 | + server: "localhost:5432" |
| 43 | + - metric_name: ccp_replication_slots_synced |
| 44 | + value_column: synced |
| 45 | + 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. |
| 46 | + attribute_columns: ["database", "slot_name", "slot_type"] |
| 47 | + static_attributes: |
| 48 | + server: "localhost:5432" |
0 commit comments