Skip to content

[Feat] Configure Netdata's pgbouncer collector when both are installed #1643

Description

@violuke

Problem

The role installs Netdata on the Postgres nodes (netdata_install defaults to true) and installs pgbouncer on
those same hosts, but nothing sets up Netdata's pgbouncer collector. The Postgres collector finds itself
through auto-detection so you get postgres.* charts for free, but pgbouncer stays invisible. Relates to #249

That gap is awkward in practice, because pgbouncer is the thing that actually governs connection capacity. We
were recently digging into connection behaviour on a cluster deployed with this role and had to SSH in and run
SHOW POOLS by hand to get numbers a collector would have been graphing all along. maxwait creeping above zero is exactly what you'd want a chart and an alarm on, and right now there's nothing.

Description

The netdata role runs the kickstart installer and templates netdata.conf. It doesn't write anything under
go.d/, so there's no existing place to hook this in.

Rough shape of what I had in mind:

netdata_pgbouncer_collector: true
netdata_pgbouncer_stats_user: netdata

templating /etc/netdata/go.d/pgbouncer.conf:

jobs:
  - name: pgbouncer
    dsn: 'postgres://{{ netdata_pgbouncer_stats_user }}:{{ netdata_pgbouncer_stats_password }}@/pgbouncer?host=/var/run/pgbouncer&port={{ pgbouncer_listen_port }}'

The unix socket seems the right default for two reasons: it sidesteps client_tls_sslmode = require, which
only applies to TCP clients, and it keeps the credential off the network. The user would need to be in
pgbouncer_stats_users, which is currently just patroni_superuser_username, so that would want extending
as well.

Worth flagging that I haven't tested any of this. It's the shape I'd expect rather than a working patch. The
bit I'm least sure about is pgbouncer_processes > 1, where pgbouncer.ini.j2 gives each process its own
socket directory with an index suffix, so a single job would only ever see the first one.

Thanks for considering this and for autobase itself, it's great!

Importance

really want

Proposed implementation

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions