'How to correctly specify the aconnection string for pgbouncer-exporter

I configure connection to my postgres db inside kubernetes cluster via pgbouncer. To monitor pgbouncer I want to use pgbouncer_exporter https://github.com/prometheus-community/pgbouncer_exporter https://github.com/wallarm/pgbouncer-chart. I have prepared a deployment file

apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: pgbouncer
  name: pgbouncer
spec:
  replicas: 1
  selector:
    matchLabels:
      app: pgbouncer
  template:
    metadata:
      labels:
        app: pgbouncer
      annotations:
        prometheus.io/scrape: "true"
        prometheus.io/port: "9127"
        prometheus.io/path: "/metrics"
    spec:
      containers:
      - name: espgbouncer
        env:
        - name: AUTH_TYPE
          valueFrom:
            configMapKeyRef:
              key: AUTH_TYPE
              name: tmp-db-config
        - name: MAX_CLIENT_CONN
          valueFrom:
            configMapKeyRef:
              key: MAX_CLIENT_CONN
              name: tmp-db-config
        - name: DB_HOST
          valueFrom:
            configMapKeyRef:
              key: POSTGRES_HOST_INNER
              name: tmp-db-config
        - name: DB_PASSWORD
          valueFrom:
            secretKeyRef:
              key: POSTGRES_PASSWORD
              name: tmp-db-secret
        - name: DB_USER
          valueFrom:
            configMapKeyRef:
              key: POSTGRES_USER
              name: tmp-db-config
        - name: POOL_MODE
          value: transaction
        - name: SERVER_RESET_QUERY
          value: DISCARD ALL
        image: edoburu/pgbouncer:1.15.0
        lifecycle:
          preStop:
            exec:
              command:
              - /bin/sh
              - -c
              - killall -INT pgbouncer && sleep 120
        ports:
        - containerPort: 5432
        securityContext:
          allowPrivilegeEscalation: false
          capabilities:
            drop:
            - all
      - name: exporter
        image: prometheuscommunity/pgbouncer-exporter
        imagePullPolicy: IfNotPresent
        args:
        - --web.listen-address=:9127
        - --web.telemetry-path=/metrics
        - --log.level=info
        - --log.format=json
        - --pgBouncer.connectionString=postgres://$(DB_USER):$(DB_PASSWORD)@127.0.0.1:5432/tmp-us-test-db?sslmode=disable&connect_timeout=10
        env:
        - name: DB_PASSWORD
          valueFrom:
            secretKeyRef:
              key: POSTGRES_PASSWORD
              name: tmp-db-secret
        - name: DB_USER
          valueFrom:
            configMapKeyRef:
              key: POSTGRES_USER
              name: tmp-db-config
        resources:
          limits:
            cpu: 250m
            memory: 150Mi
          requests:
            cpu: 30m
            memory: 40Mi
        ports:
        - containerPort: 9127
          protocol: TCP
      nodeSelector:
        kubernetes.io/os: linux

But I am getting an error

{"caller":"collector.go:129","err":"error pinging pgbouncer: \"pq: unrecognized configuration parameter \\\"stats\\\"\"","level":"error","msg":"error setting up DB connection","ts":"2022-05-10T19:56:15.348Z"}

I think it's because I have a character in the base name - and I don't know how to fix it. Or perhaps I need a separate base?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source