You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+35-4Lines changed: 35 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -18,6 +18,9 @@ docker run --net=host -e DATA_SOURCE_NAME="postgresql://postgres:password@localh
18
18
19
19
### Flags
20
20
21
+
*`help`
22
+
Show context-sensitive help (also try --help-long and --help-man).
23
+
21
24
*`web.listen-address`
22
25
Address to listen on for web interface and telemetry. Default is `:9187`.
23
26
@@ -30,6 +33,9 @@ docker run --net=host -e DATA_SOURCE_NAME="postgresql://postgres:password@localh
30
33
*`disable-settings-metrics`
31
34
Use the flag if you don't want to scrape `pg_settings`.
32
35
36
+
*`auto-discover-databases`
37
+
Enable discovering databases automatically.
38
+
33
39
*`extend.query-path`
34
40
Path to a YAML file containing custom queries to run. Check out [`queries.yaml`](queries.yaml)
35
41
for examples of the format.
@@ -38,16 +44,22 @@ docker run --net=host -e DATA_SOURCE_NAME="postgresql://postgres:password@localh
38
44
Do not run - print the internal representation of the metric maps. Useful when debugging a custom
39
45
queries file.
40
46
47
+
*`constantLabels`
48
+
Labels to set in all metrics. A list of `label=value` pairs, separated by commas.
49
+
50
+
*`version`
51
+
Show application version.
52
+
53
+
*`exclude-databases`
54
+
A list of databases to remove when autoDiscoverDatabases is enabled.
55
+
41
56
*`log.level`
42
57
Set logging level: one of `debug`, `info`, `warn`, `error`, `fatal`
43
58
44
59
*`log.format`
45
60
Set the log output target and format. e.g. `logger:syslog?appname=bob&local=7` or `logger:stdout?json=true`
46
61
Defaults to `logger:stderr`.
47
62
48
-
*`constantLabels`
49
-
Labels to set in all metrics. A list of `label=value` pairs, separated by commas.
50
-
51
63
### Environment Variables
52
64
53
65
The following environment variables configure the exporter:
@@ -60,6 +72,9 @@ The following environment variables configure the exporter:
60
72
an alternative to `DATA_SOURCE_NAME` which exclusively accepts the raw URI
61
73
without a username and password component.
62
74
75
+
*`DATA_SOURCE_URI_FILE`
76
+
The same as above but reads the URI from a file.
77
+
63
78
*`DATA_SOURCE_USER`
64
79
When using `DATA_SOURCE_URI`, this environment variable is used to specify
65
80
the username.
@@ -86,13 +101,19 @@ The following environment variables configure the exporter:
86
101
*`PG_EXPORTER_DISABLE_SETTINGS_METRICS`
87
102
Use the flag if you don't want to scrape `pg_settings`. Value can be `true` or `false`. Defauls is `false`.
88
103
104
+
*`PG_EXPORTER_AUTO_DISCOVER_DATABASES`
105
+
Enable discovering databases automatically. Value can be `true` or `false`. Defauls is `false`.
106
+
89
107
*`PG_EXPORTER_EXTEND_QUERY_PATH`
90
108
Path to a YAML file containing custom queries to run. Check out [`queries.yaml`](queries.yaml)
91
109
for examples of the format.
92
110
93
111
*`PG_EXPORTER_CONSTANT_LABELS`
94
112
Labels to set in all metrics. A list of `label=value` pairs, separated by commas.
95
113
114
+
*`PG_EXPORTER_EXCLUDE_DATABASES`
115
+
A comma-separated list of databases to remove when autoDiscoverDatabases is enabled. Default is empty string.
116
+
96
117
Settings set by environment variables starting with `PG_` will be overwritten by the corresponding CLI flag if given.
97
118
98
119
### Setting the Postgres server's data source name
@@ -138,9 +159,11 @@ flag. This removes all built-in metrics, and uses only metrics defined by querie
138
159
139
160
### Automatically discover databases
140
161
To scrape metrics from all databases on a database server, the database DSN's can be dynamically discovered via the
141
-
`--auto-discover-databases` flag. When true, `SELECT datname FROM pg_database` is run for all configured DSN's. From the
162
+
`--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
142
163
result a new set of DSN's is created for which the metrics are scraped.
143
164
165
+
In addition, the option `--exclude-databases` adds the possibily to filter the result from the auto discovery to discard databases you do not need.
166
+
144
167
### Running as non-superuser
145
168
146
169
To be able to collect metrics from `pg_stat_activity` and `pg_stat_replication`
@@ -181,6 +204,7 @@ ALTER USER postgres_exporter SET SEARCH_PATH TO postgres_exporter,pg_catalog;
181
204
-- GRANT postgres_exporter TO <MASTER_USER>;
182
205
CREATESCHEMAIF NOT EXISTS postgres_exporter;
183
206
GRANT USAGE ON SCHEMA postgres_exporter TO postgres_exporter;
207
+
GRANT CONNECT ON DATABASE postgres TO postgres_exporter;
184
208
185
209
CREATE OR REPLACEFUNCTIONget_pg_stat_activity() RETURNS SETOF pg_stat_activity AS
186
210
$$ SELECT*FROMpg_catalog.pg_stat_activity; $$
@@ -212,3 +236,10 @@ GRANT SELECT ON postgres_exporter.pg_stat_replication TO postgres_exporter;
0 commit comments