-
Notifications
You must be signed in to change notification settings - Fork 45
/
450-pg_lock.yml
49 lines (45 loc) · 1.53 KB
/
450-pg_lock.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
##
# SYNOPSIS
# pg_lock_*
#
# DESCRIPTION
# PostgreSQL lock distribution by mode and database
#
# OPTIONS
# Tags [cluster]
# TTL 10
# Priority 0
# Timeout 100ms
# Fatal false
# Version 90400 ~ higher
# Source 450-pg_lock.yml
#
# METRICS
# datname (LABEL)
# Name of the database this backend is connected to
# mode (LABEL)
# Name of the lock mode held or desired by this process
# count (GAUGE)
# Number of locks of corresponding mode and database
#
pg_lock:
name: pg_lock
desc: PostgreSQL lock distribution by mode and database
query: |
SELECT datname, mode, coalesce(count, 0) AS count
FROM (SELECT d.oid AS database, d.datname, l.mode FROM pg_database d, unnest(ARRAY ['AccessShareLock','RowShareLock','RowExclusiveLock','ShareUpdateExclusiveLock', 'ShareLock','ShareRowExclusiveLock','ExclusiveLock','AccessExclusiveLock']) l(mode) WHERE d.datallowconn AND NOT d.datistemplate) base
LEFT JOIN (SELECT database, mode, count(*) AS count FROM pg_locks WHERE database IS NOT NULL GROUP BY 1, 2) cnt USING (database, mode);
ttl: 10
min_version: 090400
tags:
- cluster
metrics:
- datname:
usage: LABEL
description: Name of the database this backend is connected to
- mode:
usage: LABEL
description: Name of the lock mode held or desired by this process
- count:
usage: GAUGE
description: Number of locks of corresponding mode and database