Skip to content

Commit

Permalink
Add Dockerfile with minimal setup
Browse files Browse the repository at this point in the history
* Uses an Python 3.6 alpine linux image to reduce memory consumption.
* Add config.yml file with minimal configuration.
* Default port set to 9127 as it is recommended by Prometheus default port allocations (https://github.com/prometheus/prometheus/wiki/Default-port-allocations).
  • Loading branch information
Marc Tudurí committed Aug 17, 2018
1 parent 57daf42 commit a8dc493
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
17 changes: 17 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM python:3.6.6-alpine

RUN apk update && \
apk add postgresql-libs && \
apk add --virtual .build-deps gcc musl-dev postgresql-dev && \
python3 -m pip install prometheus-pgbouncer-exporter --no-cache-dir && \
apk --purge del .build-deps

ENV PGBOUNCER_EXPORTER_HOST="127.0.0.1" PGBOUNCER_EXPORTER_PORT=9127 \
PGBOUNCER_USER="pgbouncer" PGBOUNCER_PASS="" \
PGBOUNCER_HOST="localhost" PGBOUNCER_PORT=6543
EXPOSE 9127

COPY config.docker.yml /etc/pgbouncer-exporter/config.yml

ENTRYPOINT ["pgbouncer-exporter"]
CMD ["--config", "/etc/pgbouncer-exporter/config.yml"]
16 changes: 16 additions & 0 deletions config.docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# The host on which the exporter should listen to (defaults to 127.0.0.1)
exporter_host: $(PGBOUNCER_EXPORTER_HOST)

# The port on which the exporter should listen to (defaults to 9127)
exporter_port: $(PGBOUNCER_EXPORTER_PORT)

# The list of pgbouncer instances to monitor
pgbouncers:
-
# The pgbouncer connection string. Supports environment variables replacement
# Ie. $(PGBOUNCER_PASS) is replaced with the content of "PGBOUNCER_PASS" environment
# variable if exist, or left untouched if doesn't exist
dsn: postgresql://$(PGBOUNCER_USER):$(PGBOUNCER_PASS)@$(PGBOUNCER_HOST):$(PGBOUNCER_PORT)/pgbouncer

# The pgbouncer connection timeout in seconds (defaults to 5 seconds)
connect_timeout: 5

0 comments on commit a8dc493

Please sign in to comment.