Skip to content

feat: add live Postgres metric tiles to the Cluster detail page - #31

Open
YogeshJain96 wants to merge 2 commits into
cloudnative-pg:mainfrom
YogeshJain96:main
Open

YogeshJain96 wants to merge 2 commits into
cloudnative-pg:mainfrom
YogeshJain96:main

Conversation

@YogeshJain96

Copy link
Copy Markdown

Each tile execs a one-shot psql query into an instance, grouped by category: CNPG-specific replication/WAL archiving state, and general health (connections, cache hit ratio, database size, blocked queries, deadlocks). Health metrics get a per-instance switch, plus an optional 5s/10s/30s auto-refresh.

Screenshot 2026-09-16 at 11 44 02 PM

Future Scope: We can let user add/edit/remove their own metric entries at runtime, on top of this fixed, built-in set. Persist them in a small ConfigMap in the cluster (we already have the k8s API access to read/write one) so they're shared across anyone using this plugin against it, not just saved locally in one browser.

Each tile execs a one-shot psql query into an instance, grouped by
category: CNPG-specific replication/WAL archiving state, and general
health (connections, cache hit ratio, database size, blocked queries,
deadlocks). Health metrics get a per-instance switch, plus an
optional 5s/10s/30s auto-refresh.

Signed-off-by: Yogesh Jain <contactyogeshjain@gmail.com>
Signed-off-by: Yogesh Jain <contactyogeshjain@gmail.com>
@YogeshJain96
YogeshJain96 requested a review from a team as a code owner September 17, 2026 06:10
}
},
{
command: ['psql', '-U', 'postgres', '-d', database, '-X', '-tAc', query],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mhhh ... why do you need to access the database as postgres? I'd rather have you fetch the Prometheus exporter directly and parse those, rather than querying the database. That way we can reuse what we already have. We should push back on superuser connections, always. The exporter uses a regular user called cnpg_metrics_exporter. You could reuse that, but you need to find a different way to connect to the database I guess.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants