因为odyssey 兼容pgbouncer,我们可以直接使用pgbouncer的exporter
version: "3"
services:
postgres:
image: postgres:12
ports:
- "5432:5432"
environment:
- "POSTGRES_PASSWORD=dalong"
pgbouncer:
image: brainsam/pgbouncer
ports:
- "6543:6543"
volumes:
- "./pgbouncer.ini:/etc/pgbouncer/pgbouncer.ini"
- "./users.txt:/opt/auth/users.txt"
app:
image: kksudo/odyssey-docker:1.1
ports:
- "6432:6432"
volumes:
- "./odyssey-dev.conf:/etc/odyssey/odyssey.conf"
prom1:
image: dalongrong/pgbouncer_exporter:v0.4.1
ports:
- "9127:9127"
command: --pgBouncer.connectionString="postgres://postgres:dalong@pgbouncer:6543/pgbouncer?sslmode=disable"
prom2:
image: dalongrong/pgbouncer_exporter:v0.4.1
ports:
- "9128:9127"
command: --pgBouncer.connectionString="postgres://postgres:dalong@app:6432/console?sslmode=disable"
pgbouncer的exporter 目前新版本的比较少,我基于源码构建提供了一个版本的容器镜像
操作方法
git clone https://github.com/prometheus-community/pgbouncer_exporter.git
make build
Dockerfile
FROM debian:stretch-slim
COPY pgbouncer_exporter /bin/pgbouncer_exporter
ENTRYPOINT [ "/bin/pgbouncer_exporter" ]
https://github.com/prometheus-community/pgbouncer_exporter
https://github.com/yandex/odyssey
https://github.com/rongfengliang/postgres-connect-pool-tools-learning
原文:https://www.cnblogs.com/rongfengliang/p/13546419.html