Skip to content

Commit ece8297

Browse files
authored
Merge branch 'prometheus-community:master' into master
2 parents 6c269ab + ddd5136 commit ece8297

Some content is hidden

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

66 files changed

+5959
-642
lines changed

.circleci/config.yml

+5-4
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,15 @@ executors:
88
# This must match .promu.yml.
99
golang:
1010
docker:
11-
- image: cimg/go:1.20
11+
- image: cimg/go:1.21
1212

1313
jobs:
1414
test:
1515
executor: golang
1616

1717
steps:
1818
- prometheus/setup_environment
19+
- run: GOHOSTARCH=386 GOARCH=386 make test
1920
- run: make
2021
- prometheus/store_artifact:
2122
file: postgres_exporter
@@ -56,12 +57,12 @@ workflows:
5657
matrix:
5758
parameters:
5859
postgres_image:
59-
- circleci/postgres:10
6060
- circleci/postgres:11
6161
- circleci/postgres:12
6262
- circleci/postgres:13
63-
- cimg/postgres:14.1
64-
- cimg/postgres:15.1
63+
- cimg/postgres:14.9
64+
- cimg/postgres:15.4
65+
- cimg/postgres:16.0
6566
- prometheus/build:
6667
name: build
6768
parallelism: 3

.github/workflows/golangci-lint.yml

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
---
2+
# This action is synced from https://github.com/prometheus/prometheus
13
name: golangci-lint
24
on:
35
push:
@@ -16,15 +18,15 @@ jobs:
1618
runs-on: ubuntu-latest
1719
steps:
1820
- name: Checkout repository
19-
uses: actions/checkout@v3
21+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
2022
- name: install Go
21-
uses: actions/setup-go@v3
23+
uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 # v3.5.0
2224
with:
23-
go-version: 1.20.x
25+
go-version: 1.21.x
2426
- name: Install snmp_exporter/generator dependencies
2527
run: sudo apt-get update && sudo apt-get -y install libsnmp-dev
2628
if: github.repository == 'prometheus/snmp_exporter'
2729
- name: Lint
28-
uses: golangci/golangci-lint-action@v3.4.0
30+
uses: golangci/golangci-lint-action@3a919529898de77ec3da873e3063ca4b10e7f5cc # v3.7.0
2931
with:
30-
version: v1.51.2
32+
version: v1.54.2

.golangci.yml

+14-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
---
2+
linters:
3+
enable:
4+
- misspell
5+
- revive
6+
27
issues:
38
exclude-rules:
49
- path: _test.go
@@ -7,4 +12,12 @@ issues:
712

813
linters-settings:
914
errcheck:
10-
exclude: scripts/errcheck_excludes.txt
15+
exclude-functions:
16+
# Never check for logger errors.
17+
- (github.com/go-kit/log.Logger).Log
18+
revive:
19+
rules:
20+
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unused-parameter
21+
- name: unused-parameter
22+
severity: warning
23+
disabled: true

.promu.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
go:
22
# This must match .circle/config.yml.
3-
version: 1.20
3+
version: 1.21
44
repository:
55
path: github.com/prometheus-community/postgres_exporter
66
build:
77
binaries:
88
- name: postgres_exporter
99
path: ./cmd/postgres_exporter
10-
flags: -a -tags 'netgo static_build'
1110
ldflags: |
1211
-X github.com/prometheus/common/version.Version={{.Version}}
1312
-X github.com/prometheus/common/version.Revision={{.Revision}}

.yamllint

+1-2
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,4 @@ rules:
2020
config/testdata/section_key_dup.bad.yml
2121
line-length: disable
2222
truthy:
23-
ignore: |
24-
.github/workflows/*.yml
23+
check-keys: false

CHANGELOG.md

+61-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,64 @@
1-
## master / unreleased
1+
## 0.15.0 / 2023-10-27
2+
3+
* [ENHANCEMENT] Add 1kB and 2kB units #915
4+
* [BUGFIX] Add error log when probe collector creation fails #918
5+
* [BUGFIX] Fix test build failures on 32-bit arch #919
6+
* [BUGFIX] Adjust collector to use separate connection per scrape #936
7+
8+
## 0.14.0 / 2023-09-11
9+
10+
* [CHANGE] Add `state` label to pg_process_idle_seconds #862
11+
* [CHANGE] Change database connections to one per scrape #882 #902
12+
* [ENHANCEMENT] Add wal collector #858
13+
* [ENHANCEMENT] Add database_wraparound collector #834
14+
* [ENHANCEMENT] Add stat_activity_autovacuum collector #840
15+
* [ENHANCEMENT] Add stat_wal_receiver collector #844
16+
* [ENHANCEMENT] Add xlog_location collector #849
17+
* [ENHANCEMENT] Add statio_user_indexes collector #845
18+
* [ENHANCEMENT] Add long_running_transactions collector #836
19+
* [ENHANCEMENT] Add pg_stat_user_tables_size_bytes metric #904
20+
* [BUGFIX] Fix tests on 32-bit systems #857
21+
* [BUGFIX] Fix pg_stat_statements metrics on Postgres 13+ #874 #876
22+
* [BUGFIX] Fix pg_stat_database metrics for NULL stats_reset #877
23+
* [BUGFIX] Fix pg_replication_lag_seconds on Postgres 10+ when master is idle #895
24+
25+
## 0.13.2 / 2023-07-21
26+
27+
* [BUGFIX] Fix type issues on pg_postmaster metrics #828
28+
* [BUGFIX] Fix pg_replication collector instantiation #854
29+
* [BUGFIX] Fix pg_process_idle metrics #855
30+
31+
## 0.13.1 / 2023-06-27
32+
33+
* [BUGFIX] Make collectors not fail on null values #823
34+
35+
## 0.13.0 / 2023-06-21
36+
37+
BREAKING CHANGES:
38+
39+
Please note, the following features are deprecated and may be removed in a future release:
40+
- `auto-discover-databases`
41+
- `extend.query-path`
42+
- `constantLabels`
43+
- `exclude-databases`
44+
- `include-databases`
45+
46+
This exporter is meant to monitor PostgresSQL servers, not the user data/databases. If
47+
you need a generic SQL report exporter https://github.com/burningalchemist/sql_exporter
48+
is recommended.
49+
50+
* [CHANGE] Adjust log level for collector startup #784
51+
* [CHANGE] Move queries from queries.yaml to collectors #801
52+
* [CHANGE] Deprecate extend queries feature #811
53+
* [CHANGE] Deprecate additional database features #815
54+
* [CHANGE] Convert pg_stat_database to new collector #685
55+
* [ENHANCEMENT] Supports alternate postgres:// prefix in URLs #787
56+
* [BUGFIX] Fix pg_setting different help values #771
57+
* [BUGFIX] Fix column type for pg_replication_slots #777
58+
* [BUGFIX] Fix pg_stat_database collector #809
59+
60+
## 0.12.1 / 2023-06-12
61+
* [BUGFIX] Fix column type for pg_replication_slots #777
262

363
## 0.12.0 / 2023-03-21
464

Makefile.common

+4-4
Original file line numberDiff line numberDiff line change
@@ -49,19 +49,19 @@ endif
4949
GOTEST := $(GO) test
5050
GOTEST_DIR :=
5151
ifneq ($(CIRCLE_JOB),)
52-
ifneq ($(shell which gotestsum),)
52+
ifneq ($(shell command -v gotestsum > /dev/null),)
5353
GOTEST_DIR := test-results
5454
GOTEST := gotestsum --junitfile $(GOTEST_DIR)/unit-tests.xml --
5555
endif
5656
endif
5757

58-
PROMU_VERSION ?= 0.14.0
58+
PROMU_VERSION ?= 0.15.0
5959
PROMU_URL := https://github.com/prometheus/promu/releases/download/v$(PROMU_VERSION)/promu-$(PROMU_VERSION).$(GO_BUILD_PLATFORM).tar.gz
6060

6161
SKIP_GOLANGCI_LINT :=
6262
GOLANGCI_LINT :=
6363
GOLANGCI_LINT_OPTS ?=
64-
GOLANGCI_LINT_VERSION ?= v1.51.2
64+
GOLANGCI_LINT_VERSION ?= v1.54.2
6565
# golangci-lint only supports linux, darwin and windows platforms on i386/amd64.
6666
# windows isn't included here because of the path separator being different.
6767
ifeq ($(GOHOSTOS),$(filter $(GOHOSTOS),linux darwin))
@@ -178,7 +178,7 @@ endif
178178
.PHONY: common-yamllint
179179
common-yamllint:
180180
@echo ">> running yamllint on all YAML files in the repository"
181-
ifeq (, $(shell which yamllint))
181+
ifeq (, $(shell command -v yamllint > /dev/null))
182182
@echo "yamllint not installed so skipping"
183183
else
184184
yamllint .

README.md

+87-19
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
Prometheus exporter for PostgreSQL server metrics.
99

10-
CI Tested PostgreSQL versions: `10`, `11`, `12`, `13`, `14`, `15`
10+
CI Tested PostgreSQL versions: `11`, `12`, `13`, `14`, `15`, `16`
1111

1212
## Quick Start
1313
This package is available for Docker:
@@ -30,6 +30,26 @@ To use the multi-target functionality, send an http request to the endpoint `/pr
3030

3131
To avoid putting sensitive information like username and password in the URL, preconfigured auth modules are supported via the [auth_modules](#auth_modules) section of the config file. auth_modules for DSNs can be used with the `/probe` endpoint by specifying the `?auth_module=foo` http parameter.
3232

33+
Example Prometheus config:
34+
```yaml
35+
scrape_configs:
36+
- job_name: 'postgres'
37+
static_configs:
38+
- targets:
39+
- server1:5432
40+
- server2:5432
41+
metrics_path: /probe
42+
params:
43+
auth_module: [foo]
44+
relabel_configs:
45+
- source_labels: [__address__]
46+
target_label: __param_target
47+
- source_labels: [__param_target]
48+
target_label: instance
49+
- target_label: __address__
50+
replacement: 127.0.0.1:9116 # The postgres exporter's real hostname:port.
51+
```
52+
3353
## Configuration File
3454
3555
The configuration file controls the behavior of the exporter. It can be set using the `--config.file` command line flag and defaults to `postgres_exporter.yml`.
@@ -61,7 +81,7 @@ auth_modules:
6181
To build the Docker image:
6282

6383
make promu
64-
promu crossbuild -p linux/amd64 -p linux/armv7 -p linux/amd64 -p linux/ppc64le
84+
promu crossbuild -p linux/amd64 -p linux/armv7 -p linux/arm64 -p linux/ppc64le
6585
make docker
6686

6787
This will build the docker image as `prometheuscommunity/postgres_exporter:${branch}`.
@@ -71,14 +91,60 @@ This will build the docker image as `prometheuscommunity/postgres_exporter:${bra
7191
* `help`
7292
Show context-sensitive help (also try --help-long and --help-man).
7393

74-
* `collector.database`
75-
Enable the pg_database collector. Default is `enabled`
7694

77-
* `collector.bgwriter`
78-
Enable the pg_stat_bgwriter collector. Default is `enabled`
95+
* `[no-]collector.database`
96+
Enable the `database` collector (default: enabled).
97+
98+
* `[no-]collector.database_wraparound`
99+
Enable the `database_wraparound` collector (default: disabled).
100+
101+
* `[no-]collector.locks`
102+
Enable the `locks` collector (default: enabled).
103+
104+
* `[no-]collector.long_running_transactions`
105+
Enable the `long_running_transactions` collector (default: disabled).
106+
107+
* `[no-]collector.postmaster`
108+
Enable the `postmaster` collector (default: disabled).
109+
110+
* `[no-]collector.process_idle`
111+
Enable the `process_idle` collector (default: disabled).
112+
113+
* `[no-]collector.replication`
114+
Enable the `replication` collector (default: enabled).
115+
116+
* `[no-]collector.replication_slot`
117+
Enable the `replication_slot` collector (default: enabled).
79118

80-
* `collector.replication_slot`
81-
Enable the replication_slot collector. Default is `enabled`
119+
* `[no-]collector.stat_activity_autovacuum`
120+
Enable the `stat_activity_autovacuum` collector (default: disabled).
121+
122+
* `[no-]collector.stat_bgwriter`
123+
Enable the `stat_bgwriter` collector (default: enabled).
124+
125+
* `[no-]collector.stat_database`
126+
Enable the `stat_database` collector (default: enabled).
127+
128+
* `[no-]collector.stat_statements`
129+
Enable the `stat_statements` collector (default: disabled).
130+
131+
* `[no-]collector.stat_user_tables`
132+
Enable the `stat_user_tables` collector (default: enabled).
133+
134+
* `[no-]collector.stat_wal_receiver`
135+
Enable the `stat_wal_receiver` collector (default: disabled).
136+
137+
* `[no-]collector.statio_user_indexes`
138+
Enable the `statio_user_indexes` collector (default: disabled).
139+
140+
* `[no-]collector.statio_user_tables`
141+
Enable the `statio_user_tables` collector (default: enabled).
142+
143+
* `[no-]collector.wal`
144+
Enable the `wal` collector (default: enabled).
145+
146+
* `[no-]collector.xlog_location`
147+
Enable the `xlog_location` collector (default: disabled).
82148

83149
* `config.file`
84150
Set the config file path. Default is `postgres_exporter.yml`
@@ -102,27 +168,27 @@ This will build the docker image as `prometheuscommunity/postgres_exporter:${bra
102168
* `disable-settings-metrics`
103169
Use the flag if you don't want to scrape `pg_settings`. Default is `false`.
104170

105-
* `auto-discover-databases`
171+
* `auto-discover-databases` (DEPRECATED)
106172
Whether to discover the databases on a server dynamically. Default is `false`.
107173

108-
* `extend.query-path`
174+
* `extend.query-path` (DEPRECATED)
109175
Path to a YAML file containing custom queries to run. Check out [`queries.yaml`](queries.yaml)
110176
for examples of the format.
111177

112178
* `dumpmaps`
113179
Do not run - print the internal representation of the metric maps. Useful when debugging a custom
114180
queries file.
115181

116-
* `constantLabels`
182+
* `constantLabels` (DEPRECATED)
117183
Labels to set in all metrics. A list of `label=value` pairs, separated by commas.
118184

119185
* `version`
120186
Show application version.
121187

122-
* `exclude-databases`
188+
* `exclude-databases` (DEPRECATED)
123189
A list of databases to remove when autoDiscoverDatabases is enabled.
124190

125-
* `include-databases`
191+
* `include-databases` (DEPRECATED)
126192
A list of databases to only include when autoDiscoverDatabases is enabled.
127193

128194
* `log.level`
@@ -170,20 +236,20 @@ The following environment variables configure the exporter:
170236
* `PG_EXPORTER_DISABLE_SETTINGS_METRICS`
171237
Use the flag if you don't want to scrape `pg_settings`. Value can be `true` or `false`. Default is `false`.
172238

173-
* `PG_EXPORTER_AUTO_DISCOVER_DATABASES`
239+
* `PG_EXPORTER_AUTO_DISCOVER_DATABASES` (DEPRECATED)
174240
Whether to discover the databases on a server dynamically. Value can be `true` or `false`. Default is `false`.
175241

176242
* `PG_EXPORTER_EXTEND_QUERY_PATH`
177243
Path to a YAML file containing custom queries to run. Check out [`queries.yaml`](queries.yaml)
178244
for examples of the format.
179245

180-
* `PG_EXPORTER_CONSTANT_LABELS`
246+
* `PG_EXPORTER_CONSTANT_LABELS` (DEPRECATED)
181247
Labels to set in all metrics. A list of `label=value` pairs, separated by commas.
182248

183-
* `PG_EXPORTER_EXCLUDE_DATABASES`
249+
* `PG_EXPORTER_EXCLUDE_DATABASES` (DEPRECATED)
184250
A comma-separated list of databases to remove when autoDiscoverDatabases is enabled. Default is empty string.
185251

186-
* `PG_EXPORTER_INCLUDE_DATABASES`
252+
* `PG_EXPORTER_INCLUDE_DATABASES` (DEPRECATED)
187253
A comma-separated list of databases to only include when autoDiscoverDatabases is enabled. Default is empty string,
188254
means allow all.
189255

@@ -222,7 +288,9 @@ for l in StringIO(x):
222288
Adjust the value of the resultant prometheus value type appropriately. This helps build
223289
rich self-documenting metrics for the exporter.
224290

225-
### Adding new metrics via a config file
291+
### Adding new metrics via a config file (DEPRECATED)
292+
293+
This feature is deprecated in favor of built-in collector functions. For generic SQL database monitoring see the [sql_exporter](https://github.com/burningalchemist/sql_exporter).
226294

227295
The -extend.query-path command-line argument specifies a YAML file containing additional queries to run.
228296
Some examples are provided in [queries.yaml](queries.yaml).
@@ -233,7 +301,7 @@ or variants of postgres (e.g. Greenplum), you can disable the default metrics wi
233301
flag. This removes all built-in metrics, and uses only metrics defined by queries in the `queries.yaml` file you supply
234302
(so you must supply one, otherwise the exporter will return nothing but internal statuses and not your database).
235303

236-
### Automatically discover databases
304+
### Automatically discover databases (DEPRECATED)
237305
To scrape metrics from all databases on a database server, the database DSN's can be dynamically discovered via the
238306
`--auto-discover-databases` flag. When true, `SELECT datname FROM pg_database WHERE datallowconn = true AND datistemplate = false and datname != current_database()` is run for all configured DSN's. From the
239307
result a new set of DSN's is created for which the metrics are scraped.

VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.12.0
1+
0.15.0

0 commit comments

Comments
 (0)