-
Notifications
You must be signed in to change notification settings - Fork 45
/
810-pg_table_size.yml
69 lines (67 loc) · 2.05 KB
/
810-pg_table_size.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
##
# SYNOPSIS
# pg_table_size_*
#
# DESCRIPTION
# PostgreSQL table size metrics, quite slow
#
# OPTIONS
# Tags []
# TTL 300
# Priority 0
# Timeout 2s
# Fatal false
# Version 100000 ~ higher
# Source 810-pg_table_size.yml
#
# METRICS
# datname (LABEL)
# Database name of this table
# relname (LABEL)
# Schema qualified table name
# bytes (GAUGE)
# Total bytes of this table (including toast, index, toast index)
# relsize (GAUGE)
# Bytes of this table itself (main, vm, fsm)
# indexsize (GAUGE)
# Bytes of all related indexes of this table
# toastsize (GAUGE)
# Bytes of toast tables of this table
#
pg_table_size:
desc: PostgreSQL table size metrics, quite slow
query: |
SELECT CURRENT_CATALOG AS datname, nsp.nspname || '.' || rel.relname AS relname,
pg_total_relation_size(rel.oid) AS bytes,
pg_relation_size(rel.oid) AS relsize,
pg_indexes_size(rel.oid) AS indexsize,
pg_total_relation_size(reltoastrelid) AS toastsize
FROM pg_namespace nsp JOIN pg_class rel ON nsp.oid = rel.relnamespace
WHERE nspname <> ALL(ARRAY['pg_catalog', 'information_schema']) AND rel.relkind = 'r'
ORDER BY 3 DESC NULLS LAST LIMIT 256;
ttl: 300
timeout: 2
min_version: 100000
metrics:
- datname:
usage: LABEL
description: Database name of this table
- relname:
usage: LABEL
description: Schema qualified table name
- bytes:
usage: GAUGE
default: 0
description: Total bytes of this table (including toast, index, toast index)
- relsize:
usage: GAUGE
default: 0
description: Bytes of this table itself (main, vm, fsm)
- indexsize:
usage: GAUGE
default: 0
description: Bytes of all related indexes of this table
- toastsize:
usage: GAUGE
default: 0
description: Bytes of toast tables of this table