Skip to content

Commit

Permalink
v0.4.0beta bug fix
Browse files Browse the repository at this point in the history
* fix env variable PG_EXPORTER_INCLUDE_DATABASE and
  PG_EXPORTER_NAMESPACE
* fix dupe metrics
  • Loading branch information
Vonng committed May 28, 2021
1 parent 6c384c2 commit f81e436
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 53 deletions.
41 changes: 0 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -240,47 +240,6 @@ Current `pg_exporter` is shipped with following metrics collector definition fil
* [pgbouncer_pool](conf/940-pgbouncer_pool.yaml)


* [doc](conf/000-doc.yaml)
* [pg](conf/110-pg.yaml)
* [pg_meta](conf/120-pg_meta.yaml)
* [pg_setting](conf/130-pg_setting.yaml)
* [pg_replication](conf/210-pg_replication.yaml)
* [pg_sync_standby](conf/220-pg_sync_standby.yaml)
* [pg_downstream](conf/230-pg_downstream.yaml)
* [pg_slot](conf/240-pg_slot.yaml)
* [pg_walreceiver](conf/260-pg_walreceiver.yaml)
* [pg_size](conf/310-pg_size.yaml)
* [pg_bgwriter](conf/320-pg_bgwriter.yaml)
* [pg_recovery](conf/330-pg_recovery.yaml)
* [pg_checkpoint](conf/340-pg_checkpoint.yaml)
* [pg_slru](conf/350-pg_slru.yaml)
* [pg_shmem](conf/360-pg_shmem.yaml)
* [pg_activity](conf/410-pg_activity.yaml)
* [pg_wait](conf/420-pg_wait.yaml)
* [pg_backend](conf/430-pg_backend.yaml)
* [pg_xact](conf/440-pg_xact.yaml)
* [pg_lock](conf/450-pg_lock.yaml)
* [pg_query](conf/460-pg_query.yaml)
* [pg_vacuuming](conf/510-pg_vacuuming.yaml)
* [pg_indexing](conf/520-pg_indexing.yaml)
* [pg_clustering](conf/530-pg_clustering.yaml)
* [pg_backup](conf/540-pg_backup.yaml)
* [pg_database](conf/610-pg_database.yaml)
* [pg_db](conf/620-pg_db.yaml)
* [pg_class](conf/710-pg_class.yaml)
* [pg_table](conf/720-pg_table.yaml)
* [pg_index](conf/730-pg_index.yaml)
* [pg_func](conf/740-pg_func.yaml)
* [pg_defpart](conf/750-pg_defpart.yaml)
* [pg_table_size](conf/810-pg_table_size.yaml)
* [pg_table_bloat](conf/820-pg_table_bloat.yaml)
* [pg_index_bloat](conf/830-pg_index_bloat.yaml)
* [pgbouncer_list](conf/910-pgbouncer_list.yaml)
* [pgbouncer_database](conf/920-pgbouncer_database.yaml)
* [pgbouncer_stat](conf/930-pgbouncer_stat.yaml)
* [pgbouncer_pool](conf/940-pgbouncer_pool.yaml)


`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.

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.
Expand Down
4 changes: 2 additions & 2 deletions conf/390-pg_wal.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ pg_wal_14:
description: Number of times WAL files were synced to disk via issue_xlog_fsync request
- write_time:
usage: COUNTER
description: Total amount of time spent writing WAL buffers to disk via XLogWrite request in milliseconds
description: Total amount of time spent writing WAL buffers to disk via XLogWrite request in ms
- sync_time:
usage: COUNTER
description: Total amount of time spent syncing WAL files to disk via issue_xlog_fsync request, in milliseconds
description: Total amount of time spent syncing WAL files to disk via issue_xlog_fsync request, in ms
- reset_time:
usage: COUNTER
description: When statistics were last reset
2 changes: 1 addition & 1 deletion conf/610-pg_db.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ pg_db_14:
# Time spent executing SQL statements in this database, in milliseconds (this corresponds to the states active and fastpath function call in pg_stat_activity)
- ixact_time:
usage: COUNTER
description: Time spent writing data file blocks by backends in this database, in milliseconds
description: Time spent idling while in a transaction in this database, in ms
- sessions:
usage: COUNTER
description: Total number of sessions established to this database
Expand Down
4 changes: 2 additions & 2 deletions conf/730-pg_table.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pg_table_13:

query: |
SELECT CURRENT_CATALOG AS datname, t.schemaname || '.' || t.relname AS relname, t.relid,
seq_scan,seq_tup_read,idx_scan,idx_tup_fetch,seq_scan + idx_scan AS tbl_scan, seq_tup_read + idx_tup_fetch AS tup_read,
seq_scan,seq_tup_read,idx_scan,idx_tup_fetch,coalesce(seq_scan,0) + coalesce(idx_scan,0) AS tbl_scan, coalesce(seq_tup_read,0) + coalesce(idx_tup_fetch,0) AS tup_read,
n_tup_ins,n_tup_upd,n_tup_del,(n_tup_ins + n_tup_upd + n_tup_del) AS n_tup_mod,n_tup_hot_upd,n_live_tup,n_dead_tup,
n_mod_since_analyze,n_ins_since_vacuum,last_vacuum,last_autovacuum,last_analyze,last_autoanalyze,vacuum_count,autovacuum_count,analyze_count,autoanalyze_count,
heap_blks_read,heap_blks_hit,idx_blks_read,idx_blks_hit,toast_blks_read,toast_blks_hit,tidx_blks_read,tidx_blks_hit
Expand Down Expand Up @@ -129,7 +129,7 @@ pg_table_10_12:

query: |
SELECT CURRENT_CATALOG AS datname, t.schemaname || '.' || t.relname AS relname, t.relid,
seq_scan,seq_tup_read,idx_scan,idx_tup_fetch,seq_scan + idx_scan AS tbl_scan, seq_tup_read + idx_tup_fetch AS tup_read,
seq_scan,seq_tup_read,idx_scan,idx_tup_fetch,coalesce(seq_scan,0) + coalesce(idx_scan,0) AS tbl_scan, coalesce(seq_tup_read,0) + coalesce(idx_tup_fetch,0) AS tup_read,
n_tup_ins,n_tup_upd,n_tup_del,(n_tup_ins + n_tup_upd + n_tup_del) AS n_tup_mod,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,
heap_blks_read,heap_blks_hit,idx_blks_read,idx_blks_hit,toast_blks_read,toast_blks_hit,tidx_blks_read,tidx_blks_hit
Expand Down
4 changes: 2 additions & 2 deletions pg_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ var (
constLabels = kingpin.Flag("label", "constant lables:comma separated list of label=value pair").Default("").Envar("PG_EXPORTER_LABEL").String()
serverTags = kingpin.Flag("tag", "tags,comma separated list of server tag").Default("").Envar("PG_EXPORTER_TAG").String()
disableCache = kingpin.Flag("disable-cache", "force not using cache").Default("false").Envar("PG_EXPORTER_DISABLE_CACHE").Bool()
disableIntro = kingpin.Flag("disable-intro", "disable collector level introspection metrics").Default("false").Envar("PG_EXPORTER_NAMESPACE").Bool()
disableIntro = kingpin.Flag("disable-intro", "disable collector level introspection metrics").Default("false").Envar("PG_EXPORTER_DISABLE_INTRO").Bool()
autoDiscovery = kingpin.Flag("auto-discovery", "automatically scrape all database for given server").Default("false").Envar("PG_EXPORTER_AUTO_DISCOVERY").Bool()
excludeDatabase = kingpin.Flag("exclude-database", "excluded databases when enabling auto-discovery").Default("template0,template1,postgres").Envar("PG_EXPORTER_EXCLUDE_DATABASE").String()
includeDatabase = kingpin.Flag("include-database", "included databases when enabling auto-discovery").Default("").Envar("PG_EXPORTER_EXCLUDE_DATABASE").String()
includeDatabase = kingpin.Flag("include-database", "included databases when enabling auto-discovery").Default("").Envar("PG_EXPORTER_INCLUDE_DATABASE").String()
exporterNamespace = kingpin.Flag("namespace", "prefix of built-in metrics, (pg|pgbouncer) by default").Default("").Envar("PG_EXPORTER_NAMESPACE").String()
failFast = kingpin.Flag("fail-fast", "fail fast instead of waiting during start-up").Envar("PG_EXPORTER_FAIL_FAST").Default("false").Bool()

Expand Down
10 changes: 5 additions & 5 deletions pg_exporter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1721,10 +1721,10 @@ pg_wal_14:
description: Number of times WAL files were synced to disk via issue_xlog_fsync request
- write_time:
usage: COUNTER
description: Total amount of time spent writing WAL buffers to disk via XLogWrite request in milliseconds
description: Total amount of time spent writing WAL buffers to disk via XLogWrite request in ms
- sync_time:
usage: COUNTER
description: Total amount of time spent syncing WAL files to disk via issue_xlog_fsync request, in milliseconds
description: Total amount of time spent syncing WAL files to disk via issue_xlog_fsync request, in ms
- reset_time:
usage: COUNTER
description: When statistics were last reset
Expand Down Expand Up @@ -2207,7 +2207,7 @@ pg_db_14:
# Time spent executing SQL statements in this database, in milliseconds (this corresponds to the states active and fastpath function call in pg_stat_activity)
- ixact_time:
usage: COUNTER
description: Time spent writing data file blocks by backends in this database, in milliseconds
description: Time spent idling while in a transaction in this database, in ms
- sessions:
usage: COUNTER
description: Total number of sessions established to this database
Expand Down Expand Up @@ -2601,7 +2601,7 @@ pg_table_13:

query: |
SELECT CURRENT_CATALOG AS datname, t.schemaname || '.' || t.relname AS relname, t.relid,
seq_scan,seq_tup_read,idx_scan,idx_tup_fetch,seq_scan + idx_scan AS tbl_scan, seq_tup_read + idx_tup_fetch AS tup_read,
seq_scan,seq_tup_read,idx_scan,idx_tup_fetch,coalesce(seq_scan,0) + coalesce(idx_scan,0) AS tbl_scan, coalesce(seq_tup_read,0) + coalesce(idx_tup_fetch,0) AS tup_read,
n_tup_ins,n_tup_upd,n_tup_del,(n_tup_ins + n_tup_upd + n_tup_del) AS n_tup_mod,n_tup_hot_upd,n_live_tup,n_dead_tup,
n_mod_since_analyze,n_ins_since_vacuum,last_vacuum,last_autovacuum,last_analyze,last_autoanalyze,vacuum_count,autovacuum_count,analyze_count,autoanalyze_count,
heap_blks_read,heap_blks_hit,idx_blks_read,idx_blks_hit,toast_blks_read,toast_blks_hit,tidx_blks_read,tidx_blks_hit
Expand Down Expand Up @@ -2725,7 +2725,7 @@ pg_table_10_12:

query: |
SELECT CURRENT_CATALOG AS datname, t.schemaname || '.' || t.relname AS relname, t.relid,
seq_scan,seq_tup_read,idx_scan,idx_tup_fetch,seq_scan + idx_scan AS tbl_scan, seq_tup_read + idx_tup_fetch AS tup_read,
seq_scan,seq_tup_read,idx_scan,idx_tup_fetch,coalesce(seq_scan,0) + coalesce(idx_scan,0) AS tbl_scan, coalesce(seq_tup_read,0) + coalesce(idx_tup_fetch,0) AS tup_read,
n_tup_ins,n_tup_upd,n_tup_del,(n_tup_ins + n_tup_upd + n_tup_del) AS n_tup_mod,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,
heap_blks_read,heap_blks_hit,idx_blks_read,idx_blks_hit,toast_blks_read,toast_blks_hit,tidx_blks_read,tidx_blks_hit
Expand Down

0 comments on commit f81e436

Please sign in to comment.