Skip to content

Commit 13f2206

Browse files
committed
update to lib/pq v1.1.1 with SCRAM auth support as used by postgres11, and modernize to go modules
Make building simpler: - move cmd/postgres_exporter to . - use go build, not mage - add a docker-compose file that spawns all postgres versions and run tests against each of them. - remove the tools directory with linting tools. i've run golangci-lint locally. - no copying of assets Not done: - travis ci tests - running (passing) the existing integration tests - running golangci-lint automatically (instead of the old linters). but then probably run it through docker. the source has a lot of go dependencies, don't want to make our go.mod huge. the alternative is a separate tools dir and go.mod file (instead of a tools.go in the root dir). - increasing test coverage
1 parent 734dc50 commit 13f2206

File tree

1,307 files changed

+80947
-322234
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,307 files changed

+80947
-322234
lines changed

.dockerignore

Lines changed: 0 additions & 2 deletions
This file was deleted.

Dockerfile

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
FROM scratch
2-
3-
ARG binary
4-
5-
COPY $binary /postgres_exporter
1+
FROM golang AS build
2+
COPY . /src
3+
WORKDIR /src
4+
RUN CGO_ENABLED=0 GOFLAGS=-mod=vendor GOPROXY=off go build
65

6+
FROM scratch
7+
COPY --from=build /src/postgres_exporter /postgres_exporter
78
EXPOSE 9187
8-
9-
ENTRYPOINT [ "/postgres_exporter" ]
9+
ENTRYPOINT ["/postgres_exporter"]

README.md

Lines changed: 7 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -6,39 +6,20 @@
66

77
Prometheus exporter for PostgreSQL server metrics.
88

9-
CI Tested PostgreSQL versions: `9.1`, `9.2`, `9.3`, `9.4`, `9.5`, `9.6`, `10`, `11`
10-
11-
## Quick Start
12-
This package is available for Docker:
13-
```
14-
# Start an example database
15-
docker run --net=host -it --rm -e POSTGRES_PASSWORD=password postgres
16-
# Connect to it
17-
docker run --net=host -e DATA_SOURCE_NAME="postgresql://postgres:password@localhost:5432/postgres?sslmode=disable" wrouesnel/postgres_exporter
18-
```
9+
Tested PostgreSQL versions: `9.1`, `9.2`, `9.3`, `9.4`, `9.5`, `9.6`, `10`, `11`, `12`.
1910

2011
## Building and running
2112

22-
The build system is based on [Mage](https://magefile.org)
23-
24-
The default make file behavior is to build the binary:
2513
```
26-
$ go get github.com/wrouesnel/postgres_exporter
27-
$ cd ${GOPATH-$HOME/go}/src/github.com/wrouesnel/postgres_exporter
28-
$ go run mage.go
29-
$ export DATA_SOURCE_NAME="postgresql://login:password@hostname:port/dbname"
30-
$ ./postgres_exporter <flags>
14+
$ go build
15+
$ DATA_SOURCE_NAME="postgresql://login:password@hostname:port/dbname" ./postgres_exporter <flags>
3116
```
3217

33-
To build the dockerfile, run `go run mage.go docker`.
18+
## Testing
3419

35-
This will build the docker image as `wrouesnel/postgres_exporter:latest`. This
36-
is a minimal docker image containing *just* postgres_exporter. By default no SSL
37-
certificates are included, if you need to use SSL you should either bind-mount
38-
`/etc/ssl/certs/ca-certificates.crt` or derive a new image containing them.
39-
40-
### Vendoring
41-
Package vendoring is handled with [`govendor`](https://github.com/kardianos/govendor)
20+
```
21+
$ docker-compose up --exit-code-from postgres_exporter
22+
```
4223

4324
### Flags
4425

@@ -211,10 +192,3 @@ GRANT SELECT ON postgres_exporter.pg_stat_replication TO postgres_exporter;
211192
> ```
212193
> DATA_SOURCE_NAME=postgresql://postgres_exporter:password@localhost:5432/postgres?sslmode=disable
213194
> ```
214-
215-
# Hacking
216-
* To build a copy for your current architecture run `go run mage.go binary` or just `go run mage.go`
217-
This will create a symlink to the just built binary in the root directory.
218-
* To build release tar balls run `go run mage.go release`.
219-
* Build system is a bit temperamental at the moment since the conversion to mage - I am working on getting it
220-
to be a perfect out of the box experience, but am time-constrained on it at the moment.

docker-compose.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
version: '3'
2+
services:
3+
postgres_exporter:
4+
image: golang:latest
5+
volumes:
6+
- .:/src
7+
working_dir: /src
8+
command: bash -c 'set -e; export GOPROXY=off; export GOFLAGS=-mod=vendor; for v in 91 92 93 94 95 96 10 11 12; do DATA_SOURCE_NAME=postgres://postgres:postgres@postgres$${v}:$${v}25/postgres?sslmode=disable go test -race -cover; done'
9+
links:
10+
- postgres91
11+
- postgres92
12+
- postgres93
13+
- postgres94
14+
- postgres95
15+
- postgres96
16+
- postgres10
17+
- postgres11
18+
- postgres12
19+
20+
postgres91:
21+
image: postgres:9.1
22+
ports:
23+
- "9125:5432"
24+
25+
postgres92:
26+
image: postgres:9.2
27+
ports:
28+
- "9225:5432"
29+
30+
postgres93:
31+
image: postgres:9.3
32+
ports:
33+
- "9325:5432"
34+
35+
postgres94:
36+
image: postgres:9.4
37+
ports:
38+
- "9425:5432"
39+
40+
postgres95:
41+
image: postgres:9.5
42+
ports:
43+
- "9525:5432"
44+
45+
postgres96:
46+
image: postgres:9.6
47+
ports:
48+
- "9625:5432"
49+
50+
postgres10:
51+
image: postgres:10
52+
ports:
53+
- "1025:5432"
54+
55+
postgres11:
56+
image: postgres:11
57+
ports:
58+
- "1125:5432"
59+
60+
postgres12:
61+
image: postgres:12
62+
ports:
63+
- "1225:5432"

gh-assets-clone.sh

Lines changed: 0 additions & 18 deletions
This file was deleted.

gh-metrics-push.sh

Lines changed: 0 additions & 29 deletions
This file was deleted.

go.mod

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
module github.com/mjl-/postgres_exporter
2+
3+
go 1.12
4+
5+
require (
6+
github.com/alecthomas/assert v0.0.0-20170929043011-405dbfeb8e38 // indirect
7+
github.com/alecthomas/colour v0.0.0-20160524082231-60882d9e2721 // indirect
8+
github.com/alecthomas/repr v0.0.0-20181024024818-d37bc2a10ba1 // indirect
9+
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc // indirect
10+
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf // indirect
11+
github.com/beorn7/perks v0.0.0-20160804104726-4c0e84591b9a // indirect
12+
github.com/blang/semver v3.5.1+incompatible
13+
github.com/lib/pq v1.1.1
14+
github.com/mattn/go-isatty v0.0.8 // indirect
15+
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
16+
github.com/onsi/ginkgo v1.8.0 // indirect
17+
github.com/onsi/gomega v1.5.0 // indirect
18+
github.com/prometheus/client_golang v0.0.0-20171005112915-5cec1d0429b0
19+
github.com/prometheus/client_model v0.0.0-20170216185247-6f3806018612
20+
github.com/prometheus/common v0.0.0-20171006141418-1bab55dd05db
21+
github.com/prometheus/procfs v0.0.0-20171017214025-a6e9df898b13 // indirect
22+
github.com/sergi/go-diff v1.0.0 // indirect
23+
github.com/sirupsen/logrus v0.0.0-20170822132746-89742aefa4b2 // indirect
24+
github.com/stretchr/testify v1.3.0 // indirect
25+
golang.org/x/crypto v0.0.0-20171023145632-2509b142fb2b // indirect
26+
golang.org/x/sync v0.0.0-20190423024810-112230192c58 // indirect
27+
gopkg.in/airbrake/gobrake.v2 v2.0.9 // indirect
28+
gopkg.in/alecthomas/kingpin.v2 v2.2.5
29+
gopkg.in/check.v1 v1.0.0-20161208181325-20d25e280405
30+
gopkg.in/gemnasium/logrus-airbrake-hook.v2 v2.1.2 // indirect
31+
gopkg.in/yaml.v2 v2.2.1
32+
)

go.sum

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
github.com/alecthomas/assert v0.0.0-20170929043011-405dbfeb8e38 h1:smF2tmSOzy2Mm+0dGI2AIUHY+w0BUc+4tn40djz7+6U=
2+
github.com/alecthomas/assert v0.0.0-20170929043011-405dbfeb8e38/go.mod h1:r7bzyVFMNntcxPZXK3/+KdruV1H5KSlyVY0gc+NgInI=
3+
github.com/alecthomas/colour v0.0.0-20160524082231-60882d9e2721 h1:JHZL0hZKJ1VENNfmXvHbgYlbUOvpzYzvy2aZU5gXVeo=
4+
github.com/alecthomas/colour v0.0.0-20160524082231-60882d9e2721/go.mod h1:QO9JBoKquHd+jz9nshCh40fOfO+JzsoXy8qTHF68zU0=
5+
github.com/alecthomas/repr v0.0.0-20181024024818-d37bc2a10ba1 h1:GDQdwm/gAcJcLAKQQZGOJ4knlw+7rfEQQcmwTbt4p5E=
6+
github.com/alecthomas/repr v0.0.0-20181024024818-d37bc2a10ba1/go.mod h1:xTS7Pm1pD1mvyM075QCDSRqH6qRLXylzS24ZTpRiSzQ=
7+
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc h1:cAKDfWh5VpdgMhJosfJnn5/FoN2SRZ4p7fJNX58YPaU=
8+
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
9+
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf h1:qet1QNfXsQxTZqLG4oE62mJzwPIB8+Tee4RNCL9ulrY=
10+
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
11+
github.com/beorn7/perks v0.0.0-20160804104726-4c0e84591b9a h1:BtpsbiV638WQZwhA98cEZw2BsbnQJrbd0BI7tsy0W1c=
12+
github.com/beorn7/perks v0.0.0-20160804104726-4c0e84591b9a/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
13+
github.com/blang/semver v3.5.1+incompatible h1:cQNTCjp13qL8KC3Nbxr/y2Bqb63oX6wdnnjpJbkM4JQ=
14+
github.com/blang/semver v3.5.1+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk=
15+
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
16+
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
17+
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
18+
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
19+
github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM=
20+
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
21+
github.com/golangci/golangci-lint v1.17.1 h1:lc8Hf9GPCjIr0hg3S/xhvFT1+Hydass8F1xchr8jkME=
22+
github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
23+
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
24+
github.com/lib/pq v1.1.1 h1:sJZmqHoEaY7f+NPP8pgLB/WxulyR3fewgCM2qaSlBb4=
25+
github.com/lib/pq v1.1.1/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
26+
github.com/mattn/go-isatty v0.0.8 h1:HLtExJ+uU2HOZ+wI0Tt5DtUDrx8yhUqDcp7fYERX4CE=
27+
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
28+
github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU=
29+
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
30+
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
31+
github.com/onsi/ginkgo v1.8.0 h1:VkHVNpR4iVnU8XQR6DBm8BqYjN7CRzw+xKUbVVbbW9w=
32+
github.com/onsi/ginkgo v1.8.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
33+
github.com/onsi/gomega v1.5.0 h1:izbySO9zDPmjJ8rDjLvkA2zJHIo+HkYXHnf7eN7SSyo=
34+
github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
35+
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
36+
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
37+
github.com/prometheus/client_golang v0.0.0-20171005112915-5cec1d0429b0 h1:uEiENdm9N5Nj3ezfwdvwBGc2EHLiUgD3hUTOaMfBn5E=
38+
github.com/prometheus/client_golang v0.0.0-20171005112915-5cec1d0429b0/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
39+
github.com/prometheus/client_model v0.0.0-20170216185247-6f3806018612 h1:13pIdM2tpaDi4OVe24fgoIS7ZTqMt0QI+bwQsX5hq+g=
40+
github.com/prometheus/client_model v0.0.0-20170216185247-6f3806018612/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
41+
github.com/prometheus/common v0.0.0-20171006141418-1bab55dd05db h1:PmL7nSW2mvuotGlJKuvUcSI/eE86zwYUcIAGoB6eHBk=
42+
github.com/prometheus/common v0.0.0-20171006141418-1bab55dd05db/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro=
43+
github.com/prometheus/procfs v0.0.0-20171017214025-a6e9df898b13 h1:leRfx9kcgnSDkqAFhaaUcRqpAZgnFdwZkZcdRcea1h0=
44+
github.com/prometheus/procfs v0.0.0-20171017214025-a6e9df898b13/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
45+
github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ=
46+
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
47+
github.com/sirupsen/logrus v0.0.0-20170822132746-89742aefa4b2 h1:+8J/sCAVv2Y9Ct1BKszDFJEVWv6Aynr2O4FYGUg6+Mc=
48+
github.com/sirupsen/logrus v0.0.0-20170822132746-89742aefa4b2/go.mod h1:pMByvHTf9Beacp5x1UXfOR9xyW/9antXMhjMPG0dEzc=
49+
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
50+
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
51+
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
52+
golang.org/x/crypto v0.0.0-20171023145632-2509b142fb2b h1:vXxKaRjFiMao1tDygYZfT9iEZkE49b7scEND45gopd0=
53+
golang.org/x/crypto v0.0.0-20171023145632-2509b142fb2b/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
54+
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd h1:nTDtHvHSdCn1m6ITfMRqtOd/9+7a3s8RBNOZ3eYZzJA=
55+
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
56+
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
57+
golang.org/x/sync v0.0.0-20190423024810-112230192c58 h1:8gQV6CLnAEikrhgkHFbMAEhagSSnXWGV915qUMm9mrU=
58+
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
59+
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
60+
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223 h1:DH4skfRX4EBpamg7iV4ZlCpblAHI6s6TDM39bFZumv8=
61+
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
62+
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
63+
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
64+
gopkg.in/airbrake/gobrake.v2 v2.0.9 h1:7z2uVWwn7oVeeugY1DtlPAy5H+KYgB1KeKTnqjNatLo=
65+
gopkg.in/airbrake/gobrake.v2 v2.0.9/go.mod h1:/h5ZAUhDkGaJfjzjKLSjv6zCL6O0LLBxU4K+aSYdM/U=
66+
gopkg.in/alecthomas/kingpin.v2 v2.2.5 h1:qskSCq465uEvC3oGocwvZNsO3RF3SpLVLumOAhL0bXo=
67+
gopkg.in/alecthomas/kingpin.v2 v2.2.5/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
68+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
69+
gopkg.in/check.v1 v1.0.0-20161208181325-20d25e280405 h1:829vOVxxusYHC+IqBtkX5mbKtsY9fheQiQn0MZRVLfQ=
70+
gopkg.in/check.v1 v1.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
71+
gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4=
72+
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
73+
gopkg.in/gemnasium/logrus-airbrake-hook.v2 v2.1.2 h1:OAj3g0cR6Dx/R07QgQe8wkA9RNjB2u4i700xBkIT4e0=
74+
gopkg.in/gemnasium/logrus-airbrake-hook.v2 v2.1.2/go.mod h1:Xk6kEKp8OKb+X14hQBKWaSkCsqBpgog8nAV2xsGOxlo=
75+
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
76+
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
77+
gopkg.in/yaml.v2 v2.2.1 h1:mUhvW9EsL+naU5Q3cakzfE91YhliOondGd6ZrsDBHQE=
78+
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=

mage.go

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)