Skip to content

Commit

Permalink
rescale pg_query pg_db pgbouncer_stat time metrics to seconds
Browse files Browse the repository at this point in the history
  • Loading branch information
Vonng committed May 13, 2022
1 parent 43b6438 commit 54955d0
Show file tree
Hide file tree
Showing 7 changed files with 93 additions and 66 deletions.
4 changes: 1 addition & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#==============================================================#
# File : Makefile
# Mtime : 2022-04-27
# Mtime : 2022-05-13
# Copyright (C) 2018-2021 Ruohang Feng
#==============================================================#

Expand Down Expand Up @@ -76,8 +76,6 @@ rpm:

# build docker image
docker: build-linux
docker build -t pg_exporter .

docker-build:
docker build -t vonng/pg_exporter .
docker image tag vonng/pg_exporter vonng/pg_exporter:$(VERSION)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ CGO_ENABLED=0 GOOS=linux go build -a -ldflags '-extldflags "-static"' -o pg_expo
To build a docker image, use:

```
docker build -t pg_exporter .
make docker
```

Or [download](https://github.com/Vonng/pg_exporter/releases) the latest prebuilt binaries from release pages.
Expand Down
2 changes: 1 addition & 1 deletion config/collector/000-doc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#┃ Desc : pg_exporter metrics collector definition ┃#
#┃ Ver : PostgreSQL 10~14 pgbouncer 1.9+ ┃#
#┃ Ctime : 2019-12-09 ┃#
#┃ Mtime : 2022-04-27 ┃#
#┃ Mtime : 2022-05-13 ┃#
#┃ Copyright (C) 2019-2022 Ruohang Feng ┃#
#┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛#
#################################################################
Expand Down
4 changes: 4 additions & 0 deletions config/collector/460-pg_query.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@ pg_query_13:
description: Total number of rows retrieved or affected by the statement
- exec_time:
usage: COUNTER
scale: 1e-3
description: Total time spent executing the statement, in µs
- io_time:
usage: COUNTER
scale: 1e-3
description: Total time the statement spent reading and writing blocks, in µs
- wal_bytes:
usage: COUNTER
Expand Down Expand Up @@ -68,8 +70,10 @@ pg_query_94_12:
description: Total number of rows retrieved or affected by the statement
- exec_time:
usage: COUNTER
scale: 1e-3
description: Total time spent executing the statement, in µs
- io_time:
usage: COUNTER
scale: 1e-3
description: Total time the statement spent reading and writing blocks, in µs

27 changes: 18 additions & 9 deletions config/collector/610-pg_db.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,23 +105,28 @@ pg_db_14:
# Time at which the last data page checksum failure was detected in this database (or on a shared object), or NULL if data checksums are not enabled.
- blk_read_time:
usage: COUNTER
description: Time spent reading data file blocks by backends in this database, in ms
scale: 1e-3
description: Time spent reading data file blocks by backends in this database, in seconds
# Time spent reading data file blocks by backends in this database, in milliseconds (if track_io_timing is enabled, otherwise zero)
- blk_write_time:
usage: COUNTER
description: Time spent writing data file blocks by backends in this database, in ms
scale: 1e-3
description: Time spent writing data file blocks by backends in this database, in seconds
# Time spent writing data file blocks by backends in this database, in milliseconds (if track_io_timing is enabled, otherwise zero)
- session_time:
usage: COUNTER
description: Time spent by database sessions in this database, in ms
scale: 1e-3
description: Time spent by database sessions in this database, in seconds
# Time spent by database sessions in this database, in milliseconds (note that statistics are only updated when the state of a session changes, so if sessions have been idle for a long time, this idle time won't be included)
- active_time:
usage: COUNTER
description: Time spent executing SQL statements in this database, in ms
scale: 1e-3
description: Time spent executing SQL statements in this database, in seconds
# 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 idling while in a transaction in this database, in ms
scale: 1e-3
description: Time spent idling while in a transaction in this database, in seconds
- sessions:
usage: COUNTER
description: Total number of sessions established to this database
Expand Down Expand Up @@ -246,11 +251,13 @@ pg_db_12_13:
# Time at which the last data page checksum failure was detected in this database (or on a shared object), or NULL if data checksums are not enabled.
- blk_read_time:
usage: COUNTER
description: Time spent reading data file blocks by backends in this database, in ms
scale: 1e-3
description: Time spent reading data file blocks by backends in this database, in seconds
# Time spent reading data file blocks by backends in this database, in milliseconds (if track_io_timing is enabled, otherwise zero)
- blk_write_time:
usage: COUNTER
description: Time spent writing data file blocks by backends in this database, in ms
scale: 1e-3
description: Time spent writing data file blocks by backends in this database, in seconds
# Time spent writing data file blocks by backends in this database, in milliseconds (if track_io_timing is enabled, otherwise zero)
- reset_time:
usage: COUNTER
Expand Down Expand Up @@ -355,11 +362,13 @@ pg_db_10_11:
description: Number of deadlocks detected in this database
- blk_read_time:
usage: COUNTER
description: Time spent reading data file blocks by backends in this database, in ms
scale: 1e-3
description: Time spent reading data file blocks by backends in this database, in seconds
# Time spent reading data file blocks by backends in this database, in milliseconds (if track_io_timing is enabled, otherwise zero)
- blk_write_time:
usage: COUNTER
description: Time spent writing data file blocks by backends in this database, in ms
scale: 1e-3
description: Time spent writing data file blocks by backends in this database, in seconds
# Time spent writing data file blocks by backends in this database, in milliseconds (if track_io_timing is enabled, otherwise zero)
- reset_time:
usage: COUNTER
Expand Down
30 changes: 18 additions & 12 deletions config/collector/930-pgbouncer_stat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@
#┃ pgbouncer_stat_total_query_count{datname} GAUGE Total number of SQL queries pooled by pgbouncer
#┃ pgbouncer_stat_total_received{datname} COUNTER Total volume in bytes of network traffic received by pgbouncer
#┃ pgbouncer_stat_total_sent{datname} COUNTER Total volume in bytes of network traffic sent by pgbouncer
#┃ pgbouncer_stat_total_xact_time{datname} COUNTER Total number of microseconds spent when in a transaction
#┃ pgbouncer_stat_total_query_time{datname} COUNTER Total number of microseconds spent when executing queries
#┃ pgbouncer_stat_total_wait_time{datname} COUNTER Time spent by clients waiting for a server, in microseconds
#┃ pgbouncer_stat_total_xact_time{datname} COUNTER Total number of seconds spent when in a transaction
#┃ pgbouncer_stat_total_query_time{datname} COUNTER Total number of seconds spent when executing queries
#┃ pgbouncer_stat_total_wait_time{datname} COUNTER Time spent by clients waiting for a server, in seconds
#┃ pgbouncer_stat_avg_xact_count{datname} GAUGE Average transactions per second in last stat period
#┃ pgbouncer_stat_avg_query_count{datname} GAUGE Average queries per second in last stat period
#┃ pgbouncer_stat_avg_recv{datname} GAUGE Average received (from clients) bytes per second
#┃ pgbouncer_stat_avg_sent{datname} GAUGE Average sent (to clients) bytes per second
#┃ pgbouncer_stat_avg_xact_time{datname} GAUGE Average transaction duration, in microseconds
#┃ pgbouncer_stat_avg_query_time{datname} GAUGE Average query duration, in microseconds
#┃ pgbouncer_stat_avg_wait_time{datname} GAUGE Time spent by clients waiting for a server, in microseconds (average per second).
#┃ pgbouncer_stat_avg_xact_time{datname} GAUGE Average transaction duration, in seconds
#┃ pgbouncer_stat_avg_query_time{datname} GAUGE Average query duration, in seconds
#┃ pgbouncer_stat_avg_wait_time{datname} GAUGE Time spent by clients waiting for a server, in seconds (average per second).
#┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
pgbouncer_stat:
name: pgbouncer_stat
Expand Down Expand Up @@ -46,13 +46,16 @@ pgbouncer_stat:
description: Total volume in bytes of network traffic sent by pgbouncer
- total_xact_time:
usage: COUNTER
description: Total number of microseconds spent when in a transaction
scale: 1e-6
description: Total number of seconds spent when in a transaction
- total_query_time:
usage: COUNTER
description: Total number of microseconds spent when executing queries
scale: 1e-6
description: Total number of seconds spent when executing queries
- total_wait_time:
usage: COUNTER
description: Time spent by clients waiting for a server, in microseconds
scale: 1e-6
description: Time spent by clients waiting for a server, in seconds
- avg_xact_count:
usage: GAUGE
description: Average transactions per second in last stat period
Expand All @@ -67,11 +70,14 @@ pgbouncer_stat:
description: Average sent (to clients) bytes per second
- avg_xact_time:
usage: GAUGE
description: Average transaction duration, in microseconds
scale: 1e-6
description: Average transaction duration, in seconds
- avg_query_time:
usage: GAUGE
description: Average query duration, in microseconds
scale: 1e-6
description: Average query duration, in seconds
- avg_wait_time:
usage: GAUGE
description: Time spent by clients waiting for a server, in microseconds (average per second).
scale: 1e-6
description: Time spent by clients waiting for a server, in seconds (average per second).

Loading

0 comments on commit 54955d0

Please sign in to comment.