Skip to content

Files

Latest commit

 

History

History

pgbouncer

PgBouncer check

Overview

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

Setup

Installation

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

This check needs an associated user to query your PgBouncer instance:

  1. Create a Datadog user in your PgBouncer pgbouncer.ini file:

    stats_users = datadog
  2. Add an associated password for the datadog user in your PgBouncer userlist.txt file:

    "datadog" "<PASSWORD>"
    
  3. To verify the credentials, run the following command:

    psql -h localhost -U datadog -p 6432 pgbouncer -c \
    "SHOW VERSION;" \
    && echo -e "\e[0;32mpgBouncer connection - OK\e[0m" \
    || echo -e "\e[0;31mCannot connect to pgBouncer\e[0m"

    When it prompts for a password, enter the password you added to the userlist.txt.

Configuration

Host

To configure this check for an Agent running on a host:

Metric collection
  1. 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:
      ## @param database_url - string - required
      ## `database_url` parameter should point to PgBouncer stats database url (ie. "pgbouncer")
      #
      - database_url: "postgresql://datadog:<PASSWORD>@<HOSTNAME>:<PORT>/<DATABASE_URL>?sslmode=require"

    Note: If your instance of PgBouncer does not have SSL support, replace sslmode=require with sslmode=allow to avoid server errors. For details, see the Postgres documentation on SSL support.

  2. Restart the Agent.

Log collection

Available for Agent versions >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.

Containerized

For containerized environments, see the Autodiscovery Integration Templates for guidance on applying the parameters below.

Metric collection
Parameter Value
<INTEGRATION_NAME> pgbouncer
<INIT_CONFIG> blank or {}
<INSTANCE_CONFIG> {"database_url": "postgresql://datadog:<PASSWORD>@%%host%%:%%port%%/<DATABASE_URL>?sslmode=require"}
Log collection

Available for Agent versions >6.0

Collecting logs is disabled by default in the Datadog Agent. To enable it, see Kubernetes Log Collection.

Parameter Value
<LOG_CONFIG> {"source": "pgbouncer", "service": "pgbouncer"}

Validation

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

Data Collected

Metrics

See metadata.csv for a list of metrics provided by this check.

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

Events

The PgBouncer check does not include any events.

Service Checks

See service_checks.json for a list of service checks provided by this integration.

Troubleshooting

Need help? Contact Datadog support.