diff --git a/.gitignore b/.gitignore index c159cb0a5..84d37acf5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,4 @@ /.build -/postgres_exporter /postgres_exporter_integration_test *.tar.gz *.test @@ -10,7 +9,6 @@ /cover.out /cover.*.out /.coverage -/bin /release /*.prom /.metrics.*.*.prom diff --git a/Dockerfile b/Dockerfile index 86128d41a..57e6df194 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,15 +1,11 @@ -FROM debian:7.11-slim -RUN useradd -u 20001 postgres_exporter +FROM debian:10-slim +RUN apt-get update \ + && apt-get -y install ca-certificates \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists -FROM scratch - -COPY --from=0 /etc/passwd /etc/passwd -USER postgres_exporter - -ARG binary - -COPY $binary /postgres_exporter +COPY bin/postgres_exporter /usr/bin/postgres_exporter EXPOSE 9187 -ENTRYPOINT [ "/postgres_exporter" ] +ENTRYPOINT [ "/usr/bin/postgres_exporter" ] diff --git a/README.md b/README.md index c16daa313..a072b6f44 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ [![Go Report Card](https://goreportcard.com/badge/github.com/wrouesnel/postgres_exporter)](https://goreportcard.com/report/github.com/wrouesnel/postgres_exporter) [![Docker Pulls](https://img.shields.io/docker/pulls/wrouesnel/postgres_exporter.svg)](https://hub.docker.com/r/wrouesnel/postgres_exporter/tags) -# PostgreSQL Server Exporter +# PostgreSQL Server Exporter with SSL Support Prometheus exporter for PostgreSQL server metrics. @@ -15,7 +15,7 @@ This package is available for Docker: # Start an example database docker run --net=host -it --rm -e POSTGRES_PASSWORD=password postgres # Connect to it -docker run --net=host -e DATA_SOURCE_NAME="postgresql://postgres:password@localhost:5432/postgres?sslmode=disable" wrouesnel/postgres_exporter +docker run --net=host -e DATA_SOURCE_NAME="postgresql://postgres:password@localhost:5432/postgres?sslmode=require" mattalord/postgres_exporter_ssl ``` ## Building and running @@ -33,11 +33,6 @@ $ ./postgres_exporter To build the dockerfile, run `go run mage.go docker`. -This will build the docker image as `wrouesnel/postgres_exporter:latest`. This -is a minimal docker image containing *just* postgres_exporter. By default no SSL -certificates are included, if you need to use SSL you should either bind-mount -`/etc/ssl/certs/ca-certificates.crt` or derive a new image containing them. - ### Vendoring Package vendoring is handled with [`govendor`](https://github.com/kardianos/govendor) @@ -127,7 +122,7 @@ must be set via the `DATA_SOURCE_NAME` environment variable. For running it locally on a default Debian/Ubuntu install, this will work (transpose to init script as appropriate): - sudo -u postgres DATA_SOURCE_NAME="user=postgres host=/var/run/postgresql/ sslmode=disable" postgres_exporter + sudo -u postgres DATA_SOURCE_NAME="user=postgres host=/var/run/postgresql/sslmode=require" postgres_exporter Also, you can set a list of sources to scrape different instances from the one exporter setup. Just define a comma separated string. @@ -237,7 +232,7 @@ GRANT SELECT ON postgres_exporter.pg_stat_replication TO postgres_exporter; > **NOTE** >
Remember to use `postgres` database name in the connection string: > ``` -> DATA_SOURCE_NAME=postgresql://postgres_exporter:password@localhost:5432/postgres?sslmode=disable +> DATA_SOURCE_NAME=postgresql://postgres_exporter:password@localhost:5432/postgres?sslmode=require > ``` # Hacking diff --git a/bin/postgres_exporter b/bin/postgres_exporter new file mode 100755 index 000000000..89edd47f7 Binary files /dev/null and b/bin/postgres_exporter differ