Datadog-PGBouncer Integration

Overview

The PgBouncer check tracks connection pool metrics and lets you monitor traffic to and from your application.

Setup

Installation

The PgBouncer check is packaged with the Agent, so simply install the Agent on your PgBouncer nodes. If you need the newest version of the check, install the dd-check-pgbouncer package.

Configuration

Create a file pgbouncer.yaml in the Agent’s conf.d directory. See the sample pgbouncer.yaml for all available configuration options:

init_config:

instances:
  - host: localhost
    port: 15433
    username: <YOUR_USERNAME>
    password: <YOUR_PASSWORD>
#   tags:
#     - env:prod
  - database_url: postgresql://<DB_USER>:<DB_PASS>@<DB_HOST>:<DB_PORT>/dbname?sslmode=require
#   tags:
#     - role:main

In your PGBouncer userlist.txt file add

  "datadog" "<your_pass>"

Next, in your PGBouncer pgbouncer.ini file add

stats_users = datadog

Restart the Agent to start sending PgBouncer metrics to Datadog.

Validation

Run the Agent’s info subcommand and look for pgbouncer under the Checks section:

  Checks
  ======
    [...]

    pgbouncer
    -------
      - instance #0 [OK]
      - Collected 26 metrics, 0 events & 1 service check

    [...]

Compatibility

The PgBouncer check is compatible with all major platforms.

Data Collected

Metrics

pgbouncer.stats.requests_per_second
(gauge)
The request rate
shown as request
pgbouncer.stats.bytes_received_per_second
(gauge)
The total network traffic received
shown as byte
pgbouncer.stats.bytes_sent_per_second
(gauge)
The total network traffic sent
shown as byte
pgbouncer.stats.total_query_time
(gauge)
Time spent by pgbouncer actively querying PostgreSQL
shown as microsecond
pgbouncer.stats.avg_req
(gauge)
The average number of requests per second in last stat period
shown as request
pgbouncer.stats.avg_recv
(gauge)
The client network traffic received
shown as byte
pgbouncer.stats.avg_sent
(gauge)
The client network traffic sent
shown as byte
pgbouncer.stats.avg_query
(gauge)
The average query duration
shown as microsecond
pgbouncer.pools.cl_active
(gauge)
Client connections linked to server connection and able to process queries
shown as connection
pgbouncer.pools.cl_waiting
(gauge)
Client connections waiting on a server connection
shown as connection
pgbouncer.pools.sv_active
(gauge)
Server connections linked to a client connection
shown as connection
pgbouncer.pools.sv_idle
(gauge)
Server connections idle and ready for a client query
shown as connection
pgbouncer.pools.sv_used
(gauge)
Server connections idle more than server_check_delay, needing server_check_query
shown as connection
pgbouncer.pools.sv_tested
(gauge)
Server connections currently running either server_reset_query or server_check_query
shown as connection
pgbouncer.pools.sv_login
(gauge)
Server connections currently in the process of logging in
shown as connection
pgbouncer.pools.maxwait
(gauge)
Age of oldest unserved client connection
shown as second

Events

The PGboucer check does not include any event at this time.

Service Checks

pgbouncer.can_connect:

Returns CRITICAL if the Agent cannot connect to PgBouncer to collect metrics, otherwise OK.

Troubleshooting

Need help? Contact Datadog Support.

Further Reading

Learn more about infrastructure monitoring and all our integrations on our blog