---
title: Telegraf Documentation
description: Telegraf plugin for collecting metrics from PgBouncer
url: https://docs.influxdata.com/telegraf/v1/input-plugins/pgbouncer/
estimated_tokens: 1837
product: Telegraf
version: v1
---

-   Telegraf v1.8.0+

# PgBouncer Input Plugin

This plugin collects metrics from a [PgBouncer load balancer](https://pgbouncer.github.io) instance. Check the [documentation](https://pgbouncer.github.io/usage.html) for available metrics and their meaning.

This plugin requires PgBouncer v1.5+.

**Introduced in:** Telegraf v1.8.0 **Tags:** server, web **OS support:** all

## Global configuration options

Plugins support additional global and plugin configuration settings for tasks such as modifying metrics, tags, and fields, creating aliases, and configuring plugin ordering. See [CONFIGURATION.md](/telegraf/v1/configuration/#plugins) for more details.

## Configuration

```toml
# Read metrics from one or many pgbouncer servers
[[inputs.pgbouncer]]
  ## specify address via a url matching:
  ##   postgres://[pqgotest[:password]]@host:port[/dbname]\
  ##       ?sslmode=[disable|verify-ca|verify-full]
  ## or a simple string:
  ##   host=localhost port=5432 user=pqgotest password=... sslmode=... dbname=app_production
  ##
  ## All connection parameters are optional.
  ##
  address = "host=localhost user=pgbouncer sslmode=disable"

  ## Specify which "show" commands to gather metrics for.
  ## Choose from: "stats", "pools", "lists", "databases"
  # show_commands = ["stats", "pools"]
```

To specify the `address` use either a PostgreSQL connection string:

```text
host=/run/postgresql port=6432 user=telegraf database=pgbouncer
```

or via an URL of the following form:

```text
postgres://[pqgotest[:password]]@host:port[/dbname]?sslmode=[disable|verify-ca|verify-full]
```

All connection parameters are optional.

Without the `dbname` parameter, the driver will default to a database with the same name as the user. The `dbname` is for instantiating a connection with the server only and doesn’t restrict access to the databases queried.

## Metrics

-   pgbouncer
    
    -   tags:
        -   db
        -   server
    -   fields:
        -   avg\_query\_count
        -   avg\_query\_time
        -   avg\_wait\_time
        -   avg\_xact\_count
        -   avg\_xact\_time
        -   total\_query\_count
        -   total\_query\_time
        -   total\_received
        -   total\_sent
        -   total\_wait\_time
        -   total\_xact\_count
        -   total\_xact\_time
-   pgbouncer\_pools
    
    -   tags:
        -   db
        -   pool\_mode
        -   server
        -   user
    -   fields:
        -   cl\_active
        -   cl\_waiting
        -   maxwait
        -   maxwait\_us
        -   sv\_active
        -   sv\_idle
        -   sv\_login
        -   sv\_tested
        -   sv\_used
-   pgbouncer\_lists
    
    -   tags:
        -   db
        -   server
        -   user
    -   fields:
        -   databases
        -   users
        -   pools
        -   free\_clients
        -   used\_clients
        -   login\_clients
        -   free\_servers
        -   used\_servers
        -   dns\_names
        -   dns\_zones
        -   dns\_queries
-   pgbouncer\_databases
    
    -   tags:
        -   db
        -   pg\_dbname
        -   server
        -   user
    -   fields:
        -   current\_connections
        -   pool\_size
        -   min\_pool\_size
        -   reserve\_pool
        -   max\_connections
        -   paused
        -   disabled

## Example Output

```text
pgbouncer,db=pgbouncer,server=host\=debian-buster-postgres\ user\=dbn\ port\=6432\ dbname\=pgbouncer\  avg_query_count=0i,avg_query_time=0i,avg_wait_time=0i,avg_xact_count=0i,avg_xact_time=0i,total_query_count=26i,total_query_time=0i,total_received=0i,total_sent=0i,total_wait_time=0i,total_xact_count=26i,total_xact_time=0i 1581569936000000000
pgbouncer_pools,db=pgbouncer,pool_mode=statement,server=host\=debian-buster-postgres\ user\=dbn\ port\=6432\ dbname\=pgbouncer\ ,user=pgbouncer cl_active=1i,cl_waiting=0i,maxwait=0i,maxwait_us=0i,sv_active=0i,sv_idle=0i,sv_login=0i,sv_tested=0i,sv_used=0i 1581569936000000000
pgbouncer_lists,db=pgbouncer,server=host\=debian-buster-postgres\ user\=dbn\ port\=6432\ dbname\=pgbouncer\ ,user=pgbouncer databases=1i,dns_names=0i,dns_queries=0i,dns_zones=0i,free_clients=47i,free_servers=0i,login_clients=0i,pools=1i,used_clients=3i,used_servers=0i,users=4i 1581569936000000000
pgbouncer_databases,db=pgbouncer,pg_dbname=pgbouncer,server=host\=debian-buster-postgres\ user\=dbn\ port\=6432\ dbname\=pgbouncer\ name=pgbouncer disabled=0i,pool_size=2i,current_connections=0i,min_pool_size=0i,reserve_pool=0i,max_connections=0i,paused=0i 1581569936000000000
pgbouncer_databases,db=postgres,pg_dbname=postgres,server=host\=debian-buster-postgres\ user\=dbn\ port\=6432\ dbname\=pgbouncer\ name=postgres current_connections=0i,disabled=0i,pool_size=20i,min_pool_size=0i,reserve_pool=0i,paused=0i,max_connections=0i 1581569936000000000
```

#### Related

-   [Configure plugins](/telegraf/v1/configure_plugins/)
-   [PgBouncer Plugin Source](https://github.com/influxdata/telegraf/tree/v1.38.4/plugins/inputs/pgbouncer/README.md)
