Skip to content

Commit 54955d0

Browse files
committed
rescale pg_query pg_db pgbouncer_stat time metrics to seconds
1 parent 43b6438 commit 54955d0

File tree

7 files changed

+93
-66
lines changed

7 files changed

+93
-66
lines changed

Makefile

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#==============================================================#
22
# File : Makefile
3-
# Mtime : 2022-04-27
3+
# Mtime : 2022-05-13
44
# Copyright (C) 2018-2021 Ruohang Feng
55
#==============================================================#
66

@@ -76,8 +76,6 @@ rpm:
7676

7777
# build docker image
7878
docker: build-linux
79-
docker build -t pg_exporter .
80-
8179
docker-build:
8280
docker build -t vonng/pg_exporter .
8381
docker image tag vonng/pg_exporter vonng/pg_exporter:$(VERSION)

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ CGO_ENABLED=0 GOOS=linux go build -a -ldflags '-extldflags "-static"' -o pg_expo
164164
To build a docker image, use:
165165

166166
```
167-
docker build -t pg_exporter .
167+
make docker
168168
```
169169

170170
Or [download](https://github.com/Vonng/pg_exporter/releases) the latest prebuilt binaries from release pages.

config/collector/000-doc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#┃ Desc : pg_exporter metrics collector definition ┃#
77
#┃ Ver : PostgreSQL 10~14 pgbouncer 1.9+ ┃#
88
#┃ Ctime : 2019-12-09 ┃#
9-
#┃ Mtime : 2022-04-27 ┃#
9+
#┃ Mtime : 2022-05-13 ┃#
1010
#┃ Copyright (C) 2019-2022 Ruohang Feng ┃#
1111
#┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛#
1212
#################################################################

config/collector/460-pg_query.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,11 @@ pg_query_13:
2929
description: Total number of rows retrieved or affected by the statement
3030
- exec_time:
3131
usage: COUNTER
32+
scale: 1e-3
3233
description: Total time spent executing the statement, in µs
3334
- io_time:
3435
usage: COUNTER
36+
scale: 1e-3
3537
description: Total time the statement spent reading and writing blocks, in µs
3638
- wal_bytes:
3739
usage: COUNTER
@@ -68,8 +70,10 @@ pg_query_94_12:
6870
description: Total number of rows retrieved or affected by the statement
6971
- exec_time:
7072
usage: COUNTER
73+
scale: 1e-3
7174
description: Total time spent executing the statement, in µs
7275
- io_time:
7376
usage: COUNTER
77+
scale: 1e-3
7478
description: Total time the statement spent reading and writing blocks, in µs
7579

config/collector/610-pg_db.yml

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -105,23 +105,28 @@ pg_db_14:
105105
# 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.
106106
- blk_read_time:
107107
usage: COUNTER
108-
description: Time spent reading data file blocks by backends in this database, in ms
108+
scale: 1e-3
109+
description: Time spent reading data file blocks by backends in this database, in seconds
109110
# Time spent reading data file blocks by backends in this database, in milliseconds (if track_io_timing is enabled, otherwise zero)
110111
- blk_write_time:
111112
usage: COUNTER
112-
description: Time spent writing data file blocks by backends in this database, in ms
113+
scale: 1e-3
114+
description: Time spent writing data file blocks by backends in this database, in seconds
113115
# Time spent writing data file blocks by backends in this database, in milliseconds (if track_io_timing is enabled, otherwise zero)
114116
- session_time:
115117
usage: COUNTER
116-
description: Time spent by database sessions in this database, in ms
118+
scale: 1e-3
119+
description: Time spent by database sessions in this database, in seconds
117120
# 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)
118121
- active_time:
119122
usage: COUNTER
120-
description: Time spent executing SQL statements in this database, in ms
123+
scale: 1e-3
124+
description: Time spent executing SQL statements in this database, in seconds
121125
# Time spent executing SQL statements in this database, in milliseconds (this corresponds to the states active and fastpath function call in pg_stat_activity)
122126
- ixact_time:
123127
usage: COUNTER
124-
description: Time spent idling while in a transaction in this database, in ms
128+
scale: 1e-3
129+
description: Time spent idling while in a transaction in this database, in seconds
125130
- sessions:
126131
usage: COUNTER
127132
description: Total number of sessions established to this database
@@ -246,11 +251,13 @@ pg_db_12_13:
246251
# 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.
247252
- blk_read_time:
248253
usage: COUNTER
249-
description: Time spent reading data file blocks by backends in this database, in ms
254+
scale: 1e-3
255+
description: Time spent reading data file blocks by backends in this database, in seconds
250256
# Time spent reading data file blocks by backends in this database, in milliseconds (if track_io_timing is enabled, otherwise zero)
251257
- blk_write_time:
252258
usage: COUNTER
253-
description: Time spent writing data file blocks by backends in this database, in ms
259+
scale: 1e-3
260+
description: Time spent writing data file blocks by backends in this database, in seconds
254261
# Time spent writing data file blocks by backends in this database, in milliseconds (if track_io_timing is enabled, otherwise zero)
255262
- reset_time:
256263
usage: COUNTER
@@ -355,11 +362,13 @@ pg_db_10_11:
355362
description: Number of deadlocks detected in this database
356363
- blk_read_time:
357364
usage: COUNTER
358-
description: Time spent reading data file blocks by backends in this database, in ms
365+
scale: 1e-3
366+
description: Time spent reading data file blocks by backends in this database, in seconds
359367
# Time spent reading data file blocks by backends in this database, in milliseconds (if track_io_timing is enabled, otherwise zero)
360368
- blk_write_time:
361369
usage: COUNTER
362-
description: Time spent writing data file blocks by backends in this database, in ms
370+
scale: 1e-3
371+
description: Time spent writing data file blocks by backends in this database, in seconds
363372
# Time spent writing data file blocks by backends in this database, in milliseconds (if track_io_timing is enabled, otherwise zero)
364373
- reset_time:
365374
usage: COUNTER

config/collector/930-pgbouncer_stat.yml

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@
77
#┃ pgbouncer_stat_total_query_count{datname} GAUGE Total number of SQL queries pooled by pgbouncer
88
#┃ pgbouncer_stat_total_received{datname} COUNTER Total volume in bytes of network traffic received by pgbouncer
99
#┃ pgbouncer_stat_total_sent{datname} COUNTER Total volume in bytes of network traffic sent by pgbouncer
10-
#┃ pgbouncer_stat_total_xact_time{datname} COUNTER Total number of microseconds spent when in a transaction
11-
#┃ pgbouncer_stat_total_query_time{datname} COUNTER Total number of microseconds spent when executing queries
12-
#┃ pgbouncer_stat_total_wait_time{datname} COUNTER Time spent by clients waiting for a server, in microseconds
10+
#┃ pgbouncer_stat_total_xact_time{datname} COUNTER Total number of seconds spent when in a transaction
11+
#┃ pgbouncer_stat_total_query_time{datname} COUNTER Total number of seconds spent when executing queries
12+
#┃ pgbouncer_stat_total_wait_time{datname} COUNTER Time spent by clients waiting for a server, in seconds
1313
#┃ pgbouncer_stat_avg_xact_count{datname} GAUGE Average transactions per second in last stat period
1414
#┃ pgbouncer_stat_avg_query_count{datname} GAUGE Average queries per second in last stat period
1515
#┃ pgbouncer_stat_avg_recv{datname} GAUGE Average received (from clients) bytes per second
1616
#┃ pgbouncer_stat_avg_sent{datname} GAUGE Average sent (to clients) bytes per second
17-
#┃ pgbouncer_stat_avg_xact_time{datname} GAUGE Average transaction duration, in microseconds
18-
#┃ pgbouncer_stat_avg_query_time{datname} GAUGE Average query duration, in microseconds
19-
#┃ pgbouncer_stat_avg_wait_time{datname} GAUGE Time spent by clients waiting for a server, in microseconds (average per second).
17+
#┃ pgbouncer_stat_avg_xact_time{datname} GAUGE Average transaction duration, in seconds
18+
#┃ pgbouncer_stat_avg_query_time{datname} GAUGE Average query duration, in seconds
19+
#┃ pgbouncer_stat_avg_wait_time{datname} GAUGE Time spent by clients waiting for a server, in seconds (average per second).
2020
#┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
2121
pgbouncer_stat:
2222
name: pgbouncer_stat
@@ -46,13 +46,16 @@ pgbouncer_stat:
4646
description: Total volume in bytes of network traffic sent by pgbouncer
4747
- total_xact_time:
4848
usage: COUNTER
49-
description: Total number of microseconds spent when in a transaction
49+
scale: 1e-6
50+
description: Total number of seconds spent when in a transaction
5051
- total_query_time:
5152
usage: COUNTER
52-
description: Total number of microseconds spent when executing queries
53+
scale: 1e-6
54+
description: Total number of seconds spent when executing queries
5355
- total_wait_time:
5456
usage: COUNTER
55-
description: Time spent by clients waiting for a server, in microseconds
57+
scale: 1e-6
58+
description: Time spent by clients waiting for a server, in seconds
5659
- avg_xact_count:
5760
usage: GAUGE
5861
description: Average transactions per second in last stat period
@@ -67,11 +70,14 @@ pgbouncer_stat:
6770
description: Average sent (to clients) bytes per second
6871
- avg_xact_time:
6972
usage: GAUGE
70-
description: Average transaction duration, in microseconds
73+
scale: 1e-6
74+
description: Average transaction duration, in seconds
7175
- avg_query_time:
7276
usage: GAUGE
73-
description: Average query duration, in microseconds
77+
scale: 1e-6
78+
description: Average query duration, in seconds
7479
- avg_wait_time:
7580
usage: GAUGE
76-
description: Time spent by clients waiting for a server, in microseconds (average per second).
81+
scale: 1e-6
82+
description: Time spent by clients waiting for a server, in seconds (average per second).
7783

0 commit comments

Comments
 (0)