New announcements for Serverless, Network, RUM, and more from Dash! New announcements from Dash!

PGBouncer

Agent Check Agent Check

Supported OS: Linux Mac OS

Overview

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

Setup

Follow the instructions below to install and configure this check for an Agent running on a host. For containerized environments, see the Autodiscovery Integration Templates for guidance on applying these instructions.

Installation

The PgBouncer check is included in the Datadog Agent package, so you don’t need to install anything else on your PgBouncer nodes.

Configuration

Edit the pgbouncer.d/conf.yaml file, in the conf.d/ folder at the root of your Agent’s configuration directory. See the sample pgbouncer.d/conf.yaml for all available configuration options:

init_config:

instances:
  - host: localhost
    port: 15433
    username: <YOUR_USERNAME>
    password: <YOUR_PASSWORD>
    # tags:
    #   - env:prod

  # Note: when the instance is configured with `database_url`, `host`, `port`, `username` and `password` are ignored.
  - database_url: postgresql://<DB_USER>:<DB_PASS>@<DB_HOST>:<DB_PORT>/dbname?sslmode=require
    # tags:
    #   - role:main

Note: database_url parameter value should point to PgBouncer stats database.

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.

Log collection

Available for Agent >6.0

  1. Collecting logs is disabled by default in the Datadog Agent, enable it in your datadog.yaml file:

      logs_enabled: true
  2. Add this configuration block to your pgbouncer.d/conf.yaml file to start collecting your Pgbouncer logs:

      logs:
        - type: file
          path: /var/log/postgresql/pgbouncer.log
          source: pgbouncer
          service: <SERVICE_NAME>

    Change the path and service parameter values and configure them for your environment. See the sample pgbouncer.d/conf.yaml for all available configuration options.

  3. Restart the Agent.

Validation

Run the Agent’s status subcommand and look for pgbouncer under the Checks section.

Data Collected

Metrics

pgbouncer.stats.requests_per_second
(rate)
The request rate
shown as request
pgbouncer.stats.queries_per_second
(rate)
The query rate
shown as query
pgbouncer.stats.transactions_per_second
(rate)
The transaction rate
shown as transaction
pgbouncer.stats.bytes_received_per_second
(rate)
The total network traffic received
shown as byte
pgbouncer.stats.bytes_sent_per_second
(rate)
The total network traffic sent
shown as byte
pgbouncer.stats.total_query_time
(rate)
Time spent by pgbouncer actively querying PostgreSQL
shown as microsecond
pgbouncer.stats.total_transaction_time
(rate)
Time spent by pgbouncer in transactions
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_query_count
(gauge)
The average number of queries per second in last stat period
shown as query
pgbouncer.stats.avg_transaction_count
(gauge)
The average number of transactions per second in last stat period
shown as transaction
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.stats.avg_query_time
(gauge)
The average query duration
shown as microsecond
pgbouncer.stats.avg_transaction_time
(gauge)
The average transaction 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
pgbouncer.databases.pool_size
(gauge)
Maximum number of server connections
shown as connection
pgbouncer.databases.max_connections
(gauge)
Maximum number of allowed connections
shown as connection
pgbouncer.databases.current_connections
(gauge)
Current number of connections for this database
shown as connection

Note: Not all metrics are available with all versions of PgBouncer.

Events

The PgBouncer check does not include any events.

Service Checks

pgbouncer.can_connect:
Returns CRITICAL if the Agent cannot connect to PgBouncer to collect metrics, otherwise returns OK.

Troubleshooting

Need help? Contact Datadog support.


Mistake in the docs? Feel free to contribute!