From 2a8bef52350736e7fc854a3b495e6702b6d43f3f Mon Sep 17 00:00:00 2001
From: Marcus Martins <marcus@docker.com>
Date: Thu, 5 May 2016 18:07:27 -0700
Subject: [PATCH 1/4] Handle `pg_runtime_variable` return values

When querying postgres `pg_runtime_variable`, postgres might return -1
for `max_standby_archive_delay` and `max_standby_streaming_delay`
---
 postgres_exporter.go | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/postgres_exporter.go b/postgres_exporter.go
index 8d2db15c..b78abad7 100644
--- a/postgres_exporter.go
+++ b/postgres_exporter.go
@@ -286,6 +286,10 @@ func makeDescMap(metricMaps map[string]map[string]ColumnMapping) map[string]Metr
 							return math.NaN(), false
 						}
 
+						if durationString == "-1" {
+							return math.NaN(), false
+						}
+
 						d, err := time.ParseDuration(durationString)
 						if err != nil {
 							log.Errorln("Failed converting result to metric:", columnName, in, err)

From 8cca2a59a5368c1f7dc05cc04ba3c7f4cc02b7fb Mon Sep 17 00:00:00 2001
From: Will Rouesnel <w.rouesnel@gmail.com>
Date: Sat, 28 May 2016 17:03:38 +1000
Subject: [PATCH 2/4] Add docker based integration test suite.

This simply pulls and runs postgres against a number of versions and checks
that we can successfully connect to it.
---
 .travis.yml          |  1 +
 Makefile             |  3 ++
 postgres_exporter.go |  2 +-
 tests/test-smoke     | 73 ++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 78 insertions(+), 1 deletion(-)
 create mode 100755 tests/test-smoke

diff --git a/.travis.yml b/.travis.yml
index 0576fa40..b6f9994a 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -7,6 +7,7 @@ go:
 script:
 - make all
 - make docker
+- make test-integration
 after_success:
 - if [ "$TRAVIS_BRANCH" == "master" ]; then docker login -e $DOCKER_EMAIL -u $DOCKER_USER
   -p $DOCKER_PASS ; docker push wrouesnel/postgres_exporter ; fi
diff --git a/Makefile b/Makefile
index 4266de96..860109a8 100644
--- a/Makefile
+++ b/Makefile
@@ -21,6 +21,9 @@ vet:
 test:
 	go test -v .
 
+test-integration:
+	tests/test-smoke
+
 # Do a self-contained docker build - we pull the official upstream container,
 # then template out a dockerfile which builds the real image.
 docker-build: postgres_exporter
diff --git a/postgres_exporter.go b/postgres_exporter.go
index 12ba8192..efc236db 100644
--- a/postgres_exporter.go
+++ b/postgres_exporter.go
@@ -19,7 +19,7 @@ import (
 	"strconv"
 )
 
-var Version string = "0.0.0-dev"
+var Version string = "0.0.1"
 
 var (
 	listenAddress = flag.String(
diff --git a/tests/test-smoke b/tests/test-smoke
new file mode 100755
index 00000000..ff089b75
--- /dev/null
+++ b/tests/test-smoke
@@ -0,0 +1,73 @@
+#!/bin/bash
+# Basic integration tests with postgres. Requires docker to work.
+
+VERSIONS=( \
+    9.1 \
+    9.2 \
+    9.3 \
+    9.4 \
+    9.5 \
+)
+
+smoketest_postgres() {
+    local version=$1
+    local CONTAINER_NAME=postgres_exporter-test-smoke
+    local TIMEOUT=30
+    local IMAGE_NAME=postgres
+    
+    local CUR_IMAGE=$IMAGE_NAME:$version
+    
+    docker run -d --name=$CONTAINER_NAME -e POSTGRES_PASSWORD=password -p 127.0.0.1:55432:5432 $CUR_IMAGE
+
+    local WAIT_START=$(date +%s)
+    while ! docker exec $CONTAINER_NAME bash -c "psql -U postgres -c \"select 'running'\" > /dev/null 2>&1 " ; do
+        echo "Waiting for postgres to start..."
+        if [ $(( $(date +%s) - $WAIT_START )) -gt $TIMEOUT ]; then
+            echo "Timed out waiting for postgres!" 1>&2
+            docker logs $CONTAINER_NAME
+            docker kill $CONTAINER_NAME
+            docker rm $CONTAINER_NAME
+            exit 1
+        fi
+        sleep 1
+    done
+
+    DATA_SOURCE_NAME="postgresql://postgres:password@localhost:55432/?sslmode=disable" ./postgres_exporter &
+    exporter_pid=$!
+    local DAEMON_WAIT_START=$(date +%s)
+    while ! nc -z localhost 9113 ; do
+        echo "Waiting for exporter to start..."
+        if [ $(( $(date +%s) - $WAIT_START )) -gt $TIMEOUT ]; then
+            echo "Timed out waiting for exporter!" 1>&2
+            docker logs $CONTAINER_NAME
+            docker kill $CONTAINER_NAME
+            docker rm $CONTAINER_NAME
+            exit 1            
+        fi
+        sleep 1
+    done
+
+    wget -q -O - http://localhost:9113/metrics 1> /dev/null
+    if [ "$?" != "0" ]; then
+        echo "Failed on postgres $version ($DOCKER_IMAGE)" 1>&2
+        kill $exporter_pid
+        docker logs $CONTAINER_NAME
+        docker kill $CONTAINER_NAME
+        docker rm $CONTAINER_NAME
+        exit 1
+    fi
+
+    kill $exporter_pid
+    docker kill $CONTAINER_NAME
+    docker rm $CONTAINER_NAME
+}
+
+# Start pulling the docker images in advance
+for version in ${VERSIONS[@]}; do
+    docker pull postgres:$version > /dev/null &
+done
+
+for version in ${VERSIONS[@]}; do
+    echo "Testing postgres version $version"
+    smoketest_postgres $version
+done

From 0830d3e098f757fc505bb8b406ae256a03bae121 Mon Sep 17 00:00:00 2001
From: Brian Sutherland <brian@vanguardistas.net>
Date: Thu, 28 Jul 2016 12:59:28 +0200
Subject: [PATCH 3/4] Parse strings to floats. fixes
 https://github.com/wrouesnel/postgres_exporter/issues/15

---
 postgres_exporter.go | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/postgres_exporter.go b/postgres_exporter.go
index efc236db..693880f0 100644
--- a/postgres_exporter.go
+++ b/postgres_exporter.go
@@ -323,6 +323,13 @@ func dbToFloat64(t interface{}) (float64, bool) {
 			return math.NaN(), false
 		}
 		return result, true
+	case string:
+		result, err := strconv.ParseFloat(v, 64)
+		if err != nil {
+			log.Println("Could not parse string:", err)
+			return math.NaN(), false
+		}
+		return result, true
 	case nil:
 		return math.NaN(), true
 	default:

From 09a998035d0cf8f10c05f8689fc21f43388af517 Mon Sep 17 00:00:00 2001
From: Travis Cline <travis.cline@gmail.com>
Date: Fri, 5 Aug 2016 18:54:41 -0700
Subject: [PATCH 4/4] update to use common/log

---
 postgres_exporter.go                          |  21 +-
 .../prometheus/{log => common}/LICENSE        |   0
 vendor/github.com/prometheus/common/NOTICE    |   5 +
 .../github.com/prometheus/common/log/log.go   | 324 ++++++++++++++++++
 .../prometheus/common/log/syslog_formatter.go | 119 +++++++
 vendor/github.com/prometheus/log/AUTHORS.md   |  11 -
 .../github.com/prometheus/log/CONTRIBUTING.md |  18 -
 vendor/github.com/prometheus/log/NOTICE       |   2 -
 vendor/github.com/prometheus/log/README.md    |  10 -
 vendor/github.com/prometheus/log/log.go       | 171 ---------
 vendor/vendor.json                            |  14 +-
 11 files changed, 465 insertions(+), 230 deletions(-)
 rename vendor/github.com/prometheus/{log => common}/LICENSE (100%)
 create mode 100644 vendor/github.com/prometheus/common/NOTICE
 create mode 100644 vendor/github.com/prometheus/common/log/log.go
 create mode 100644 vendor/github.com/prometheus/common/log/syslog_formatter.go
 delete mode 100644 vendor/github.com/prometheus/log/AUTHORS.md
 delete mode 100644 vendor/github.com/prometheus/log/CONTRIBUTING.md
 delete mode 100644 vendor/github.com/prometheus/log/NOTICE
 delete mode 100644 vendor/github.com/prometheus/log/README.md
 delete mode 100644 vendor/github.com/prometheus/log/log.go

diff --git a/postgres_exporter.go b/postgres_exporter.go
index 1d7248fa..681daa4f 100644
--- a/postgres_exporter.go
+++ b/postgres_exporter.go
@@ -1,22 +1,19 @@
 package main
 
 import (
-	//"bytes"
 	"database/sql"
 	"flag"
 	"fmt"
+	"math"
 	"net/http"
 	"os"
-	//"regexp"
-	//"strconv"
-	//"strings"
-	"math"
 	"time"
 
+	"strconv"
+
 	_ "github.com/lib/pq"
 	"github.com/prometheus/client_golang/prometheus"
-	"github.com/prometheus/log"
-	"strconv"
+	"github.com/prometheus/common/log"
 )
 
 var Version string = "0.0.1"
@@ -330,7 +327,7 @@ func dbToFloat64(t interface{}) (float64, bool) {
 	case string:
 		result, err := strconv.ParseFloat(v, 64)
 		if err != nil {
-			log.Println("Could not parse string:", err)
+			log.Infoln("Could not parse string:", err)
 			return math.NaN(), false
 		}
 		return result, true
@@ -452,7 +449,7 @@ func (e *Exporter) scrape(ch chan<- prometheus.Metric) {
 
 	db, err := sql.Open("postgres", e.dsn)
 	if err != nil {
-		log.Println("Error opening connection to database:", err)
+		log.Infoln("Error opening connection to database:", err)
 		e.error.Set(1)
 		return
 	}
@@ -498,7 +495,7 @@ func (e *Exporter) scrape(ch chan<- prometheus.Metric) {
 			// Don't fail on a bad scrape of one metric
 			rows, err := db.Query(query)
 			if err != nil {
-				log.Println("Error running query on database: ", namespace, err)
+				log.Infoln("Error running query on database: ", namespace, err)
 				e.error.Set(1)
 				return
 			}
@@ -507,7 +504,7 @@ func (e *Exporter) scrape(ch chan<- prometheus.Metric) {
 			var columnNames []string
 			columnNames, err = rows.Columns()
 			if err != nil {
-				log.Println("Error retrieving column list for: ", namespace, err)
+				log.Infoln("Error retrieving column list for: ", namespace, err)
 				e.error.Set(1)
 				return
 			}
@@ -527,7 +524,7 @@ func (e *Exporter) scrape(ch chan<- prometheus.Metric) {
 			for rows.Next() {
 				err = rows.Scan(scanArgs...)
 				if err != nil {
-					log.Println("Error retrieving rows:", namespace, err)
+					log.Infoln("Error retrieving rows:", namespace, err)
 					e.error.Set(1)
 					return
 				}
diff --git a/vendor/github.com/prometheus/log/LICENSE b/vendor/github.com/prometheus/common/LICENSE
similarity index 100%
rename from vendor/github.com/prometheus/log/LICENSE
rename to vendor/github.com/prometheus/common/LICENSE
diff --git a/vendor/github.com/prometheus/common/NOTICE b/vendor/github.com/prometheus/common/NOTICE
new file mode 100644
index 00000000..636a2c1a
--- /dev/null
+++ b/vendor/github.com/prometheus/common/NOTICE
@@ -0,0 +1,5 @@
+Common libraries shared by Prometheus Go components.
+Copyright 2015 The Prometheus Authors
+
+This product includes software developed at
+SoundCloud Ltd. (http://soundcloud.com/).
diff --git a/vendor/github.com/prometheus/common/log/log.go b/vendor/github.com/prometheus/common/log/log.go
new file mode 100644
index 00000000..47e58c15
--- /dev/null
+++ b/vendor/github.com/prometheus/common/log/log.go
@@ -0,0 +1,324 @@
+// Copyright 2015 The Prometheus Authors
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package log
+
+import (
+	"flag"
+	"fmt"
+	"log"
+	"net/url"
+	"os"
+	"runtime"
+	"strings"
+
+	"github.com/Sirupsen/logrus"
+)
+
+type levelFlag struct{}
+
+// String implements flag.Value.
+func (f levelFlag) String() string {
+	return origLogger.Level.String()
+}
+
+// Set implements flag.Value.
+func (f levelFlag) Set(level string) error {
+	l, err := logrus.ParseLevel(level)
+	if err != nil {
+		return err
+	}
+	origLogger.Level = l
+	return nil
+}
+
+// setSyslogFormatter is nil if the target architecture does not support syslog.
+var setSyslogFormatter func(string, string) error
+
+func setJSONFormatter() {
+	origLogger.Formatter = &logrus.JSONFormatter{}
+}
+
+type logFormatFlag struct{ uri string }
+
+// String implements flag.Value.
+func (f logFormatFlag) String() string {
+	return f.uri
+}
+
+// Set implements flag.Value.
+func (f logFormatFlag) Set(format string) error {
+	f.uri = format
+	u, err := url.Parse(format)
+	if err != nil {
+		return err
+	}
+	if u.Scheme != "logger" {
+		return fmt.Errorf("invalid scheme %s", u.Scheme)
+	}
+	jsonq := u.Query().Get("json")
+	if jsonq == "true" {
+		setJSONFormatter()
+	}
+
+	switch u.Opaque {
+	case "syslog":
+		if setSyslogFormatter == nil {
+			return fmt.Errorf("system does not support syslog")
+		}
+		appname := u.Query().Get("appname")
+		facility := u.Query().Get("local")
+		return setSyslogFormatter(appname, facility)
+	case "stdout":
+		origLogger.Out = os.Stdout
+	case "stderr":
+		origLogger.Out = os.Stderr
+
+	default:
+		return fmt.Errorf("unsupported logger %s", u.Opaque)
+	}
+	return nil
+}
+
+func init() {
+	AddFlags(flag.CommandLine)
+}
+
+// AddFlags adds the flags used by this package to the given FlagSet. That's
+// useful if working with a custom FlagSet. The init function of this package
+// adds the flags to flag.CommandLine anyway. Thus, it's usually enough to call
+// flag.Parse() to make the logging flags take effect.
+func AddFlags(fs *flag.FlagSet) {
+	fs.Var(levelFlag{}, "log.level", "Only log messages with the given severity or above. Valid levels: [debug, info, warn, error, fatal].")
+	fs.Var(logFormatFlag{}, "log.format", "If set use a syslog logger or JSON logging. Example: logger:syslog?appname=bob&local=7 or logger:stdout?json=true. Defaults to stderr.")
+}
+
+type Logger interface {
+	Debug(...interface{})
+	Debugln(...interface{})
+	Debugf(string, ...interface{})
+
+	Info(...interface{})
+	Infoln(...interface{})
+	Infof(string, ...interface{})
+
+	Warn(...interface{})
+	Warnln(...interface{})
+	Warnf(string, ...interface{})
+
+	Error(...interface{})
+	Errorln(...interface{})
+	Errorf(string, ...interface{})
+
+	Fatal(...interface{})
+	Fatalln(...interface{})
+	Fatalf(string, ...interface{})
+
+	With(key string, value interface{}) Logger
+}
+
+type logger struct {
+	entry *logrus.Entry
+}
+
+func (l logger) With(key string, value interface{}) Logger {
+	return logger{l.entry.WithField(key, value)}
+}
+
+// Debug logs a message at level Debug on the standard logger.
+func (l logger) Debug(args ...interface{}) {
+	l.sourced().Debug(args...)
+}
+
+// Debug logs a message at level Debug on the standard logger.
+func (l logger) Debugln(args ...interface{}) {
+	l.sourced().Debugln(args...)
+}
+
+// Debugf logs a message at level Debug on the standard logger.
+func (l logger) Debugf(format string, args ...interface{}) {
+	l.sourced().Debugf(format, args...)
+}
+
+// Info logs a message at level Info on the standard logger.
+func (l logger) Info(args ...interface{}) {
+	l.sourced().Info(args...)
+}
+
+// Info logs a message at level Info on the standard logger.
+func (l logger) Infoln(args ...interface{}) {
+	l.sourced().Infoln(args...)
+}
+
+// Infof logs a message at level Info on the standard logger.
+func (l logger) Infof(format string, args ...interface{}) {
+	l.sourced().Infof(format, args...)
+}
+
+// Warn logs a message at level Warn on the standard logger.
+func (l logger) Warn(args ...interface{}) {
+	l.sourced().Warn(args...)
+}
+
+// Warn logs a message at level Warn on the standard logger.
+func (l logger) Warnln(args ...interface{}) {
+	l.sourced().Warnln(args...)
+}
+
+// Warnf logs a message at level Warn on the standard logger.
+func (l logger) Warnf(format string, args ...interface{}) {
+	l.sourced().Warnf(format, args...)
+}
+
+// Error logs a message at level Error on the standard logger.
+func (l logger) Error(args ...interface{}) {
+	l.sourced().Error(args...)
+}
+
+// Error logs a message at level Error on the standard logger.
+func (l logger) Errorln(args ...interface{}) {
+	l.sourced().Errorln(args...)
+}
+
+// Errorf logs a message at level Error on the standard logger.
+func (l logger) Errorf(format string, args ...interface{}) {
+	l.sourced().Errorf(format, args...)
+}
+
+// Fatal logs a message at level Fatal on the standard logger.
+func (l logger) Fatal(args ...interface{}) {
+	l.sourced().Fatal(args...)
+}
+
+// Fatal logs a message at level Fatal on the standard logger.
+func (l logger) Fatalln(args ...interface{}) {
+	l.sourced().Fatalln(args...)
+}
+
+// Fatalf logs a message at level Fatal on the standard logger.
+func (l logger) Fatalf(format string, args ...interface{}) {
+	l.sourced().Fatalf(format, args...)
+}
+
+// sourced adds a source field to the logger that contains
+// the file name and line where the logging happened.
+func (l logger) sourced() *logrus.Entry {
+	_, file, line, ok := runtime.Caller(2)
+	if !ok {
+		file = "<???>"
+		line = 1
+	} else {
+		slash := strings.LastIndex(file, "/")
+		file = file[slash+1:]
+	}
+	return l.entry.WithField("source", fmt.Sprintf("%s:%d", file, line))
+}
+
+var origLogger = logrus.New()
+var baseLogger = logger{entry: logrus.NewEntry(origLogger)}
+
+func Base() Logger {
+	return baseLogger
+}
+
+func With(key string, value interface{}) Logger {
+	return baseLogger.With(key, value)
+}
+
+// Debug logs a message at level Debug on the standard logger.
+func Debug(args ...interface{}) {
+	baseLogger.sourced().Debug(args...)
+}
+
+// Debug logs a message at level Debug on the standard logger.
+func Debugln(args ...interface{}) {
+	baseLogger.sourced().Debugln(args...)
+}
+
+// Debugf logs a message at level Debug on the standard logger.
+func Debugf(format string, args ...interface{}) {
+	baseLogger.sourced().Debugf(format, args...)
+}
+
+// Info logs a message at level Info on the standard logger.
+func Info(args ...interface{}) {
+	baseLogger.sourced().Info(args...)
+}
+
+// Info logs a message at level Info on the standard logger.
+func Infoln(args ...interface{}) {
+	baseLogger.sourced().Infoln(args...)
+}
+
+// Infof logs a message at level Info on the standard logger.
+func Infof(format string, args ...interface{}) {
+	baseLogger.sourced().Infof(format, args...)
+}
+
+// Warn logs a message at level Warn on the standard logger.
+func Warn(args ...interface{}) {
+	baseLogger.sourced().Warn(args...)
+}
+
+// Warn logs a message at level Warn on the standard logger.
+func Warnln(args ...interface{}) {
+	baseLogger.sourced().Warnln(args...)
+}
+
+// Warnf logs a message at level Warn on the standard logger.
+func Warnf(format string, args ...interface{}) {
+	baseLogger.sourced().Warnf(format, args...)
+}
+
+// Error logs a message at level Error on the standard logger.
+func Error(args ...interface{}) {
+	baseLogger.sourced().Error(args...)
+}
+
+// Error logs a message at level Error on the standard logger.
+func Errorln(args ...interface{}) {
+	baseLogger.sourced().Errorln(args...)
+}
+
+// Errorf logs a message at level Error on the standard logger.
+func Errorf(format string, args ...interface{}) {
+	baseLogger.sourced().Errorf(format, args...)
+}
+
+// Fatal logs a message at level Fatal on the standard logger.
+func Fatal(args ...interface{}) {
+	baseLogger.sourced().Fatal(args...)
+}
+
+// Fatal logs a message at level Fatal on the standard logger.
+func Fatalln(args ...interface{}) {
+	baseLogger.sourced().Fatalln(args...)
+}
+
+// Fatalf logs a message at level Fatal on the standard logger.
+func Fatalf(format string, args ...interface{}) {
+	baseLogger.sourced().Fatalf(format, args...)
+}
+
+type errorLogWriter struct{}
+
+func (errorLogWriter) Write(b []byte) (int, error) {
+	baseLogger.sourced().Error(string(b))
+	return len(b), nil
+}
+
+// NewErrorLogger returns a log.Logger that is meant to be used
+// in the ErrorLog field of an http.Server to log HTTP server errors.
+func NewErrorLogger() *log.Logger {
+	return log.New(&errorLogWriter{}, "", 0)
+}
diff --git a/vendor/github.com/prometheus/common/log/syslog_formatter.go b/vendor/github.com/prometheus/common/log/syslog_formatter.go
new file mode 100644
index 00000000..fd8c6fbe
--- /dev/null
+++ b/vendor/github.com/prometheus/common/log/syslog_formatter.go
@@ -0,0 +1,119 @@
+// Copyright 2015 The Prometheus Authors
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+// +build !windows,!nacl,!plan9
+
+package log
+
+import (
+	"fmt"
+	"log/syslog"
+	"os"
+
+	"github.com/Sirupsen/logrus"
+)
+
+func init() {
+	setSyslogFormatter = func(appname, local string) error {
+		if appname == "" {
+			return fmt.Errorf("missing appname parameter")
+		}
+		if local == "" {
+			return fmt.Errorf("missing local parameter")
+		}
+
+		fmter, err := newSyslogger(appname, local, origLogger.Formatter)
+		if err != nil {
+			fmt.Fprintf(os.Stderr, "error creating syslog formatter: %v\n", err)
+			origLogger.Errorf("can't connect logger to syslog: %v", err)
+			return err
+		}
+		origLogger.Formatter = fmter
+		return nil
+	}
+}
+
+var ceeTag = []byte("@cee:")
+
+type syslogger struct {
+	wrap logrus.Formatter
+	out  *syslog.Writer
+}
+
+func newSyslogger(appname string, facility string, fmter logrus.Formatter) (*syslogger, error) {
+	priority, err := getFacility(facility)
+	if err != nil {
+		return nil, err
+	}
+	out, err := syslog.New(priority, appname)
+	return &syslogger{
+		out:  out,
+		wrap: fmter,
+	}, err
+}
+
+func getFacility(facility string) (syslog.Priority, error) {
+	switch facility {
+	case "0":
+		return syslog.LOG_LOCAL0, nil
+	case "1":
+		return syslog.LOG_LOCAL1, nil
+	case "2":
+		return syslog.LOG_LOCAL2, nil
+	case "3":
+		return syslog.LOG_LOCAL3, nil
+	case "4":
+		return syslog.LOG_LOCAL4, nil
+	case "5":
+		return syslog.LOG_LOCAL5, nil
+	case "6":
+		return syslog.LOG_LOCAL6, nil
+	case "7":
+		return syslog.LOG_LOCAL7, nil
+	}
+	return syslog.LOG_LOCAL0, fmt.Errorf("invalid local(%s) for syslog", facility)
+}
+
+func (s *syslogger) Format(e *logrus.Entry) ([]byte, error) {
+	data, err := s.wrap.Format(e)
+	if err != nil {
+		fmt.Fprintf(os.Stderr, "syslogger: can't format entry: %v\n", err)
+		return data, err
+	}
+	// only append tag to data sent to syslog (line), not to what
+	// is returned
+	line := string(append(ceeTag, data...))
+
+	switch e.Level {
+	case logrus.PanicLevel:
+		err = s.out.Crit(line)
+	case logrus.FatalLevel:
+		err = s.out.Crit(line)
+	case logrus.ErrorLevel:
+		err = s.out.Err(line)
+	case logrus.WarnLevel:
+		err = s.out.Warning(line)
+	case logrus.InfoLevel:
+		err = s.out.Info(line)
+	case logrus.DebugLevel:
+		err = s.out.Debug(line)
+	default:
+		err = s.out.Notice(line)
+	}
+
+	if err != nil {
+		fmt.Fprintf(os.Stderr, "syslogger: can't send log to syslog: %v\n", err)
+	}
+
+	return data, err
+}
diff --git a/vendor/github.com/prometheus/log/AUTHORS.md b/vendor/github.com/prometheus/log/AUTHORS.md
deleted file mode 100644
index 3aaa7f27..00000000
--- a/vendor/github.com/prometheus/log/AUTHORS.md
+++ /dev/null
@@ -1,11 +0,0 @@
-The Prometheus project was started by Matt T. Proud (emeritus) and
-Julius Volz in 2012.
-
-Maintainers of this repository:
-
-* Julius Volz <julius.volz@gmail.com>
-
-The following individuals have contributed code to this repository
-(listed in alphabetical order):
-
-* Julius Volz <julius.volz@gmail.com>
diff --git a/vendor/github.com/prometheus/log/CONTRIBUTING.md b/vendor/github.com/prometheus/log/CONTRIBUTING.md
deleted file mode 100644
index 5705f0fb..00000000
--- a/vendor/github.com/prometheus/log/CONTRIBUTING.md
+++ /dev/null
@@ -1,18 +0,0 @@
-# Contributing
-
-Prometheus uses GitHub to manage reviews of pull requests.
-
-* If you have a trivial fix or improvement, go ahead and create a pull
-  request, addressing (with `@...`) one or more of the maintainers
-  (see [AUTHORS.md](AUTHORS.md)) in the description of the pull request.
-
-* If you plan to do something more involved, first discuss your ideas
-  on our [mailing list](https://groups.google.com/forum/?fromgroups#!forum/prometheus-developers).
-  This will avoid unnecessary work and surely give you and us a good deal
-  of inspiration.
-
-* Relevant coding style guidelines are the [Go Code Review
-  Comments](https://code.google.com/p/go-wiki/wiki/CodeReviewComments)
-  and the _Formatting and style_ section of Peter Bourgon's [Go: Best
-  Practices for Production
-  Environments](http://peter.bourgon.org/go-in-production/#formatting-and-style).
diff --git a/vendor/github.com/prometheus/log/NOTICE b/vendor/github.com/prometheus/log/NOTICE
deleted file mode 100644
index 1f37552e..00000000
--- a/vendor/github.com/prometheus/log/NOTICE
+++ /dev/null
@@ -1,2 +0,0 @@
-Standard logging library for Go-based Prometheus components.
-Copyright 2015 The Prometheus Authors
diff --git a/vendor/github.com/prometheus/log/README.md b/vendor/github.com/prometheus/log/README.md
deleted file mode 100644
index 453abc3f..00000000
--- a/vendor/github.com/prometheus/log/README.md
+++ /dev/null
@@ -1,10 +0,0 @@
-# Prometheus Logging Library
-
-**Deprecated: This repository is superseded by [common/log](https://github.com/prometheus/common/tree/master/log).**
-
-Standard logging library for Go-based Prometheus components.
-
-This library wraps
-[https://github.com/Sirupsen/logrus](https://github.com/Sirupsen/logrus) in
-order to add line:file annotations to log lines, as well as to provide common
-command-line flags for Prometheus components using it.
diff --git a/vendor/github.com/prometheus/log/log.go b/vendor/github.com/prometheus/log/log.go
deleted file mode 100644
index 8c85df3b..00000000
--- a/vendor/github.com/prometheus/log/log.go
+++ /dev/null
@@ -1,171 +0,0 @@
-// Copyright 2015 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package log
-
-import (
-	"flag"
-	"runtime"
-	"strings"
-
-	"github.com/Sirupsen/logrus"
-)
-
-var logger = logrus.New()
-
-type levelFlag struct{}
-
-// String implements flag.Value.
-func (f levelFlag) String() string {
-	return logger.Level.String()
-}
-
-// Set implements flag.Value.
-func (f levelFlag) Set(level string) error {
-	l, err := logrus.ParseLevel(level)
-	if err != nil {
-		return err
-	}
-	logger.Level = l
-	return nil
-}
-
-func init() {
-	// In order for this flag to take effect, the user of the package must call
-	// flag.Parse() before logging anything.
-	flag.Var(levelFlag{}, "log.level", "Only log messages with the given severity or above. Valid levels: [debug, info, warn, error, fatal, panic].")
-}
-
-// fileLineEntry returns a logrus.Entry with file and line annotations for the
-// original user log statement (two stack frames up from this function).
-func fileLineEntry() *logrus.Entry {
-	_, file, line, ok := runtime.Caller(2)
-	if !ok {
-		file = "<???>"
-		line = 1
-	} else {
-		slash := strings.LastIndex(file, "/")
-		if slash >= 0 {
-			file = file[slash+1:]
-		}
-	}
-	return logger.WithFields(logrus.Fields{
-		"file": file,
-		"line": line,
-	})
-}
-
-// Debug logs a message at level Debug on the standard logger.
-func Debug(args ...interface{}) {
-	fileLineEntry().Debug(args...)
-}
-
-// Debugln logs a message at level Debug on the standard logger.
-func Debugln(args ...interface{}) {
-	fileLineEntry().Debugln(args...)
-}
-
-// Debugf logs a message at level Debug on the standard logger.
-func Debugf(format string, args ...interface{}) {
-	fileLineEntry().Debugf(format, args...)
-}
-
-// Info logs a message at level Info on the standard logger.
-func Info(args ...interface{}) {
-	fileLineEntry().Info(args...)
-}
-
-// Infoln logs a message at level Info on the standard logger.
-func Infoln(args ...interface{}) {
-	fileLineEntry().Infoln(args...)
-}
-
-// Infof logs a message at level Info on the standard logger.
-func Infof(format string, args ...interface{}) {
-	fileLineEntry().Infof(format, args...)
-}
-
-// Print logs a message at level Info on the standard logger.
-func Print(args ...interface{}) {
-	fileLineEntry().Info(args...)
-}
-
-// Println logs a message at level Info on the standard logger.
-func Println(args ...interface{}) {
-	fileLineEntry().Infoln(args...)
-}
-
-// Printf logs a message at level Info on the standard logger.
-func Printf(format string, args ...interface{}) {
-	fileLineEntry().Infof(format, args...)
-}
-
-// Warn logs a message at level Warn on the standard logger.
-func Warn(args ...interface{}) {
-	fileLineEntry().Warn(args...)
-}
-
-// Warnln logs a message at level Warn on the standard logger.
-func Warnln(args ...interface{}) {
-	fileLineEntry().Warnln(args...)
-}
-
-// Warnf logs a message at level Warn on the standard logger.
-func Warnf(format string, args ...interface{}) {
-	fileLineEntry().Warnf(format, args...)
-}
-
-// Error logs a message at level Error on the standard logger.
-func Error(args ...interface{}) {
-	fileLineEntry().Error(args...)
-}
-
-// Errorln logs a message at level Error on the standard logger.
-func Errorln(args ...interface{}) {
-	fileLineEntry().Errorln(args...)
-}
-
-// Errorf logs a message at level Error on the standard logger.
-func Errorf(format string, args ...interface{}) {
-	fileLineEntry().Errorf(format, args...)
-}
-
-// Fatal logs a message at level Fatal on the standard logger.
-func Fatal(args ...interface{}) {
-	fileLineEntry().Fatal(args...)
-}
-
-// Fatalln logs a message at level Fatal on the standard logger.
-func Fatalln(args ...interface{}) {
-	fileLineEntry().Fatalln(args...)
-}
-
-// Fatalf logs a message at level Fatal on the standard logger.
-func Fatalf(format string, args ...interface{}) {
-	fileLineEntry().Fatalf(format, args...)
-}
-
-// Panic logs a message at level Panic on the standard logger.
-func Panic(args ...interface{}) {
-	fileLineEntry().Panicln(args...)
-}
-
-// Panicln logs a message at level Panic on the standard logger.
-func Panicln(args ...interface{}) {
-	fileLineEntry().Panicln(args...)
-}
-
-// Panicf logs a message at level Panic on the standard logger.
-func Panicf(format string, args ...interface{}) {
-	fileLineEntry().Panicf(format, args...)
-}
diff --git a/vendor/vendor.json b/vendor/vendor.json
index cea9ba28..819c8eda 100644
--- a/vendor/vendor.json
+++ b/vendor/vendor.json
@@ -52,20 +52,22 @@
 			"revision": "5cb53e5c863aca6e2b8ec958d16d9a93753ecea6",
 			"revisionTime": "2015-12-08T14:32:55+01:00"
 		},
+		{
+			"checksumSHA1": "fKMoxZehNhXbklRQy7lpFAVH0XY=",
+			"path": "github.com/prometheus/common/log",
+			"revision": "bc0a4460d0fc2693fcdebafafbf07c6d18913b97",
+			"revisionTime": "2016-07-26T17:19:51Z"
+		},
 		{
 			"path": "github.com/prometheus/common/model",
 			"revision": "5cb53e5c863aca6e2b8ec958d16d9a93753ecea6",
 			"revisionTime": "2015-12-08T14:32:55+01:00"
 		},
-		{
-			"path": "github.com/prometheus/log",
-			"revision": "9a3136781e1ff7bc42736ba4acb81339b1422551",
-			"revisionTime": "2015-10-26T02:24:52+01:00"
-		},
 		{
 			"path": "github.com/prometheus/procfs",
 			"revision": "406e5b7bfd8201a36e2bb5f7bdae0b03380c2ce8",
 			"revisionTime": "2015-10-29T15:50:50-04:00"
 		}
-	]
+	],
+	"rootPath": "github.com/wrouesnel/postgres_exporter"
 }