Closed
Description
This error is thrown when I run the postgres_exporter container as a service inside docker swarm
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x6fbe6a]
goroutine 18 [running]:
main.(*Exporter).scrape(0xc4201080c0, 0xc42010c1e0)
/home/travis/gopath/src/github.com/wrouesnel/postgres_exporter/postgres_exporter.go:956 +0x25a
main.(*Exporter).Collect(0xc4201080c0, 0xc42010c1e0)
/home/travis/gopath/src/github.com/wrouesnel/postgres_exporter/postgres_exporter.go:744 +0x39
main.(*Exporter).Describe(0xc4201080c0, 0xc42010c180)
/home/travis/gopath/src/github.com/wrouesnel/postgres_exporter/postgres_exporter.go:737 +0xb0
github.com/wrouesnel/postgres_exporter/vendor/github.com/prometheus/client_golang/prometheus.(*registry).Register.func1(0x9459c0, 0xc4201080c0, 0xc42010c180)
/home/travis/gopath/src/github.com/wrouesnel/postgres_exporter/vendor/github.com/prometheus/client_golang/prometheus/registry.go:218 +0x3b
created by github.com/wrouesnel/postgres_exporter/vendor/github.com/prometheus/client_golang/prometheus.(*registry).Register
/home/travis/gopath/src/github.com/wrouesnel/postgres_exporter/vendor/github.com/prometheus/client_golang/prometheus/registry.go:220 +0xbc
Observations
- It works well when I run the container as standalone container in same server
- The
DATA_SOURCE_NAME
is set properly. I've verified this by getting inside container (I had to create docker image with alpine linux for debugging this)
/ # env
DATA_SOURCE_NAME="postgresql://postgres_exporter:[email protected]:5432/postgres"
- I've verified that psql client can connect to postgres using same connection string
apk --update add postgresql-client
/ # psql "postgresql://postgres_exporter:[email protected]:5432/postgres"
psql (9.6.3, server 9.5.7)
SSL connection (protocol: TLSv1.2, cipher: ECDHE-RSA-AES256-GCM-SHA384, bits: 256, compression: off)
Type "help" for help.
postgres=#
Dockerfile
used for creating image for debugging
FROM alpine:3.6
ARG POSTGRES_EXPORTER_VERSION=v0.2.1
RUN apk --no-cache add openssl
RUN wget -O /usr/local/bin/postgres_exporter https://github.com/wrouesnel/postgres_exporter/releases/download/$POSTGRES_EXPORTER_VERSION/postgres_exporter && \
chmod +x /usr/local/bin/postgres_exporter
EXPOSE 9187
ENTRYPOINT ["/usr/local/bin/postgres_exporter"]
Metadata
Metadata
Assignees
Labels
No labels