PGBouncer

Supported OS Linux Mac OS

통합 버전8.1.1

개요

PgBouncer 점검은 연결 풀 메트릭을 추적하고 애플리케이션과 주고받는 모니터링 트래픽을 추적합니다.

설정

설치

PgBouncer 점검이 Datadog 에이전트 패키지에 포함되어 있으므로 PgBouncer 노드에 아무 것도 설치하지 않아도 됩니다.

이 점검에는 연결된 사용자가 쿼리 PgBouncer 인스턴스에 필요합니다.

  1. PgBouncer pgbouncer.ini 파일에 Datadog 사용자를 생성합니다.

    stats_users = datadog
    
  2. 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에 추가한 비밀번호를 입력합니다.

구성

호스트

호스트에서 실행 중인 에이전트에 대해 이 점검을 구성하려면:

메트릭 수집
  1. 에이전트 설정 디렉토리 루트의 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 에이전트에서 로그 수집은 기본적으로 사용하지 않도록 설정되어 있습니다. datadog.yaml파일에서 로그 수집을 사용하도록 설정합니다.

    logs_enabled: true
    
  2. 이 설정 블록을 pgbouncer.d/conf.yaml 파일에 추가하여 Pgbouncer 로그 수집을 시작하세요.

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

    pathservice 파라미터 값을 변경하고 설정를 환경으로 변경합니다. 사용 가능한 모든 설정 옵션은 샘플 pgbouncer.d/conf.yaml을 참조하세요.

  3. Agent를 재시작합니다.

컨테이너화

컨테이너화된 환경의 경우 자동탐지 통합 템플릿에 다음 파라미터를 적용하는 방법이 안내되어 있습니다.

메트릭 수집
파라미터
<INTEGRATION_NAME>pgbouncer
<INIT_CONFIG>비어 있음 또는 {}
<INSTANCE_CONFIG>{"database_url": "postgresql://datadog:<PASSWORD>@%%host%%:%%port%%/<DATABASE_URL>?sslmode=require"}
로그 수집

Agent 버전 6.0 이상에서 사용 가능

Datadog Agent에서 로그 수집은 기본값으로 비활성화되어 있습니다. 이를 활성화하려면 쿠버네티스(Kubernetes) 로그 수집을 참조하세요.

파라미터
<LOG_CONFIG>{“source”: “pgbouncer”, “service”: “pgbouncer”}

검증

에이전트의 상태 하위 명령을 실행하고 점검 섹션에서 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 serverresetquery or servercheckquery
Shown as connection
pgbouncer.pools.sv_used
(gauge)
Server connections idle more than servercheckdelay, needing servercheckquery
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

참고: 일부 메트릭은 일부 버전의 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 지원팀에 문의하세요.