Supported OS Linux Mac OS

インテグレーションバージョン8.1.0

To find out if this integration is available in your organization, see your Datadog Integrations page or ask your organization administrator.

To initiate an exception request to enable this integration for your organization, email [email protected].

概要

PgBouncer チェックは、接続プールメトリクスを追跡し、アプリケーションに出入りするトラフィックの監視を可能にします。

セットアップ

インストール

PgBouncer チェックは Datadog Agent パッケージに含まれています。PgBouncer ノードに追加でインストールする必要はありません。

このチェックには、PgBouncer インスタンスを照会するための関連ユーザーが必要です。

  1. PgBouncer の pgbouncer.ini ファイルに Datadog ユーザーを作成します。

    stats_users = datadog
    
  2. PgBouncer の userlist.txt ファイルに datadog ユーザーの関連パスワードを追加します。

    "datadog" "<PASSWORD>"
    
  3. 認証情報を確認するには、次のコマンドを実行します。

    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"
    

    パスワードの入力を要求されたら、userlist.txt に追加したパスワードを入力します。

構成

ホスト

ホストで実行中の Agent に対してこのチェックを構成するには

メトリクスの収集
  1. Agent のコンフィギュレーションディレクトリのルートにある conf.d/ フォルダーの pgbouncer.d/conf.yaml ファイルを編集します。使用可能なすべてのコンフィギュレーションオプションの詳細については、サンプル pgbouncer.d/conf.yaml を参照してください。

    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"
    

    : PgBouncer のインスタンスに SSL サポートがない場合は、sslmode=requiresslmode=allow と置換してサーバーエラーを防ぎます。詳細は、SSL サポートの Postgres ドキュメントを参照してください。

  2. Agent を再起動します

ログ収集

Agent バージョン 6.0 以降で利用可能

  1. Datadog Agent で、ログの収集はデフォルトで無効になっています。以下のように、datadog.yaml ファイルでこれを有効にします。

    logs_enabled: true
    
  2. Pgbouncer のログの収集を開始するには、次の構成ブロックを pgbouncer.d/conf.yaml ファイルに追加します。

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

    path パラメーターと service パラメーターの値を変更し、環境に合わせて構成してください。使用可能なすべてのコンフィギュレーションオプションの詳細については、サンプル pgbouncer.d/conf.yaml を参照してください。

  3. Agent を再起動します

コンテナ化

コンテナ環境の場合は、オートディスカバリーのインテグレーションテンプレートのガイドを参照して、次のパラメーターを適用してください。

メトリクスの収集
パラメーター
<INTEGRATION_NAME>pgbouncer
<INIT_CONFIG>空白または {}
<INSTANCE_CONFIG>{"database_url": "postgresql://datadog:<パスワード>@%%host%%:%%port%%/<データベース_URL>?sslmode=require"}
ログ収集

Agent バージョン 6.0 以降で利用可能

Datadog Agent で、ログの収集はデフォルトで無効になっています。有効にする方法については、Kubernetes ログ収集を参照してください。

パラメーター
<LOG_CONFIG>{“source”: “pgbouncer”, “service”: “pgbouncer”}

検証

Agent の status サブコマンドを実行し、Checks セクションで pgbouncer を探します。

収集データ

メトリクス

pgbouncer.clients.connect_time
(gauge)
When the connection was made (seconds since epoch)
Shown as second
pgbouncer.clients.request_time
(gauge)
When last request was issued (seconds since epoch)
Shown as second
pgbouncer.clients.wait
(gauge)
Current waiting time in seconds
Shown as second
pgbouncer.clients.wait_us
(gauge)
The microsecond portion of the current waiting time
Shown as microsecond
pgbouncer.databases.current_connections
(gauge)
Current number of connections for this database
Shown as connection
pgbouncer.databases.max_connections
(gauge)
Maximum number of allowed connections
Shown as connection
pgbouncer.databases.pool_size
(gauge)
Maximum number of server connections
Shown as connection
pgbouncer.max_client_conn
(gauge)
The maximum number of client connections allowed.
Shown as connection
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.maxwait
(gauge)
How long the first (oldest) client in the queue has waited, in seconds
Shown as second
pgbouncer.pools.maxwait_us
(gauge)
Microsecond part of the maximum waiting time
Shown as microsecond
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_login
(gauge)
Server connections currently in the process of logging in
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_used
(gauge)
Server connections idle more than server_check_delay, needing server_check_query
Shown as connection
pgbouncer.servers.connect_time
(gauge)
When the connection was made (seconds since epoch)
Shown as second
pgbouncer.servers.request_time
(gauge)
When last request was issued (seconds since epoch)
Shown as second
pgbouncer.stats.avg_query
(gauge)
The average query duration
Shown as microsecond
pgbouncer.stats.avg_query_count
(gauge)
The average number of queries per second in last stat period
Shown as query
pgbouncer.stats.avg_query_time
(gauge)
The average query duration
Shown as microsecond
pgbouncer.stats.avg_recv
(gauge)
The client network traffic received
Shown as byte
pgbouncer.stats.avg_req
(gauge)
The average number of requests per second in last stat period
Shown as request
pgbouncer.stats.avg_sent
(gauge)
The client network traffic sent
Shown as byte
pgbouncer.stats.avg_transaction_count
(gauge)
The average number of transactions per second in last stat period
Shown as transaction
pgbouncer.stats.avg_transaction_time
(gauge)
The average transaction duration
Shown as microsecond
pgbouncer.stats.avg_wait_time
(gauge)
Time spent by clients waiting for a server, in microseconds (average per second)
Shown as microsecond
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.queries_per_second
(rate)
The query rate
Shown as query
pgbouncer.stats.requests_per_second
(rate)
The request rate
Shown as request
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.total_wait_time
(gauge)
Time spent by clients waiting for a server, in microseconds
Shown as microsecond
pgbouncer.stats.transactions_per_second
(rate)
The transaction rate
Shown as transaction

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

: PgBouncer のバージョンによっては、すべてのメトリクスを使用できないことがあります。

イベント

PgBouncer チェックには、イベントは含まれません。

サービスチェック

pgbouncer.can_connect

Returns CRITICAL if the Agent is unable to connect to the monitored PGBouncer instance. Returns OK otherwise.

Statuses: ok, critical

トラブルシューティング

ご不明な点は、Datadog のサポートチームまでお問合せください。