Skip to content

Commit

Permalink
Updated README, adding new Docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
Marco Pracucci committed Dec 11, 2018
1 parent fc3c2a1 commit 7a6e288
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 13 deletions.
21 changes: 21 additions & 0 deletions DOCKER-IMAGE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
This public image provides an easy way to run the [prometheus-pgbouncer-exporter](https://github.com/spreaker/prometheus-pgbouncer-exporter).


## Basic configuration via environment variables

The image is shipped with a [default config file](https://github.com/spreaker/prometheus-pgbouncer-exporter/blob/master/config.docker.yml) which should be suitable to cover a basic usage. The default config file supports the following placeholders to be replaced via environment variables:


| Environment variable | Default value | Description |
| ----------------------- | ------------- | ----------- |
| PGBOUNCER_EXPORTER_HOST | `127.0.0.1` | Host on which the exporter should listen to |
| PGBOUNCER_EXPORTER_PORT | `9127` | Port on which the exporter should listen to |
| PGBOUNCER_HOST | `localhost` | Host of the backend pgbouncer to which the exporter should connect to |
| PGBOUNCER_PORT | `6432` | Port of the backend pgbouncer to which the exporter should connect to |
| PGBOUNCER_USER | `pgbouncer` | Username used to connect to pgbouncer |
| PGBOUNCER_PASS | _empty_ | Password used to connect to pgbouncer |


## Providing a custom configuration file

If the default config file doesn't fit your use case, you can provide a custom one mounting it as a single-file to `/etc/pgbouncer-exporter/config.yml`.
16 changes: 10 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
FROM python:3.6.6-alpine
FROM python:3.6.7-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 && \
python3 -m pip install prometheus-pgbouncer-exporter==2.0.1 --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
ENV PGBOUNCER_EXPORTER_HOST="127.0.0.1" \
PGBOUNCER_EXPORTER_PORT=9127 \
PGBOUNCER_USER="pgbouncer" \
PGBOUNCER_PASS="" \
PGBOUNCER_HOST="localhost" \
PGBOUNCER_PORT=6432

EXPOSE 9127

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

ENTRYPOINT ["pgbouncer-exporter"]
CMD ["--config", "/etc/pgbouncer-exporter/config.yml"]
CMD ["--config", "/etc/pgbouncer-exporter/config.yml"]
39 changes: 32 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
# Prometheus exporter for PgBouncer


## How to install
## How to use it

You have two options to use it:

1. Manually install and run the `prometheus-pgbouncer-exporter` Python package
2. Use the [Docker image available on Docker hub](https://hub.docker.com/r/spreaker/prometheus-pgbouncer-exporter/) (_see instructions on Docker hub_)


## How to manually install and run it

The following will install the exporter whose entrypoint binary is called `pgbouncer-exporter`:

```
pip3 install prometheus-pgbouncer-exporter
```


## How to run it

The exporter accepts configuration via config file, you can specify with `--config` argument:

`pgbouncer-exporter --config ./config.yml`
Expand Down Expand Up @@ -141,9 +146,29 @@ pycodestyle --max-line-length=300 prometheus_pgbouncer_exporter/*.py

### How to publish a new version

1. [Release new version on GitHub](https://github.com/spreaker/prometheus-pgbouncer-exporter/releases)
2. Update version in `setup.py`
3. Run `python3 setup.py sdist upload -r pypi`
**Release python package**:

1. Update version in `setup.py`
2. Update `CHANGELOG.md`
3. [Release new version on GitHub](https://github.com/spreaker/prometheus-pgbouncer-exporter/releases)
4. Run `python3 setup.py sdist upload -r pypi`

**Release Docker image**:

1. Update package version in `Dockerfile`
2. Build image
```
docker rmi -f prometheus-pgbouncer-exporter && \
docker build -t prometheus-pgbouncer-exporter .
```
3. Tag the image and push it to Docker Hub
```
docker tag prometheus-pgbouncer-exporter spreaker/prometheus-pgbouncer-exporter:latest && \
docker push spreaker/prometheus-pgbouncer-exporter:latest

docker tag prometheus-pgbouncer-exporter spreaker/prometheus-pgbouncer-exporter:2.0.1 && \
docker push spreaker/prometheus-pgbouncer-exporter:2.0.1
```
## License
Expand Down

0 comments on commit 7a6e288

Please sign in to comment.