Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export CLI args as ENV variables in Docker container #23

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@ ENV POSTGRES_PASSWORD postgres
ENV POSTGRES_DATABASE postgres
ENV PGPOOL_SERVICE localhost
ENV PGPOOL_SERVICE_PORT 9999
ENV PGPOOL_LISTEN_ADDRESS 9179
ENV PGPOOL_METRICS_PATH /metrics
ENV PGPOOL_LOG_LEVEL info
ENV PGPOOL_LOG_FORMAT logfmt
ENV SSLMODE disable

COPY pgpool2_exporter /bin/pgpool2_exporter

CMD ["/bin/sh", "-c", "export DATA_SOURCE_USER=\"${POSTGRES_USERNAME}\" ; export DATA_SOURCE_PASS=\"${POSTGRES_PASSWORD}\" ; export DATA_SOURCE_URI=\"${PGPOOL_SERVICE}:${PGPOOL_SERVICE_PORT}/${POSTGRES_DATABASE}?sslmode=${SSLMODE}\" ; /bin/pgpool2_exporter"]
CMD ["/bin/sh", "-c", "export PGPOOL_LOG_LEVEL=\"${PGPOOL_LOG_LEVEL}\"; export PGPOOL_LOG_FORMAT=\"${PGPOOL_LOG_FORMAT}\"; export PGPOOL_METRICS_PATH=\"${PGPOOL_METRICS_PATH}\"; export PGPOOL_LISTEN_ADDRESS=\"${PGPOOL_LISTEN_ADDRESS}\"; export DATA_SOURCE_USER=\"${POSTGRES_USERNAME}\" ; export DATA_SOURCE_PASS=\"${POSTGRES_PASSWORD}\" ; export DATA_SOURCE_URI=\"${PGPOOL_SERVICE}:${PGPOOL_SERVICE_PORT}/${POSTGRES_DATABASE}?sslmode=${SSLMODE}\" ; /bin/pgpool2_exporter --web.listen-address=:${PGPOOL_LISTEN_ADDRESS} --web.telemetry-path=${PGPOOL_METRICS_PATH} --log.level=${PGPOOL_LOG_LEVEL} --log.format=${PGPOOL_LOG_FORMAT}"]

EXPOSE 9719
EXPOSE ${PGPOOL_LISTEN_ADDRESS}
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,19 @@ This package is available for Docker. The following environment variables config

* `PGPOOL_SERVICE_PORT`
Pgpool-II port number. Default is `9999`.


* `PGPOOL_LISTEN_ADDRESS`
Pgpool-II metrics listen address. Default is `9179`.

* `PGPOOL_METRICS_PATH`
Pgpool-II metrics path. Default is `/metrics`.

* `PGPOOL_LOG_LEVEL`
Pgpool-II log level. Default is `info`.

* `PGPOOL_LOG_FORMAT`
Pgpool-II log format. Default is `logfmt`.

* `SSLMODE`
Whether or not to use SSL. Default is `disable`. Valid values: disable, require, verify-ca, verify-full.

Expand All @@ -80,6 +92,10 @@ docker run --name pgpool2_exporter \
-e POSTGRES_DATABASE=<database> \
-e PGPOOL_SERVICE=<hostname> \
-e PGPOOL_SERVICE_PORT=<port> \
-e PGPOOL_LISTEN_ADDRESS=<listen port> \
-e PGPOOL_METRICS_PATH=<path> \
-e PGPOOL_LOG_LEVEL=<log level> \
-e PGPOOL_LOG_FORMAT=<log format> \
-e SSLMODE=<sslmode> \
pgpool/pgpool2_exporter:latest
```
Expand Down