Example metrics
Suggest editsHere are some helpful queries for monitoring the health of your Cloud Service database. This isn't a complete list. It's intended only as a starting point.
The examples are in PromQL with variables suitable for use in a Grafana dashboard.
Status
This query shows if the pods are up as provided by Kube State metrics:
kube_pod_container_status_ready{container="postgres"}
CPU
This query shows CPU usage as provided by Kubernetes metrics:
rate(container_cpu_usage_seconds_total{container="postgres"}[5m])
Memory
This query shows memory usage in megabytes as provided by Kubernetes metrics:
container_memory_working_set_bytes{container="postgres"}/1000000
Storage
This query shows the percentage of available storage used as provided by Kubernetes metrics:
(sum(kubelet_volume_stats_used_bytes{namespace=~"default"}) by (persistentvolumeclaim) / sum(kubelet_volume_stats_capacity_bytes{namespace=~"default"}) by (persistentvolumeclaim)) * 100
Replication lag
This query shows the replication lag as provided by the CNP replication lag metric filtered by the Postgres Instance ($instance)
pod:
cnp_pg_replication_lag{container="postgres", pod="$instance"}
Connections used
To calculate the connections used as a percentage, you can leverage the cnp_backends_total and cnp_pg_settings_setting metrics. This query calculates the percentage of connections used filtered by the Postgres Instance ($instance)
pod:
100* (sum by (pod)(cnp_backends_total{pod="$instance"}) / max by (pod)(max_over_time(cnp_pg_settings_setting{name="max_connections",pod="$instance"}[30m])))
Transaction ID age
This query shows the database transaction ID age as provided by the CNP database xid metric filtered by the Postgres Instance ($instance)
pod:
(max by (pod) (cnp_pg_database_xid_age{container="postgres", pod="$instance"}))
The age is relative to the workloads being run on your database and the following settings. See the Postgres documentation for details:
- autovacuum_freeze_max_age. The default is 200000000.
- vacuum_multixact_failsafe_age. The default is 1600000000.
Could this page be better? Report a problem or suggest an addition!