pax_global_header00006660000000000000000000000064132145245040014512gustar00rootroot0000000000000052 comment=72e83fba51b549cbf179f1001a3a1b2532360fc8 prometheus-postgres-exporter-0.4.1+ds/000077500000000000000000000000001321452450400200235ustar00rootroot00000000000000prometheus-postgres-exporter-0.4.1+ds/.gitignore000066400000000000000000000002451321452450400220140ustar00rootroot00000000000000.build postgres_exporter postgres_exporter_integration_test *.tar.gz *.test *-stamp .idea *.iml cover.out cover.*.out .coverage bin release *.prom .metrics.*.*.prom prometheus-postgres-exporter-0.4.1+ds/.travis.yml000066400000000000000000000100171321452450400221330ustar00rootroot00000000000000sudo: required services: - docker language: go go: - '1.9' # Make sure we have p2 and the postgres client. before_install: - go get -v github.com/mattn/goveralls - sudo wget -O /usr/local/bin/p2 https://github.com/wrouesnel/p2cli/releases/download/r4/p2 && sudo chmod +x /usr/local/bin/p2 - sudo wget -O /usr/local/bin/docker-compose https://github.com/docker/compose/releases/download/1.9.0-rc4/docker-compose-Linux-x86_64 && sudo chmod +x /usr/local/bin/docker-compose - sudo apt-get update && sudo apt-get install postgresql-client-common script: - make all - make docker - make test-integration - make cover.out - make release - $HOME/gopath/bin/goveralls -coverprofile=cover.out -service=travis-ci after_success: - docker login -e $DOCKER_EMAIL -u $DOCKER_USER -p $DOCKER_PASS # Push a tagged build if a tag is found. - if [ ! -z "$TRAVIS_TAG" ]; then docker tag wrouesnel/postgres_exporter:latest wrouesnel/postgres_exporter:$TRAVIS_TAG ; docker push wrouesnel/postgres_exporter:$TRAVIS_TAG ; fi # Push a latest version - if [ "$TRAVIS_BRANCH" == "master" ]; then docker push wrouesnel/postgres_exporter ; fi env: global: - secure: RfoWQj5tEB/t3XL2tqJW7u7Qscpz1QBOfF9lMFpB4kAUMTtZU0zBbXfMo1JheGoJQQxD/7NLRHhbUWPT2489o3KKpRTQ7RHn3k8n5U7opH01bWX0+l/EPVmhlsKjSDSLGgmxz80j3I6C8ZV3qDUijSx7r90QUNHGbZtV7g+KtoUTpRV0zir/heK6qq9LHWNHbNsJyHK8qHmd6g1UzWIBaZPJ6a/n/rO2jq4uS1JR0VlIJPRF11HOLH8IjFQvVYpN7YbEslxyNsfQJUSP/7CghSLLVWPSATEjMm8a5GJVLc564+nYghm484psEtiMXkZ3n6ie7AT8aJrKfexWrwh2aCc+cK4PiyXrf4euZehZNYogmFCqWzd1LJKcN2uIkpBSuZQDm3e6c4qkkWGpx+RdFWtAMG8IgZLDbcuryxFNzMwHc2CJ009s9Zsa+g7D57csyR5LCZ8YtNGI3g8FmhwpCKvYkfKa9aijUEWyJMyT4Vhd/w7btMTuwYHgUQ85k4ov4Xjz5SNpAGgemig5G5w7PJj4NhGvIBz9weL154x/BFVjHOZZ6Y/bWgJIPoW1KM15x5K8QylWYEBUHtwiyVyXOxHqt6MOX1vYo1L37jMK88IErrfh/VmlxEhtN9wOghk8IudMfFwQtjIwiWlJf218wxMIzUjoyb5/25tU9f2OJrg= - secure: WP96T7yshE03XsPVc9ICbwZXZ6nVsQDCQ9NGKnIEQa4T1Swu5uLVzxjGeowHPykKbKphQmT8inMniBxB48OLc3VVqNxVI+00ppLPEf7n79w2wVbwFOEa6TiOdws+0wOphkeSYc0L+o2aSfoMKJHF+rVW9tmM2tszVjofYHhdWjqloc2pqsfOnqbR7icfpmzMWKyezIE20YOIBsiKZJTKXiZ1SaG9ExkNwuZ7L+HRF1yeI0OdAM4VfEzBK1Gwicy2BtrbyHnl4zgcSoIBmuzo+pNuvqyGmBn3C221M6ki7NoDJDfW5brcvDmiMODWGnka7iW0nt5aUbVtURM8BhWZR0uINo30aYjr4j39UBq8y+mqYV0dp/dMEmy2fa1mogr+DuHUNVSg59Au45AZeom8N6FT03nlg+RcG/tV1skvP/mn9n9CKsyfvC4Rf3jp4+LTiJ9JIch74MecRYVwlpKM+i8s6uDftt3mvxeIYdK+NEMcfwKMv8KTwuxRo/3KRhif7z2cOE+oMbT5POWO19bfboRPCs4xiMTcqpx8dJVs41SacY52PPgjFSnyVrKvzAyjn6mePjLhpoPZueHZuJYPNa9QC8JcASMlCI7lf2Eq+2Dmp2JxmndkRs/cIfHgmO4gtiNM7Vb/rlML1D/8LYPWU/Rdp82/yDffC0ugMNovXt0= - secure: RRQH4Tr94OblZoqls50BIoyK1OvK9fALs4pAq1Uk5dksY1NWnomheQzOaHzbVfMfXc4zXAzppZIqxUDGn8GiSLbtJL6pnxsxYNGoCGdS8lMjjKWXbCAs8TBJobi3krOOjqgbhOWTpyluTEShnBcg7CjrRQUa/ChS3uE5kl21/4eIl9Be6Q08Eqm3p1yvMAyAgIL6Y6oPAAtBa6zIsi2MSNlryz3RKHJO7AheilppYx3E8B03A+a/oqvTTcw6w/RwBYxB8MYfSLC0jSssZz5pUSX/byUaklGFhQLnKAzJyhrMOvRyMVcO4PHaLgVi1eAKQz6eLQh7uEiIqKh19cuvTbZHDgu8zMpLDTxOW9U95e4kbjOZ5pWZ7E5QTrb24RZIt42JGbmme7PWOvy3zNbWHwfwiOF1qwYwISUcj2KFCpes8mDGt6iv46LfdlU0uoZdZu3MAiTiW0u2SD5hIeFq4XYesPtkS/TKFoAbB5Tu1qbxdmYu5NqmfvmxsmeNEm4inFJ5ap3fRRCVo668Z6qRMuQ1URcEfOz8iEftP9CnwSOXRuiuMo+W9GgckRuDZcPyQMCftq8+PhB+SjK57zrAd4Kxqf6kVHV16tcWqmFjfJJUFqmL+gpjT/VMEVDY2FOnbOARjkeLTjVC4dADBjxfJ6wmlLrfHdUm4GinbaHq0iA= deploy: skip_cleanup: true provider: releases api_key: secure: rwlge/Rs3wnWyfKRhD9fd5GviVe0foYUp20DY3AjKdDjhtwScA1EeR9QHOkB3raze52en0+KkpqlLCWbt3q4CRT7+ku1DNKhd6VWALdTZ1RPJYvNlU6CKJdRnWUJsECmSBsShXlbiYR8axqNVedzFPFGKzS9gYlFN6rr7pez/JZhxqucopZ6I+TkRHMELrFXyQK7/Y2bNRCLC4a+rGsjKeLLtYXbRXCmS0G4BSJEBRk7d69fIRzBApCMfrcLftgHzPuPth616yyUusQSCQYvaZ5tlwrPP8/E0wG3SVJVeDCMuDOSBZ9M6vNzR8W8VR/hxQamegn1OQgC5kNOaLZCTcJ5xguRouqb+FNFBqrd/Zi6vESo7RiVLULawzwxkh9sIPa3WZYDb3VK/Z/cpggUeR7wAu0S5ZYEvJHRefIZpqofZEHzDE3Blqp5yErz05e/zmjpd6HHK3f/UHmRRYfbulkvGT3aL/dlq5GcFvuxVC/vTL2VPvg9cGbqtf7PakC5IhoHpDs35tOyLxifOBLHvkwtGSxEfsCohIG8Hz2XFD83EsxgOiKSXVPLNd6yxjdqZj7OeAKFFU3bzGndnRbDIXaf987IN1imgUtP6wegfImoRStqxN4gEwwIMFsZCF86Ug4eLhlajLbWhudriDxDPBM/F9950aVxLwmWh9l5cRI= file_glob: true file: release/* on: tags: true branch: master repo: wrouesnel/postgres_exporter prometheus-postgres-exporter-0.4.1+ds/Dockerfile000066400000000000000000000001541321452450400220150ustar00rootroot00000000000000FROM scratch ARG binary COPY $binary /postgres_exporter EXPOSE 9187 ENTRYPOINT [ "/postgres_exporter" ] prometheus-postgres-exporter-0.4.1+ds/LICENSE000066400000000000000000000260751321452450400210420ustar00rootroot00000000000000Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "{}" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright {yyyy} {name of copyright owner} 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. prometheus-postgres-exporter-0.4.1+ds/Makefile000066400000000000000000000076571321452450400215020ustar00rootroot00000000000000 COVERDIR = .coverage TOOLDIR = tools BINDIR = bin RELEASEDIR = release DIRS = $(BINDIR) $(RELEASEDIR) GO_SRC := $(shell find . -name '*.go' ! -path '*/vendor/*' ! -path 'tools/*' ! -path 'bin/*' ! -path 'release/*' ) GO_DIRS := $(shell find . -type d -name '*.go' ! -path '*/vendor/*' ! -path 'tools/*' ! -path 'bin/*' ! -path 'release/*' ) GO_PKGS := $(shell go list ./... | grep -v '/vendor/') CONTAINER_NAME ?= wrouesnel/postgres_exporter:latest BINARY := $(shell basename $(shell pwd)) VERSION ?= $(shell git describe --dirty 2>/dev/null) VERSION_SHORT ?= $(shell git describe --abbrev=0 2>/dev/null) ifeq ($(VERSION),) VERSION := v0.0.0 endif ifeq ($(VERSION_SHORT),) VERSION_SHORT := v0.0.0 endif # By default this list is filtered down to some common platforms. platforms := $(subst /,-,$(shell go tool dist list | grep -e linux -e windows -e darwin | grep -e 386 -e amd64)) PLATFORM_BINS := $(patsubst %,$(BINDIR)/$(BINARY)_$(VERSION_SHORT)_%/$(BINARY),$(platforms)) PLATFORM_DIRS := $(patsubst %,$(BINDIR)/$(BINARY)_$(VERSION_SHORT)_%,$(platforms)) PLATFORM_TARS := $(patsubst %,$(RELEASEDIR)/$(BINARY)_$(VERSION_SHORT)_%.tar.gz,$(platforms)) # These are evaluated on use, and so will have the correct values in the build # rule (https://vic.demuzere.be/articles/golang-makefile-crosscompile/) PLATFORMS_TEMP = $(subst -, ,$(patsubst $(BINDIR)/$(BINARY)_$(VERSION_SHORT)_%/$(BINARY),%,$@)) GOOS = $(word 1, $(PLATFORMS_TEMP)) GOARCH = $(word 2, $(PLATFORMS_TEMP)) CURRENT_PLATFORM := $(BINDIR)/$(BINARY)_$(VERSION_SHORT)_$(shell go env GOOS)-$(shell go env GOARCH)/$(BINARY) CONCURRENT_LINTERS ?= ifeq ($(CONCURRENT_LINTERS),) CONCURRENT_LINTERS = $(shell gometalinter --help | grep -o 'concurrency=\w*' | cut -d= -f2 | cut -d' ' -f1) endif LINTER_DEADLINE ?= 30s $(shell mkdir -p $(DIRS)) export PATH := $(TOOLDIR)/bin:$(PATH) SHELL := env PATH=$(PATH) /bin/bash all: style lint test binary binary: $(BINARY) $(BINARY): $(CURRENT_PLATFORM) ln -sf $< $@ $(PLATFORM_BINS): $(GO_SRC) CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(GOARCH) go build -a \ -ldflags "-extldflags '-static' -X main.Version=$(VERSION)" \ -o $@ . $(PLATFORM_DIRS): $(PLATFORM_BINS) $(PLATFORM_TARS): $(RELEASEDIR)/%.tar.gz : $(BINDIR)/% tar -czf $@ -C $(BINDIR) $$(basename $<) release-bin: $(PLATFORM_BINS) release: $(PLATFORM_TARS) # Take a go build and turn it into a minimal container docker: $(CURRENT_PLATFORM) docker build --build-arg=binary=$(CURRENT_PLATFORM) -t $(CONTAINER_NAME) . style: tools gometalinter --disable-all --enable=gofmt --vendor lint: tools @echo Using $(CONCURRENT_LINTERS) processes gometalinter -j $(CONCURRENT_LINTERS) --deadline=$(LINTER_DEADLINE) --disable=gotype --disable=gocyclo $(GO_DIRS) fmt: tools gofmt -s -w $(GO_SRC) postgres_exporter_integration_test: $(GO_SRC) CGO_ENABLED=0 go test -c -tags integration \ -a -ldflags "-extldflags '-static' -X main.Version=$(VERSION)" \ -o postgres_exporter_integration_test -cover -covermode count . test: tools @mkdir -p $(COVERDIR) @rm -f $(COVERDIR)/* for pkg in $(GO_PKGS) ; do \ go test -v -covermode count -coverprofile=$(COVERDIR)/$$(echo $$pkg | tr '/' '-').out $$pkg || exit 1 ; \ done gocovmerge $(shell find $(COVERDIR) -name '*.out') > cover.test.out test-integration: postgres_exporter postgres_exporter_integration_test tests/test-smoke "$(shell pwd)/postgres_exporter" "$(shell pwd)/postgres_exporter_integration_test_script $(shell pwd)/postgres_exporter_integration_test $(shell pwd)/cover.integration.out" cover.out: tools gocovmerge cover.*.out > cover.out clean: [ ! -z $(BINDIR) ] && [ -e $(BINDIR) ] && find $(BINDIR) -print -delete || /bin/true [ ! -z $(COVERDIR) ] && [ -e $(COVERDIR) ] && find $(COVERDIR) -print -delete || /bin/true [ ! -z $(RELEASEDIR) ] && [ -e $(RELEASEDIR) ] && find $(RELEASEDIR) -print -delete || /bin/true rm -f postgres_exporter postgres_exporter_integration_test tools: $(MAKE) -C $(TOOLDIR) .PHONY: tools style fmt test all release binary clean prometheus-postgres-exporter-0.4.1+ds/README.md000066400000000000000000000126271321452450400213120ustar00rootroot00000000000000[![Build Status](https://travis-ci.org/wrouesnel/postgres_exporter.svg?branch=master)](https://travis-ci.org/wrouesnel/postgres_exporter) [![Coverage Status](https://coveralls.io/repos/github/wrouesnel/postgres_exporter/badge.svg?branch=master)](https://coveralls.io/github/wrouesnel/postgres_exporter?branch=master) [![Go Report Card](https://goreportcard.com/badge/github.com/wrouesnel/postgres_exporter)](https://goreportcard.com/report/github.com/wrouesnel/postgres_exporter) # PostgreSQL Server Exporter Prometheus exporter for PostgreSQL server metrics. Supported Postgres versions: 9.1 and up. ## Quick Start 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 -e DATA_SOURCE_NAME="postgresql://postgres:password@localhost:5432/?sslmode=disable" -p 9187:9187 wrouesnel/postgres_exporter ``` ## Building and running The default make file behavior is to build the binary: ``` make export DATA_SOURCE_NAME="postgresql://login:password@hostname:port/dbname" ./postgres_exporter ``` To build the dockerfile, run `make 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) ### Flags * `web.listen-address` Address to listen on for web interface and telemetry. * `web.telemetry-path` Path under which to expose metrics. ### Environment Variables The following environment variables configure the exporter: * `DATA_SOURCE_NAME` the default legacy format. Accepts URI form and key=value form arguments. The URI may contain the username and password to connect with. * `DATA_SOURCE_URI` an alternative to DATA_SOURCE_NAME which exclusively accepts the raw URI without a username and password component. * `DATA_SOURCE_USER` When using `DATA_SOURCE_URI`, this environment variable is used to specify the username. * `DATA_SOURCE_USER_FILE` The same, but reads the username from a file. * `DATA_SOURCE_PASS` When using `DATA_SOURCE_URI`, this environment variable is used to specify the password to connect with. * `DATA_SOURCE_PASS_FILE` The same as above but reads the password from a file. ### Setting the Postgres server's data source name The PostgreSQL server's [data source name](http://en.wikipedia.org/wiki/Data_source_name) 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 See the [github.com/lib/pq](http://github.com/lib/pq) module for other ways to format the connection string. ### Adding new metrics The exporter will attempt to dynamically export additional metrics if they are added in the future, but they will be marked as "untyped". Additional metric maps can be easily created from Postgres documentation by copying the tables and using the following Python snippet: ```python x = """tab separated raw text of a documentation table""" for l in StringIO(x): column, ctype, description = l.split('\t') print """"{0}" : {{ prometheus.CounterValue, prometheus.NewDesc("pg_stat_database_{0}", "{2}", nil, nil) }}, """.format(column.strip(), ctype, description.strip()) ``` Adjust the value of the resultant prometheus value type appropriately. This helps build rich self-documenting metrics for the exporter. ### Adding new metrics via a config file The -extend.query-path command-line argument specifies a YAML file containing additional queries to run. Some examples are provided in [queries.yaml](queries.yaml). ### Running as non-superuser To be able to collect metrics from pg_stat_activity and pg_stat_replication as non-superuser you have to create views as a superuser, and assign permissions separately to those. In PostgreSQL, views run with the permissions of the user that created them so they can act as security barriers. ```sql CREATE USER postgres_exporter PASSWORD 'password'; ALTER USER postgres_exporter SET SEARCH_PATH TO postgres_exporter,pg_catalog; -- If deploying as non-superuser (for example in AWS RDS) -- GRANT postgres_exporter TO :MASTER_USER; CREATE SCHEMA postgres_exporter AUTHORIZATION postgres_exporter; CREATE VIEW postgres_exporter.pg_stat_activity AS SELECT * from pg_catalog.pg_stat_activity; GRANT SELECT ON postgres_exporter.pg_stat_activity TO postgres_exporter; CREATE VIEW postgres_exporter.pg_stat_replication AS SELECT * from pg_catalog.pg_stat_replication; 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 > ``` # Hacking * The build system is currently only supported for Linux-like platforms. It depends on GNU Make. * To build a copy for your current architecture run `make binary` or just `make` This will create a symlink to the just built binary in the root directory. * To build release tar balls run `make release`. prometheus-postgres-exporter-0.4.1+ds/pg_setting.go000066400000000000000000000062651321452450400225260ustar00rootroot00000000000000package main import ( "database/sql" "errors" "fmt" "math" "strconv" "strings" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/common/log" ) // Query the pg_settings view containing runtime variables func querySettings(ch chan<- prometheus.Metric, db *sql.DB) error { log.Debugln("Querying pg_setting view") // pg_settings docs: https://www.postgresql.org/docs/current/static/view-pg-settings.html // // NOTE: If you add more vartypes here, you must update the supported // types in normaliseUnit() below query := "SELECT name, setting, COALESCE(unit, ''), short_desc, vartype FROM pg_settings WHERE vartype IN ('bool', 'integer', 'real');" rows, err := db.Query(query) if err != nil { return errors.New(fmt.Sprintln("Error running query on database: ", namespace, err)) } defer rows.Close() // nolint: errcheck for rows.Next() { s := &pgSetting{} err = rows.Scan(&s.name, &s.setting, &s.unit, &s.shortDesc, &s.vartype) if err != nil { return errors.New(fmt.Sprintln("Error retrieving rows:", namespace, err)) } ch <- s.metric() } return nil } // pgSetting is represents a PostgreSQL runtime variable as returned by the // pg_settings view. type pgSetting struct { name, setting, unit, shortDesc, vartype string } func (s *pgSetting) metric() prometheus.Metric { var ( err error name = strings.Replace(s.name, ".", "_", -1) unit = s.unit // nolint: ineffassign shortDesc = s.shortDesc subsystem = "settings" val float64 ) switch s.vartype { case "bool": if s.setting == "on" { val = 1 } case "integer", "real": if val, unit, err = s.normaliseUnit(); err != nil { // Panic, since we should recognise all units // and don't want to silently exlude metrics panic(err) } if len(unit) > 0 { name = fmt.Sprintf("%s_%s", name, unit) shortDesc = fmt.Sprintf("%s [Units converted to %s.]", shortDesc, unit) } default: // Panic because we got a type we didn't ask for panic(fmt.Sprintf("Unsupported vartype %q", s.vartype)) } desc := newDesc(subsystem, name, shortDesc) return prometheus.MustNewConstMetric(desc, prometheus.GaugeValue, val) } func (s *pgSetting) normaliseUnit() (val float64, unit string, err error) { val, err = strconv.ParseFloat(s.setting, 64) if err != nil { return val, unit, fmt.Errorf("Error converting setting %q value %q to float: %s", s.name, s.setting, err) } // Units defined in: https://www.postgresql.org/docs/current/static/config-setting.html switch s.unit { case "": return case "ms", "s", "min", "h", "d": unit = "seconds" case "kB", "MB", "GB", "TB", "8kB", "16kB", "16MB": unit = "bytes" default: err = fmt.Errorf("Unknown unit for runtime variable: %q", s.unit) return } // -1 is special, don't modify the value if val == -1 { return } switch s.unit { case "ms": val /= 1000 case "min": val *= 60 case "h": val *= 60 * 60 case "d": val *= 60 * 60 * 24 case "kB": val *= math.Pow(2, 10) case "MB": val *= math.Pow(2, 20) case "GB": val *= math.Pow(2, 30) case "TB": val *= math.Pow(2, 40) case "8kB": val *= math.Pow(2, 13) case "16kB": val *= math.Pow(2, 14) case "16MB": val *= math.Pow(2, 24) } return } prometheus-postgres-exporter-0.4.1+ds/pg_setting_test.go000066400000000000000000000116011321452450400235530ustar00rootroot00000000000000// +build !integration package main import ( dto "github.com/prometheus/client_model/go" . "gopkg.in/check.v1" ) type PgSettingSuite struct{} var _ = Suite(&PgSettingSuite{}) var fixtures = []fixture{ { p: pgSetting{ name: "seconds_fixture_metric", setting: "5", unit: "s", shortDesc: "Foo foo foo", vartype: "integer", }, n: normalised{ val: 5, unit: "seconds", err: "", }, d: "Desc{fqName: \"pg_settings_seconds_fixture_metric_seconds\", help: \"Foo foo foo [Units converted to seconds.]\", constLabels: {}, variableLabels: []}", v: 5, }, { p: pgSetting{ name: "milliseconds_fixture_metric", setting: "5000", unit: "ms", shortDesc: "Foo foo foo", vartype: "integer", }, n: normalised{ val: 5, unit: "seconds", err: "", }, d: "Desc{fqName: \"pg_settings_milliseconds_fixture_metric_seconds\", help: \"Foo foo foo [Units converted to seconds.]\", constLabels: {}, variableLabels: []}", v: 5, }, { p: pgSetting{ name: "eight_kb_fixture_metric", setting: "17", unit: "8kB", shortDesc: "Foo foo foo", vartype: "integer", }, n: normalised{ val: 139264, unit: "bytes", err: "", }, d: "Desc{fqName: \"pg_settings_eight_kb_fixture_metric_bytes\", help: \"Foo foo foo [Units converted to bytes.]\", constLabels: {}, variableLabels: []}", v: 139264, }, { p: pgSetting{ name: "16_kb_real_fixture_metric", setting: "3.0", unit: "16kB", shortDesc: "Foo foo foo", vartype: "real", }, n: normalised{ val: 49152, unit: "bytes", err: "", }, d: "Desc{fqName: \"pg_settings_16_kb_real_fixture_metric_bytes\", help: \"Foo foo foo [Units converted to bytes.]\", constLabels: {}, variableLabels: []}", v: 49152, }, { p: pgSetting{ name: "16_mb_real_fixture_metric", setting: "3.0", unit: "16MB", shortDesc: "Foo foo foo", vartype: "real", }, n: normalised{ val: 5.0331648e+07, unit: "bytes", err: "", }, d: "Desc{fqName: \"pg_settings_16_mb_real_fixture_metric_bytes\", help: \"Foo foo foo [Units converted to bytes.]\", constLabels: {}, variableLabels: []}", v: 5.0331648e+07, }, { p: pgSetting{ name: "bool_on_fixture_metric", setting: "on", unit: "", shortDesc: "Foo foo foo", vartype: "bool", }, n: normalised{ val: 1, unit: "", err: "", }, d: "Desc{fqName: \"pg_settings_bool_on_fixture_metric\", help: \"Foo foo foo\", constLabels: {}, variableLabels: []}", v: 1, }, { p: pgSetting{ name: "bool_off_fixture_metric", setting: "off", unit: "", shortDesc: "Foo foo foo", vartype: "bool", }, n: normalised{ val: 0, unit: "", err: "", }, d: "Desc{fqName: \"pg_settings_bool_off_fixture_metric\", help: \"Foo foo foo\", constLabels: {}, variableLabels: []}", v: 0, }, { p: pgSetting{ name: "special_minus_one_value", setting: "-1", unit: "d", shortDesc: "foo foo foo", vartype: "integer", }, n: normalised{ val: -1, unit: "seconds", err: "", }, d: "Desc{fqName: \"pg_settings_special_minus_one_value_seconds\", help: \"foo foo foo [Units converted to seconds.]\", constLabels: {}, variableLabels: []}", v: -1, }, { p: pgSetting{ name: "rds.rds_superuser_reserved_connections", setting: "2", unit: "", shortDesc: "Sets the number of connection slots reserved for rds_superusers.", vartype: "integer", }, n: normalised{ val: 2, unit: "", err: "", }, d: "Desc{fqName: \"pg_settings_rds_rds_superuser_reserved_connections\", help: \"Sets the number of connection slots reserved for rds_superusers.\", constLabels: {}, variableLabels: []}", v: 2, }, { p: pgSetting{ name: "unknown_unit", setting: "10", unit: "nonexistent", shortDesc: "foo foo foo", vartype: "integer", }, n: normalised{ val: 10, unit: "", err: `Unknown unit for runtime variable: "nonexistent"`, }, }, } func (s *PgSettingSuite) TestNormaliseUnit(c *C) { for _, f := range fixtures { switch f.p.vartype { case "integer", "real": val, unit, err := f.p.normaliseUnit() c.Check(val, Equals, f.n.val) c.Check(unit, Equals, f.n.unit) if err == nil { c.Check("", Equals, f.n.err) } else { c.Check(err.Error(), Equals, f.n.err) } } } } func (s *PgSettingSuite) TestMetric(c *C) { defer func() { if r := recover(); r != nil { if r.(error).Error() != `Unknown unit for runtime variable: "nonexistent"` { panic(r) } } }() for _, f := range fixtures { d := &dto.Metric{} m := f.p.metric() m.Write(d) // nolint: errcheck c.Check(m.Desc().String(), Equals, f.d) c.Check(d.GetGauge().GetValue(), Equals, f.v) } } type normalised struct { val float64 unit string err string } type fixture struct { p pgSetting n normalised d string v float64 } prometheus-postgres-exporter-0.4.1+ds/postgres_exporter.go000066400000000000000000001242461321452450400241610ustar00rootroot00000000000000package main import ( "database/sql" "errors" "fmt" "io/ioutil" "math" "net/http" "net/url" "os" "regexp" "runtime" "strconv" "strings" "sync" "time" "gopkg.in/alecthomas/kingpin.v2" "gopkg.in/yaml.v2" "crypto/sha256" "github.com/blang/semver" _ "github.com/lib/pq" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promhttp" "github.com/prometheus/common/log" ) // Version is set during build to the git describe version // (semantic version)-(commitish) form. var Version = "0.0.1" var ( listenAddress = kingpin.Flag("web.listen-address", "Address to listen on for web interface and telemetry.").Default(":9187").String() metricPath = kingpin.Flag("web.telemetry-path", "Path under which to expose metrics.").Default("/metrics").String() queriesPath = kingpin.Flag("extend.query-path", "Path to custom queries to run.").Default("").String() onlyDumpMaps = kingpin.Flag("dumpmaps", "Do not run, simply dump the maps.").Bool() ) // Metric name parts. const ( // Namespace for all metrics. namespace = "pg" // Subsystems. exporter = "exporter" // Metric label used for static string data thats handy to send to Prometheus // e.g. version staticLabelName = "static" ) // ColumnUsage should be one of several enum values which describe how a // queried row is to be converted to a Prometheus metric. type ColumnUsage int // nolint: golint const ( DISCARD ColumnUsage = iota // Ignore this column LABEL ColumnUsage = iota // Use this column as a label COUNTER ColumnUsage = iota // Use this column as a counter GAUGE ColumnUsage = iota // Use this column as a gauge MAPPEDMETRIC ColumnUsage = iota // Use this column with the supplied mapping of text values DURATION ColumnUsage = iota // This column should be interpreted as a text duration (and converted to milliseconds) ) // UnmarshalYAML implements the yaml.Unmarshaller interface. func (cu *ColumnUsage) UnmarshalYAML(unmarshal func(interface{}) error) error { var value string if err := unmarshal(&value); err != nil { return err } columnUsage, err := stringToColumnUsage(value) if err != nil { return err } *cu = columnUsage return nil } // Regex used to get the "short-version" from the postgres version field. var versionRegex = regexp.MustCompile(`^\w+ ((\d+)(\.\d+)?(\.\d+)?)\s`) var lowestSupportedVersion = semver.MustParse("9.1.0") // Parses the version of postgres into the short version string we can use to // match behaviors. func parseVersion(versionString string) (semver.Version, error) { submatches := versionRegex.FindStringSubmatch(versionString) if len(submatches) > 1 { return semver.ParseTolerant(submatches[1]) } return semver.Version{}, errors.New(fmt.Sprintln("Could not find a postgres version in string:", versionString)) } // ColumnMapping is the user-friendly representation of a prometheus descriptor map type ColumnMapping struct { usage ColumnUsage `yaml:"usage"` description string `yaml:"description"` mapping map[string]float64 `yaml:"metric_mapping"` // Optional column mapping for MAPPEDMETRIC supportedVersions semver.Range `yaml:"pg_version"` // Semantic version ranges which are supported. Unsupported columns are not queried (internally converted to DISCARD). } // UnmarshalYAML implements yaml.Unmarshaller func (cm *ColumnMapping) UnmarshalYAML(unmarshal func(interface{}) error) error { type plain ColumnMapping return unmarshal((*plain)(cm)) } // MetricMapNamespace groups metric maps under a shared set of labels. type MetricMapNamespace struct { labels []string // Label names for this namespace columnMappings map[string]MetricMap // Column mappings in this namespace } // MetricMap stores the prometheus metric description which a given column will // be mapped to by the collector type MetricMap struct { discard bool // Should metric be discarded during mapping? vtype prometheus.ValueType // Prometheus valuetype desc *prometheus.Desc // Prometheus descriptor conversion func(interface{}) (float64, bool) // Conversion function to turn PG result into float64 } // TODO: revisit this with the semver system func dumpMaps() { // TODO: make this function part of the exporter for name, cmap := range builtinMetricMaps { query, ok := queryOverrides[name] if !ok { fmt.Println(name) } else { for _, queryOverride := range query { fmt.Println(name, queryOverride.versionRange, queryOverride.query) } } for column, details := range cmap { fmt.Printf(" %-40s %v\n", column, details) } fmt.Println() } } var builtinMetricMaps = map[string]map[string]ColumnMapping{ "pg_stat_bgwriter": { "checkpoints_timed": {COUNTER, "Number of scheduled checkpoints that have been performed", nil, nil}, "checkpoints_req": {COUNTER, "Number of requested checkpoints that have been performed", nil, nil}, "checkpoint_write_time": {COUNTER, "Total amount of time that has been spent in the portion of checkpoint processing where files are written to disk, in milliseconds", nil, nil}, "checkpoint_sync_time": {COUNTER, "Total amount of time that has been spent in the portion of checkpoint processing where files are synchronized to disk, in milliseconds", nil, nil}, "buffers_checkpoint": {COUNTER, "Number of buffers written during checkpoints", nil, nil}, "buffers_clean": {COUNTER, "Number of buffers written by the background writer", nil, nil}, "maxwritten_clean": {COUNTER, "Number of times the background writer stopped a cleaning scan because it had written too many buffers", nil, nil}, "buffers_backend": {COUNTER, "Number of buffers written directly by a backend", nil, nil}, "buffers_backend_fsync": {COUNTER, "Number of times a backend had to execute its own fsync call (normally the background writer handles those even when the backend does its own write)", nil, nil}, "buffers_alloc": {COUNTER, "Number of buffers allocated", nil, nil}, "stats_reset": {COUNTER, "Time at which these statistics were last reset", nil, nil}, }, "pg_stat_database": { "datid": {LABEL, "OID of a database", nil, nil}, "datname": {LABEL, "Name of this database", nil, nil}, "numbackends": {GAUGE, "Number of backends currently connected to this database. This is the only column in this view that returns a value reflecting current state; all other columns return the accumulated values since the last reset.", nil, nil}, "xact_commit": {COUNTER, "Number of transactions in this database that have been committed", nil, nil}, "xact_rollback": {COUNTER, "Number of transactions in this database that have been rolled back", nil, nil}, "blks_read": {COUNTER, "Number of disk blocks read in this database", nil, nil}, "blks_hit": {COUNTER, "Number of times disk blocks were found already in the buffer cache, so that a read was not necessary (this only includes hits in the PostgreSQL buffer cache, not the operating system's file system cache)", nil, nil}, "tup_returned": {COUNTER, "Number of rows returned by queries in this database", nil, nil}, "tup_fetched": {COUNTER, "Number of rows fetched by queries in this database", nil, nil}, "tup_inserted": {COUNTER, "Number of rows inserted by queries in this database", nil, nil}, "tup_updated": {COUNTER, "Number of rows updated by queries in this database", nil, nil}, "tup_deleted": {COUNTER, "Number of rows deleted by queries in this database", nil, nil}, "conflicts": {COUNTER, "Number of queries canceled due to conflicts with recovery in this database. (Conflicts occur only on standby servers; see pg_stat_database_conflicts for details.)", nil, nil}, "temp_files": {COUNTER, "Number of temporary files created by queries in this database. All temporary files are counted, regardless of why the temporary file was created (e.g., sorting or hashing), and regardless of the log_temp_files setting.", nil, nil}, "temp_bytes": {COUNTER, "Total amount of data written to temporary files by queries in this database. All temporary files are counted, regardless of why the temporary file was created, and regardless of the log_temp_files setting.", nil, nil}, "deadlocks": {COUNTER, "Number of deadlocks detected in this database", nil, nil}, "blk_read_time": {COUNTER, "Time spent reading data file blocks by backends in this database, in milliseconds", nil, nil}, "blk_write_time": {COUNTER, "Time spent writing data file blocks by backends in this database, in milliseconds", nil, nil}, "stats_reset": {COUNTER, "Time at which these statistics were last reset", nil, nil}, }, "pg_stat_database_conflicts": { "datid": {LABEL, "OID of a database", nil, nil}, "datname": {LABEL, "Name of this database", nil, nil}, "confl_tablespace": {COUNTER, "Number of queries in this database that have been canceled due to dropped tablespaces", nil, nil}, "confl_lock": {COUNTER, "Number of queries in this database that have been canceled due to lock timeouts", nil, nil}, "confl_snapshot": {COUNTER, "Number of queries in this database that have been canceled due to old snapshots", nil, nil}, "confl_bufferpin": {COUNTER, "Number of queries in this database that have been canceled due to pinned buffers", nil, nil}, "confl_deadlock": {COUNTER, "Number of queries in this database that have been canceled due to deadlocks", nil, nil}, }, "pg_locks": { "datname": {LABEL, "Name of this database", nil, nil}, "mode": {LABEL, "Type of Lock", nil, nil}, "count": {GAUGE, "Number of locks", nil, nil}, }, "pg_stat_replication": { "procpid": {DISCARD, "Process ID of a WAL sender process", nil, semver.MustParseRange("<9.2.0")}, "pid": {DISCARD, "Process ID of a WAL sender process", nil, semver.MustParseRange(">=9.2.0")}, "usesysid": {DISCARD, "OID of the user logged into this WAL sender process", nil, nil}, "usename": {DISCARD, "Name of the user logged into this WAL sender process", nil, nil}, "application_name": {DISCARD, "Name of the application that is connected to this WAL sender", nil, nil}, "client_addr": {LABEL, "IP address of the client connected to this WAL sender. If this field is null, it indicates that the client is connected via a Unix socket on the server machine.", nil, nil}, "client_hostname": {DISCARD, "Host name of the connected client, as reported by a reverse DNS lookup of client_addr. This field will only be non-null for IP connections, and only when log_hostname is enabled.", nil, nil}, "client_port": {DISCARD, "TCP port number that the client is using for communication with this WAL sender, or -1 if a Unix socket is used", nil, nil}, "backend_start": {DISCARD, "with time zone Time when this process was started, i.e., when the client connected to this WAL sender", nil, nil}, "backend_xmin": {DISCARD, "The current backend's xmin horizon.", nil, nil}, "state": {LABEL, "Current WAL sender state", nil, nil}, "sent_location": {DISCARD, "Last transaction log position sent on this connection", nil, semver.MustParseRange("<10.0.0")}, "write_location": {DISCARD, "Last transaction log position written to disk by this standby server", nil, semver.MustParseRange("<10.0.0")}, "flush_location": {DISCARD, "Last transaction log position flushed to disk by this standby server", nil, semver.MustParseRange("<10.0.0")}, "replay_location": {DISCARD, "Last transaction log position replayed into the database on this standby server", nil, semver.MustParseRange("<10.0.0")}, "sent_lsn": {DISCARD, "Last transaction log position sent on this connection", nil, semver.MustParseRange(">=10.0.0")}, "write_lsn": {DISCARD, "Last transaction log position written to disk by this standby server", nil, semver.MustParseRange(">=10.0.0")}, "flush_lsn": {DISCARD, "Last transaction log position flushed to disk by this standby server", nil, semver.MustParseRange(">=10.0.0")}, "replay_lsn": {DISCARD, "Last transaction log position replayed into the database on this standby server", nil, semver.MustParseRange(">=10.0.0")}, "sync_priority": {DISCARD, "Priority of this standby server for being chosen as the synchronous standby", nil, nil}, "sync_state": {DISCARD, "Synchronous state of this standby server", nil, nil}, "slot_name": {LABEL, "A unique, cluster-wide identifier for the replication slot", nil, semver.MustParseRange(">=9.2.0")}, "plugin": {DISCARD, "The base name of the shared object containing the output plugin this logical slot is using, or null for physical slots", nil, nil}, "slot_type": {DISCARD, "The slot type - physical or logical", nil, nil}, "datoid": {DISCARD, "The OID of the database this slot is associated with, or null. Only logical slots have an associated database", nil, nil}, "database": {DISCARD, "The name of the database this slot is associated with, or null. Only logical slots have an associated database", nil, nil}, "active": {DISCARD, "True if this slot is currently actively being used", nil, nil}, "active_pid": {DISCARD, "Process ID of a WAL sender process", nil, nil}, "xmin": {DISCARD, "The oldest transaction that this slot needs the database to retain. VACUUM cannot remove tuples deleted by any later transaction", nil, nil}, "catalog_xmin": {DISCARD, "The oldest transaction affecting the system catalogs that this slot needs the database to retain. VACUUM cannot remove catalog tuples deleted by any later transaction", nil, nil}, "restart_lsn": {DISCARD, "The address (LSN) of oldest WAL which still might be required by the consumer of this slot and thus won't be automatically removed during checkpoints", nil, nil}, "pg_current_xlog_location": {DISCARD, "pg_current_xlog_location", nil, nil}, "pg_current_wal_lsn": {DISCARD, "pg_current_xlog_location", nil, semver.MustParseRange(">=10.0.0")}, "pg_xlog_location_diff": {GAUGE, "Lag in bytes between master and slave", nil, semver.MustParseRange(">=9.2.0 <10.0.0")}, "pg_wal_lsn_diff": {GAUGE, "Lag in bytes between master and slave", nil, semver.MustParseRange(">=10.0.0")}, "confirmed_flush_lsn": {DISCARD, "LSN position a consumer of a slot has confirmed flushing the data received", nil, nil}, "write_lag": {DISCARD, "Time elapsed between flushing recent WAL locally and receiving notification that this standby server has written it (but not yet flushed it or applied it). This can be used to gauge the delay that synchronous_commit level remote_write incurred while committing if this server was configured as a synchronous standby.", nil, semver.MustParseRange(">=10.0.0")}, "flush_lag": {DISCARD, "Time elapsed between flushing recent WAL locally and receiving notification that this standby server has written and flushed it (but not yet applied it). This can be used to gauge the delay that synchronous_commit level remote_flush incurred while committing if this server was configured as a synchronous standby.", nil, semver.MustParseRange(">=10.0.0")}, "replay_lag": {DISCARD, "Time elapsed between flushing recent WAL locally and receiving notification that this standby server has written, flushed and applied it. This can be used to gauge the delay that synchronous_commit level remote_apply incurred while committing if this server was configured as a synchronous standby.", nil, semver.MustParseRange(">=10.0.0")}, }, "pg_stat_activity": { "datname": {LABEL, "Name of this database", nil, nil}, "state": {LABEL, "connection state", nil, semver.MustParseRange(">=9.2.0")}, "count": {GAUGE, "number of connections in this state", nil, nil}, "max_tx_duration": {GAUGE, "max duration in seconds any active transaction has been running", nil, nil}, }, } // OverrideQuery 's are run in-place of simple namespace look ups, and provide // advanced functionality. But they have a tendency to postgres version specific. // There aren't too many versions, so we simply store customized versions using // the semver matching we do for columns. type OverrideQuery struct { versionRange semver.Range query string } // Overriding queries for namespaces above. // TODO: validate this is a closed set in tests, and there are no overlaps var queryOverrides = map[string][]OverrideQuery{ "pg_locks": { { semver.MustParseRange(">0.0.0"), `SELECT pg_database.datname,tmp.mode,COALESCE(count,0) as count FROM ( VALUES ('accesssharelock'), ('rowsharelock'), ('rowexclusivelock'), ('shareupdateexclusivelock'), ('sharelock'), ('sharerowexclusivelock'), ('exclusivelock'), ('accessexclusivelock') ) AS tmp(mode) CROSS JOIN pg_database LEFT JOIN (SELECT database, lower(mode) AS mode,count(*) AS count FROM pg_locks WHERE database IS NOT NULL GROUP BY database, lower(mode) ) AS tmp2 ON tmp.mode=tmp2.mode and pg_database.oid = tmp2.database ORDER BY 1`, }, }, "pg_stat_replication": { { semver.MustParseRange(">=10.0.0"), ` SELECT *, (case pg_is_in_recovery() when 't' then null else pg_current_wal_lsn() end) AS pg_current_wal_lsn, (case pg_is_in_recovery() when 't' then null else pg_wal_lsn_diff(pg_current_wal_lsn(), replay_lsn)::float end) AS pg_wal_lsn_diff FROM pg_stat_replication `, }, { semver.MustParseRange(">=9.2.0 <10.0.0"), ` SELECT *, (case pg_is_in_recovery() when 't' then null else pg_current_xlog_location() end) AS pg_current_xlog_location, (case pg_is_in_recovery() when 't' then null else pg_xlog_location_diff(pg_current_xlog_location(), replay_location)::float end) AS pg_xlog_location_diff FROM pg_stat_replication `, }, { semver.MustParseRange("<9.2.0"), ` SELECT *, (case pg_is_in_recovery() when 't' then null else pg_current_xlog_location() end) AS pg_current_xlog_location FROM pg_stat_replication `, }, }, "pg_stat_activity": { // This query only works { semver.MustParseRange(">=9.2.0"), ` SELECT pg_database.datname, tmp.state, COALESCE(count,0) as count, COALESCE(max_tx_duration,0) as max_tx_duration FROM ( VALUES ('active'), ('idle'), ('idle in transaction'), ('idle in transaction (aborted)'), ('fastpath function call'), ('disabled') ) AS tmp(state) CROSS JOIN pg_database LEFT JOIN ( SELECT datname, state, count(*) AS count, MAX(EXTRACT(EPOCH FROM now() - xact_start))::float AS max_tx_duration FROM pg_stat_activity GROUP BY datname,state) AS tmp2 ON tmp.state = tmp2.state AND pg_database.datname = tmp2.datname `, }, // No query is applicable for 9.1 that gives any sensible data. }, } // Convert the query override file to the version-specific query override file // for the exporter. func makeQueryOverrideMap(pgVersion semver.Version, queryOverrides map[string][]OverrideQuery) map[string]string { resultMap := make(map[string]string) for name, overrideDef := range queryOverrides { // Find a matching semver. We make it an error to have overlapping // ranges at test-time, so only 1 should ever match. matched := false for _, queryDef := range overrideDef { if queryDef.versionRange(pgVersion) { resultMap[name] = queryDef.query matched = true break } } if !matched { log.Warnln("No query matched override for", name, "- disabling metric space.") resultMap[name] = "" } } return resultMap } // Add queries to the builtinMetricMaps and queryOverrides maps. Added queries do not // respect version requirements, because it is assumed that the user knows // what they are doing with their version of postgres. // // This function modifies metricMap and queryOverrideMap to contain the new // queries. // TODO: test code for all cu. // TODO: use proper struct type system // TODO: the YAML this supports is "non-standard" - we should move away from it. func addQueries(content []byte, pgVersion semver.Version, exporterMap map[string]MetricMapNamespace, queryOverrideMap map[string]string) error { var extra map[string]interface{} err := yaml.Unmarshal(content, &extra) if err != nil { return err } // Stores the loaded map representation metricMaps := make(map[string]map[string]ColumnMapping) newQueryOverrides := make(map[string]string) for metric, specs := range extra { log.Debugln("New user metric namespace from YAML:", metric) for key, value := range specs.(map[interface{}]interface{}) { switch key.(string) { case "query": query := value.(string) newQueryOverrides[metric] = query case "metrics": for _, c := range value.([]interface{}) { column := c.(map[interface{}]interface{}) for n, a := range column { var columnMapping ColumnMapping // Fetch the metric map we want to work on. metricMap, ok := metricMaps[metric] if !ok { // Namespace for metric not found - add it. metricMap = make(map[string]ColumnMapping) metricMaps[metric] = metricMap } // Get name. name := n.(string) for attrKey, attrVal := range a.(map[interface{}]interface{}) { switch attrKey.(string) { case "usage": usage, err := stringToColumnUsage(attrVal.(string)) if err != nil { return err } columnMapping.usage = usage case "description": columnMapping.description = attrVal.(string) } } // TODO: we should support cu columnMapping.mapping = nil // Should we support this for users? columnMapping.supportedVersions = nil metricMap[name] = columnMapping } } } } } // Convert the loaded metric map into exporter representation partialExporterMap := makeDescMap(pgVersion, metricMaps) // Merge the two maps (which are now quite flatteend) for k, v := range partialExporterMap { _, found := exporterMap[k] if found { log.Debugln("Overriding metric", k, "from user YAML file.") } else { log.Debugln("Adding new metric", k, "from user YAML file.") } exporterMap[k] = v } // Merge the query override map for k, v := range newQueryOverrides { _, found := queryOverrideMap[k] if found { log.Debugln("Overriding query override", k, "from user YAML file.") } else { log.Debugln("Adding new query override", k, "from user YAML file.") } queryOverrideMap[k] = v } return nil } // Turn the MetricMap column mapping into a prometheus descriptor mapping. func makeDescMap(pgVersion semver.Version, metricMaps map[string]map[string]ColumnMapping) map[string]MetricMapNamespace { var metricMap = make(map[string]MetricMapNamespace) for namespace, mappings := range metricMaps { thisMap := make(map[string]MetricMap) // Get the constant labels var constLabels []string for columnName, columnMapping := range mappings { if columnMapping.usage == LABEL { constLabels = append(constLabels, columnName) } } for columnName, columnMapping := range mappings { // Check column version compatibility for the current map // Force to discard if not compatible. if columnMapping.supportedVersions != nil { if !columnMapping.supportedVersions(pgVersion) { // It's very useful to be able to see what columns are being // rejected. log.Debugln(columnName, "is being forced to discard due to version incompatibility.") thisMap[columnName] = MetricMap{ discard: true, conversion: func(in interface{}) (float64, bool) { return math.NaN(), true }, } continue } } // Determine how to convert the column based on its usage. switch columnMapping.usage { case DISCARD, LABEL: thisMap[columnName] = MetricMap{ discard: true, conversion: func(in interface{}) (float64, bool) { return math.NaN(), true }, } case COUNTER: thisMap[columnName] = MetricMap{ vtype: prometheus.CounterValue, desc: prometheus.NewDesc(fmt.Sprintf("%s_%s", namespace, columnName), columnMapping.description, constLabels, nil), conversion: func(in interface{}) (float64, bool) { return dbToFloat64(in) }, } case GAUGE: thisMap[columnName] = MetricMap{ vtype: prometheus.GaugeValue, desc: prometheus.NewDesc(fmt.Sprintf("%s_%s", namespace, columnName), columnMapping.description, constLabels, nil), conversion: func(in interface{}) (float64, bool) { return dbToFloat64(in) }, } case MAPPEDMETRIC: thisMap[columnName] = MetricMap{ vtype: prometheus.GaugeValue, desc: prometheus.NewDesc(fmt.Sprintf("%s_%s", namespace, columnName), columnMapping.description, constLabels, nil), conversion: func(in interface{}) (float64, bool) { text, ok := in.(string) if !ok { return math.NaN(), false } val, ok := columnMapping.mapping[text] if !ok { return math.NaN(), false } return val, true }, } case DURATION: thisMap[columnName] = MetricMap{ vtype: prometheus.GaugeValue, desc: prometheus.NewDesc(fmt.Sprintf("%s_%s_milliseconds", namespace, columnName), columnMapping.description, constLabels, nil), conversion: func(in interface{}) (float64, bool) { var durationString string switch t := in.(type) { case []byte: durationString = string(t) case string: durationString = t default: log.Errorln("DURATION conversion metric was not a string") 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) return math.NaN(), false } return float64(d / time.Millisecond), true }, } } } metricMap[namespace] = MetricMapNamespace{constLabels, thisMap} } return metricMap } // convert a string to the corresponding ColumnUsage func stringToColumnUsage(s string) (u ColumnUsage, err error) { switch s { case "DISCARD": u = DISCARD case "LABEL": u = LABEL case "COUNTER": u = COUNTER case "GAUGE": u = GAUGE case "MAPPEDMETRIC": u = MAPPEDMETRIC case "DURATION": u = DURATION default: err = fmt.Errorf("wrong ColumnUsage given : %s", s) } return } // Convert database.sql types to float64s for Prometheus consumption. Null types are mapped to NaN. string and []byte // types are mapped as NaN and !ok func dbToFloat64(t interface{}) (float64, bool) { switch v := t.(type) { case int64: return float64(v), true case float64: return v, true case time.Time: return float64(v.Unix()), true case []byte: // Try and convert to string and then parse to a float64 strV := string(v) result, err := strconv.ParseFloat(strV, 64) if err != nil { log.Infoln("Could not parse []byte:", err) return math.NaN(), false } return result, true case string: result, err := strconv.ParseFloat(v, 64) if err != nil { log.Infoln("Could not parse string:", err) return math.NaN(), false } return result, true case nil: return math.NaN(), true default: return math.NaN(), false } } // Convert database.sql to string for Prometheus labels. Null types are mapped to empty strings. func dbToString(t interface{}) (string, bool) { switch v := t.(type) { case int64: return fmt.Sprintf("%v", v), true case float64: return fmt.Sprintf("%v", v), true case time.Time: return fmt.Sprintf("%v", v.Unix()), true case nil: return "", true case []byte: // Try and convert to string return string(v), true case string: return v, true default: return "", false } } // Exporter collects Postgres metrics. It implements prometheus.Collector. type Exporter struct { // Holds a reference to the build in column mappings. Currently this is for testing purposes // only, since it just points to the global. builtinMetricMaps map[string]map[string]ColumnMapping dsn string userQueriesPath string duration prometheus.Gauge error prometheus.Gauge psqlUp prometheus.Gauge userQueriesError *prometheus.GaugeVec totalScrapes prometheus.Counter // dbDsn is the connection string used to establish the dbConnection dbDsn string // dbConnection is used to allow re-using the DB connection between scrapes dbConnection *sql.DB // Last version used to calculate metric map. If mismatch on scrape, // then maps are recalculated. lastMapVersion semver.Version // Currently active metric map metricMap map[string]MetricMapNamespace // Currently active query overrides queryOverrides map[string]string mappingMtx sync.RWMutex } // NewExporter returns a new PostgreSQL exporter for the provided DSN. func NewExporter(dsn string, userQueriesPath string) *Exporter { return &Exporter{ builtinMetricMaps: builtinMetricMaps, dsn: dsn, userQueriesPath: userQueriesPath, duration: prometheus.NewGauge(prometheus.GaugeOpts{ Namespace: namespace, Subsystem: exporter, Name: "last_scrape_duration_seconds", Help: "Duration of the last scrape of metrics from PostgresSQL.", }), totalScrapes: prometheus.NewCounter(prometheus.CounterOpts{ Namespace: namespace, Subsystem: exporter, Name: "scrapes_total", Help: "Total number of times PostgresSQL was scraped for metrics.", }), error: prometheus.NewGauge(prometheus.GaugeOpts{ Namespace: namespace, Subsystem: exporter, Name: "last_scrape_error", Help: "Whether the last scrape of metrics from PostgreSQL resulted in an error (1 for error, 0 for success).", }), psqlUp: prometheus.NewGauge(prometheus.GaugeOpts{ Namespace: namespace, Name: "up", Help: "Whether the last scrape of metrics from PostgreSQL was able to connect to the server (1 for yes, 0 for no).", }), userQueriesError: prometheus.NewGaugeVec(prometheus.GaugeOpts{ Namespace: namespace, Subsystem: exporter, Name: "user_queries_load_error", Help: "Whether the user queries file was loaded and parsed successfully (1 for error, 0 for success).", }, []string{"filename", "hashsum"}), metricMap: nil, queryOverrides: nil, } } // Describe implements prometheus.Collector. func (e *Exporter) Describe(ch chan<- *prometheus.Desc) { // We cannot know in advance what metrics the exporter will generate // from Postgres. So we use the poor man's describe method: Run a collect // and send the descriptors of all the collected metrics. The problem // here is that we need to connect to the Postgres DB. If it is currently // unavailable, the descriptors will be incomplete. Since this is a // stand-alone exporter and not used as a library within other code // implementing additional metrics, the worst that can happen is that we // don't detect inconsistent metrics created by this exporter // itself. Also, a change in the monitored Postgres instance may change the // exported metrics during the runtime of the exporter. metricCh := make(chan prometheus.Metric) doneCh := make(chan struct{}) go func() { for m := range metricCh { ch <- m.Desc() } close(doneCh) }() e.Collect(metricCh) close(metricCh) <-doneCh } // Collect implements prometheus.Collector. func (e *Exporter) Collect(ch chan<- prometheus.Metric) { e.scrape(ch) ch <- e.duration ch <- e.totalScrapes ch <- e.error ch <- e.psqlUp e.userQueriesError.Collect(ch) } func newDesc(subsystem, name, help string) *prometheus.Desc { return prometheus.NewDesc( prometheus.BuildFQName(namespace, subsystem, name), help, nil, nil, ) } // Query within a namespace mapping and emit metrics. Returns fatal errors if // the scrape fails, and a slice of errors if they were non-fatal. func queryNamespaceMapping(ch chan<- prometheus.Metric, db *sql.DB, namespace string, mapping MetricMapNamespace, queryOverrides map[string]string) ([]error, error) { // Check for a query override for this namespace query, found := queryOverrides[namespace] // Was this query disabled (i.e. nothing sensible can be queried on cu // version of PostgreSQL? if query == "" && found { // Return success (no pertinent data) return []error{}, nil } // Don't fail on a bad scrape of one metric var rows *sql.Rows var err error if !found { // I've no idea how to avoid this properly at the moment, but this is // an admin tool so you're not injecting SQL right? // nolint: gas rows, err = db.Query(fmt.Sprintf("SELECT * FROM %s;", namespace)) } else { rows, err = db.Query(query) } if err != nil { return []error{}, errors.New(fmt.Sprintln("Error running query on database: ", namespace, err)) } defer rows.Close() // nolint: errcheck var columnNames []string columnNames, err = rows.Columns() if err != nil { return []error{}, errors.New(fmt.Sprintln("Error retrieving column list for: ", namespace, err)) } // Make a lookup map for the column indices var columnIdx = make(map[string]int, len(columnNames)) for i, n := range columnNames { columnIdx[n] = i } var columnData = make([]interface{}, len(columnNames)) var scanArgs = make([]interface{}, len(columnNames)) for i := range columnData { scanArgs[i] = &columnData[i] } nonfatalErrors := []error{} for rows.Next() { err = rows.Scan(scanArgs...) if err != nil { return []error{}, errors.New(fmt.Sprintln("Error retrieving rows:", namespace, err)) } // Get the label values for this row var labels = make([]string, len(mapping.labels)) for idx, columnName := range mapping.labels { labels[idx], _ = dbToString(columnData[columnIdx[columnName]]) } // Loop over column names, and match to scan data. Unknown columns // will be filled with an untyped metric number *if* they can be // converted to float64s. NULLs are allowed and treated as NaN. for idx, columnName := range columnNames { if metricMapping, ok := mapping.columnMappings[columnName]; ok { // Is this a metricy metric? if metricMapping.discard { continue } value, ok := dbToFloat64(columnData[idx]) if !ok { nonfatalErrors = append(nonfatalErrors, errors.New(fmt.Sprintln("Unexpected error parsing column: ", namespace, columnName, columnData[idx]))) continue } // Generate the metric ch <- prometheus.MustNewConstMetric(metricMapping.desc, metricMapping.vtype, value, labels...) } else { // Unknown metric. Report as untyped if scan to float64 works, else note an error too. metricLabel := fmt.Sprintf("%s_%s", namespace, columnName) desc := prometheus.NewDesc(metricLabel, fmt.Sprintf("Unknown metric from %s", namespace), mapping.labels, nil) // Its not an error to fail here, since the values are // unexpected anyway. value, ok := dbToFloat64(columnData[idx]) if !ok { nonfatalErrors = append(nonfatalErrors, errors.New(fmt.Sprintln("Unparseable column type - discarding: ", namespace, columnName, err))) continue } ch <- prometheus.MustNewConstMetric(desc, prometheus.UntypedValue, value, labels...) } } } return nonfatalErrors, nil } // Iterate through all the namespace mappings in the exporter and run their // queries. func queryNamespaceMappings(ch chan<- prometheus.Metric, db *sql.DB, metricMap map[string]MetricMapNamespace, queryOverrides map[string]string) map[string]error { // Return a map of namespace -> errors namespaceErrors := make(map[string]error) for namespace, mapping := range metricMap { log.Debugln("Querying namespace: ", namespace) nonFatalErrors, err := queryNamespaceMapping(ch, db, namespace, mapping, queryOverrides) // Serious error - a namespace disappeard if err != nil { namespaceErrors[namespace] = err log.Infoln(err) } // Non-serious errors - likely version or parsing problems. if len(nonFatalErrors) > 0 { for _, err := range nonFatalErrors { log.Infoln(err.Error()) } } } return namespaceErrors } // Check and update the exporters query maps if the version has changed. func (e *Exporter) checkMapVersions(ch chan<- prometheus.Metric, db *sql.DB) error { log.Debugln("Querying Postgres Version") versionRow := db.QueryRow("SELECT version();") var versionString string err := versionRow.Scan(&versionString) if err != nil { return fmt.Errorf("Error scanning version string: %v", err) } semanticVersion, err := parseVersion(versionString) if err != nil { return fmt.Errorf("Error parsing version string: %v", err) } if semanticVersion.LT(lowestSupportedVersion) { log.Warnln("PostgreSQL version is lower then our lowest supported version! Got", semanticVersion.String(), "minimum supported is", lowestSupportedVersion.String()) } // Check if semantic version changed and recalculate maps if needed. if semanticVersion.NE(e.lastMapVersion) || e.metricMap == nil { log.Infoln("Semantic Version Changed:", e.lastMapVersion.String(), "->", semanticVersion.String()) e.mappingMtx.Lock() e.metricMap = makeDescMap(semanticVersion, e.builtinMetricMaps) e.queryOverrides = makeQueryOverrideMap(semanticVersion, queryOverrides) e.lastMapVersion = semanticVersion if e.userQueriesPath != "" { // Clear the metric while a reload is happening e.userQueriesError.Reset() // Calculate the hashsum of the useQueries userQueriesData, err := ioutil.ReadFile(e.userQueriesPath) if err != nil { log.Errorln("Failed to reload user queries:", e.userQueriesPath, err) e.userQueriesError.WithLabelValues(e.userQueriesPath, "").Set(1) } else { hashsumStr := fmt.Sprintf("%x", sha256.Sum256(userQueriesData)) if err := addQueries(userQueriesData, semanticVersion, e.metricMap, e.queryOverrides); err != nil { log.Errorln("Failed to reload user queries:", e.userQueriesPath, err) e.userQueriesError.WithLabelValues(e.userQueriesPath, hashsumStr).Set(1) } else { // Mark user queries as successfully loaded e.userQueriesError.WithLabelValues(e.userQueriesPath, hashsumStr).Set(0) } } } e.mappingMtx.Unlock() } // Output the version as a special metric versionDesc := prometheus.NewDesc(fmt.Sprintf("%s_%s", namespace, staticLabelName), "Version string as reported by postgres", []string{"version", "short_version"}, nil) ch <- prometheus.MustNewConstMetric(versionDesc, prometheus.UntypedValue, 1, versionString, semanticVersion.String()) return nil } func (e *Exporter) getDB(conn string) (*sql.DB, error) { // Has dsn changed? if (e.dbConnection != nil) && (e.dsn != e.dbDsn) { err := e.dbConnection.Close() log.Warnln("Error while closing obsolete DB connection:", err) e.dbConnection = nil e.dbDsn = "" } if e.dbConnection == nil { d, err := sql.Open("postgres", conn) if err != nil { e.psqlUp.Set(0) return nil, err } err = d.Ping() if err != nil { e.psqlUp.Set(0) return nil, err } e.psqlUp.Set(1) d.SetMaxOpenConns(1) d.SetMaxIdleConns(1) e.dbConnection = d e.dbDsn = e.dsn log.Infoln("Established new database connection.") } return e.dbConnection, nil } func (e *Exporter) scrape(ch chan<- prometheus.Metric) { defer func(begun time.Time) { e.duration.Set(time.Since(begun).Seconds()) }(time.Now()) e.error.Set(0) e.totalScrapes.Inc() db, err := e.getDB(e.dsn) if err != nil { loggableDsn := "could not parse DATA_SOURCE_NAME" // If the DSN is parseable, log it with a blanked out password pDsn, pErr := url.Parse(e.dsn) if pErr == nil { // Blank user info if not nil if pDsn.User != nil { pDsn.User = url.UserPassword(pDsn.User.Username(), "PASSWORD_REMOVED") } loggableDsn = pDsn.String() } log.Infof("Error opening connection to database (%s): %s", loggableDsn, err) e.error.Set(1) return } // Check if map versions need to be updated if err := e.checkMapVersions(ch, db); err != nil { log.Warnln("Proceeding with outdated query maps, as the Postgres version could not be determined:", err) e.error.Set(1) } // Lock the exporter maps e.mappingMtx.RLock() defer e.mappingMtx.RUnlock() if err := querySettings(ch, db); err != nil { log.Infof("Error retrieving settings: %s", err) e.error.Set(1) } errMap := queryNamespaceMappings(ch, db, e.metricMap, e.queryOverrides) if len(errMap) > 0 { e.error.Set(1) } } // try to get the DataSource // DATA_SOURCE_NAME always wins so we do not break older versions // reading secrets from files wins over secrets in environment variables // DATA_SOURCE_NAME > DATA_SOURCE_{USER|FILE}_FILE > DATA_SOURCE_{USER|FILE} func getDataSource() string { var dsn = os.Getenv("DATA_SOURCE_NAME") if len(dsn) == 0 { var user string var pass string if len(os.Getenv("DATA_SOURCE_USER_FILE")) != 0 { fileContents, err := ioutil.ReadFile(os.Getenv("DATA_SOURCE_USER_FILE")) if err != nil { panic(err) } user = strings.TrimSpace(string(fileContents)) } else { user = os.Getenv("DATA_SOURCE_USER") } if len(os.Getenv("DATA_SOURCE_PASS_FILE")) != 0 { fileContents, err := ioutil.ReadFile(os.Getenv("DATA_SOURCE_PASS_FILE")) if err != nil { panic(err) } pass = strings.TrimSpace(string(fileContents)) } else { pass = os.Getenv("DATA_SOURCE_PASS") } uri := os.Getenv("DATA_SOURCE_URI") dsn = "postgresql://" + user + ":" + pass + "@" + uri } return dsn } func main() { kingpin.Version(fmt.Sprintf("postgres_exporter %s (built with %s)\n", Version, runtime.Version())) log.AddFlags(kingpin.CommandLine) kingpin.Parse() // landingPage contains the HTML served at '/'. // TODO: Make this nicer and more informative. var landingPage = []byte(` Postgres exporter

Postgres exporter

Metrics

`) if *onlyDumpMaps { dumpMaps() return } dsn := getDataSource() if len(dsn) == 0 { log.Fatal("couldn't find environment variables describing the datasource to use") } exporter := NewExporter(dsn, *queriesPath) defer func() { if exporter.dbConnection != nil { exporter.dbConnection.Close() // nolint: errcheck } }() prometheus.MustRegister(exporter) http.Handle(*metricPath, promhttp.Handler()) http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { w.Write(landingPage) // nolint: errcheck }) log.Infof("Starting Server: %s", *listenAddress) log.Fatal(http.ListenAndServe(*listenAddress, nil)) } prometheus-postgres-exporter-0.4.1+ds/postgres_exporter.rc000066400000000000000000000061741321452450400241570ustar00rootroot00000000000000#!/bin/sh # PROVIDE: postgres_exporter # REQUIRE: LOGIN # KEYWORD: shutdown # # rc-script for postgres_exporter # # # Add the following lines to /etc/rc.conf.local or /etc/rc.conf # to enable this service: # # postgres_exporter_enable (bool): Set to NO by default. # Set it to YES to enable postgres_exporter. # postgres_exporter_user (string): Set user that postgres_exporter will run under # Default is "nobody". # postgres_exporter_group (string): Set group that postgres_exporter will run under # Default is "nobody". # postgres_exporter_args (string): Set extra arguments to pass to postgres_exporter # Default is "". # postgres_exporter_listen_address (string):Set ip:port to listen on for web interface and telemetry. # Defaults to ":9187" # postgres_exporter_pg_user (string): Set the Postgres database user # Defaults to "postgres_exporter" # postgres_exporter_pg_pass (string): Set the Postgres datase password # Default is empty # postgres_exporter_pg_host (string): Set the Postgres database server # Defaults to "localhost" # postgres_exporter_pg_port (string): Set the Postgres database port # Defaults to "5432" # Add extra arguments via "postgres_exporter_args" which could be choosen from: # (see $ postgres_exporter --help) # # -dumpmaps # Do not run, simply dump the maps. # -extend.query-path string # Path to custom queries to run. # -log.level value # Only log messages with the given severity or above. Valid levels: [debug, info, warn, error, fatal]. # -version # print version and exit # -web.telemetry-path string # Path under which to expose metrics. (default "/metrics") # -log.format value # If set use a syslog logger or JSON logging. Example: logger:syslog?appname=bob&local=7 or logger:stdout?json=true. Defaults to stderr. # -extend.query-path string # Path to custom queries to run. . /etc/rc.subr name=postgres_exporter rcvar=postgres_exporter_enable load_rc_config $name : ${postgres_exporter_enable:="NO"} : ${postgres_exporter_user:="nobody"} : ${postgres_exporter_group:="nobody"} : ${postgres_exporter_args:=""} : ${postgres_exporter_listen_address:=":9187"} : ${postgres_exporter_pg_user:="postgres_exporter"} : ${postgres_exporter_pg_pass:=""} : ${postgres_exporter_pg_host:="localhost"} : ${postgres_exporter_pg_port:="5432"} postgres_exporter_data_source_name="postgresql://${postgres_exporter_pg_user}:${postgres_exporter_pg_pass}@${postgres_exporter_pg_host}:${postgres_exporter_pg_port}/postgres?sslmode=disable" pidfile=/var/run/postgres_exporter.pid command="/usr/sbin/daemon" procname="/usr/local/bin/postgres_exporter" command_args="-p ${pidfile} /usr/bin/env DATA_SOURCE_NAME="${postgres_exporter_data_source_name}" ${procname} \ -web.listen-address=${postgres_exporter_listen_address} \ ${postgres_exporter_args}" start_precmd=postgres_exporter_startprecmd postgres_exporter_startprecmd() { if [ ! -e ${pidfile} ]; then install -o ${postgres_exporter_user} -g ${postgres_exporter_group} /dev/null ${pidfile}; fi } load_rc_config $name run_rc_command "$1" prometheus-postgres-exporter-0.4.1+ds/postgres_exporter_integration_test.go000066400000000000000000000062431321452450400276170ustar00rootroot00000000000000// These are specialized integration tests. We only build them when we're doing // a lot of additional work to keep the external docker environment they require // working. // +build integration package main import ( "os" "testing" . "gopkg.in/check.v1" "database/sql" "fmt" _ "github.com/lib/pq" "github.com/prometheus/client_golang/prometheus" ) // Hook up gocheck into the "go test" runner. func Test(t *testing.T) { TestingT(t) } type IntegrationSuite struct { e *Exporter } var _ = Suite(&IntegrationSuite{}) func (s *IntegrationSuite) SetUpSuite(c *C) { dsn := os.Getenv("DATA_SOURCE_NAME") c.Assert(dsn, Not(Equals), "") exporter := NewExporter(dsn, "") c.Assert(exporter, NotNil) // Assign the exporter to the suite s.e = exporter prometheus.MustRegister(exporter) } // TODO: it would be nice if cu didn't mostly just recreate the scrape function func (s *IntegrationSuite) TestAllNamespacesReturnResults(c *C) { // Setup a dummy channel to consume metrics ch := make(chan prometheus.Metric, 100) go func() { for range ch { } }() // Open a database connection db, err := sql.Open("postgres", s.e.dsn) c.Assert(db, NotNil) c.Assert(err, IsNil) defer db.Close() // Do a version update err = s.e.checkMapVersions(ch, db) c.Assert(err, IsNil) err = querySettings(ch, db) if !c.Check(err, Equals, nil) { fmt.Println("## ERRORS FOUND") fmt.Println(err) } // This should never happen in our test cases. errMap := queryNamespaceMappings(ch, db, s.e.metricMap, s.e.queryOverrides) if !c.Check(len(errMap), Equals, 0) { fmt.Println("## NAMESPACE ERRORS FOUND") for namespace, err := range errMap { fmt.Println(namespace, ":", err) } } } // TestInvalidDsnDoesntCrash tests that specifying an invalid DSN doesn't crash // the exporter. Related to https://github.com/wrouesnel/postgres_exporter/issues/93 // although not a replication of the scenario. func (s *IntegrationSuite) TestInvalidDsnDoesntCrash(c *C) { // Setup a dummy channel to consume metrics ch := make(chan prometheus.Metric, 100) go func() { for range ch { } }() // Send a bad DSN exporter := NewExporter("invalid dsn", *queriesPath) c.Assert(exporter, NotNil) exporter.scrape(ch) // Send a DSN to a non-listening port. exporter = NewExporter("postgresql://nothing:nothing@127.0.0.1:1/nothing", *queriesPath) c.Assert(exporter, NotNil) exporter.scrape(ch) } // TestUnknownMetricParsingDoesntCrash deliberately deletes all the column maps out // of an exporter to test that the default metric handling code can cope with unknown columns. func (s *IntegrationSuite) TestUnknownMetricParsingDoesntCrash(c *C) { // Setup a dummy channel to consume metrics ch := make(chan prometheus.Metric, 100) go func() { for range ch { } }() dsn := os.Getenv("DATA_SOURCE_NAME") c.Assert(dsn, Not(Equals), "") exporter := NewExporter(dsn, "") c.Assert(exporter, NotNil) // Convert the default maps into a list of empty maps. emptyMaps := make(map[string]map[string]ColumnMapping, 0) for k := range exporter.builtinMetricMaps { emptyMaps[k] = map[string]ColumnMapping{} } exporter.builtinMetricMaps = emptyMaps // scrape the exporter and make sure it works exporter.scrape(ch) } prometheus-postgres-exporter-0.4.1+ds/postgres_exporter_integration_test_script000077500000000000000000000004621321452450400305770ustar00rootroot00000000000000#!/bin/bash # This script wraps the integration test binary so it produces concatenated # test output. test_binary=$1 shift output_cov=$1 shift echo "mode: count" > $output_cov test_cov=$(mktemp) $test_binary -test.coverprofile=$test_cov $@ || exit 1 tail -n +2 $test_cov >> $output_cov rm -f $test_cov prometheus-postgres-exporter-0.4.1+ds/postgres_exporter_test.go000066400000000000000000000104171321452450400252120ustar00rootroot00000000000000// +build !integration package main import ( . "gopkg.in/check.v1" "testing" "github.com/blang/semver" "os" ) // Hook up gocheck into the "go test" runner. func Test(t *testing.T) { TestingT(t) } type FunctionalSuite struct { } var _ = Suite(&FunctionalSuite{}) func (s *FunctionalSuite) SetUpSuite(c *C) { } func (s *FunctionalSuite) TestSemanticVersionColumnDiscard(c *C) { testMetricMap := map[string]map[string]ColumnMapping{ "test_namespace": { "metric_which_stays": {COUNTER, "This metric should not be eliminated", nil, nil}, "metric_which_discards": {COUNTER, "This metric should be forced to DISCARD", nil, nil}, }, } { // No metrics should be eliminated resultMap := makeDescMap(semver.MustParse("0.0.1"), testMetricMap) c.Check( resultMap["test_namespace"].columnMappings["metric_which_stays"].discard, Equals, false, ) c.Check( resultMap["test_namespace"].columnMappings["metric_which_discards"].discard, Equals, false, ) } { // Update the map so the discard metric should be eliminated discardableMetric := testMetricMap["test_namespace"]["metric_which_discards"] discardableMetric.supportedVersions = semver.MustParseRange(">0.0.1") testMetricMap["test_namespace"]["metric_which_discards"] = discardableMetric // Discard metric should be discarded resultMap := makeDescMap(semver.MustParse("0.0.1"), testMetricMap) c.Check( resultMap["test_namespace"].columnMappings["metric_which_stays"].discard, Equals, false, ) c.Check( resultMap["test_namespace"].columnMappings["metric_which_discards"].discard, Equals, true, ) } { // Update the map so the discard metric should be kept but has a version discardableMetric := testMetricMap["test_namespace"]["metric_which_discards"] discardableMetric.supportedVersions = semver.MustParseRange(">0.0.1") testMetricMap["test_namespace"]["metric_which_discards"] = discardableMetric // Discard metric should be discarded resultMap := makeDescMap(semver.MustParse("0.0.2"), testMetricMap) c.Check( resultMap["test_namespace"].columnMappings["metric_which_stays"].discard, Equals, false, ) c.Check( resultMap["test_namespace"].columnMappings["metric_which_discards"].discard, Equals, false, ) } } // test read username and password from file func (s *FunctionalSuite) TestEnvironmentSettingWithSecretsFiles(c *C) { err := os.Setenv("DATA_SOURCE_USER_FILE", "./tests/username_file") c.Assert(err, IsNil) defer UnsetEnvironment(c, "DATA_SOURCE_USER_FILE") err = os.Setenv("DATA_SOURCE_PASS_FILE", "./tests/userpass_file") c.Assert(err, IsNil) defer UnsetEnvironment(c, "DATA_SOURCE_PASS_FILE") err = os.Setenv("DATA_SOURCE_URI", "localhost:5432/?sslmode=disable") c.Assert(err, IsNil) defer UnsetEnvironment(c, "DATA_SOURCE_URI") var expected = "postgresql://custom_username:custom_password@localhost:5432/?sslmode=disable" dsn := getDataSource() if dsn != expected { c.Errorf("Expected Username to be read from file. Found=%v, expected=%v", dsn, expected) } } // test read DATA_SOURCE_NAME from environment func (s *FunctionalSuite) TestEnvironmentSettingWithDns(c *C) { envDsn := "postgresql://user:password@localhost:5432/?sslmode=enabled" err := os.Setenv("DATA_SOURCE_NAME", envDsn) c.Assert(err, IsNil) defer UnsetEnvironment(c, "DATA_SOURCE_NAME") dsn := getDataSource() if dsn != envDsn { c.Errorf("Expected Username to be read from file. Found=%v, expected=%v", dsn, envDsn) } } // test DATA_SOURCE_NAME is used even if username and password environment variables are set func (s *FunctionalSuite) TestEnvironmentSettingWithDnsAndSecrets(c *C) { envDsn := "postgresql://userDsn:passwordDsn@localhost:55432/?sslmode=disabled" err := os.Setenv("DATA_SOURCE_NAME", envDsn) c.Assert(err, IsNil) defer UnsetEnvironment(c, "DATA_SOURCE_NAME") err = os.Setenv("DATA_SOURCE_USER_FILE", "./tests/username_file") c.Assert(err, IsNil) defer UnsetEnvironment(c, "DATA_SOURCE_USER_FILE") err = os.Setenv("DATA_SOURCE_PASS", "envUserPass") c.Assert(err, IsNil) defer UnsetEnvironment(c, "DATA_SOURCE_PASS") dsn := getDataSource() if dsn != envDsn { c.Errorf("Expected Username to be read from file. Found=%v, expected=%v", dsn, envDsn) } } func UnsetEnvironment(c *C, d string) { err := os.Unsetenv(d) c.Assert(err, IsNil) } prometheus-postgres-exporter-0.4.1+ds/postgres_metrics_added_and_removed000077500000000000000000000005121321452450400270270ustar00rootroot00000000000000#!/bin/bash # Script to determine added and removed metrics. # Not currently used in CI but useful for inspecting complicated changes. type=$1 version=$2 old_version=$3 new_version=$4 comm -23 $old_version $new_version > .metrics.${type}.${version}.removed comm -13 $old_version $new_version > .metrics.${type}.${version}.added prometheus-postgres-exporter-0.4.1+ds/postgres_metrics_parse_script000077500000000000000000000007141321452450400261250ustar00rootroot00000000000000#!/bin/bash # Script to parse a text exposition format file into a unique list of metrics # output by the exporter. # Not currently used for CI, but useful for inspecting the differences of # complicated PRs. for raw_prom in $(echo .*.prom) ; do # Strip, sort and deduplicate the label names cat $raw_prom | grep -v '#' | \ rev | cut -d' ' -f2- | \ rev | cut -d'{' -f1 | \ sort | \ uniq > ${raw_prom}.unique done prometheus-postgres-exporter-0.4.1+ds/queries.yaml000066400000000000000000000067661321452450400224030ustar00rootroot00000000000000pg_replication: query: "SELECT EXTRACT(EPOCH FROM (now() - pg_last_xact_replay_timestamp()))::INT as lag" metrics: - lag: usage: "GAUGE" description: "Replication lag behind master in seconds" pg_postmaster: query: "SELECT pg_postmaster_start_time as start_time_seconds from pg_postmaster_start_time()" metrics: - start_time_seconds: usage: "GAUGE" description: "Time at which postmaster started" pg_stat_user_tables: query: "SELECT schemaname, relname, seq_scan, seq_tup_read, idx_scan, idx_tup_fetch, n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze, last_vacuum, last_autovacuum, last_analyze, last_autoanalyze, vacuum_count, autovacuum_count, analyze_count, autoanalyze_count FROM pg_stat_user_tables" metrics: - schemaname: usage: "LABEL" description: "Name of the schema that this table is in" - relname: usage: "LABEL" description: "Name of this table" - seq_scan: usage: "COUNTER" description: "Number of sequential scans initiated on this table" - seq_tup_read: usage: "COUNTER" description: "Number of live rows fetched by sequential scans" - idx_scan: usage: "COUNTER" description: "Number of index scans initiated on this table" - idx_tup_fetch: usage: "COUNTER" description: "Number of live rows fetched by index scans" - n_tup_ins: usage: "COUNTER" description: "Number of rows inserted" - n_tup_upd: usage: "COUNTER" description: "Number of rows updated" - n_tup_del: usage: "COUNTER" description: "Number of rows deleted" - n_tup_hot_upd: usage: "COUNTER" description: "Number of rows HOT updated (i.e., with no separate index update required)" - n_live_tup: usage: "GAUGE" description: "Estimated number of live rows" - n_dead_tup: usage: "GAUGE" description: "Estimated number of dead rows" - n_mod_since_analyze: usage: "GAUGE" description: "Estimated number of rows changed since last analyze" - last_vacuum: usage: "GAUGE" description: "Last time at which this table was manually vacuumed (not counting VACUUM FULL)" - last_autovacuum: usage: "GAUGE" description: "Last time at which this table was vacuumed by the autovacuum daemon" - last_analyze: usage: "GAUGE" description: "Last time at which this table was manually analyzed" - last_autoanalyze: usage: "GAUGE" description: "Last time at which this table was analyzed by the autovacuum daemon" - vacuum_count: usage: "COUNTER" description: "Number of times this table has been manually vacuumed (not counting VACUUM FULL)" - autovacuum_count: usage: "COUNTER" description: "Number of times this table has been vacuumed by the autovacuum daemon" - analyze_count: usage: "COUNTER" description: "Number of times this table has been manually analyzed" - autoanalyze_count: usage: "COUNTER" description: "Number of times this table has been analyzed by the autovacuum daemon" pg_database: query: " SELECT pg_database.datname, pg_database_size(pg_database.datname) as size FROM pg_database" metrics: - datname: usage: "LABEL" description: "Name of the database" - size: usage: "GAUGE" description: "Disk space used by the database" prometheus-postgres-exporter-0.4.1+ds/tests/000077500000000000000000000000001321452450400211655ustar00rootroot00000000000000prometheus-postgres-exporter-0.4.1+ds/tests/docker-postgres-replication/000077500000000000000000000000001321452450400266075ustar00rootroot00000000000000prometheus-postgres-exporter-0.4.1+ds/tests/docker-postgres-replication/Dockerfile000077500000000000000000000004651321452450400306110ustar00rootroot00000000000000FROM postgres:9.6 MAINTAINER Daniel Dent (https://www.danieldent.com) ENV PG_MAX_WAL_SENDERS 8 ENV PG_WAL_KEEP_SEGMENTS 8 COPY setup-replication.sh /docker-entrypoint-initdb.d/ COPY docker-entrypoint.sh /docker-entrypoint.sh RUN chmod +x /docker-entrypoint-initdb.d/setup-replication.sh /docker-entrypoint.sh prometheus-postgres-exporter-0.4.1+ds/tests/docker-postgres-replication/Dockerfile.p2000066400000000000000000000004751321452450400311270ustar00rootroot00000000000000FROM postgres:{{VERSION}} MAINTAINER Daniel Dent (https://www.danieldent.com) ENV PG_MAX_WAL_SENDERS 8 ENV PG_WAL_KEEP_SEGMENTS 8 COPY setup-replication.sh /docker-entrypoint-initdb.d/ COPY docker-entrypoint.sh /docker-entrypoint.sh RUN chmod +x /docker-entrypoint-initdb.d/setup-replication.sh /docker-entrypoint.sh prometheus-postgres-exporter-0.4.1+ds/tests/docker-postgres-replication/README.md000066400000000000000000000006131321452450400300660ustar00rootroot00000000000000# Replicated postgres cluster in docker. Upstream is forked from https://github.com/DanielDent/docker-postgres-replication My version lives at https://github.com/wrouesnel/docker-postgres-replication This very simple docker-compose file lets us stand up a replicated postgres cluster so we can test streaming. # TODO: Pull in p2 and template the Dockerfile so we can test multiple versions. prometheus-postgres-exporter-0.4.1+ds/tests/docker-postgres-replication/docker-compose.yml000066400000000000000000000012631321452450400322460ustar00rootroot00000000000000 version: '2' services: pg-master: build: '.' image: 'danieldent/postgres-replication' restart: 'always' environment: POSTGRES_USER: 'postgres' POSTGRES_PASSWORD: 'postgres' PGDATA: '/var/lib/postgresql/data/pgdata' volumes: - '/var/lib/postgresql/data' expose: - '5432' pg-slave: build: '.' image: 'danieldent/postgres-replication' restart: 'always' environment: POSTGRES_USER: 'postgres' POSTGRES_PASSWORD: 'postgres' PGDATA: '/var/lib/postgresql/data/pgdata' REPLICATE_FROM: 'pg-master' volumes: - '/var/lib/postgresql/data' expose: - '5432' links: - 'pg-master' prometheus-postgres-exporter-0.4.1+ds/tests/docker-postgres-replication/docker-entrypoint.sh000077500000000000000000000076031321452450400326340ustar00rootroot00000000000000#!/bin/bash # Backwards compatibility for old variable names (deprecated) if [ "x$PGUSER" != "x" ]; then POSTGRES_USER=$PGUSER fi if [ "x$PGPASSWORD" != "x" ]; then POSTGRES_PASSWORD=$PGPASSWORD fi # Forwards-compatibility for old variable names (pg_basebackup uses them) if [ "x$PGPASSWORD" = "x" ]; then export PGPASSWORD=$POSTGRES_PASSWORD fi # Based on official postgres package's entrypoint script (https://hub.docker.com/_/postgres/) # Modified to be able to set up a slave. The docker-entrypoint-initdb.d hook provided is inadequate. set -e if [ "${1:0:1}" = '-' ]; then set -- postgres "$@" fi if [ "$1" = 'postgres' ]; then mkdir -p "$PGDATA" chmod 700 "$PGDATA" chown -R postgres "$PGDATA" mkdir -p /run/postgresql chmod g+s /run/postgresql chown -R postgres /run/postgresql # look specifically for PG_VERSION, as it is expected in the DB dir if [ ! -s "$PGDATA/PG_VERSION" ]; then if [ "x$REPLICATE_FROM" == "x" ]; then eval "gosu postgres initdb $POSTGRES_INITDB_ARGS" else until ping -c 1 -W 1 ${REPLICATE_FROM} do echo "Waiting for master to ping..." sleep 1s done until gosu postgres pg_basebackup -h ${REPLICATE_FROM} -D ${PGDATA} -U ${POSTGRES_USER} -vP -w do echo "Waiting for master to connect..." sleep 1s done fi # check password first so we can output the warning before postgres # messes it up if [ ! -z "$POSTGRES_PASSWORD" ]; then pass="PASSWORD '$POSTGRES_PASSWORD'" authMethod=md5 else # The - option suppresses leading tabs but *not* spaces. :) cat >&2 <<-'EOWARN' **************************************************** WARNING: No password has been set for the database. This will allow anyone with access to the Postgres port to access your database. In Docker's default configuration, this is effectively any other container on the same system. Use "-e POSTGRES_PASSWORD=password" to set it in "docker run". **************************************************** EOWARN pass= authMethod=trust fi if [ "x$REPLICATE_FROM" == "x" ]; then { echo; echo "host replication all 0.0.0.0/0 $authMethod"; } | gosu postgres tee -a "$PGDATA/pg_hba.conf" > /dev/null { echo; echo "host all all 0.0.0.0/0 $authMethod"; } | gosu postgres tee -a "$PGDATA/pg_hba.conf" > /dev/null # internal start of server in order to allow set-up using psql-client # does not listen on external TCP/IP and waits until start finishes gosu postgres pg_ctl -D "$PGDATA" \ -o "-c listen_addresses='localhost'" \ -w start : ${POSTGRES_USER:=postgres} : ${POSTGRES_DB:=$POSTGRES_USER} export POSTGRES_USER POSTGRES_DB psql=( psql -v ON_ERROR_STOP=1 ) if [ "$POSTGRES_DB" != 'postgres' ]; then "${psql[@]}" --username postgres <<-EOSQL CREATE DATABASE "$POSTGRES_DB" ; EOSQL echo fi if [ "$POSTGRES_USER" = 'postgres' ]; then op='ALTER' else op='CREATE' fi "${psql[@]}" --username postgres <<-EOSQL $op USER "$POSTGRES_USER" WITH SUPERUSER $pass ; EOSQL echo fi psql+=( --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" ) echo for f in /docker-entrypoint-initdb.d/*; do case "$f" in *.sh) echo "$0: running $f"; . "$f" ;; *.sql) echo "$0: running $f"; "${psql[@]}" < "$f"; echo ;; *.sql.gz) echo "$0: running $f"; gunzip -c "$f" | "${psql[@]}"; echo ;; *) echo "$0: ignoring $f" ;; esac echo done if [ "x$REPLICATE_FROM" == "x" ]; then gosu postgres pg_ctl -D "$PGDATA" -m fast -w stop fi echo echo 'PostgreSQL init process complete; ready for start up.' echo fi # We need this health check so we know when it's started up. touch /tmp/.postgres_init_complete exec gosu postgres "$@" fi exec "$@" prometheus-postgres-exporter-0.4.1+ds/tests/docker-postgres-replication/setup-replication.sh000077500000000000000000000010101321452450400326050ustar00rootroot00000000000000#!/bin/bash if [ "x$REPLICATE_FROM" == "x" ]; then cat >> ${PGDATA}/postgresql.conf < ${PGDATA}/recovery.conf <&2 exit 1 fi if [ -z $port ]; then echo "No port specified." 1>&2 exit 1 fi local wait_start=$(date +%s) echo "Waiting for postgres to start listening..." while ! pg_isready --host=$ip --port=$port &> /dev/null; do if [ $(( $(date +%s) - $wait_start )) -gt $TIMEOUT ]; then echo "Timed out waiting for postgres to start!" 1>&2 exit 1 fi sleep 1 done } wait_for_exporter() { local wait_start=$(date +%s) echo "Waiting for exporter to start..." while ! nc -z localhost $exporter_port ; do if [ $(( $(date +%s) - $wait_start )) -gt $TIMEOUT ]; then echo "Timed out waiting for exporter!" 1>&2 exit 1 fi sleep 1 done } 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 echo "#######################" echo "Standalone Postgres $version" echo "#######################" local docker_cmd="docker run -d -e POSTGRES_PASSWORD=$POSTGRES_PASSWORD $CUR_IMAGE" echo "Docker Cmd: $docker_cmd" CONTAINER_NAME=$($docker_cmd) standalone_ip=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $CONTAINER_NAME) trap "docker logs $CONTAINER_NAME ; docker kill $CONTAINER_NAME ; docker rm -v $CONTAINER_NAME; exit 1" EXIT INT TERM wait_for_postgres $standalone_ip 5432 # Run the test binary. DATA_SOURCE_NAME="postgresql://postgres:$POSTGRES_PASSWORD@$standalone_ip:5432/?sslmode=disable" $test_binary || exit $? # Extract a raw metric list. DATA_SOURCE_NAME="postgresql://postgres:$POSTGRES_PASSWORD@$standalone_ip:5432/?sslmode=disable" $postgres_exporter --log.level=debug --web.listen-address=:$exporter_port & exporter_pid=$! trap "docker logs $CONTAINER_NAME ; docker kill $CONTAINER_NAME ; docker rm -v $CONTAINER_NAME; kill $exporter_pid; exit 1" EXIT INT TERM wait_for_exporter # Dump the metrics to a file. wget -q -O - http://localhost:$exporter_port/metrics 1> $METRICS_DIR/.metrics.single.$version.prom if [ "$?" != "0" ]; then echo "Failed on postgres $version ($DOCKER_IMAGE)" 1>&2 kill $exporter_pid exit 1 fi kill $exporter_pid docker kill $CONTAINER_NAME docker rm -v $CONTAINER_NAME trap - EXIT INT TERM echo "#######################" echo "Replicated Postgres $version" echo "#######################" old_pwd=$(pwd) cd docker-postgres-replication VERSION=$version p2 -t Dockerfile.p2 -o Dockerfile if [ "$?" != "0" ]; then echo "Templating failed" 1>&2 exit 1 fi trap "docker-compose logs; docker-compose down ; docker-compose rm -v; exit 1" EXIT INT TERM local compose_cmd="POSTGRES_PASSWORD=$POSTGRES_PASSWORD docker-compose up -d --force-recreate --build" echo "Compose Cmd: $compose_cmd" eval $compose_cmd master_container=$(docker-compose ps -q pg-master) slave_container=$(docker-compose ps -q pg-slave) master_ip=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $master_container) slave_ip=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $slave_container) echo "Got master IP: $master_ip" wait_for_postgres $master_ip 5432 wait_for_postgres $slave_ip 5432 DATA_SOURCE_NAME="postgresql://postgres:$POSTGRES_PASSWORD@$master_ip:5432/?sslmode=disable" $test_binary || exit $? DATA_SOURCE_NAME="postgresql://postgres:$POSTGRES_PASSWORD@$master_ip:5432/?sslmode=disable" $postgres_exporter --log.level=debug --web.listen-address=:$exporter_port & exporter_pid=$! trap "docker-compose logs; docker-compose down ; docker-compose rm -v ; kill $exporter_pid; exit 1" EXIT INT TERM wait_for_exporter wget -q -O - http://localhost:$exporter_port/metrics 1> $METRICS_DIR/.metrics.replicated.$version.prom if [ "$?" != "0" ]; then echo "Failed on postgres $version ($DOCKER_IMAGE)" 1>&2 exit 1 fi kill $exporter_pid docker-compose down docker-compose rm -v trap - EXIT INT TERM cd $old_pwd } # 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 prometheus-postgres-exporter-0.4.1+ds/tests/username_file000066400000000000000000000000201321452450400237160ustar00rootroot00000000000000custom_username prometheus-postgres-exporter-0.4.1+ds/tests/userpass_file000066400000000000000000000000201321452450400237440ustar00rootroot00000000000000custom_password prometheus-postgres-exporter-0.4.1+ds/tools/000077500000000000000000000000001321452450400211635ustar00rootroot00000000000000prometheus-postgres-exporter-0.4.1+ds/tools/.gitignore000066400000000000000000000000461321452450400231530ustar00rootroot00000000000000/pkg /bin /tools.deps /metatools.deps prometheus-postgres-exporter-0.4.1+ds/tools/Makefile000066400000000000000000000041721321452450400226270ustar00rootroot00000000000000# Makefile to build the tools used in the build system. # If recreating from scratch, you will need a local install of govendor # and to run govendor init in this folder before running govendor fetch. # Ensure we use local bin dir export PATH := bin:$(PATH) SHELL := env PATH=$(PATH) /bin/bash THIS_FILE := $(lastword $(MAKEFILE_LIST)) # This function is used to get the linters used by metalinter get_metalinters := gometalinter --help | grep -oP '\s+\w+:\s*\(.+\)' | tr -s ' ' | cut -d' ' -f3 | grep -oP '[^()]+' # This is a list of external tools we want to vendor TOOL_SRCS := github.com/kardianos/govendor \ github.com/wadey/gocovmerge \ github.com/mattn/goveralls \ github.com/alecthomas/gometalinter # This is populated by imported dependencies from gometalinter METATOOL_SRCS := GO_SRC := $(shell find $(SOURCEDIR) -name '*.go') GO := GOPATH=$(shell pwd) go DEFAULT: all tools.deps: $(GO_SRC) @# Generate build patterns for static tools @for pkg in $(TOOL_SRCS); do \ echo -e "bin/$$(basename $$pkg): $$GO_SRC\n\t\$$(GO) install -v $$pkg" ; \ done > tools.deps -include tools.deps metatools.deps: bin/gometalinter $(GO_SRC) # Generate build patterns for metalinters tools @echo -e "METATOOL_SRCS+=$(shell $(get_metalinters))" > metatools.deps @for pkg in $(shell $(get_metalinters)) ; do \ echo -e "bin/$$(basename $$pkg): $$GO_SRC\n\t\$$(GO) install -v $$pkg" ; \ done >> metatools.deps -include metatools.deps update: # Fetch govendor, then rebuild govendor. govendor fetch github.com/kardianos/govendor $(GO) install -v github.com/kardianos/govendor # Fetch gometalinter and rebuild gometalinter. govendor fetch github.com/alecthomas/gometalinter $(GO) install -v github.com/alecthomas/gometalinter $(MAKE) -f $(THIS_FILE) update-phase-2 update-phase-2: # Fetch the new metalinter list. for pkg in $(TOOL_SRCS) $$($(get_metalinters)); do \ govendor fetch -v $$pkg ; \ done clean: rm -rf bin pkg tools.deps metatools.deps all: $(addprefix bin/,$(notdir $(TOOL_SRCS) $(METATOOL_SRCS) )) # TOOL_SRCS is included here since we'll never really have these files. .PHONY: all update clean $(TOOL_SRCS) $(METATOOL_SRCS) prometheus-postgres-exporter-0.4.1+ds/tools/README.md000066400000000000000000000004641321452450400224460ustar00rootroot00000000000000 Vendored versions of the build tooling. gocovmerge is used to merge coverage reports for uploading to a service like coveralls, and gometalinter conveniently incorporates multiple Go linters. By vendoring both, we gain a self-contained build system. Run `make all` to build, and `make update` to update. prometheus-postgres-exporter-0.4.1+ds/tools/src000077700000000000000000000000001321452450400231102vendorustar00rootroot00000000000000prometheus-postgres-exporter-0.4.1+ds/tools/vendor/000077500000000000000000000000001321452450400224605ustar00rootroot00000000000000prometheus-postgres-exporter-0.4.1+ds/tools/vendor/vendor.json000066400000000000000000000631161321452450400246570ustar00rootroot00000000000000{ "comment": "", "ignore": "test", "package": [ { "checksumSHA1": "4Tc07iR3HloUYC4HNT4xc0875WY=", "path": "github.com/Bowery/prompt", "revision": "0f1139e9a1c74b57ccce6bdb3cd2f7cd04dd3449", "revisionTime": "2017-02-19T07:16:37Z" }, { "checksumSHA1": "IL9TI69eihi/XUfY/k/uuBRI8WY=", "path": "github.com/GoASTScanner/gas", "revision": "6de76c92610b387855cdfdd53c99b149928916f7", "revisionTime": "2017-10-04T14:01:47Z" }, { "checksumSHA1": "sK1dOo48F424xLCvE+ic8tRk7i8=", "path": "github.com/GoASTScanner/gas/core", "revision": "1beec25f7754273c9672a3368ea7048d4e73138e", "revisionTime": "2017-04-11T19:38:53Z" }, { "checksumSHA1": "7S1Y+wwGdmJi8LnKONzA2GbV78M=", "path": "github.com/GoASTScanner/gas/output", "revision": "1beec25f7754273c9672a3368ea7048d4e73138e", "revisionTime": "2017-04-11T19:38:53Z" }, { "checksumSHA1": "IkxNgpECcB1DvI3TGPIFixVqRZU=", "path": "github.com/GoASTScanner/gas/rules", "revision": "1beec25f7754273c9672a3368ea7048d4e73138e", "revisionTime": "2017-04-11T19:38:53Z" }, { "checksumSHA1": "cItvKwnl+gkO2j0Q2964efC+vTw=", "path": "github.com/alecthomas/gocyclo", "revision": "aa8f8b160214d8dfccfe3e17e578dd0fcc6fede7", "revisionTime": "2015-02-08T22:17:26Z" }, { "checksumSHA1": "HL3Dyr4dmbtBo+V3ULfRJMWAyoA=", "path": "github.com/alecthomas/gometalinter", "revision": "212b1b91e362ea0b0e441c9b53ce31e81405c240", "revisionTime": "2017-11-26T10:02:12Z" }, { "checksumSHA1": "fCc3grA7vIxfBru7R3SqjcW+oLI=", "path": "github.com/alecthomas/units", "revision": "2efee857e7cfd4f3d0138cc3cbb1b4966962b93a", "revisionTime": "2015-10-22T06:55:26Z" }, { "checksumSHA1": "kjygOPbr5jsND2nU4NJnyyDRVF8=", "path": "github.com/alexflint/go-arg", "revision": "cef6506c97e5731da728c374ff3523e481026423", "revisionTime": "2017-03-30T21:10:29Z" }, { "checksumSHA1": "M5vBatiAKUjyLYrb9nS+6QbpEjE=", "path": "github.com/alexflint/go-scalar", "revision": "e80c3b7ed292b052c7083b6fd7154a8422c33f65", "revisionTime": "2017-02-16T02:04:25Z" }, { "checksumSHA1": "rDM1YOCSZE4BLxZoBJV56/VmZSo=", "path": "github.com/alexkohler/nakedret", "revision": "c0e305a4f690fed163d47628bcc06a6d5655bf92", "revisionTime": "2017-11-06T22:32:15Z" }, { "checksumSHA1": "z6mKUmWeXRT0k+xrXxA5CLKOWiE=", "path": "github.com/client9/misspell", "revision": "1d9ab7749ee27131547244ff2f9953d235b591fb", "revisionTime": "2017-05-30T22:15:07Z" }, { "checksumSHA1": "3Lbx+qNi8brwKa9dU41O6SEOW6c=", "path": "github.com/client9/misspell/cmd/misspell", "revision": "9ce5d979ffdaca6385988d7ad1079a33ec942d20", "revisionTime": "2017-09-28T00:02:06Z" }, { "checksumSHA1": "ULnk7ggN82JFO0ZdBCmSsQH3Vh8=", "path": "github.com/dchest/safefile", "revision": "855e8d98f1852d48dde521e0522408d1fe7e836a", "revisionTime": "2015-10-22T10:31:44Z" }, { "checksumSHA1": "aLXmB5i+PFfM/dVqfHxoB3a8v/g=", "path": "github.com/dnephin/govet", "revision": "4a96d43e39d340b63daa8bc5576985aa599885f6", "revisionTime": "2017-10-12T18:51:37Z", "version": "fork", "versionExact": "fork" }, { "checksumSHA1": "Ba6cj2wCpDZcjE0kZ4Q32PJW4fg=", "path": "github.com/dnephin/govet/internal/cfg", "revision": "4a96d43e39d340b63daa8bc5576985aa599885f6", "revisionTime": "2017-10-12T18:51:37Z", "version": "fork", "versionExact": "fork" }, { "checksumSHA1": "ttQiZmni3k7Tbfi4/CX3JG6NjAw=", "path": "github.com/dnephin/govet/internal/whitelist", "revision": "4a96d43e39d340b63daa8bc5576985aa599885f6", "revisionTime": "2017-10-12T18:51:37Z", "version": "fork", "versionExact": "fork" }, { "checksumSHA1": "+U50xksZS8g53vruOP7px7cLilE=", "path": "github.com/golang/lint", "revision": "c5fb716d6688a859aae56d26d3e6070808df29f7", "revisionTime": "2017-06-02T23:41:31Z" }, { "checksumSHA1": "REm9ddVDL+Pm1OPxjVMxxpIjyw4=", "path": "github.com/golang/lint/golint", "revision": "6aaf7c34af0f4c36a57e0c429bace4d706d8e931", "revisionTime": "2017-10-05T22:33:36Z" }, { "checksumSHA1": "e/Kc2UOy1lKAy31xWlK37M1r2e8=", "path": "github.com/google/shlex", "revision": "6f45313302b9c56850fc17f99e40caebce98c716", "revisionTime": "2015-01-27T13:39:51Z" }, { "checksumSHA1": "TKaX+8YCZQwYv7Kiy2o/E86V0aE=", "path": "github.com/gordonklaus/ineffassign", "revision": "7bae11eba15a3285c75e388f77eb6357a2d73ee2", "revisionTime": "2017-11-18T19:06:32Z" }, { "checksumSHA1": "DbSCKltce7IrgpDUF8+C7J+z+GU=", "path": "github.com/jgautheron/goconst", "revision": "6a7633b712b6fb1d6821d33851d086a1d545dacd", "revisionTime": "2016-05-14T19:25:19Z" }, { "checksumSHA1": "0tPXJ5Wul0FXiUDwVWsd/RA3tWg=", "path": "github.com/jgautheron/goconst/cmd/goconst", "revision": "9740945f5dcb78c2faa8eedcce78c2a04aa6e1e9", "revisionTime": "2017-07-03T17:01:52Z" }, { "checksumSHA1": "NKvKUGq0lp/GjLS7Ffp7BAjcoTg=", "path": "github.com/kardianos/govendor", "revision": "d644d03c4cc00cf7c88a365de8508c12ce56c392", "revisionTime": "2017-11-27T22:34:05Z" }, { "checksumSHA1": "m24kWw3bFoAkKVvTjmxSLsywdHY=", "path": "github.com/kardianos/govendor/cliprompt", "revision": "c86c10d612bf08e847456ce91d495eb69ad87087", "revisionTime": "2017-05-06T05:20:04Z" }, { "checksumSHA1": "/6r+luJ0EK07RknNd0zrubHtMuQ=", "path": "github.com/kardianos/govendor/context", "revision": "c86c10d612bf08e847456ce91d495eb69ad87087", "revisionTime": "2017-05-06T05:20:04Z" }, { "checksumSHA1": "Y0WMEgLxFAzHAIxFViFSWh7dqqY=", "path": "github.com/kardianos/govendor/help", "revision": "c86c10d612bf08e847456ce91d495eb69ad87087", "revisionTime": "2017-05-06T05:20:04Z" }, { "checksumSHA1": "SPRzsXaOsg9dENhLfHRjmFMmGQM=", "path": "github.com/kardianos/govendor/internal/pathos", "revision": "c86c10d612bf08e847456ce91d495eb69ad87087", "revisionTime": "2017-05-06T05:20:04Z" }, { "checksumSHA1": "Bl6I6yMiK60dzOAfyO7As6MSPIk=", "path": "github.com/kardianos/govendor/internal/vfilepath", "revision": "c86c10d612bf08e847456ce91d495eb69ad87087", "revisionTime": "2017-05-06T05:20:04Z" }, { "checksumSHA1": "2Vg+J79rEhmtnprErQ7fTZdneIk=", "path": "github.com/kardianos/govendor/internal/vos", "revision": "c86c10d612bf08e847456ce91d495eb69ad87087", "revisionTime": "2017-05-06T05:20:04Z" }, { "checksumSHA1": "rpK9ccIJkLV4IbKb3lUjUo5DSfU=", "path": "github.com/kardianos/govendor/migrate", "revision": "c86c10d612bf08e847456ce91d495eb69ad87087", "revisionTime": "2017-05-06T05:20:04Z" }, { "checksumSHA1": "wL4SaLS/HTn32Gmq8kpYRr/cn68=", "path": "github.com/kardianos/govendor/pkgspec", "revision": "c86c10d612bf08e847456ce91d495eb69ad87087", "revisionTime": "2017-05-06T05:20:04Z" }, { "checksumSHA1": "I9oQBOtXoOinofTJrBE+zI+vDCs=", "path": "github.com/kardianos/govendor/prompt", "revision": "c86c10d612bf08e847456ce91d495eb69ad87087", "revisionTime": "2017-05-06T05:20:04Z" }, { "checksumSHA1": "tXbK0YAL7/ZrLWkokBrLdp30xjw=", "path": "github.com/kardianos/govendor/run", "revision": "c86c10d612bf08e847456ce91d495eb69ad87087", "revisionTime": "2017-05-06T05:20:04Z" }, { "checksumSHA1": "ZDlz1nWDmErU501lCChKbTT3kEs=", "path": "github.com/kardianos/govendor/vcs", "revision": "c86c10d612bf08e847456ce91d495eb69ad87087", "revisionTime": "2017-05-06T05:20:04Z" }, { "checksumSHA1": "oXa3HaUXhXktMp4C0xTOSrzPDTE=", "path": "github.com/kardianos/govendor/vendorfile", "revision": "c86c10d612bf08e847456ce91d495eb69ad87087", "revisionTime": "2017-05-06T05:20:04Z" }, { "checksumSHA1": "GkLbM8KFqtVcp4kzc40+VinQukY=", "path": "github.com/kisielk/errcheck", "revision": "b1445a9dd8285a50c6d1661d16f0a9ceb08125f7", "revisionTime": "2017-09-18T09:31:01Z" }, { "checksumSHA1": "GP25rgIPshJh0tpiBg3Z8Dexqj4=", "path": "github.com/kisielk/errcheck/internal/errcheck", "revision": "23699b7e2cbfdb89481023524954ba2aeff6be90", "revisionTime": "2017-03-17T17:34:29Z" }, { "checksumSHA1": "9fvV44Csmu+K5BpFvEBs2p8alBI=", "path": "github.com/kisielk/gotool", "revision": "0de1eaf82fa3f583ce21fde859f1e7e0c5e9b220", "revisionTime": "2016-11-30T08:01:11Z" }, { "checksumSHA1": "+ArBDwAK19OC1iDy1yEbXOC9sgQ=", "path": "github.com/mattn/goveralls", "revision": "b71a1e4855f87991aff01c2c833a75a07059c61c", "revisionTime": "2017-11-14T04:29:57Z" }, { "checksumSHA1": "dk0ehYSmMaGLWFQPND3cVgk744I=", "path": "github.com/mdempsky/maligned", "revision": "08c8e9db1bce03f1af283686c0943fcb75f0109e", "revisionTime": "2016-08-25T09:47:39Z" }, { "checksumSHA1": "90pFJb64MwgYvN5AmPVaWl87ZyU=", "path": "github.com/mdempsky/unconvert", "revision": "beb68d938016d2dec1d1b078054f4d3db25f97be", "revisionTime": "2016-08-03T23:01:54Z" }, { "checksumSHA1": "k3eGAQ+pCIffVpgvoBrPuLK6Yz8=", "path": "github.com/mibk/dupl", "revision": "72dc2d83bec70e053e9294378aacb1a032f51a31", "revisionTime": "2017-11-19T16:48:37Z" }, { "checksumSHA1": "sHi3Qhc2/0XMcIXB31NLXkbIoz0=", "path": "github.com/mibk/dupl/job", "revision": "3447d9b0cb5a3e7dccb1a9f1c975f35683f304e6", "revisionTime": "2017-02-27T22:14:17Z" }, { "checksumSHA1": "VZ5EU9NrZck4UX3OpC9YK/gB/A4=", "path": "github.com/mibk/dupl/output", "revision": "3447d9b0cb5a3e7dccb1a9f1c975f35683f304e6", "revisionTime": "2017-02-27T22:14:17Z" }, { "checksumSHA1": "mGQ3tVbY9uLwfwoeQjvBBBm7yRw=", "path": "github.com/mibk/dupl/printer", "revision": "72dc2d83bec70e053e9294378aacb1a032f51a31", "revisionTime": "2017-11-19T16:48:37Z" }, { "checksumSHA1": "o9BJwhna5BuCTYWBGBo9VA+Ez/M=", "path": "github.com/mibk/dupl/suffixtree", "revision": "3447d9b0cb5a3e7dccb1a9f1c975f35683f304e6", "revisionTime": "2017-02-27T22:14:17Z" }, { "checksumSHA1": "HveZ42ihDCZQumgGFMQIs8Nendg=", "path": "github.com/mibk/dupl/syntax", "revision": "3447d9b0cb5a3e7dccb1a9f1c975f35683f304e6", "revisionTime": "2017-02-27T22:14:17Z" }, { "checksumSHA1": "YuBPssHbL/iU+1poNlfBDl2IqG4=", "path": "github.com/mibk/dupl/syntax/golang", "revision": "3447d9b0cb5a3e7dccb1a9f1c975f35683f304e6", "revisionTime": "2017-02-27T22:14:17Z" }, { "checksumSHA1": "GtTRl0HhAPDjp+s02RJnFg3znZ0=", "path": "github.com/mvdan/interfacer", "revision": "22c51662ff476dfd97944f74db1b263ed920ee83", "revisionTime": "2017-04-06T16:05:15Z" }, { "checksumSHA1": "zD/VW+BRbOjxk1xq5bmdigi0cp8=", "path": "github.com/mvdan/interfacer/cmd/interfacer", "revision": "22c51662ff476dfd97944f74db1b263ed920ee83", "revisionTime": "2017-04-06T16:05:15Z" }, { "checksumSHA1": "18GDIJCo0vo+mmQDIYmyb2JSWqo=", "path": "github.com/mvdan/lint", "revision": "c9cbe299b369cbfea16318baaa037b19a69e45d2", "revisionTime": "2017-04-06T10:09:31Z" }, { "checksumSHA1": "5LiZtu67exUdRJ0/QQvU/epG9no=", "path": "github.com/mvdan/unparam", "revision": "d647bb803b10a6777ee4c6a176416b91fa14713e", "revisionTime": "2017-05-30T08:59:07Z" }, { "checksumSHA1": "tuOLCrGa9DjfXheKkMXtHtQu3bs=", "path": "github.com/mvdan/unparam/check", "revision": "d647bb803b10a6777ee4c6a176416b91fa14713e", "revisionTime": "2017-05-30T08:59:07Z" }, { "checksumSHA1": "DP8R0Q7TDlHbhz9Livyj8RkRKvU=", "path": "github.com/nbutton23/zxcvbn-go", "revision": "a22cb81b2ecdde8b68e9ffb8824731cbf88e1de4", "revisionTime": "2016-06-27T00:44:24Z" }, { "checksumSHA1": "HEqKoRuKJ86gic8DPZqtDKZNo7E=", "path": "github.com/nbutton23/zxcvbn-go/adjacency", "revision": "a22cb81b2ecdde8b68e9ffb8824731cbf88e1de4", "revisionTime": "2016-06-27T00:44:24Z" }, { "checksumSHA1": "etc47rBuvFfzUZ7n8EDLQiDQeXU=", "path": "github.com/nbutton23/zxcvbn-go/data", "revision": "a22cb81b2ecdde8b68e9ffb8824731cbf88e1de4", "revisionTime": "2016-06-27T00:44:24Z" }, { "checksumSHA1": "/NSHii4ih+43IBnoXrjAtIzTtPI=", "path": "github.com/nbutton23/zxcvbn-go/entropy", "revision": "a22cb81b2ecdde8b68e9ffb8824731cbf88e1de4", "revisionTime": "2016-06-27T00:44:24Z" }, { "checksumSHA1": "VyH3r1FJcSB13wj0T812EMASq1Q=", "path": "github.com/nbutton23/zxcvbn-go/frequency", "revision": "a22cb81b2ecdde8b68e9ffb8824731cbf88e1de4", "revisionTime": "2016-06-27T00:44:24Z" }, { "checksumSHA1": "U6O/H84jE24jhCSOgi+IsjSPomM=", "path": "github.com/nbutton23/zxcvbn-go/match", "revision": "a22cb81b2ecdde8b68e9ffb8824731cbf88e1de4", "revisionTime": "2016-06-27T00:44:24Z" }, { "checksumSHA1": "BHO5wnIg2NQTYSILHmpezEJFv4E=", "path": "github.com/nbutton23/zxcvbn-go/matching", "revision": "a22cb81b2ecdde8b68e9ffb8824731cbf88e1de4", "revisionTime": "2016-06-27T00:44:24Z" }, { "checksumSHA1": "vRXGbBJSonwD03A/WAkhNkYNY38=", "path": "github.com/nbutton23/zxcvbn-go/scoring", "revision": "a22cb81b2ecdde8b68e9ffb8824731cbf88e1de4", "revisionTime": "2016-06-27T00:44:24Z" }, { "checksumSHA1": "cEdCjSL9cNJm5o+nGwPM3WgloyM=", "path": "github.com/nbutton23/zxcvbn-go/utils/math", "revision": "a22cb81b2ecdde8b68e9ffb8824731cbf88e1de4", "revisionTime": "2016-06-27T00:44:24Z" }, { "checksumSHA1": "uEc9/1HbYGeK7wPStF6FmUlfzGE=", "path": "github.com/nicksnyder/go-i18n/i18n", "revision": "3e70a1a463008cea6726380c908b1a6a8bdf7b24", "revisionTime": "2017-05-12T15:20:54Z" }, { "checksumSHA1": "gDe7nlx3FyCVxLkARgl0VAntDRk=", "path": "github.com/nicksnyder/go-i18n/i18n/bundle", "revision": "3e70a1a463008cea6726380c908b1a6a8bdf7b24", "revisionTime": "2017-05-12T15:20:54Z" }, { "checksumSHA1": "+XOg99I1zdmBRUb04ZswvzQ2WS0=", "path": "github.com/nicksnyder/go-i18n/i18n/language", "revision": "3e70a1a463008cea6726380c908b1a6a8bdf7b24", "revisionTime": "2017-05-12T15:20:54Z" }, { "checksumSHA1": "WZOU406In2hs8FJOHWqV8PWkJKs=", "path": "github.com/nicksnyder/go-i18n/i18n/translation", "revision": "3e70a1a463008cea6726380c908b1a6a8bdf7b24", "revisionTime": "2017-05-12T15:20:54Z" }, { "checksumSHA1": "rpXu/2iiIGcK3KMKqXfko3g6rdk=", "path": "github.com/opennota/check/cmd/aligncheck", "revision": "11e2eec79ec4f789607e3efbf405cdca2504d4cb", "revisionTime": "2017-04-02T03:17:31Z" }, { "checksumSHA1": "eWl/ySoMqPr+Q9p9smYNkTgXu2w=", "path": "github.com/opennota/check/cmd/structcheck", "revision": "11e2eec79ec4f789607e3efbf405cdca2504d4cb", "revisionTime": "2017-04-02T03:17:31Z" }, { "checksumSHA1": "Ja04Qe8nP2zw9SYO+TzbebFt5M4=", "path": "github.com/opennota/check/cmd/varcheck", "revision": "11e2eec79ec4f789607e3efbf405cdca2504d4cb", "revisionTime": "2017-04-02T03:17:31Z" }, { "checksumSHA1": "F1IYMLBLAZaTOWnmXsgaxTGvrWI=", "path": "github.com/pelletier/go-buffruneio", "revision": "c37440a7cf42ac63b919c752ca73a85067e05992", "revisionTime": "2017-02-27T22:03:11Z" }, { "checksumSHA1": "vHrGGP777P2fqQHr2IYwNVVRQ/o=", "path": "github.com/pelletier/go-toml", "revision": "fe7536c3dee2596cdd23ee9976a17c22bdaae286", "revisionTime": "2017-06-02T06:55:32Z" }, { "checksumSHA1": "rJab1YdNhQooDiBWNnt7TLWPyBU=", "path": "github.com/pkg/errors", "revision": "c605e284fe17294bda444b34710735b29d1a9d90", "revisionTime": "2017-05-05T04:36:39Z" }, { "checksumSHA1": "6JP37UqrI0H80Gpk0Y2P+KXgn5M=", "path": "github.com/ryanuber/go-glob", "revision": "256dc444b735e061061cf46c809487313d5b0065", "revisionTime": "2017-01-28T01:21:29Z" }, { "checksumSHA1": "2oomtTH6LB5cZZe1xOs4XJV0GTU=", "path": "github.com/stripe/safesql", "revision": "452e37ed794488bd0d99676532f346e03cc6cd2c", "revisionTime": "2016-03-04T06:18:37Z" }, { "checksumSHA1": "fZaFaXc4iKu9PXl8xrmK3RrZpIY=", "path": "github.com/tsenart/deadcode", "revision": "210d2dc333e90c7e3eedf4f2242507a8e83ed4ab", "revisionTime": "2016-07-24T21:28:37Z" }, { "checksumSHA1": "ih4CCYD19rjjF9fjid+l7w/+cIg=", "path": "github.com/wadey/gocovmerge", "revision": "b5bfa59ec0adc420475f97f89b58045c721d761c", "revisionTime": "2016-03-31T18:18:00Z" }, { "checksumSHA1": "g27xFm/EIghjjcT3DuGt976CgNo=", "path": "github.com/walle/lll", "revision": "8b13b3fbf7312913fcfdbfa78997b9bd1dbb11af", "revisionTime": "2016-07-02T15:04:58Z" }, { "checksumSHA1": "V74uq4M+82grbD85c6TQ3JyMCL4=", "path": "github.com/walle/lll/cmd/lll", "revision": "8b13b3fbf7312913fcfdbfa78997b9bd1dbb11af", "revisionTime": "2016-07-02T15:04:58Z" }, { "checksumSHA1": "PugQbLLjnbBSj+NOXRYBVRnLuuQ=", "path": "golang.org/x/sys/unix", "revision": "b90f89a1e7a9c1f6b918820b3daa7f08488c8594", "revisionTime": "2017-05-29T13:44:53Z" }, { "checksumSHA1": "ziMb9+ANGRJSSIuxYdRbA+cDRBQ=", "path": "golang.org/x/text/transform", "revision": "ccbd3f7822129ff389f8ca4858a9b9d4d910531c", "revisionTime": "2017-05-18T06:42:59Z" }, { "checksumSHA1": "aCXemG0knLp8YJedta7fYAIiX/8=", "path": "golang.org/x/text/width", "revision": "ccbd3f7822129ff389f8ca4858a9b9d4d910531c", "revisionTime": "2017-05-18T06:42:59Z" }, { "checksumSHA1": "V4M/6A62nVBzPFxPbN+EAatCrVs=", "path": "golang.org/x/tools/cmd/goimports", "revision": "36c7af3342056179a831c19ec142f2763b310f7b", "revisionTime": "2017-11-29T19:51:57Z" }, { "checksumSHA1": "V6/A1ZOZ2GUOZcRWcXegtci2FoU=", "path": "golang.org/x/tools/cmd/gotype", "revision": "36c7af3342056179a831c19ec142f2763b310f7b", "revisionTime": "2017-11-29T19:51:57Z" }, { "checksumSHA1": "nD89PLkMqA5CakR8SoDuj3iQz1M=", "path": "golang.org/x/tools/container/intsets", "revision": "2a5864fcfb595b4ee9a7607f1beb25778cf64c6e", "revisionTime": "2017-03-22T18:59:57Z" }, { "checksumSHA1": "O5eYI3n1WdaC30AxQjETe3dAQHU=", "path": "golang.org/x/tools/cover", "revision": "2a5864fcfb595b4ee9a7607f1beb25778cf64c6e", "revisionTime": "2017-03-22T18:59:57Z" }, { "checksumSHA1": "p3gWsy4fQOSXGRMUHr3TnmVFias=", "path": "golang.org/x/tools/go/ast/astutil", "revision": "2a5864fcfb595b4ee9a7607f1beb25778cf64c6e", "revisionTime": "2017-03-22T18:59:57Z" }, { "checksumSHA1": "AnXFEvmaJ7w2Q7hWPcLUmCbPgq0=", "path": "golang.org/x/tools/go/buildutil", "revision": "2a5864fcfb595b4ee9a7607f1beb25778cf64c6e", "revisionTime": "2017-03-22T18:59:57Z" }, { "checksumSHA1": "9evbcWFxUJMFmnXQ2ja5765p3iE=", "path": "golang.org/x/tools/go/callgraph", "revision": "2a5864fcfb595b4ee9a7607f1beb25778cf64c6e", "revisionTime": "2017-03-22T18:59:57Z" }, { "checksumSHA1": "XAetbnZ2wmiJ68+j0am4Hp7K3j8=", "path": "golang.org/x/tools/go/callgraph/cha", "revision": "2a5864fcfb595b4ee9a7607f1beb25778cf64c6e", "revisionTime": "2017-03-22T18:59:57Z" }, { "checksumSHA1": "rSUfKH182TkCgMhJVsr84a19cbo=", "path": "golang.org/x/tools/go/gcexportdata", "revision": "2a5864fcfb595b4ee9a7607f1beb25778cf64c6e", "revisionTime": "2017-03-22T18:59:57Z" }, { "checksumSHA1": "o6uoZozSLnj3Ph+hj399ZPqJYhE=", "path": "golang.org/x/tools/go/gcimporter15", "revision": "2a5864fcfb595b4ee9a7607f1beb25778cf64c6e", "revisionTime": "2017-03-22T18:59:57Z" }, { "checksumSHA1": "3HnsDHAsl+izX3j9xpU6veKrWpk=", "path": "golang.org/x/tools/go/loader", "revision": "2a5864fcfb595b4ee9a7607f1beb25778cf64c6e", "revisionTime": "2017-03-22T18:59:57Z" }, { "checksumSHA1": "SzM7AWf+ZXc67vcI3jxvaD6iyM0=", "path": "golang.org/x/tools/go/pointer", "revision": "2a5864fcfb595b4ee9a7607f1beb25778cf64c6e", "revisionTime": "2017-03-22T18:59:57Z" }, { "checksumSHA1": "q0kKsRINLQjcGI4RVJ8//lmsHsc=", "path": "golang.org/x/tools/go/ssa", "revision": "2a5864fcfb595b4ee9a7607f1beb25778cf64c6e", "revisionTime": "2017-03-22T18:59:57Z" }, { "checksumSHA1": "FSjqqXMVKi4WoCqohpzt5z+6mMI=", "path": "golang.org/x/tools/go/ssa/ssautil", "revision": "2a5864fcfb595b4ee9a7607f1beb25778cf64c6e", "revisionTime": "2017-03-22T18:59:57Z" }, { "checksumSHA1": "QKvPv3TJ+ZnOLkUeUkT8Wm8eCV0=", "path": "golang.org/x/tools/go/types/typeutil", "revision": "2a5864fcfb595b4ee9a7607f1beb25778cf64c6e", "revisionTime": "2017-03-22T18:59:57Z" }, { "checksumSHA1": "TNJiDMoJEKYZyXo8Vkj37gqH5A0=", "path": "golang.org/x/tools/go/vcs", "revision": "2a5864fcfb595b4ee9a7607f1beb25778cf64c6e", "revisionTime": "2017-03-22T18:59:57Z" }, { "checksumSHA1": "DKr5TDU73FjKqiag3sAiVRKRfK0=", "path": "golang.org/x/tools/imports", "revision": "2a5864fcfb595b4ee9a7607f1beb25778cf64c6e", "revisionTime": "2017-03-22T18:59:57Z" }, { "checksumSHA1": "1FcU7G3PX7GVBLOrtxtvDWVvImo=", "path": "gopkg.in/alecthomas/kingpin.v3-unstable", "revision": "bd961acaef2390fc48159c3acaad41ef31833920", "revisionTime": "2017-05-21T07:44:49Z" }, { "checksumSHA1": "fALlQNY1fM99NesfLJ50KguWsio=", "path": "gopkg.in/yaml.v2", "revision": "cd8b52f8269e0feb286dfeef29f8fe4d5b397e0b", "revisionTime": "2017-04-07T17:21:22Z" }, { "checksumSHA1": "FG8LnaSRTHBnrPHwa0zW4zX9K7M=", "path": "honnef.co/go/tools/callgraph", "revision": "376b3b58b9e4def403181ee2fd3d4cc7de8375ae", "revisionTime": "2017-11-25T07:40:24Z" }, { "checksumSHA1": "fR7Q7BVwKHUEsUNGn6Q2zygAvTU=", "path": "honnef.co/go/tools/callgraph/static", "revision": "376b3b58b9e4def403181ee2fd3d4cc7de8375ae", "revisionTime": "2017-11-25T07:40:24Z" }, { "checksumSHA1": "YL/UCzWYvDXeFInLOLC1buYve6w=", "path": "honnef.co/go/tools/cmd/gosimple", "revision": "376b3b58b9e4def403181ee2fd3d4cc7de8375ae", "revisionTime": "2017-11-25T07:40:24Z" }, { "checksumSHA1": "84jyAI0Uv1PQ3fN3Ufi0T7/IpOw=", "path": "honnef.co/go/tools/cmd/megacheck", "revision": "376b3b58b9e4def403181ee2fd3d4cc7de8375ae", "revisionTime": "2017-11-25T07:40:24Z" }, { "checksumSHA1": "dP4Ft0yiZSTZOzzNho1Gg5b7o2w=", "path": "honnef.co/go/tools/cmd/staticcheck", "revision": "376b3b58b9e4def403181ee2fd3d4cc7de8375ae", "revisionTime": "2017-11-25T07:40:24Z" }, { "checksumSHA1": "Qipy1/3Z8n4UnoWF9X0sQ/VC5JI=", "path": "honnef.co/go/tools/cmd/unused", "revision": "376b3b58b9e4def403181ee2fd3d4cc7de8375ae", "revisionTime": "2017-11-25T07:40:24Z" }, { "checksumSHA1": "smQXvyCgi0lsTRk7edZNx/z44rc=", "path": "honnef.co/go/tools/deprecated", "revision": "376b3b58b9e4def403181ee2fd3d4cc7de8375ae", "revisionTime": "2017-11-25T07:40:24Z" }, { "checksumSHA1": "ZQAEQCc18o76M9Cyncm1W5cczJ8=", "path": "honnef.co/go/tools/functions", "revision": "376b3b58b9e4def403181ee2fd3d4cc7de8375ae", "revisionTime": "2017-11-25T07:40:24Z" }, { "checksumSHA1": "NPXYxmyCQTv53OmGTCiHvbfIct4=", "path": "honnef.co/go/tools/gcsizes", "revision": "e94d1c1a34c6b61d8d06c7793b8f22cd0dfcdd90", "revisionTime": "2017-05-22T19:09:05Z" }, { "checksumSHA1": "ZWtH73AO33mmXmK2RfGwld1/00I=", "path": "honnef.co/go/tools/internal/sharedcheck", "revision": "376b3b58b9e4def403181ee2fd3d4cc7de8375ae", "revisionTime": "2017-11-25T07:40:24Z" }, { "checksumSHA1": "44oONKG61hcaBAPaA2jNhBgYLmE=", "path": "honnef.co/go/tools/lint", "revision": "376b3b58b9e4def403181ee2fd3d4cc7de8375ae", "revisionTime": "2017-11-25T07:40:24Z" }, { "checksumSHA1": "gKJKwlFyfVebwzqA3P/N3HJIq/0=", "path": "honnef.co/go/tools/lint/lintutil", "revision": "376b3b58b9e4def403181ee2fd3d4cc7de8375ae", "revisionTime": "2017-11-25T07:40:24Z" }, { "checksumSHA1": "kkVszwWx3L3erU3QkMDIppFv34o=", "path": "honnef.co/go/tools/simple", "revision": "376b3b58b9e4def403181ee2fd3d4cc7de8375ae", "revisionTime": "2017-11-25T07:40:24Z" }, { "checksumSHA1": "OB5QjdkxC9rYXruXUuoYSsxK+VY=", "path": "honnef.co/go/tools/ssa", "revision": "376b3b58b9e4def403181ee2fd3d4cc7de8375ae", "revisionTime": "2017-11-25T07:40:24Z" }, { "checksumSHA1": "jgNTrcXg52qlqjkb/R2vKxtcDu4=", "path": "honnef.co/go/tools/ssa/ssautil", "revision": "376b3b58b9e4def403181ee2fd3d4cc7de8375ae", "revisionTime": "2017-11-25T07:40:24Z" }, { "checksumSHA1": "9kqdoLEm2gHS9QVE1OXWBCtRqhI=", "path": "honnef.co/go/tools/staticcheck", "revision": "376b3b58b9e4def403181ee2fd3d4cc7de8375ae", "revisionTime": "2017-11-25T07:40:24Z" }, { "checksumSHA1": "9u74dwwwi+tg9eBr86by4i4CMNM=", "path": "honnef.co/go/tools/staticcheck/vrp", "revision": "376b3b58b9e4def403181ee2fd3d4cc7de8375ae", "revisionTime": "2017-11-25T07:40:24Z" }, { "checksumSHA1": "tDBL3athXaJ9JoiY75NktH+OTjQ=", "path": "honnef.co/go/tools/unused", "revision": "376b3b58b9e4def403181ee2fd3d4cc7de8375ae", "revisionTime": "2017-11-25T07:40:24Z" }, { "checksumSHA1": "RY0sZkXnDI/MxBauBD28dwuulSs=", "path": "honnef.co/go/tools/version", "revision": "376b3b58b9e4def403181ee2fd3d4cc7de8375ae", "revisionTime": "2017-11-25T07:40:24Z" }, { "path": "local/numcpus", "revision": "" }, { "checksumSHA1": "uKQMTzjTI15hy1sTGgsZ/b8PImA=", "path": "mvdan.cc/interfacer", "revision": "d7e7372184a059b8fd99d96a593e3811bf989d75", "revisionTime": "2017-09-08T18:13:45Z" }, { "checksumSHA1": "0+bmt/m62xZSbyATqBbp1MTy6ZI=", "path": "mvdan.cc/interfacer/check", "revision": "d7e7372184a059b8fd99d96a593e3811bf989d75", "revisionTime": "2017-09-08T18:13:45Z" }, { "checksumSHA1": "pCQUv3qVciM9V98kVNkOw1JWKzs=", "path": "mvdan.cc/lint", "revision": "adc824a0674b99099789b6188a058d485eaf61c0", "revisionTime": "2017-09-08T18:12:59Z" }, { "checksumSHA1": "TCj3HvSF+NLYG4SPv7Mv4GQ09xE=", "path": "mvdan.cc/unparam", "revision": "644240604b3c6d719b0f981ef28cd1168962efb9", "revisionTime": "2017-11-25T20:11:03Z" }, { "checksumSHA1": "Cdz2FebEWti1vA3eW36lypbYn9w=", "path": "mvdan.cc/unparam/check", "revision": "644240604b3c6d719b0f981ef28cd1168962efb9", "revisionTime": "2017-11-25T20:11:03Z" } ], "rootPath": "github.com/wrouesnel/self-contained-go-project/tools" } prometheus-postgres-exporter-0.4.1+ds/vendor/000077500000000000000000000000001321452450400213205ustar00rootroot00000000000000prometheus-postgres-exporter-0.4.1+ds/vendor/vendor.json000066400000000000000000000134601321452450400235140ustar00rootroot00000000000000{ "comment": "", "ignore": "test", "package": [ { "checksumSHA1": "9cl7+wv0GvxpQV+HOtV93F9pbmE=", "path": "github.com/Sirupsen/logrus", "revision": "89742aefa4b206dcf400792f3bd35b542998eb3b", "revisionTime": "2017-08-22T13:27:46Z" }, { "checksumSHA1": "KmjnydoAbofMieIWm+it5OWERaM=", "path": "github.com/alecthomas/template", "revision": "a0175ee3bccc567396460bf5acd36800cb10c49c", "revisionTime": "2016-04-05T07:15:01Z" }, { "checksumSHA1": "3wt0pTXXeS+S93unwhGoLIyGX/Q=", "path": "github.com/alecthomas/template/parse", "revision": "a0175ee3bccc567396460bf5acd36800cb10c49c", "revisionTime": "2016-04-05T07:15:01Z" }, { "checksumSHA1": "fCc3grA7vIxfBru7R3SqjcW+oLI=", "path": "github.com/alecthomas/units", "revision": "2efee857e7cfd4f3d0138cc3cbb1b4966962b93a", "revisionTime": "2015-10-22T06:55:26Z" }, { "checksumSHA1": "spyv5/YFBjYyZLZa1U2LBfDR8PM=", "path": "github.com/beorn7/perks/quantile", "revision": "4c0e84591b9aa9e6dcfdf3e020114cd81f89d5f9", "revisionTime": "2016-08-04T10:47:26Z" }, { "checksumSHA1": "OT4XN9z5k69e2RsMSpwW74B+yk4=", "path": "github.com/blang/semver", "revision": "2ee87856327ba09384cabd113bc6b5d174e9ec0f", "revisionTime": "2017-07-27T06:48:18Z" }, { "checksumSHA1": "yqF125xVSkmfLpIVGrLlfE05IUk=", "path": "github.com/golang/protobuf/proto", "revision": "1643683e1b54a9e88ad26d98f81400c8c9d9f4f9", "revisionTime": "2017-10-21T04:39:52Z" }, { "checksumSHA1": "3HVfwgLpCDH8JX211UWdrSi/GU4=", "path": "github.com/lib/pq", "revision": "b609790bd85edf8e9ab7e0f8912750a786177bcf", "revisionTime": "2017-10-22T19:20:43Z" }, { "checksumSHA1": "AU3fA8Sm33Vj9PBoRPSeYfxLRuE=", "path": "github.com/lib/pq/oid", "revision": "b609790bd85edf8e9ab7e0f8912750a786177bcf", "revisionTime": "2017-10-22T19:20:43Z" }, { "checksumSHA1": "bKMZjd2wPw13VwoE7mBeSv5djFA=", "path": "github.com/matttproud/golang_protobuf_extensions/pbutil", "revision": "c12348ce28de40eed0136aa2b644d0ee0650e56c", "revisionTime": "2016-04-24T11:30:07Z" }, { "checksumSHA1": "hu0MsbTdFzZxNRyAxe2HmTFFFak=", "path": "github.com/prometheus/client_golang/prometheus", "revision": "5cec1d0429b02e4323e042eb04dafdb079ddf568", "revisionTime": "2017-10-05T11:29:15Z" }, { "checksumSHA1": "wsAkYlRRUNx+OAuUOIqdjO7dICM=", "path": "github.com/prometheus/client_golang/prometheus/promhttp", "revision": "5cec1d0429b02e4323e042eb04dafdb079ddf568", "revisionTime": "2017-10-05T11:29:15Z" }, { "checksumSHA1": "DvwvOlPNAgRntBzt3b3OSRMS2N4=", "path": "github.com/prometheus/client_model/go", "revision": "6f3806018612930941127f2a7c6c453ba2c527d2", "revisionTime": "2017-02-16T18:52:47Z" }, { "checksumSHA1": "xfnn0THnqNwjwimeTClsxahYrIo=", "path": "github.com/prometheus/common/expfmt", "revision": "1bab55dd05dbff384524a6a1c99006d9eb5f139b", "revisionTime": "2017-10-06T14:14:18Z" }, { "checksumSHA1": "GWlM3d2vPYyNATtTFgftS10/A9w=", "path": "github.com/prometheus/common/internal/bitbucket.org/ww/goautoneg", "revision": "1bab55dd05dbff384524a6a1c99006d9eb5f139b", "revisionTime": "2017-10-06T14:14:18Z" }, { "checksumSHA1": "urKbLgaVUBz64iwZ6z4fHijDfXE=", "path": "github.com/prometheus/common/log", "revision": "1bab55dd05dbff384524a6a1c99006d9eb5f139b", "revisionTime": "2017-10-06T14:14:18Z" }, { "checksumSHA1": "3VoqH7TFfzA6Ds0zFzIbKCUvBmw=", "path": "github.com/prometheus/common/model", "revision": "1bab55dd05dbff384524a6a1c99006d9eb5f139b", "revisionTime": "2017-10-06T14:14:18Z" }, { "checksumSHA1": "pW1yt1G1J9jnQMCxr1TDI7LQr3s=", "path": "github.com/prometheus/procfs", "revision": "a6e9df898b1336106c743392c48ee0b71f5c4efa", "revisionTime": "2017-10-17T21:40:25Z" }, { "checksumSHA1": "xCiFAAwVTrjsfZT1BIJQ3DgeNCY=", "path": "github.com/prometheus/procfs/xfs", "revision": "a6e9df898b1336106c743392c48ee0b71f5c4efa", "revisionTime": "2017-10-17T21:40:25Z" }, { "checksumSHA1": "BYvROBsiyAXK4sq6yhDe8RgT4LM=", "path": "github.com/sirupsen/logrus", "revision": "89742aefa4b206dcf400792f3bd35b542998eb3b", "revisionTime": "2017-08-22T13:27:46Z" }, { "checksumSHA1": "nqWNlnMmVpt628zzvyo6Yv2CX5Q=", "path": "golang.org/x/crypto/ssh/terminal", "revision": "2509b142fb2b797aa7587dad548f113b2c0f20ce", "revisionTime": "2017-10-23T14:45:55Z" }, { "checksumSHA1": "ftE54xFDY2r5NPWskbK88BQPrb4=", "path": "golang.org/x/sys/unix", "revision": "a1a1f1746d156bbc9954f29134b20ed4ce2752f1", "revisionTime": "2017-10-23T12:30:29Z" }, { "checksumSHA1": "wGkVl9xZjgnLs/olurjDX2Yg8Xw=", "path": "golang.org/x/sys/windows", "revision": "a1a1f1746d156bbc9954f29134b20ed4ce2752f1", "revisionTime": "2017-10-23T12:30:29Z" }, { "checksumSHA1": "ZdFZFaXmCgEEaEhVPkyXrnhKhsg=", "path": "golang.org/x/sys/windows/registry", "revision": "a1a1f1746d156bbc9954f29134b20ed4ce2752f1", "revisionTime": "2017-10-23T12:30:29Z" }, { "checksumSHA1": "uVlUSSKplihZG7N+QJ6fzDZ4Kh8=", "path": "golang.org/x/sys/windows/svc/eventlog", "revision": "a1a1f1746d156bbc9954f29134b20ed4ce2752f1", "revisionTime": "2017-10-23T12:30:29Z" }, { "checksumSHA1": "3SZTatHIy9OTKc95YlVfXKnoySg=", "path": "gopkg.in/alecthomas/kingpin.v2", "revision": "1087e65c9441605df944fb12c33f0fe7072d18ca", "revisionTime": "2017-07-27T04:22:29Z" }, { "checksumSHA1": "CEFTYXtWmgSh+3Ik1NmDaJcz4E0=", "path": "gopkg.in/check.v1", "revision": "20d25e2804050c1cd24a7eea1e7a6447dd0e74ec", "revisionTime": "2016-12-08T18:13:25Z" }, { "checksumSHA1": "RDJpJQwkF012L6m/2BJizyOksNw=", "path": "gopkg.in/yaml.v2", "revision": "eb3733d160e74a9c7e442f435eb3bea458e1d19f", "revisionTime": "2017-08-12T16:00:11Z" } ], "rootPath": "github.com/wrouesnel/postgres_exporter" }