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
[Prometheus](https://prometheus.io/)[exporter](https://prometheus.io/docs/instrumenting/exporters/) for [PostgreSQL](https://www.postgresql.org) metrics. **Gives you complete insight on your favourate elephant!**
4
4
5
-
Latest binaries can be found on [release](https://github.com/Vonng/pg_exporter/releases) page. [Support](pg_exporter.yaml) for PostgreSQL 10+ & Pgbouncer 1.9+ is provided ([`conf`](conf/)). Lower version support could be add in the future, or you can provide your own conf to achieve it.
6
-
7
-
Latest version is v0.1.2 Here are how self monitoring dashboards looks like:
8
-
9
-

5
+
Latest binaries & rpm can be found on [release](https://github.com/Vonng/pg_exporter/releases) page. Supported pg version: PostgreSQL 9.4+ & Pgbouncer 1.8+
10
6
7
+
The latest version of `pg_exporter` is v0.2.0
11
8
9
+
## Feature
12
10
13
-
## Features
14
-
15
-
* Support Postgres & Pgbouncer (pgbouncer mode is enabled when target dbname is `pgbouncer`)
16
-
* Fine-grained execution control (Tags Filter, Facts Filter, Version Filter, Timeout, Cache, etc...)
11
+
* Support both Postgres & Pgbouncer
17
12
* Flexible: Almost all metrics are defined in customizable config files with SQL query.
13
+
* Fine-grained execution control (Tags Filter, Facts Filter, Version Filter, Timeout, Cache, etc...)
18
14
* Dynamic Planning: User could provide multiple branches of a metric queries. Queries matches server version & fact & tag will be actually installed.
19
15
* Configurable caching policy & query timeout
20
16
* Rich metrics about `pg_exporter` itself.
@@ -24,12 +20,14 @@ Latest version is v0.1.2 Here are how self monitoring dashboards looks like:
24
20
25
21
26
22
23
+
(pgbouncer mode is enabled when target dbname is `pgbouncer`)
24
+
27
25
## Quick Start
28
26
29
27
To run this exporter, you will need two things
30
28
31
29
***Where** to scrape: A postgres or pgbouncer URL given via `PG_EXPORTER_URL` or `--url`
32
-
***What** to scrape: A path to config file or directory, by default `./pg_exporter.yaml`
30
+
***What** to scrape: A path to config file or directory, by default `./pg_exporter.yaml` or `/etc/pg_exporter`
`pg_exporter` will generate approximately 200~300 metrics for completely new database cluster. For a real-world database with 10 ~ 100 tables, it may generate serveral 1k ~ 10k metrics. You may need modifying or disable some database-level metrics on database with serveral thousands or more tables in order to complete scrape in time.
170
176
171
177
Config files are using YAML format, there are lots of examples in the [conf](https://github.com/Vonng/pg_exporter/tree/master/conf) dir. and here is a [sample](conf/100-doc.txt) config.
172
178
173
179
```yaml
174
-
# pg_primary_only: <---- Branch name, distinguish different branch of a metric query
175
-
# name: pg <---- actual Query name, used as metric prefix, will set to branch if not provide
176
-
# desc: PostgreSQL basic information (on primary) <---- query description
177
-
# query: | <---- query string
178
-
#
179
-
# SELECT extract(EPOCH FROM CURRENT_TIMESTAMP) AS timestamp,
180
-
# pg_current_wal_lsn() - '0/0' AS lsn,
181
-
# pg_current_wal_insert_lsn() - '0/0' AS insert_lsn,
182
-
# pg_current_wal_lsn() - '0/0' AS write_lsn,
183
-
# pg_current_wal_flush_lsn() - '0/0' AS flush_lsn,
184
-
# extract(EPOCH FROM now() - pg_postmaster_start_time()) AS uptime,
185
-
# extract(EPOCH FROM now() - pg_conf_load_time()) AS conf_reload_time,
186
-
# pg_is_in_backup() AS is_in_backup,
187
-
# extract(EPOCH FROM now() - pg_backup_start_time()) AS backup_time;
188
-
#
189
-
# <---- following field are [OPTIONAL], control execution policy
190
-
# ttl: 10 <---- cache ttl: how long will exporter cache it's result. set to 0 to disable cache
191
-
# timeout: 0.1 <---- timeout: in seconds, query execeed this will be canceled. default is 0.1, set to -1 to disable timeout
192
-
# min_version: 100000 <---- minimal supported version in server version number format, e.g 120001 = 12.1, 090601 = 9.6.1
193
-
# max_version: 130000 <---- maximal supported version in server version number format, boundary not include
194
-
# fatal: false <---- if query marked fatal fail, this scrape will abort immidiately
195
-
#
196
-
# tags: [cluster, primary] <---- tags consist of one or more string, which could be:
197
-
# * 'cluster' marks this query as cluster level, so it will only execute once for same PostgreSQL Server
198
-
# * 'primary' marks this query can only run on a master instance (will not execute if pg_is_in_recovery())
199
-
# * 'standby' marks this query can only run on a recoverying instance (will execute if pg_is_in_recovery())
200
-
# * some special tag prefix will have special effect:
201
-
# * 'dbname:<dbname>' means this query will only execute on database with name '<dbname>'
202
-
# * 'username:<user>' means this query will only execute when connect with user '<user>'
203
-
# * 'extension:<extname>' means this query will only execute when extension '<extname>' is installed
204
-
# * 'schema:<nspname>' means this query will only execute when schema '<nspname>' exist
205
-
# * 'not:<negtag>' means this query will only execute when exporter is launch without tag '<negtag>'
206
-
# * '<tag>' means this query will only execute when exporter is launch with tag '<tag>'
207
-
# (tag could not be cluster,primary,standby or have special prefix)
208
-
#
209
-
#
210
-
# metrics: <---- this is a list of returned columns, each column must have a name, usage, could have an alias and description
211
-
# - timestamp: <---- this is column name, should be exactly same as returned column name
212
-
# rename: ts <---- rename is optional, will use this alias instead of column name
213
-
# usage: GAUGE <---- usage could be
214
-
# * DISCARD: completely ignore this field
215
-
# * LABEL: use columnName:columnValue as a label in result
216
-
# * GAUGE: use this column as a metric, which is '<query.name>_<column.name>{<labels>} column.value'
217
-
# * COUNTER: same as GAUGE, except it is a counter.
218
-
#
219
-
# description: database current timestamp
220
-
# - lsn:
221
-
# usage: COUNTER
222
-
# description: log sequence number, current write location (on primary)
223
-
# - insert_lsn:
224
-
# usage: COUNTER
225
-
# description: primary only, location of current wal inserting
226
-
# - write_lsn:
227
-
# usage: COUNTER
228
-
# description: primary only, location of current wal writing
229
-
# - flush_lsn:
230
-
# usage: COUNTER
231
-
# description: primary only, location of current wal syncing
232
-
# - uptime:
233
-
# usage: GAUGE
234
-
# description: seconds since postmaster start
235
-
# - conf_reload_time:
236
-
# usage: GAUGE
237
-
# description: seconds since last configuration reload
238
-
# - is_in_backup:
239
-
# usage: GAUGE
240
-
# description: 1 if backup is in progress
241
-
# - backup_time:
242
-
# usage: GAUGE
243
-
# description: seconds since current backup start. null if don't have one
0 commit comments