Skip to content

Commit c1ddbee

Browse files
authored
Merge pull request prometheus-community#480 from prometheus-community/superq/community
Update for Prometheus Community
2 parents 8531aba + b67b69a commit c1ddbee

File tree

1,455 files changed

+684
-529255
lines changed

Some content is hidden

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

1,455 files changed

+684
-529255
lines changed

.circleci/config.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
---
2+
version: 2.1
3+
4+
orbs:
5+
prometheus: prometheus/prometheus@0.8.0
6+
7+
executors:
8+
# This must match .promu.yml.
9+
golang:
10+
docker:
11+
- image: circleci/golang:1.15
12+
13+
jobs:
14+
test:
15+
executor: golang
16+
17+
steps:
18+
- prometheus/setup_environment
19+
- run: make
20+
- prometheus/store_artifact:
21+
file: postgres_exporter
22+
23+
workflows:
24+
version: 2
25+
postgres_exporter:
26+
jobs:
27+
- test:
28+
filters:
29+
tags:
30+
only: /.*/
31+
- prometheus/build:
32+
name: build
33+
filters:
34+
tags:
35+
only: /.*/
36+
- prometheus/publish_master:
37+
context: org-context
38+
docker_hub_organization: prometheuscommunity
39+
quay_io_organization: prometheuscommunity
40+
requires:
41+
- test
42+
- build
43+
filters:
44+
branches:
45+
only: master
46+
- prometheus/publish_release:
47+
context: org-context
48+
docker_hub_organization: prometheuscommunity
49+
quay_io_organization: prometheuscommunity
50+
requires:
51+
- test
52+
- build
53+
filters:
54+
tags:
55+
only: /^v.*/
56+
branches:
57+
ignore: /.*/

.dockerignore

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

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@
1919
/.metrics.*.added
2020
/.metrics.*.removed
2121
/tools/src
22+
/vendor

.golangci.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
issues:
3+
exclude-rules:
4+
- path: _test.go
5+
linters:
6+
- errcheck
7+
8+
linters-settings:
9+
errcheck:
10+
exclude: scripts/errcheck_excludes.txt

.promu.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
go:
2+
# This must match .circle/config.yml.
3+
version: 1.15
4+
repository:
5+
path: github.com/prometheus-community/postgres_exporter
6+
build:
7+
binaries:
8+
- name: postgres_exporter
9+
path: ./cmd/postgres_exporter
10+
flags: -a -tags 'netgo static_build'
11+
ldflags: |
12+
-X github.com/prometheus/common/version.Version={{.Version}}
13+
-X github.com/prometheus/common/version.Revision={{.Revision}}
14+
-X github.com/prometheus/common/version.Branch={{.Branch}}
15+
-X github.com/prometheus/common/version.BuildUser={{user}}@{{host}}
16+
-X github.com/prometheus/common/version.BuildDate={{date "20060102-15:04:05"}}
17+
tarball:
18+
files:
19+
- LICENSE

.travis.yml

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

Dockerfile

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
FROM debian:10-slim
2-
RUN useradd -u 20001 postgres_exporter
3-
4-
USER postgres_exporter
5-
6-
ARG binary
7-
8-
COPY $binary /postgres_exporter
9-
10-
EXPOSE 9187
11-
12-
ENTRYPOINT [ "/postgres_exporter" ]
1+
ARG ARCH="amd64"
2+
ARG OS="linux"
3+
FROM quay.io/prometheus/busybox-${OS}-${ARCH}:latest
4+
LABEL maintainer="The Prometheus Authors <prometheus-developers@googlegroups.com>"
5+
6+
ARG ARCH="amd64"
7+
ARG OS="linux"
8+
COPY .build/${OS}-${ARCH}/postgres_exporter /bin/postgres_exporter
9+
10+
EXPOSE 9187
11+
USER nobody
12+
ENTRYPOINT [ "/bin/postgres_exporter" ]

Makefile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Ensure that 'all' is the default target otherwise it will be the first target from Makefile.common.
2+
all::
3+
4+
# Needs to be defined before including Makefile.common to auto-generate targets
5+
DOCKER_ARCHS ?= amd64 armv7 arm64 ppc64le
6+
DOCKER_REPO ?= prometheuscommunity
7+
8+
include Makefile.common
9+
10+
DOCKER_IMAGE_NAME ?= postgres-exporter

vendor/github.com/prometheus/procfs/Makefile.common renamed to Makefile.common

Lines changed: 39 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,21 @@ else
6969
GO_BUILD_PLATFORM ?= $(GOHOSTOS)-$(GOHOSTARCH)
7070
endif
7171

72-
PROMU_VERSION ?= 0.4.0
72+
GOTEST := $(GO) test
73+
GOTEST_DIR :=
74+
ifneq ($(CIRCLE_JOB),)
75+
ifneq ($(shell which gotestsum),)
76+
GOTEST_DIR := test-results
77+
GOTEST := gotestsum --junitfile $(GOTEST_DIR)/unit-tests.xml --
78+
endif
79+
endif
80+
81+
PROMU_VERSION ?= 0.7.0
7382
PROMU_URL := https://github.com/prometheus/promu/releases/download/v$(PROMU_VERSION)/promu-$(PROMU_VERSION).$(GO_BUILD_PLATFORM).tar.gz
7483

7584
GOLANGCI_LINT :=
7685
GOLANGCI_LINT_OPTS ?=
77-
GOLANGCI_LINT_VERSION ?= v1.16.0
86+
GOLANGCI_LINT_VERSION ?= v1.36.0
7887
# golangci-lint only supports linux, darwin and windows platforms on i386/amd64.
7988
# windows isn't included here because of the path separator being different.
8089
ifeq ($(GOHOSTOS),$(filter $(GOHOSTOS),linux darwin))
@@ -86,6 +95,8 @@ endif
8695
PREFIX ?= $(shell pwd)
8796
BIN_DIR ?= $(shell pwd)
8897
DOCKER_IMAGE_TAG ?= $(subst /,-,$(shell git rev-parse --abbrev-ref HEAD))
98+
DOCKERFILE_PATH ?= ./Dockerfile
99+
DOCKERBUILD_CONTEXT ?= ./
89100
DOCKER_REPO ?= prom
90101

91102
DOCKER_ARCHS ?= amd64
@@ -139,15 +150,29 @@ else
139150
$(GO) get $(GOOPTS) -t ./...
140151
endif
141152

153+
.PHONY: update-go-deps
154+
update-go-deps:
155+
@echo ">> updating Go dependencies"
156+
@for m in $$($(GO) list -mod=readonly -m -f '{{ if and (not .Indirect) (not .Main)}}{{.Path}}{{end}}' all); do \
157+
$(GO) get $$m; \
158+
done
159+
GO111MODULE=$(GO111MODULE) $(GO) mod tidy
160+
ifneq (,$(wildcard vendor))
161+
GO111MODULE=$(GO111MODULE) $(GO) mod vendor
162+
endif
163+
142164
.PHONY: common-test-short
143-
common-test-short:
165+
common-test-short: $(GOTEST_DIR)
144166
@echo ">> running short tests"
145-
GO111MODULE=$(GO111MODULE) $(GO) test -short $(GOOPTS) $(pkgs)
167+
GO111MODULE=$(GO111MODULE) $(GOTEST) -short $(GOOPTS) $(pkgs)
146168

147169
.PHONY: common-test
148-
common-test:
170+
common-test: $(GOTEST_DIR)
149171
@echo ">> running all tests"
150-
GO111MODULE=$(GO111MODULE) $(GO) test $(test-flags) $(GOOPTS) $(pkgs)
172+
GO111MODULE=$(GO111MODULE) $(GOTEST) $(test-flags) $(GOOPTS) $(pkgs)
173+
174+
$(GOTEST_DIR):
175+
@mkdir -p $@
151176

152177
.PHONY: common-format
153178
common-format:
@@ -199,7 +224,7 @@ endif
199224
.PHONY: common-build
200225
common-build: promu
201226
@echo ">> building binaries"
202-
GO111MODULE=$(GO111MODULE) $(PROMU) build --prefix $(PREFIX)
227+
GO111MODULE=$(GO111MODULE) $(PROMU) build --prefix $(PREFIX) $(PROMU_BINARIES)
203228

204229
.PHONY: common-tarball
205230
common-tarball: promu
@@ -210,19 +235,22 @@ common-tarball: promu
210235
common-docker: $(BUILD_DOCKER_ARCHS)
211236
$(BUILD_DOCKER_ARCHS): common-docker-%:
212237
docker build -t "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)-linux-$*:$(DOCKER_IMAGE_TAG)" \
238+
-f $(DOCKERFILE_PATH) \
213239
--build-arg ARCH="$*" \
214240
--build-arg OS="linux" \
215-
.
241+
$(DOCKERBUILD_CONTEXT)
216242

217243
.PHONY: common-docker-publish $(PUBLISH_DOCKER_ARCHS)
218244
common-docker-publish: $(PUBLISH_DOCKER_ARCHS)
219245
$(PUBLISH_DOCKER_ARCHS): common-docker-publish-%:
220246
docker push "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)-linux-$*:$(DOCKER_IMAGE_TAG)"
221247

248+
DOCKER_MAJOR_VERSION_TAG = $(firstword $(subst ., ,$(shell cat VERSION)))
222249
.PHONY: common-docker-tag-latest $(TAG_DOCKER_ARCHS)
223250
common-docker-tag-latest: $(TAG_DOCKER_ARCHS)
224251
$(TAG_DOCKER_ARCHS): common-docker-tag-latest-%:
225252
docker tag "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)-linux-$*:$(DOCKER_IMAGE_TAG)" "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)-linux-$*:latest"
253+
docker tag "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)-linux-$*:$(DOCKER_IMAGE_TAG)" "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)-linux-$*:v$(DOCKER_MAJOR_VERSION_TAG)"
226254

227255
.PHONY: common-docker-manifest
228256
common-docker-manifest:
@@ -247,7 +275,9 @@ proto:
247275
ifdef GOLANGCI_LINT
248276
$(GOLANGCI_LINT):
249277
mkdir -p $(FIRST_GOPATH)/bin
250-
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(FIRST_GOPATH)/bin $(GOLANGCI_LINT_VERSION)
278+
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/$(GOLANGCI_LINT_VERSION)/install.sh \
279+
| sed -e '/install -d/d' \
280+
| sh -s -- -b $(FIRST_GOPATH)/bin $(GOLANGCI_LINT_VERSION)
251281
endif
252282

253283
ifdef GOVENDOR

README-RDS.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
### When using postgres-exporter with Amazon Web Services' RDS, the
44
rolname "rdsadmin" and datname "rdsadmin" must be excluded.
55

6-
I had success running docker container 'wrouesnel/postgres_exporter:latest'
6+
I had success running docker container 'quay.io/prometheuscommunity/postgres-exporter:latest'
77
with queries.yaml as the PG_EXPORTER_EXTEND_QUERY_PATH. errors
88
mentioned in issue#335 appeared and I had to modify the
99
'pg_stat_statements' query with the following:
@@ -24,7 +24,7 @@ Running postgres-exporter in a container like so:
2424
-e PG_EXPORTER_DISABLE_DEFAULT_METRICS=true \
2525
-e PG_EXPORTER_DISABLE_SETTINGS_METRICS=true \
2626
-e PG_EXPORTER_EXTEND_QUERY_PATH='/var/lib/postgresql/queries.yaml' \
27-
wrouesnel/postgres_exporter
27+
quay.io/prometheuscommunity/postgres-exporter
2828
```
2929

3030
### Expected changes to RDS:

0 commit comments

Comments
 (0)