/
460-pg_query.yml
135 lines (131 loc) · 4.67 KB
/
460-pg_query.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
##
# SYNOPSIS
# pg_query.pg_query_13_*
#
# DESCRIPTION
# PostgreSQL Query metrics, require pg_stat_statements installed in schema monitor, pg13
#
# OPTIONS
# Tags [cluster, schema:monitor, extension:pg_stat_statements]
# TTL 10
# Priority 0
# Timeout 1s
# Fatal false
# Version 130000 ~ higher
# Source 460-pg_query.yml
#
# METRICS
# datname (LABEL)
# Name of database
# query (LABEL)
# QueryID generated from internal hash code, computed from the statement's parse tree
# calls (COUNTER)
# Number of times the statement was executed
# rows (COUNTER)
# Total number of rows retrieved or affected by the statement
# exec_time (COUNTER)
# Total time spent executing the statement, in µs
# io_time (COUNTER)
# Total time the statement spent reading and writing blocks, in µs
# wal_bytes (COUNTER)
# Total amount of WAL bytes generated by the statement
#
pg_query_13:
name: pg_query
desc: PostgreSQL Query metrics, require pg_stat_statements installed, pg13
query: |
SELECT datname, queryid AS query, sum(calls) AS calls, sum(rows) AS rows, sum(total_exec_time) AS exec_time, sum(blk_read_time) + sum(blk_write_time) AS io_time, sum(wal_bytes) AS wal_bytes
FROM pg_stat_statements(false) s JOIN pg_database d ON s.dbid = d.oid WHERE userid != 10 AND calls > 4 GROUP BY 1, 2 ORDER BY 3 DESC LIMIT 128;
ttl: 10
timeout: 1
min_version: 130000
tags:
- cluster
- extension:pg_stat_statements
metrics:
- datname:
usage: LABEL
description: Name of database
- query:
usage: LABEL
description: QueryID generated from internal hash code, computed from the statement's parse tree
- calls:
usage: COUNTER
description: Number of times the statement was executed
- rows:
usage: COUNTER
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
description: Total amount of WAL bytes generated by the statement
##
# SYNOPSIS
# pg_query.pg_query_94_12_*
#
# DESCRIPTION
# PostgreSQL query statement metrics, require pg_stat_statements installed in schema monitor, 9.4 ~ 12
#
# OPTIONS
# Tags [cluster, schema:monitor, extension:pg_stat_statements]
# TTL 10
# Priority 0
# Timeout 1s
# Fatal false
# Version 90400 ~ 130000
# Source 460-pg_query.yml
#
# METRICS
# datname (LABEL)
# Name of database
# query (LABEL)
# QueryID generated from internal hash code, computed from the statement's parse tree
# calls (COUNTER)
# Number of times the statement was executed
# rows (COUNTER)
# Total number of rows retrieved or affected by the statement
# exec_time (COUNTER)
# Total time spent executing the statement, in µs
# io_time (COUNTER)
# Total time the statement spent reading and writing blocks, in µs
#
pg_query_94_12:
name: pg_query
desc: PostgreSQL query statement metrics, require pg_stat_statements installed, 9.4 ~ 12
# note that postgres user or db and one-time job are not recorded in Monitoring System
query: SELECT datname, queryid AS query, sum(calls) AS calls, sum(rows) AS rows, sum(total_time) AS exec_time, sum(blk_read_time) + sum(blk_write_time) AS io_time FROM pg_stat_statements(false) s JOIN pg_database d ON s.dbid = d.oid WHERE userid != 10 AND calls > 4 GROUP BY 1, 2 ORDER BY 3 DESC LIMIT 128;
ttl: 10
timeout: 1
min_version: 090400
max_version: 130000
tags:
- cluster
- extension:pg_stat_statements
metrics:
- datname:
usage: LABEL
description: Name of database
- query:
usage: LABEL
description: QueryID generated from internal hash code, computed from the statement's parse tree
- calls:
usage: COUNTER
description: Number of times the statement was executed
- rows:
usage: COUNTER
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