34 lines
1.0 KiB
YAML
34 lines
1.0 KiB
YAML
---
|
|
apiVersion: v1
|
|
kind: ConfigMap
|
|
metadata:
|
|
name: postgresql-dashboard-metrics
|
|
namespace: postgresql-system
|
|
labels:
|
|
app: postgresql-shared
|
|
cnpg.io/reload: ""
|
|
data:
|
|
queries: |
|
|
# Simple replication lag metric
|
|
pg_replication_lag_seconds:
|
|
query: |
|
|
SELECT
|
|
pg_stat_replication.application_name,
|
|
pg_stat_replication.client_addr,
|
|
pg_stat_replication.state,
|
|
COALESCE(EXTRACT(EPOCH FROM (now() - pg_stat_activity.query_start)), 0) AS lag_seconds
|
|
FROM pg_stat_replication
|
|
LEFT JOIN pg_stat_activity ON pg_stat_replication.pid = pg_stat_activity.pid
|
|
metrics:
|
|
- application_name:
|
|
usage: "LABEL"
|
|
description: "Application name of the standby"
|
|
- client_addr:
|
|
usage: "LABEL"
|
|
description: "IP address of the standby server"
|
|
- state:
|
|
usage: "LABEL"
|
|
description: "Current WAL sender state"
|
|
- lag_seconds:
|
|
usage: "GAUGE"
|
|
description: "Replication lag in seconds" |