Example metrics

Here are some helpful queries for monitoring the health of your BigAnimal 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"}

status_example

CPU

This query shows CPU usage as provided by Kubernetes metrics:

rate(container_cpu_usage_seconds_total{container="postgres"}[5m])

cpu_usage_example

Memory

This query shows memory usage in megabytes as provided by Kubernetes metrics:

container_memory_working_set_bytes{container="postgres"}/1000000

memory_usage_example

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

pvc_usage_example

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"}

replication_lag_example

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])))

connections_example

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"}))

xid_age_example

The age is relative to the workloads being run on your database and the following settings. See the Postgres documentation for details: