You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2726 lines
111 KiB

zabbix_export:
version: '7.0'
template_groups:
- uuid: 748ad4d098d447d492bb935c907f652f
name: Templates/Databases
templates:
- uuid: e0a7c3e725c445228b03116dc6114fe9
template: 'PostgreSQL by ODBC'
name: 'PostgreSQL by ODBC'
description: |
This template is designed for the effortless deployment of PostgreSQL monitoring by Zabbix via ODBC and doesn't require any external scripts.
Setup:
1. Create the PostgreSQL user for monitoring (`<password>` at your discretion) and inherit permissions from the default role `pg_monitor`:
CREATE USER zbx_monitor WITH PASSWORD '<PASSWORD>' INHERIT;
GRANT pg_monitor TO zbx_monitor;
2. Edit the `pg_hba.conf` configuration file to allow TCP connections for the user `zbx_monitor`. You can check the PostgreSQL documentation for examples (https://www.postgresql.org/docs/current/auth-pg-hba-conf.html).
3. Install the PostgreSQL ODBC driver.
4. Set up the connection string with the `{$PG.CONNSTRING}` macro. The minimum required parameters are:
- `Driver=` - set the name of the driver which will be used for monitoring (from the `odbcinst.ini` file) or specify the path to the driver file (for example `/usr/lib64/psqlodbcw.so`);
- `Servername=` - set the host name or IP address of the PostgreSQL instance;
- `Port=` - adjust the port number if needed.
If you want to use SSL/TLS encryption to protect communications with the remote PostgreSQL instance, you can also specify encryption parameters here.
It is assumed that you set up the PostgreSQL instance to work in the desired encryption mode. Check the PostgreSQL documentation (https://www.postgresql.org/docs/current/ssl-tcp.html) for details.
For example, to enable required encryption in transport mode without identity checks, the connection string could look like this (replace `<instanceip>` with the address of the PostgreSQL instance):
Servername=<instanceip>;Port=5432;Driver=/usr/lib64/psqlodbcw.so;SSLmode=require
5. Set the password that you specified in step 1 in the macro `{$PG.PASSWORD}`.
You can discuss this template or leave feedback on our forum https://www.zabbix.com/forum/zabbix-suggestions-and-feedback/384190-%C2%A0discussion-thread-for-official-zabbix-template-db-postgresql
Generated by official Zabbix template tool "Templator" 2.0.0
vendor:
name: Zabbix
version: 7.0-0
groups:
- name: Templates/Databases
items:
- uuid: 9440208c49134347809eff39109c644f
name: 'PostgreSQL: Get archive'
type: ODBC
key: 'db.odbc.select[pgsql.archive,,"Database={$PG.DATABASE};{$PG.CONNSTRING}"]'
history: '0'
trends: '0'
value_type: TEXT
params: |
WITH values AS (
SELECT
4096/(ceil(pg_settings.setting::numeric/1024/1024))::int AS segment_parts_count,
setting::bigint AS segment_size,
('x' || substring(pg_stat_archiver.last_archived_wal from 9 for 8))::bit(32)::int AS last_wal_div,
('x' || substring(pg_stat_archiver.last_archived_wal from 17 for 8))::bit(32)::int AS last_wal_mod,
CASE WHEN pg_is_in_recovery() THEN NULL
ELSE ('x' || substring(pg_walfile_name(pg_current_wal_lsn()) from 9 for 8))::bit(32)::int END AS current_wal_div,
CASE WHEN pg_is_in_recovery() THEN NULL
ELSE ('x' || substring(pg_walfile_name(pg_current_wal_lsn()) from 17 for 8))::bit(32)::int END AS current_wal_mod
FROM pg_settings, pg_stat_archiver
WHERE pg_settings.name = 'wal_segment_size')
SELECT json_build_object(
'archived_count', (SELECT archived_count FROM pg_stat_archiver),
'failed_count', (SELECT failed_count FROM pg_stat_archiver),
'count_files', (SELECT greatest(coalesce((segment_parts_count - last_wal_mod) + ((current_wal_div - last_wal_div - 1) * segment_parts_count) + current_wal_mod - 1, 0), 0) FROM values),
'size_files', (SELECT greatest(coalesce(((segment_parts_count - last_wal_mod) + ((current_wal_div - last_wal_div - 1) * segment_parts_count) + current_wal_mod - 1) * segment_size, 0), 0) FROM values)
) AS result
username: '{$PG.USER}'
password: '{$PG.PASSWORD}'
description: 'Collect archive status metrics.'
tags:
- tag: component
value: raw
- uuid: dd79edeb2d65420fb58d587e411c440f
name: 'PostgreSQL: Count of autovacuum workers'
type: ODBC
key: 'db.odbc.select[pgsql.autovacuum.count,,"Database={$PG.DATABASE};{$PG.CONNSTRING}"]'
history: 7d
value_type: FLOAT
params: |
SELECT count(*)
FROM pg_catalog.pg_stat_activity
WHERE query like '%%autovacuum%%'
AND state <> 'idle'
AND pid <> pg_catalog.pg_backend_pid()
username: '{$PG.USER}'
password: '{$PG.PASSWORD}'
description: 'Number of autovacuum workers.'
tags:
- tag: component
value: system
- uuid: ec6e574448804ed5bb71fa6dafa3b3f8
name: 'PostgreSQL: Get bgwriter'
type: ODBC
key: 'db.odbc.select[pgsql.bgwriter,,"Database={$PG.DATABASE};{$PG.CONNSTRING}"]'
history: '0'
trends: '0'
value_type: TEXT
params: |
SELECT row_to_json(T) FROM (
SELECT checkpoints_timed,
checkpoints_req,
checkpoint_write_time,
checkpoint_sync_time,
current_setting('block_size')::int*buffers_checkpoint AS buffers_checkpoint,
current_setting('block_size')::int*buffers_clean AS buffers_clean,
maxwritten_clean,
current_setting('block_size')::int*buffers_backend AS buffers_backend,
buffers_backend_fsync,
current_setting('block_size')::int*buffers_alloc AS buffers_alloc
FROM pg_stat_bgwriter) T
username: '{$PG.USER}'
password: '{$PG.PASSWORD}'
description: |
Collect all metrics from pg_stat_bgwriter:
https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-BGWRITER-VIEW
tags:
- tag: component
value: raw
- uuid: 1d267b6aed064d03b4f464b27c1e897e
name: 'PostgreSQL: Get connections sum'
type: ODBC
key: 'db.odbc.select[pgsql.connections.sum,,"Database={$PG.DATABASE};{$PG.CONNSTRING}"]'
history: '0'
trends: '0'
value_type: TEXT
params: |
SELECT row_to_json(T)
FROM (
SELECT
sum(CASE WHEN state = 'active' THEN 1 ELSE 0 END) AS active,
sum(CASE WHEN state = 'idle' THEN 1 ELSE 0 END) AS idle,
sum(CASE WHEN state = 'idle in transaction' THEN 1 ELSE 0 END) AS idle_in_transaction,
sum(CASE WHEN state = 'idle in transaction (aborted)' THEN 1 ELSE 0 END) AS idle_in_transaction_aborted,
sum(CASE WHEN state = 'fastpath function call' THEN 1 ELSE 0 END) AS fastpath_function_call,
sum(CASE WHEN state = 'disabled' THEN 1 ELSE 0 END) AS disabled,
count(*) AS total,
count(*)*100/(SELECT current_setting('max_connections')::int) AS total_pct,
sum(CASE WHEN wait_event IS NOT NULL THEN 1 ELSE 0 END) AS waiting,
(SELECT count(*) FROM pg_prepared_xacts) AS prepared
FROM pg_stat_activity WHERE datid IS NOT NULL AND state IS NOT NULL) T
username: '{$PG.USER}'
password: '{$PG.PASSWORD}'
description: |
Collect all metrics from pg_stat_activity:
https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-ACTIVITY-VIEW
tags:
- tag: component
value: raw
- uuid: 0f93764d56574a288467ad16dce11a17
name: 'PostgreSQL: Get dbstat'
type: ODBC
key: 'db.odbc.select[pgsql.dbstat,,"Database={$PG.DATABASE};{$PG.CONNSTRING}"]'
history: '0'
trends: '0'
value_type: TEXT
params: |
SELECT json_object_agg(coalesce (datname,'null'), row_to_json(T)) FROM (
SELECT datname,
numbackends AS numbackends,
xact_commit AS xact_commit,
xact_rollback AS xact_rollback,
blks_read AS blks_read,
blks_hit AS blks_hit,
tup_returned AS tup_returned,
tup_fetched AS tup_fetched,
tup_inserted AS tup_inserted,
tup_updated AS tup_updated,
tup_deleted AS tup_deleted,
conflicts AS conflicts,
temp_files AS temp_files,
temp_bytes AS temp_bytes,
deadlocks AS deadlocks,
blk_read_time AS blk_read_time,
blk_write_time AS blk_write_time
FROM pg_catalog.pg_stat_database WHERE datname IS NOT NULL) T;
username: '{$PG.USER}'
password: '{$PG.PASSWORD}'
description: |
Collect all metrics from pg_stat_database per database:
https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-DATABASE-VIEW
tags:
- tag: component
value: raw
- uuid: 6ea1a17fad8b4ef3aba8b49a0922a77d
name: 'PostgreSQL: Get dbstat sum'
type: ODBC
key: 'db.odbc.select[pgsql.dbstat.sum,,"Database={$PG.DATABASE};{$PG.CONNSTRING}"]'
history: '0'
trends: '0'
value_type: TEXT
params: |
SELECT row_to_json(T) FROM (
SELECT sum(numbackends) AS numbackends,
sum(xact_commit) AS xact_commit,
sum(xact_rollback) AS xact_rollback,
sum(blks_read) AS blks_read,
sum(blks_hit) AS blks_hit,
sum(tup_returned) AS tup_returned,
sum(tup_fetched) AS tup_fetched,
sum(tup_inserted) AS tup_inserted,
sum(tup_updated) AS tup_updated,
sum(tup_deleted) AS tup_deleted,
sum(conflicts) AS conflicts,
sum(temp_files) AS temp_files,
sum(temp_bytes) AS temp_bytes,
sum(deadlocks) AS deadlocks,
sum(blk_read_time) AS blk_read_time,
sum(blk_write_time) AS blk_write_time
FROM pg_stat_database) T
username: '{$PG.USER}'
password: '{$PG.PASSWORD}'
description: |
Collect all metrics from pg_stat_database as sums for all databases:
https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-DATABASE-VIEW
tags:
- tag: component
value: raw
- uuid: efa015e294684fdeb711a0fde1256cf9
name: 'PostgreSQL: Get locks'
type: ODBC
key: 'db.odbc.select[pgsql.locks,,"Database={$PG.DATABASE};{$PG.CONNSTRING}"]'
history: '0'
trends: '0'
value_type: TEXT
params: |
WITH T AS
(SELECT db.datname dbname,
lower(replace(Q.mode, 'Lock', '')) AS MODE,
coalesce(T.qty, 0) val
FROM pg_database db
JOIN (
VALUES ('AccessShareLock') ,('RowShareLock') ,('RowExclusiveLock') ,('ShareUpdateExclusiveLock') ,('ShareLock') ,('ShareRowExclusiveLock') ,('ExclusiveLock') ,('AccessExclusiveLock')) Q(MODE) ON TRUE NATURAL
LEFT JOIN
(SELECT datname,
MODE,
count(MODE) qty
FROM pg_locks lc
RIGHT JOIN pg_database db ON db.oid = lc.database
GROUP BY 1, 2) T
WHERE NOT db.datistemplate
ORDER BY 1, 2)
SELECT json_object_agg(dbname, row_to_json(T2))
FROM
(SELECT dbname,
sum(val) AS total,
sum(CASE
WHEN MODE = 'accessexclusive' THEN val
END) AS accessexclusive,
sum(CASE
WHEN MODE = 'accessshare' THEN val
END) AS accessshare,
sum(CASE
WHEN MODE = 'exclusive' THEN val
END) AS EXCLUSIVE,
sum(CASE
WHEN MODE = 'rowexclusive' THEN val
END) AS rowexclusive,
sum(CASE
WHEN MODE = 'rowshare' THEN val
END) AS rowshare,
sum(CASE
WHEN MODE = 'share' THEN val
END) AS SHARE,
sum(CASE
WHEN MODE = 'sharerowexclusive' THEN val
END) AS sharerowexclusive,
sum(CASE
WHEN MODE = 'shareupdateexclusive' THEN val
END) AS shareupdateexclusive
FROM T
GROUP BY dbname) T2
username: '{$PG.USER}'
password: '{$PG.PASSWORD}'
description: |
Collect all metrics from pg_locks per database:
https://www.postgresql.org/docs/current/explicit-locking.html#LOCKING-TABLES
tags:
- tag: component
value: raw
- uuid: 266a9b5c1e604d97ac5a74ccdb598c97
name: 'PostgreSQL: Age of oldest xid'
type: ODBC
key: 'db.odbc.select[pgsql.oldest.xid,,"Database={$PG.DATABASE};{$PG.CONNSTRING}"]'
history: 7d
value_type: FLOAT
params: |
SELECT greatest(max(age(backend_xmin)), max(age(backend_xid)))
FROM pg_catalog.pg_stat_activity
username: '{$PG.USER}'
password: '{$PG.PASSWORD}'
description: 'Age of oldest xid.'
tags:
- tag: component
value: transactions
triggers:
- uuid: 4d32971898d441fb94d5f029649dddfa
expression: 'last(/PostgreSQL by ODBC/db.odbc.select[pgsql.oldest.xid,,"Database={$PG.DATABASE};{$PG.CONNSTRING}"]) > 18000000'
name: 'PostgreSQL: Oldest xid is too big'
priority: AVERAGE
tags:
- tag: scope
value: availability
- uuid: 3c16a3c2db7641c2b6958649d7b4809e
name: 'PostgreSQL: Ping'
type: ODBC
key: 'db.odbc.select[pgsql.ping,,"Database={$PG.DATABASE};{$PG.CONNSTRING}"]'
history: 7d
params: 'SELECT 1'
username: '{$PG.USER}'
password: '{$PG.PASSWORD}'
description: 'Used to test a connection to see if it is alive. It is set to 0 if the query is unsuccessful.'
valuemap:
name: 'Service state'
preprocessing:
- type: CHECK_NOT_SUPPORTED
parameters:
- ''
error_handler: CUSTOM_VALUE
error_handler_params: '0'
- type: DISCARD_UNCHANGED_HEARTBEAT
parameters:
- 1h
tags:
- tag: component
value: application
- tag: component
value: health
triggers:
- uuid: 758e569b51954fcf82c7cb3fa391c882
expression: 'last(/PostgreSQL by ODBC/db.odbc.select[pgsql.ping,,"Database={$PG.DATABASE};{$PG.CONNSTRING}"])=0'
name: 'PostgreSQL: Service is down'
priority: HIGH
description: 'Last test of a connection was unsuccessful.'
tags:
- tag: scope
value: availability
- uuid: ee6b3f64e07d4acd875dbd83dccd51d0
name: 'PostgreSQL: Get queries'
type: ODBC
key: 'db.odbc.select[pgsql.queries,,"Database={$PG.DATABASE};{$PG.CONNSTRING}"]'
history: '0'
trends: '0'
value_type: TEXT
params: |
WITH T AS
(SELECT db.datname,
coalesce(T.query_time_max, 0) query_time_max,
coalesce(T.tx_time_max, 0) tx_time_max,
coalesce(T.mro_time_max, 0) mro_time_max,
coalesce(T.query_time_sum, 0) query_time_sum,
coalesce(T.tx_time_sum, 0) tx_time_sum,
coalesce(T.mro_time_sum, 0) mro_time_sum,
coalesce(T.query_slow_count, 0) query_slow_count,
coalesce(T.tx_slow_count, 0) tx_slow_count,
coalesce(T.mro_slow_count, 0) mro_slow_count
FROM pg_database db NATURAL
LEFT JOIN (
SELECT datname,
extract(epoch FROM now())::integer ts,
coalesce(max(extract('epoch' FROM (clock_timestamp() - query_start))::integer * (state NOT IN ('idle', 'idle in transaction', 'idle in transaction (aborted)') AND query !~* E'^(\\s*(--[^\\n]*\\n|/\\*.*\\*/|\\n))*(autovacuum|VACUUM|ANALYZE|REINDEX|CLUSTER|CREATE|ALTER|TRUNCATE|DROP)')::integer), 0) query_time_max,
coalesce(max(extract('epoch' FROM (clock_timestamp() - query_start))::integer * (state NOT IN ('idle') AND query !~* E'^(\\s*(--[^\\n]*\\n|/\\*.*\\*/|\\n))*(autovacuum|VACUUM|ANALYZE|REINDEX|CLUSTER|CREATE|ALTER|TRUNCATE|DROP)')::integer), 0) tx_time_max,
coalesce(max(extract('epoch' FROM (clock_timestamp() - query_start))::integer * (state NOT IN ('idle') AND query ~* E'^(\\s*(--[^\\n]*\\n|/\\*.*\\*/|\\n))*(autovacuum|VACUUM|ANALYZE|REINDEX|CLUSTER|CREATE|ALTER|TRUNCATE|DROP)')::integer), 0) mro_time_max,
coalesce(sum(extract('epoch' FROM (clock_timestamp() - query_start))::integer * (state NOT IN ('idle', 'idle in transaction', 'idle in transaction (aborted)') AND query !~* E'^(\\s*(--[^\\n]*\\n|/\\*.*\\*/|\\n))*(autovacuum|VACUUM|ANALYZE|REINDEX|CLUSTER|CREATE|ALTER|TRUNCATE|DROP)')::integer), 0) query_time_sum,
coalesce(sum(extract('epoch' FROM (clock_timestamp() - query_start))::integer * (state NOT IN ('idle') AND query !~* E'^(\\s*(--[^\\n]*\\n|/\\*.*\\*/|\\n))*(autovacuum|VACUUM|ANALYZE|REINDEX|CLUSTER|CREATE|ALTER|TRUNCATE|DROP)')::integer), 0) tx_time_sum,
coalesce(sum(extract('epoch' FROM (clock_timestamp() - query_start))::integer * (state NOT IN ('idle') AND query ~* E'^(\\s*(--[^\\n]*\\n|/\\*.*\\*/|\\n))*(autovacuum|VACUUM|ANALYZE|REINDEX|CLUSTER|CREATE|ALTER|TRUNCATE|DROP)')::integer), 0) mro_time_sum,
coalesce(sum((extract('epoch' FROM (clock_timestamp() - query_start)) > {$PG.QUERY_ETIME.MAX.WARN})::integer * (state NOT IN ('idle', 'idle in transaction', 'idle in transaction (aborted)') AND query !~* E'^(\\s*(--[^\\n]*\\n|/\\*.*\\*/|\\n))*(autovacuum|VACUUM|ANALYZE|REINDEX|CLUSTER|CREATE|ALTER|TRUNCATE|DROP)')::integer), 0) query_slow_count,
coalesce(sum((extract('epoch' FROM (clock_timestamp() - query_start)) > {$PG.QUERY_ETIME.MAX.WARN})::integer * (state NOT IN ('idle') AND query !~* E'^(\\s*(--[^\\n]*\\n|/\\*.*\\*/|\\n))*(autovacuum|VACUUM|ANALYZE|REINDEX|CLUSTER|CREATE|ALTER|TRUNCATE|DROP)')::integer), 0) tx_slow_count,
coalesce(sum((extract('epoch' FROM (clock_timestamp() - query_start)) > {$PG.QUERY_ETIME.MAX.WARN})::integer * (state NOT IN ('idle') AND query ~* E'^(\\s*(--[^\\n]*\\n|/\\*.*\\*/|\\n))*(autovacuum|VACUUM|ANALYZE|REINDEX|CLUSTER|CREATE|ALTER|TRUNCATE|DROP)')::integer), 0) mro_slow_count
FROM pg_stat_activity
WHERE pid <> pg_backend_pid()
GROUP BY 1) T
WHERE NOT db.datistemplate )
SELECT json_object_agg(datname, row_to_json(T))
FROM T
username: '{$PG.USER}'
password: '{$PG.PASSWORD}'
description: 'Collect all metrics by query execution time.'
tags:
- tag: component
value: raw
- uuid: d156db3cb35049a88179060583961156
name: 'PostgreSQL: Replication: Standby count'
type: ODBC
key: 'db.odbc.select[pgsql.replication.count,,"Database={$PG.DATABASE};{$PG.CONNSTRING}"]'
history: 7d
params: 'SELECT count(*) FROM pg_stat_replication'
username: '{$PG.USER}'
password: '{$PG.PASSWORD}'
description: 'Number of standby servers.'
tags:
- tag: component
value: replication
- uuid: 669d87ebf9324d6eaa26c3cb44efc850
name: 'PostgreSQL: Replication: Lag in bytes'
type: ODBC
key: 'db.odbc.select[pgsql.replication.lag.b,,"Database={$PG.DATABASE};{$PG.CONNSTRING}"]'
history: 7d
units: B
params: |
SELECT
CASE
WHEN NOT pg_is_in_recovery() OR pg_last_wal_receive_lsn() = pg_last_wal_replay_lsn() THEN 0
ELSE COALESCE(EXTRACT(EPOCH FROM now() - pg_last_xact_replay_timestamp())::integer, 0)
END AS lag
username: '{$PG.USER}'
password: '{$PG.PASSWORD}'
description: 'Replication lag with master, in bytes.'
tags:
- tag: component
value: replication
- uuid: bb87b83d35784d3ea5be2263fa3722b0
name: 'PostgreSQL: Replication: Lag in seconds'
type: ODBC
key: 'db.odbc.select[pgsql.replication.lag.sec,,"Database={$PG.DATABASE};{$PG.CONNSTRING}"]'
history: 7d
units: s
params: |
SELECT
CASE
WHEN NOT pg_is_in_recovery() OR pg_last_wal_receive_lsn() = pg_last_wal_replay_lsn() THEN 0
ELSE COALESCE(EXTRACT(EPOCH FROM now() - pg_last_xact_replay_timestamp())::integer, 0)
END AS lag
username: '{$PG.USER}'
password: '{$PG.PASSWORD}'
description: 'Replication lag with master, in seconds.'
tags:
- tag: component
value: replication
- uuid: 3f2b5c02a6be40d4837205f68aaacabb
name: 'PostgreSQL: Get replication'
type: ODBC
key: 'db.odbc.select[pgsql.replication.process,,"Database={$PG.DATABASE};{$PG.CONNSTRING}"]'
history: '0'
trends: '0'
value_type: TEXT
params: |
SELECT json_object_agg(application_name, row_to_json(T))
FROM (
SELECT
application_name,
EXTRACT(epoch FROM COALESCE(flush_lag,'0'::interval)) AS flush_lag,
EXTRACT(epoch FROM COALESCE(replay_lag,'0'::interval)) AS replay_lag,
EXTRACT(epoch FROM COALESCE(write_lag, '0'::interval)) AS write_lag
FROM pg_stat_replication
) T
username: '{$PG.USER}'
password: '{$PG.PASSWORD}'
description: 'Collect metrics from the pg_stat_replication, which contains information about the WAL sender process, showing statistics about replication to that sender''s connected standby server.'
preprocessing:
- type: CHECK_NOT_SUPPORTED
parameters:
- ''
tags:
- tag: component
value: raw
- uuid: f8205cdd902a4a688b5bcb7f65d8e41d
name: 'PostgreSQL: Replication: Recovery role'
type: ODBC
key: 'db.odbc.select[pgsql.replication.recovery_role,,"Database={$PG.DATABASE};{$PG.CONNSTRING}"]'
history: 7d
params: 'SELECT pg_is_in_recovery()::int'
username: '{$PG.USER}'
password: '{$PG.PASSWORD}'
description: 'Replication role: 1 — recovery is still in progress (standby mode), 0 — master mode.'
valuemap:
name: 'PostgreSQL recovery role'
tags:
- tag: component
value: replication
- uuid: 6cc8c748f6174d3dba9aa9b39570b006
name: 'PostgreSQL: Replication: Status'
type: ODBC
key: 'db.odbc.select[pgsql.replication.status,,"Database={$PG.DATABASE};{$PG.CONNSTRING}"]'
history: 7d
params: |
SELECT
CASE
WHEN NOT pg_is_in_recovery() THEN 2
ELSE (SELECT count(*) FROM pg_stat_wal_receiver)
END AS repl_status
username: '{$PG.USER}'
password: '{$PG.PASSWORD}'
description: 'Replication status: 0 — streaming is down, 1 — streaming is up, 2 — master mode.'
valuemap:
name: 'PostgreSQL replication status'
tags:
- tag: component
value: replication
- uuid: 817c494132044fff88ea4c9fcaacb60a
name: 'PostgreSQL: Uptime'
type: ODBC
key: 'db.odbc.select[pgsql.uptime,,"Database={$PG.DATABASE};{$PG.CONNSTRING}"]'
history: 7d
value_type: FLOAT
units: s
params: 'SELECT date_part(''epoch'', now() - pg_postmaster_start_time())'
username: '{$PG.USER}'
password: '{$PG.PASSWORD}'
description: 'Time since the server started.'
tags:
- tag: component
value: application
triggers:
- uuid: 22077f0b0ee54becb43ef9ab808c3e43
expression: 'last(/PostgreSQL by ODBC/db.odbc.select[pgsql.uptime,,"Database={$PG.DATABASE};{$PG.CONNSTRING}"]) < 10m'
name: 'PostgreSQL: Service has been restarted'
event_name: 'PostgreSQL: Service has been restarted (uptime < 10m)'
priority: AVERAGE
description: 'PostgreSQL uptime is less than 10 minutes.'
tags:
- tag: scope
value: notice
- uuid: 8af13c6154744e9596a0f96dfbf09d8b
name: 'PostgreSQL: Get WAL'
type: ODBC
key: 'db.odbc.select[pgsql.wal.stat,,"Database={$PG.DATABASE};{$PG.CONNSTRING}"]'
delay: 5m
history: '0'
trends: '0'
value_type: TEXT
params: |
SELECT row_to_json(T)
FROM (
SELECT
CASE
WHEN pg_is_in_recovery() THEN 0
ELSE pg_wal_lsn_diff(pg_current_wal_lsn(),'0/00000000')
END AS WRITE,
CASE
WHEN NOT pg_is_in_recovery() THEN 0
ELSE pg_wal_lsn_diff(pg_last_wal_receive_lsn(),'0/00000000')
END AS RECEIVE,
count(*)
FROM pg_ls_waldir() AS COUNT
) T
username: '{$PG.USER}'
password: '{$PG.PASSWORD}'
description: 'Collect write-ahead log (WAL) metrics.'
tags:
- tag: component
value: raw
- uuid: d69d40f3e7064f668b0bf150ff73aafc
name: 'Archive: Count of archived files'
type: DEPENDENT
key: pgsql.archive.count_archived_files
delay: '0'
history: 7d
value_type: FLOAT
description: 'Count of archived files.'
preprocessing:
- type: JSONPATH
parameters:
- $.archived_count
master_item:
key: 'db.odbc.select[pgsql.archive,,"Database={$PG.DATABASE};{$PG.CONNSTRING}"]'
tags:
- tag: component
value: archive
- uuid: c1cc1236cf0c412a84e7d1ff3fec14e5
name: 'Archive: Count of files in archive_status need to archive'
type: DEPENDENT
key: pgsql.archive.count_files_to_archive
delay: '0'
history: 7d
value_type: FLOAT
description: 'Count of files to archive.'
preprocessing:
- type: JSONPATH
parameters:
- $.count_files
master_item:
key: 'db.odbc.select[pgsql.archive,,"Database={$PG.DATABASE};{$PG.CONNSTRING}"]'
tags:
- tag: component
value: archive
- uuid: 1ea44a48aaf042debc078ad920dd4f02
name: 'Archive: Count of failed attempts to archive files'
type: DEPENDENT
key: pgsql.archive.failed_trying_to_archive
delay: '0'
history: 7d
value_type: FLOAT
description: 'Count of failed attempts to archive files.'
preprocessing:
- type: JSONPATH
parameters:
- $.failed_count
master_item:
key: 'db.odbc.select[pgsql.archive,,"Database={$PG.DATABASE};{$PG.CONNSTRING}"]'
tags:
- tag: component
value: archive
- uuid: 13f563e6152a482fb48415d81f916af2
name: 'Archive: Size of files need to archive'
type: DEPENDENT
key: pgsql.archive.size_files_to_archive
delay: '0'
history: 7d
value_type: FLOAT
description: 'Size of files to archive.'
preprocessing:
- type: JSONPATH
parameters:
- $.size_files
master_item:
key: 'db.odbc.select[pgsql.archive,,"Database={$PG.DATABASE};{$PG.CONNSTRING}"]'
tags:
- tag: component
value: archive
- uuid: 01b14665e1154c748324612d1e1ac8e3
name: 'Bgwriter: Buffers allocated per second'
type: DEPENDENT
key: pgsql.bgwriter.buffers_alloc.rate
delay: '0'
history: 7d
value_type: FLOAT
description: 'Number of buffers allocated per second.'
preprocessing:
- type: JSONPATH
parameters:
- $.buffers_alloc
- type: CHANGE_PER_SECOND
parameters:
- ''
master_item:
key: 'db.odbc.select[pgsql.bgwriter,,"Database={$PG.DATABASE};{$PG.CONNSTRING}"]'
tags:
- tag: component
value: bgwriter
- uuid: bea9f6c0525c4a03a8ded982da45635d
name: 'Bgwriter: Buffers written directly by a backend per second'
type: DEPENDENT
key: pgsql.bgwriter.buffers_backend.rate
delay: '0'
history: 7d
value_type: FLOAT
description: 'Number of buffers written directly by a backend per second.'
preprocessing:
- type: JSONPATH
parameters:
- $.buffers_backend
- type: CHANGE_PER_SECOND
parameters:
- ''
master_item:
key: 'db.odbc.select[pgsql.bgwriter,,"Database={$PG.DATABASE};{$PG.CONNSTRING}"]'
tags:
- tag: component
value: bgwriter
- uuid: c6c5e980ffde4e62a7194602eaaa4c93
name: 'Bgwriter: Times a backend executed its own fsync per second'
type: DEPENDENT
key: pgsql.bgwriter.buffers_backend_fsync.rate
delay: '0'
history: 7d
value_type: FLOAT
description: 'Number of times a backend had to execute its own fsync call per second (normally the background writer handles those even when the backend does its own write).'
preprocessing:
- type: JSONPATH
parameters:
- $.buffers_backend_fsync
- type: CHANGE_PER_SECOND
parameters:
- ''
master_item:
key: 'db.odbc.select[pgsql.bgwriter,,"Database={$PG.DATABASE};{$PG.CONNSTRING}"]'
tags:
- tag: component
value: bgwriter
- uuid: c8cbd79cf23f4ef0a374d2afabe1d204
name: 'Checkpoint: Buffers written during checkpoints per second'
type: DEPENDENT
key: pgsql.bgwriter.buffers_checkpoint.rate
delay: '0'
history: 7d
value_type: FLOAT
description: 'Number of buffers written during checkpoints per second.'
preprocessing:
- type: JSONPATH
parameters:
- $.buffers_checkpoint
- type: CHANGE_PER_SECOND
parameters:
- ''
master_item:
key: 'db.odbc.select[pgsql.bgwriter,,"Database={$PG.DATABASE};{$PG.CONNSTRING}"]'
tags:
- tag: component
value: bgwriter
- uuid: 79563e8b9f054ce7afc93e50c0156f6f
name: 'Checkpoint: Buffers written by the background writer per second'
type: DEPENDENT
key: pgsql.bgwriter.buffers_clean.rate
delay: '0'
history: 7d
value_type: FLOAT
description: 'Number of buffers written by the background writer per second.'
preprocessing:
- type: JSONPATH
parameters:
- $.buffers_clean
- type: CHANGE_PER_SECOND
parameters:
- ''
master_item:
key: 'db.odbc.select[pgsql.bgwriter,,"Database={$PG.DATABASE};{$PG.CONNSTRING}"]'
tags:
- tag: component
value: bgwriter
- uuid: 9664a657f80246a687e4f60194abd608
name: 'Checkpoint: Requested per second'
type: DEPENDENT
key: pgsql.bgwriter.checkpoints_req.rate
delay: '0'
history: 7d
value_type: FLOAT
description: 'Number of requested checkpoints that have been performed per second.'
preprocessing:
- type: JSONPATH
parameters:
- $.checkpoints_req
- type: CHANGE_PER_SECOND
parameters:
- ''
master_item:
key: 'db.odbc.select[pgsql.bgwriter,,"Database={$PG.DATABASE};{$PG.CONNSTRING}"]'
tags:
- tag: component
value: bgwriter
- uuid: 1956bd5ce6d1456298efb28b0d41f061
name: 'Checkpoint: Scheduled per second'
type: DEPENDENT
key: pgsql.bgwriter.checkpoints_timed.rate
delay: '0'
history: 7d
value_type: FLOAT
description: 'Number of scheduled checkpoints that have been performed per second.'
preprocessing:
- type: JSONPATH
parameters:
- $.checkpoints_timed
- type: CHANGE_PER_SECOND
parameters:
- ''
master_item:
key: 'db.odbc.select[pgsql.bgwriter,,"Database={$PG.DATABASE};{$PG.CONNSTRING}"]'
tags:
- tag: component
value: bgwriter
- uuid: acdc021b00144e70a8326bd1cc1f2b28
name: 'Checkpoint: Checkpoint sync time per second'
type: DEPENDENT
key: pgsql.bgwriter.checkpoint_sync_time.rate
delay: '0'
history: 7d
value_type: FLOAT
units: s
description: 'Total amount of time per second that has been spent in the portion of checkpoint processing where files are synchronized to disk.'
preprocessing:
- type: JSONPATH
parameters:
- $.checkpoint_sync_time
- type: MULTIPLIER
parameters:
- '0.001'
- type: CHANGE_PER_SECOND
parameters:
- ''
master_item:
key: 'db.odbc.select[pgsql.bgwriter,,"Database={$PG.DATABASE};{$PG.CONNSTRING}"]'
tags:
- tag: component
value: bgwriter
- uuid: 6db37bd846e8406a965c0638bb55b230
name: 'Checkpoint: Checkpoint write time per second'
type: DEPENDENT
key: pgsql.bgwriter.checkpoint_write_time.rate
delay: '0'
history: 7d
value_type: FLOAT
units: s
description: 'Total amount of time per second that has been spent in the portion of checkpoint processing where files are written to disk.'
preprocessing:
- type: JSONPATH
parameters:
- $.checkpoint_write_time
- type: MULTIPLIER
parameters:
- '0.001'
- type: CHANGE_PER_SECOND
parameters:
- ''
master_item:
key: 'db.odbc.select[pgsql.bgwriter,,"Database={$PG.DATABASE};{$PG.CONNSTRING}"]'
tags:
- tag: component
value: bgwriter
- uuid: 073572decc084ff39d5a58cabb4860a5
name: 'Bgwriter: Number of bgwriter cleaning scan stopped per second'
type: DEPENDENT
key: pgsql.bgwriter.maxwritten_clean.rate
delay: '0'
history: 7d
value_type: FLOAT
description: 'Number of times the background writer stopped a cleaning scan because it had written too many buffers per second.'
preprocessing:
- type: JSONPATH
parameters:
- $.maxwritten_clean
- type: CHANGE_PER_SECOND
parameters:
- ''
master_item:
key: 'db.odbc.select[pgsql.bgwriter,,"Database={$PG.DATABASE};{$PG.CONNSTRING}"]'
tags:
- tag: component
value: bgwriter
- uuid: 6444043a810b4b2f89740c1c794a47c0
name: 'PostgreSQL: Cache hit ratio, %'
type: CALCULATED
key: pgsql.cache.hit
history: 7d
value_type: FLOAT
units: '%'
params: 'last(//pgsql.dbstat.sum.blks_hit.rate) * 100 / (last(//pgsql.dbstat.sum.blks_hit.rate) + last(//pgsql.dbstat.sum.blks_read.rate))'
description: 'Cache hit ratio.'
tags:
- tag: component
value: cache
- uuid: 5e3e5b6a244c4dfdacc7167196e28d7d
name: 'Connections sum: Active'
type: DEPENDENT
key: pgsql.connections.sum.active
delay: '0'
history: 7d
description: 'Total number of connections executing a query.'
preprocessing:
- type: JSONPATH
parameters:
- $.active
master_item:
key: 'db.odbc.select[pgsql.connections.sum,,"Database={$PG.DATABASE};{$PG.CONNSTRING}"]'
tags:
- tag: component
value: connections
- uuid: 2dd753d41b5e4c4098fef4fe5ac51060
name: 'Connections sum: Disabled'
type: DEPENDENT
key: pgsql.connections.sum.disabled
delay: '0'
history: 7d
description: 'Total number of disabled connections.'
preprocessing:
- type: JSONPATH
parameters:
- $.disabled
master_item:
key: 'db.odbc.select[pgsql.connections.sum,,"Database={$PG.DATABASE};{$PG.CONNSTRING}"]'
tags:
- tag: component
value: connections
- uuid: 6d379fe1fe424ed68dea03a90da81da0
name: 'Connections sum: Fastpath function call'
type: DEPENDENT
key: pgsql.connections.sum.fastpath_function_call
delay: '0'
history: 7d
description: 'Total number of connections executing a fast-path function.'
preprocessing:
- type: JSONPATH
parameters:
- $.fastpath_function_call
master_item:
key: 'db.odbc.select[pgsql.connections.sum,,"Database={$PG.DATABASE};{$PG.CONNSTRING}"]'
tags:
- tag: component
value: connections
- uuid: 8b777c5628c4462580f1ae70790fb584
name: 'Connections sum: Idle'
type: DEPENDENT
key: pgsql.connections.sum.idle
delay: '0'
history: 7d
description: 'Total number of connections waiting for a new client command.'
preprocessing:
- type: JSONPATH
parameters:
- $.idle
master_item:
key: 'db.odbc.select[pgsql.connections.sum,,"Database={$PG.DATABASE};{$PG.CONNSTRING}"]'
tags:
- tag: component
value: connections
- uuid: 7851bc86735e46a48fd5c82d83ef066a
name: 'Connections sum: Idle in transaction'
type: DEPENDENT
key: pgsql.connections.sum.idle_in_transaction
delay: '0'
history: 7d
description: 'Total number of connections in a transaction state but not executing a query.'
preprocessing:
- type: JSONPATH
parameters:
- $.idle_in_transaction
master_item:
key: 'db.odbc.select[pgsql.connections.sum,,"Database={$PG.DATABASE};{$PG.CONNSTRING}"]'
tags:
- tag: component
value: connections
- uuid: 9267653f21b445beaacd3de3e55ad4ae
name: 'Connections sum: Idle in transaction (aborted)'
type: DEPENDENT
key: pgsql.connections.sum.idle_in_transaction_aborted
delay: '0'
history: 7d
description: 'Total number of connections in a transaction state but not executing a query, and where one of the statements in the transaction caused an error.'
preprocessing:
- type: JSONPATH
parameters:
- $.idle_in_transaction_aborted
master_item:
key: 'db.odbc.select[pgsql.connections.sum,,"Database={$PG.DATABASE};{$PG.CONNSTRING}"]'
tags:
- tag: component
value: connections
- uuid: 512e90360d4d4b95aa23014181697afe
name: 'Connections sum: Prepared'
type: DEPENDENT
key: pgsql.connections.sum.prepared
delay: '0'
history: 7d
description: |
Total number of prepared transactions:
https://www.postgresql.org/docs/current/sql-prepare-transaction.html
preprocessing:
- type: JSONPATH
parameters:
- $.prepared
master_item:
key: 'db.odbc.select[pgsql.connections.sum,,"Database={$PG.DATABASE};{$PG.CONNSTRING}"]'
tags:
- tag: component
value: connections
- uuid: 4d092ed405e2410f9e1a4cdb31249fe0
name: 'Connections sum: Total'
type: DEPENDENT
key: pgsql.connections.sum.total
delay: '0'
history: 7d
description: 'Total number of connections.'
preprocessing:
- type: JSONPATH
parameters:
- $.total
master_item:
key: 'db.odbc.select[pgsql.connections.sum,,"Database={$PG.DATABASE};{$PG.CONNSTRING}"]'
tags:
- tag: component
value: connections
- uuid: 2b2ca7abb85b4ae1992cbfc6902206a1
name: 'Connections sum: Total, %'
type: DEPENDENT
key: pgsql.connections.sum.total_pct
delay: '0'
history: 7d
units: '%'
description: 'Total number of connections, in percentage.'
preprocessing:
- type: JSONPATH
parameters:
- $.total_pct
master_item:
key: 'db.odbc.select[pgsql.connections.sum,,"Database={$PG.DATABASE};{$PG.CONNSTRING}"]'
tags:
- tag: component
value: connections
triggers:
- uuid: 3b6662191c3b46ac930af02797a7162b
expression: 'min(/PostgreSQL by ODBC/pgsql.connections.sum.total_pct,5m) > {$PG.CONN_TOTAL_PCT.MAX.WARN}'
name: 'PostgreSQL: Total number of connections is too high'
event_name: 'PostgreSQL: Total number of connections is too high (over {$PG.CONN_TOTAL_PCT.MAX.WARN}% in 5m)'
priority: AVERAGE
description: 'Total number of current connections exceeds the limit of {$PG.CONN_TOTAL_PCT.MAX.WARN}% out of the maximum number of concurrent connections to the database server (the "max_connections" setting).'
tags:
- tag: scope
value: performance
- uuid: 7f525a9b9b6a494db660649388b8cb21
name: 'Connections sum: Waiting'
type: DEPENDENT
key: pgsql.connections.sum.waiting
delay: '0'
history: 7d
description: |
Total number of waiting connections:
https://www.postgresql.org/docs/current/monitoring-stats.html#WAIT-EVENT-TABLE
preprocessing:
- type: JSONPATH
parameters:
- $.waiting
master_item:
key: 'db.odbc.select[pgsql.connections.sum,,"Database={$PG.DATABASE};{$PG.CONNSTRING}"]'
tags:
- tag: component
value: connections
- uuid: 6cb6aaa39f494f13b792ea0d1570f0af
name: 'Dbstat: Hit blocks read per second'
type: DEPENDENT
key: pgsql.dbstat.sum.blks_hit.rate
delay: '0'
history: 7d
value_type: FLOAT
description: 'Number of times per second disk blocks were found already in the buffer cache.'
preprocessing:
- type: JSONPATH
parameters:
- $.blks_hit
- type: CHANGE_PER_SECOND
parameters:
- ''
master_item:
key: 'db.odbc.select[pgsql.dbstat.sum,,"Database={$PG.DATABASE};{$PG.CONNSTRING}"]'
tags:
- tag: component
value: cache
- uuid: 8861dbcc607b481e9f7ca6b3081530a8
name: 'Dbstat: Disk blocks read per second'
type: DEPENDENT
key: pgsql.dbstat.sum.blks_read.rate
delay: '0'
history: 7d
value_type: FLOAT
description: 'Number of disk blocks read per second.'
preprocessing:
- type: JSONPATH
parameters:
- $.blks_read
- type: CHANGE_PER_SECOND
parameters:
- ''
master_item:
key: 'db.odbc.select[pgsql.dbstat.sum,,"Database={$PG.DATABASE};{$PG.CONNSTRING}"]'
tags:
- tag: component
value: storage
- uuid: a8a7afddbe7546068e3d629747d73848
name: 'Dbstat: Blocks read time'
type: DEPENDENT
key: pgsql.dbstat.sum.blk_read_time
delay: '0'
history: 7d
value_type: FLOAT
units: s
description: 'Time spent reading data file blocks by backends.'
preprocessing:
- type: JSONPATH
parameters:
- $.blk_read_time
- type: MULTIPLIER
parameters:
- '0.001'
master_item:
key: 'db.odbc.select[pgsql.dbstat.sum,,"Database={$PG.DATABASE};{$PG.CONNSTRING}"]'
tags:
- tag: component
value: storage
- uuid: 40b1da9a55cf4312a66dffa9031b9b15
name: 'Dbstat: Blocks write time'
type: DEPENDENT
key: pgsql.dbstat.sum.blk_write_time
delay: '0'
history: 7d
value_type: FLOAT
units: s
description: 'Time spent writing data file blocks by backends.'
preprocessing:
- type: JSONPATH
parameters:
- $.blk_write_time
- type: MULTIPLIER
parameters:
- '0.001'
master_item:
key: 'db.odbc.select[pgsql.dbstat.sum,,"Database={$PG.DATABASE};{$PG.CONNSTRING}"]'
tags:
- tag: component
value: storage
- uuid: ef6c8945243f41e88a08d93e66eec666
name: 'Dbstat: Conflicts per second'
type: DEPENDENT
key: pgsql.dbstat.sum.conflicts.rate
delay: '0'
history: 7d
value_type: FLOAT
description: 'Number of queries canceled per second due to conflicts with recovery (conflicts occur only on standby servers; see pg_stat_database_conflicts for details).'
preprocessing:
- type: JSONPATH
parameters:
- $.conflicts
- type: CHANGE_PER_SECOND
parameters:
- ''
master_item:
key: 'db.odbc.select[pgsql.dbstat.sum,,"Database={$PG.DATABASE};{$PG.CONNSTRING}"]'
tags:
- tag: component
value: queries
- uuid: 5adcf2ce06984da2b0b0600d88e88451
name: 'Dbstat: Deadlocks per second'
type: DEPENDENT
key: pgsql.dbstat.sum.deadlocks.rate
delay: '0'
history: 7d
value_type: FLOAT
description: 'Number of deadlocks detected per second.'
preprocessing:
- type: JSONPATH
parameters:
- $.deadlocks
- type: CHANGE_PER_SECOND
parameters:
- ''
master_item:
key: 'db.odbc.select[pgsql.dbstat.sum,,"Database={$PG.DATABASE};{$PG.CONNSTRING}"]'
tags:
- tag: component
value: deadlocks
- uuid: 26da7e85356644cdbe4d9efd20e43dd2
name: 'Dbstat: Backends connected'
type: DEPENDENT
key: pgsql.dbstat.sum.numbackends
delay: '0'
history: 7d
description: 'Number of connected backends.'
preprocessing:
- type: JSONPATH
parameters:
- $.numbackends
master_item:
key: 'db.odbc.select[pgsql.dbstat.sum,,"Database={$PG.DATABASE};{$PG.CONNSTRING}"]'
tags:
- tag: component
value: backends
- uuid: 4c18ecf383154136ad68d5d938fc83d7
name: 'Dbstat: Number temp bytes per second'
type: DEPENDENT
key: pgsql.dbstat.sum.temp_bytes.rate
delay: '0'
history: 7d
value_type: FLOAT
units: b
description: 'Total amount of data written per second to temporary files by queries.'
preprocessing:
- type: JSONPATH
parameters:
- $.temp_bytes
- type: CHANGE_PER_SECOND
parameters:
- ''
master_item:
key: 'db.odbc.select[pgsql.dbstat.sum,,"Database={$PG.DATABASE};{$PG.CONNSTRING}"]'
tags:
- tag: component
value: storage
- uuid: 0c7ad16e40e3454aaad27a6fe4b5e62d
name: 'Dbstat: Number temp files per second'
type: DEPENDENT
key: pgsql.dbstat.sum.temp_files.rate
delay: '0'
history: 7d
value_type: FLOAT
description: 'Number of temporary files created by queries per second.'
preprocessing:
- type: JSONPATH
parameters:
- $.temp_files
- type: CHANGE_PER_SECOND
parameters:
- ''
master_item:
key: 'db.odbc.select[pgsql.dbstat.sum,,"Database={$PG.DATABASE};{$PG.CONNSTRING}"]'
tags:
- tag: component
value: storage
- uuid: e3cd2d8ec2b8454f949c69bb00e0db57
name: 'Dbstat: Rows deleted per second'
type: DEPENDENT
key: pgsql.dbstat.sum.tup_deleted.rate
delay: '0'
history: 7d
value_type: FLOAT
description: 'Number of rows deleted by queries per second.'
preprocessing:
- type: JSONPATH
parameters:
- $.tup_deleted
- type: CHANGE_PER_SECOND
parameters:
- ''
master_item:
key: 'db.odbc.select[pgsql.dbstat.sum,,"Database={$PG.DATABASE};{$PG.CONNSTRING}"]'
tags:
- tag: component
value: queries
- uuid: 9f09f94dcd6744e8b6a53167b1835a16
name: 'Dbstat: Rows fetched per second'
type: DEPENDENT
key: pgsql.dbstat.sum.tup_fetched.rate
delay: '0'
history: 7d
value_type: FLOAT
description: 'Number of rows fetched by queries per second.'
preprocessing:
- type: JSONPATH
parameters:
- $.tup_fetched
- type: CHANGE_PER_SECOND
parameters:
- ''
master_item:
key: 'db.odbc.select[pgsql.dbstat.sum,,"Database={$PG.DATABASE};{$PG.CONNSTRING}"]'
tags:
- tag: component
value: queries
- uuid: 916291299e624959993f8a585da6c9c0
name: 'Dbstat: Rows inserted per second'
type: DEPENDENT
key: pgsql.dbstat.sum.tup_inserted.rate
delay: '0'
history: 7d
value_type: FLOAT
description: 'Number of rows inserted by queries per second.'
preprocessing:
- type: JSONPATH
parameters:
- $.tup_inserted
- type: CHANGE_PER_SECOND
parameters:
- ''
master_item:
key: 'db.odbc.select[pgsql.dbstat.sum,,"Database={$PG.DATABASE};{$PG.CONNSTRING}"]'
tags:
- tag: component
value: queries
- uuid: fc8f68f5068240f3acd2d18443efc624
name: 'Dbstat: Rows returned per second'
type: DEPENDENT
key: pgsql.dbstat.sum.tup_returned.rate
delay: '0'
history: 7d
value_type: FLOAT
description: 'Number of rows returned by queries per second.'
preprocessing:
- type: JSONPATH
parameters:
- $.tup_returned
- type: CHANGE_PER_SECOND
parameters:
- ''
master_item:
key: 'db.odbc.select[pgsql.dbstat.sum,,"Database={$PG.DATABASE};{$PG.CONNSTRING}"]'
tags:
- tag: component
value: queries
- uuid: 802d541dd0314f8fba827e6d28013b5c
name: 'Dbstat: Rows updated per second'
type: DEPENDENT
key: pgsql.dbstat.sum.tup_updated.rate
delay: '0'
history: 7d
value_type: FLOAT
description: 'Number of rows updated by queries per second.'
preprocessing:
- type: JSONPATH
parameters:
- $.tup_updated
- type: CHANGE_PER_SECOND
parameters:
- ''
master_item:
key: 'db.odbc.select[pgsql.dbstat.sum,,"Database={$PG.DATABASE};{$PG.CONNSTRING}"]'
tags:
- tag: component
value: queries
- uuid: c00a09d04d4443d885006b29c5c14546
name: 'Dbstat: Committed transactions per second'
type: DEPENDENT
key: pgsql.dbstat.sum.xact_commit.rate
delay: '0'
history: 7d
value_type: FLOAT
description: 'Number of transactions that have been committed per second.'
preprocessing:
- type: JSONPATH
parameters:
- $.xact_commit
- type: CHANGE_PER_SECOND
parameters:
- ''
master_item:
key: 'db.odbc.select[pgsql.dbstat.sum,,"Database={$PG.DATABASE};{$PG.CONNSTRING}"]'
tags:
- tag: component
value: transactions
- uuid: 8f2259521add4cc0bd5e274604172d04
name: 'Dbstat: Roll backed transactions per second'
type: DEPENDENT
key: pgsql.dbstat.sum.xact_rollback.rate
delay: '0'
history: 7d
value_type: FLOAT
description: 'Number of transactions that have been rolled back per second.'
preprocessing:
- type: JSONPATH
parameters:
- $.xact_rollback
- type: CHANGE_PER_SECOND
parameters:
- ''
master_item:
key: 'db.odbc.select[pgsql.dbstat.sum,,"Database={$PG.DATABASE};{$PG.CONNSTRING}"]'
tags:
- tag: component
value: transactions
- uuid: 59722a42ba084a4f9a65f6b11f1180f4
name: 'WAL: Segments count'
type: DEPENDENT
key: pgsql.wal.count
delay: '0'
history: 7d
description: 'Number of WAL segments.'
preprocessing:
- type: JSONPATH
parameters:
- $.count
master_item:
key: 'db.odbc.select[pgsql.wal.stat,,"Database={$PG.DATABASE};{$PG.CONNSTRING}"]'
tags:
- tag: component
value: wal
- uuid: 5ffd0e54dd464b5c941ba40b696beda9
name: 'WAL: Bytes received'
type: DEPENDENT
key: pgsql.wal.receive
delay: '0'
history: 7d
units: B
description: 'WAL receive, in bytes.'
preprocessing:
- type: JSONPATH
parameters:
- $.receive
- type: CHANGE_PER_SECOND
parameters:
- ''
master_item:
key: 'db.odbc.select[pgsql.wal.stat,,"Database={$PG.DATABASE};{$PG.CONNSTRING}"]'
tags:
- tag: component
value: wal
- uuid: 0dec7fe5cbe24fcf802cb387ca8edf98
name: 'WAL: Bytes written'
type: DEPENDENT
key: pgsql.wal.write
delay: '0'
history: 7d
units: B
description: 'WAL write, in bytes.'
preprocessing:
- type: JSONPATH
parameters:
- $.write
- type: CHANGE_PER_SECOND
parameters:
- ''
master_item:
key: 'db.odbc.select[pgsql.wal.stat,,"Database={$PG.DATABASE};{$PG.CONNSTRING}"]'
tags:
- tag: component
value: wal
discovery_rules:
- uuid: 1c51decca55847a8adba4260f53e0acf
name: 'Database discovery'
type: ODBC
key: 'db.odbc.select[pgsql.db.discovery,,"Database={$PG.DATABASE};{$PG.CONNSTRING}"]'
delay: 1h
params: |
WITH T AS (
SELECT
datname AS "{#DBNAME}"
FROM pg_database
WHERE
NOT datistemplate
AND datallowconn
AND datname != 'postgres'
)
SELECT '{"data":'|| regexp_replace(coalesce(json_agg(T), '[]'::json)::text, E'[\\n\\r\\s]+', '', 'g') || '}'
FROM T
username: '{$PG.USER}'
password: '{$PG.PASSWORD}'
filter:
evaltype: AND
conditions:
- macro: '{#DBNAME}'
value: '{$PG.LLD.FILTER.DBNAME}'
formulaid: A
description: |
Discovers databases (DB) in the database management system (DBMS), except:
- templates;
- default "postgres" DB;
- DBs that do not allow connections.
item_prototypes:
- uuid: 98b74e578a3e48f3990bc16eb0217a17
name: 'DB [{#DBNAME}]: Database age'
type: ODBC
key: 'db.odbc.select[pgsql.db.age,,"Database={#DBNAME};{$PG.CONNSTRING}"]'
delay: 10m
history: 7d
params: |
SELECT age(datfrozenxid)
FROM pg_catalog.pg_database
WHERE datname = '{#DBNAME}'
username: '{$PG.USER}'
password: '{$PG.PASSWORD}'
description: 'Database age.'
tags:
- tag: component
value: application
- tag: database
value: '{#DBNAME}'
- uuid: cb7067b756bc4b3eb5be2ee2361df6f8
name: 'DB [{#DBNAME}]: Bloating tables'
type: ODBC
key: 'db.odbc.select[pgsql.db.bloating_tables,,"Database={#DBNAME};{$PG.CONNSTRING}"]'
history: 7d
params: |
SELECT count(*)
FROM pg_catalog.pg_stat_all_tables
WHERE (n_dead_tup/(n_live_tup+n_dead_tup)::float8) > 0.2
AND (n_live_tup+n_dead_tup) > 50
username: '{$PG.USER}'
password: '{$PG.PASSWORD}'
description: 'Number of bloating tables.'
tags:
- tag: component
value: tables
- tag: database
value: '{#DBNAME}'
- uuid: f6bc4dd7f66a4a399a16230b6a7a8f2d
name: 'DB [{#DBNAME}]: Database size'
type: ODBC
key: 'db.odbc.select[pgsql.db.size,,"Database={#DBNAME};{$PG.CONNSTRING}"]'
delay: 5m
history: 7d
units: B
params: 'SELECT pg_database_size(current_database())'
username: '{$PG.USER}'
password: '{$PG.PASSWORD}'
description: 'Database size.'
tags:
- tag: component
value: storage
- tag: database
value: '{#DBNAME}'
- uuid: d6c61f75147e414a99dfba56ea8ba422
name: 'DB [{#DBNAME}]: Blocks hit per second'
type: DEPENDENT
key: 'pgsql.dbstat.blks_hit.rate["{#DBNAME}"]'
delay: '0'
history: 7d
value_type: FLOAT
description: 'Total number of times per second disk blocks were found already in the buffer cache, so that a read was not necessary.'
preprocessing:
- type: JSONPATH
parameters:
- $.blks_hit
- type: CHANGE_PER_SECOND
parameters:
- ''
master_item:
key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]'
tags:
- tag: component
value: cache
- tag: database
value: '{#DBNAME}'
- uuid: 086c614609174dabab3b7a231353f4fa
name: 'DB [{#DBNAME}]: Disk blocks read per second'
type: DEPENDENT
key: 'pgsql.dbstat.blks_read.rate["{#DBNAME}"]'
delay: '0'
history: 7d
value_type: FLOAT
description: 'Total number of disk blocks read per second in this database.'
preprocessing:
- type: JSONPATH
parameters:
- $.blks_read
- type: CHANGE_PER_SECOND
parameters:
- ''
master_item:
key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]'
tags:
- tag: component
value: storage
- tag: database
value: '{#DBNAME}'
- uuid: 3ce43b1b7b874278abef353c6c791c95
name: 'DB [{#DBNAME}]: Disk blocks read time per second'
type: DEPENDENT
key: 'pgsql.dbstat.blk_read_time.rate["{#DBNAME}"]'
delay: '0'
history: 7d
value_type: FLOAT
units: s
description: 'Time spent reading data file blocks by backends per second.'
preprocessing:
- type: JSONPATH
parameters:
- $.blk_read_time
- type: MULTIPLIER
parameters:
- '0.001'
- type: CHANGE_PER_SECOND
parameters:
- ''
master_item:
key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]'
tags:
- tag: component
value: storage
- tag: database
value: '{#DBNAME}'
- uuid: 9c443a5bae6b4b4c84e6272cb254a38e
name: 'DB [{#DBNAME}]: Disk blocks write time per second'
type: DEPENDENT
key: 'pgsql.dbstat.blk_write_time.rate["{#DBNAME}"]'
delay: '0'
history: 7d
value_type: FLOAT
units: s
description: 'Time spent writing data file blocks by backends per second.'
preprocessing:
- type: JSONPATH
parameters:
- $.blk_write_time
- type: MULTIPLIER
parameters:
- '0.001'
- type: CHANGE_PER_SECOND
parameters:
- ''
master_item:
key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]'
tags:
- tag: component
value: storage
- tag: database
value: '{#DBNAME}'
- uuid: 8a772dae1d8f40978bfcceebfabe87de
name: 'DB [{#DBNAME}]: Detected conflicts per second'
type: DEPENDENT
key: 'pgsql.dbstat.conflicts.rate["{#DBNAME}"]'
delay: '0'
history: 7d
value_type: FLOAT
description: 'Total number of queries canceled due to conflicts with recovery in this database per second.'
preprocessing:
- type: JSONPATH
parameters:
- $.conflicts
- type: CHANGE_PER_SECOND
parameters:
- ''
master_item:
key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]'
tags:
- tag: component
value: queries
- tag: database
value: '{#DBNAME}'
trigger_prototypes:
- uuid: 8dc225c8a2824e5cb62b0ce4dd11dc1e
expression: 'min(/PostgreSQL by ODBC/pgsql.dbstat.conflicts.rate["{#DBNAME}"],5m) > {$PG.CONFLICTS.MAX.WARN:"{#DBNAME}"}'
name: 'DB [{#DBNAME}]: Too many recovery conflicts'
event_name: 'DB [{#DBNAME}]: Too many recovery conflicts (over {$PG.CONFLICTS.MAX.WARN:"{#DBNAME}"} in 5m)'
priority: AVERAGE
description: |
The primary and standby servers are in many ways loosely connected. Actions on the primary will have an effect on the standby. As a result, there is potential for negative interactions or conflicts between them.
https://www.postgresql.org/docs/current/hot-standby.html#HOT-STANDBY-CONFLICT
tags:
- tag: scope
value: performance
- uuid: c4f382ef370640aa93c265dabe0b6dcd
name: 'DB [{#DBNAME}]: Detected deadlocks per second'
type: DEPENDENT
key: 'pgsql.dbstat.deadlocks.rate["{#DBNAME}"]'
delay: '0'
history: 7d
value_type: FLOAT
description: 'Total number of detected deadlocks in this database per second.'
preprocessing:
- type: JSONPATH
parameters:
- $.deadlocks
- type: CHANGE_PER_SECOND
parameters:
- ''
master_item:
key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]'
tags:
- tag: component
value: deadlocks
- tag: database
value: '{#DBNAME}'
trigger_prototypes:
- uuid: 7e9c3fad615448deafbd21abdac7936d
expression: 'min(/PostgreSQL by ODBC/pgsql.dbstat.deadlocks.rate["{#DBNAME}"],5m) > {$PG.DEADLOCKS.MAX.WARN:"{#DBNAME}"}'
name: 'DB [{#DBNAME}]: Deadlock occurred'
event_name: 'DB [{#DBNAME}]: Deadlock occurred (over {$PG.DEADLOCKS.MAX.WARN:"{#DBNAME}"} in 5m)'
priority: HIGH
description: 'Number of deadlocks detected per second exceeds {$PG.DEADLOCKS.MAX.WARN:"{#DBNAME}"} for 5m.'
tags:
- tag: scope
value: availability
- uuid: 4e977e75b4044928a75dcdd713be1169
name: 'DB [{#DBNAME}]: Get dbstat'
type: DEPENDENT
key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]'
delay: '0'
history: '0'
trends: '0'
value_type: TEXT
description: 'Get dbstat metrics for database "{#DBNAME}".'
preprocessing:
- type: JSONPATH
parameters:
- '$[''{#DBNAME}'']'
error_handler: DISCARD_VALUE
master_item:
key: 'db.odbc.select[pgsql.dbstat,,"Database={$PG.DATABASE};{$PG.CONNSTRING}"]'
tags:
- tag: component
value: raw
- tag: database
value: '{#DBNAME}'
- uuid: d65dc8860c6e4e00aca8dfc35c5e3346
name: 'DB [{#DBNAME}]: Backends connected'
type: DEPENDENT
key: 'pgsql.dbstat.numbackends["{#DBNAME}"]'
delay: '0'
history: 7d
description: 'Number of backends currently connected to this database.'
preprocessing:
- type: JSONPATH
parameters:
- $.numbackends
master_item:
key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]'
tags:
- tag: component
value: backends
- tag: database
value: '{#DBNAME}'
- uuid: 65ce0c82404340bbb180bdb734573596
name: 'DB [{#DBNAME}]: Temp_bytes written per second'
type: DEPENDENT
key: 'pgsql.dbstat.temp_bytes.rate["{#DBNAME}"]'
delay: '0'
history: 7d
units: B
description: 'Total amount of data written to temporary files by queries in this database.'
preprocessing:
- type: JSONPATH
parameters:
- $.temp_bytes
- type: CHANGE_PER_SECOND
parameters:
- ''
master_item:
key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]'
tags:
- tag: component
value: storage
- tag: database
value: '{#DBNAME}'
- uuid: 9b079ed6377841ee87005af6ebaaa830
name: 'DB [{#DBNAME}]: Temp_files created per second'
type: DEPENDENT
key: 'pgsql.dbstat.temp_files.rate["{#DBNAME}"]'
delay: '0'
history: 7d
description: 'Total number of temporary files created by queries in this database.'
preprocessing:
- type: JSONPATH
parameters:
- $.temp_files
- type: CHANGE_PER_SECOND
parameters:
- ''
master_item:
key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]'
tags:
- tag: component
value: storage
- tag: database
value: '{#DBNAME}'
- uuid: 207b2e99c61044e091007f45cceb7088
name: 'DB [{#DBNAME}]: Tuples deleted per second'
type: DEPENDENT
key: 'pgsql.dbstat.tup_deleted.rate["{#DBNAME}"]'
delay: '0'
history: 7d
value_type: FLOAT
description: 'Total number of rows deleted by queries in this database per second.'
preprocessing:
- type: JSONPATH
parameters:
- $.tup_deleted
- type: CHANGE_PER_SECOND
parameters:
- ''
master_item:
key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]'
tags:
- tag: component
value: queries
- tag: database
value: '{#DBNAME}'
- uuid: 7e6add2efe2f4cc79982351c448bd921
name: 'DB [{#DBNAME}]: Tuples fetched per second'
type: DEPENDENT
key: 'pgsql.dbstat.tup_fetched.rate["{#DBNAME}"]'
delay: '0'
history: 7d
value_type: FLOAT
description: 'Total number of rows fetched by queries in this database per second.'
preprocessing:
- type: JSONPATH
parameters:
- $.tup_fetched
- type: CHANGE_PER_SECOND
parameters:
- ''
master_item:
key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]'
tags:
- tag: component
value: queries
- tag: database
value: '{#DBNAME}'
- uuid: 43bb96408a9e4832b7e272770c989593
name: 'DB [{#DBNAME}]: Tuples inserted per second'
type: DEPENDENT
key: 'pgsql.dbstat.tup_inserted.rate["{#DBNAME}"]'
delay: '0'
history: 7d
value_type: FLOAT
description: 'Total number of rows inserted by queries in this database per second.'
preprocessing:
- type: JSONPATH
parameters:
- $.tup_inserted
- type: CHANGE_PER_SECOND
parameters:
- ''
master_item:
key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]'
tags:
- tag: component
value: queries
- tag: database
value: '{#DBNAME}'
- uuid: 638cde24706448d09fa06c9571657a9d
name: 'DB [{#DBNAME}]: Tuples returned per second'
type: DEPENDENT
key: 'pgsql.dbstat.tup_returned.rate["{#DBNAME}"]'
delay: '0'
history: 7d
value_type: FLOAT
description: 'Number of rows returned by queries in this database per second.'
preprocessing:
- type: JSONPATH
parameters:
- $.tup_returned
- type: CHANGE_PER_SECOND
parameters:
- ''
master_item:
key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]'
tags:
- tag: component
value: queries
- tag: database
value: '{#DBNAME}'
- uuid: 73f71c2f1b9043b48152e91a3e3c41a1
name: 'DB [{#DBNAME}]: Tuples updated per second'
type: DEPENDENT
key: 'pgsql.dbstat.tup_updated.rate["{#DBNAME}"]'
delay: '0'
history: 7d
value_type: FLOAT
description: 'Total number of rows updated by queries in this database per second.'
preprocessing:
- type: JSONPATH
parameters:
- $.tup_updated
- type: CHANGE_PER_SECOND
parameters:
- ''
master_item:
key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]'
tags:
- tag: component
value: queries
- tag: database
value: '{#DBNAME}'
- uuid: 7ff29324ad4c48b7b28faaf3e16efbd6
name: 'DB [{#DBNAME}]: Commits per second'
type: DEPENDENT
key: 'pgsql.dbstat.xact_commit.rate["{#DBNAME}"]'
delay: '0'
history: 7d
value_type: FLOAT
description: 'Number of transactions in this database that have been committed per second.'
preprocessing:
- type: JSONPATH
parameters:
- $.xact_commit
- type: CHANGE_PER_SECOND
parameters:
- ''
master_item:
key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]'
tags:
- tag: component
value: transactions
- tag: database
value: '{#DBNAME}'
- uuid: a840bb06684140c8b70406a7f8b14873
name: 'DB [{#DBNAME}]: Rollbacks per second'
type: DEPENDENT
key: 'pgsql.dbstat.xact_rollback.rate["{#DBNAME}"]'
delay: '0'
history: 7d
value_type: FLOAT
description: 'Total number of transactions in this database that have been rolled back.'
preprocessing:
- type: JSONPATH
parameters:
- $.xact_rollback
- type: CHANGE_PER_SECOND
parameters:
- ''
master_item:
key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]'
tags:
- tag: component
value: transactions
- tag: database
value: '{#DBNAME}'
- uuid: e9fa95b198b14da9b416bd1bc7c00911
name: 'DB [{#DBNAME}]: Num of accessexclusive locks'
type: DEPENDENT
key: 'pgsql.locks.accessexclusive["{#DBNAME}"]'
delay: '0'
history: 7d
description: 'Number of accessexclusive locks for this database.'
preprocessing:
- type: JSONPATH
parameters:
- $.accessexclusive
master_item:
key: 'pgsql.locks.get_metrics["{#DBNAME}"]'
tags:
- tag: component
value: locks
- tag: database
value: '{#DBNAME}'
- uuid: fbc1bb60b8214041b64095672995e8ec
name: 'DB [{#DBNAME}]: Num of accessshare locks'
type: DEPENDENT
key: 'pgsql.locks.accessshare["{#DBNAME}"]'
delay: '0'
history: 7d
description: 'Number of accessshare locks for this database.'
preprocessing:
- type: JSONPATH
parameters:
- $.accessshare
master_item:
key: 'pgsql.locks.get_metrics["{#DBNAME}"]'
tags:
- tag: component
value: locks
- tag: database
value: '{#DBNAME}'
- uuid: a98106f8644b4f77b8e2cf1dc7ed9586
name: 'DB [{#DBNAME}]: Num of exclusive locks'
type: DEPENDENT
key: 'pgsql.locks.exclusive["{#DBNAME}"]'
delay: '0'
history: 7d
description: 'Number of exclusive locks for this database.'
preprocessing:
- type: JSONPATH
parameters:
- $.exclusive
master_item:
key: 'pgsql.locks.get_metrics["{#DBNAME}"]'
tags:
- tag: component
value: locks
- tag: database
value: '{#DBNAME}'
- uuid: 350ebc4e054c4290a92293ba625c40dd
name: 'DB [{#DBNAME}]: Get locks'
type: DEPENDENT
key: 'pgsql.locks.get_metrics["{#DBNAME}"]'
delay: '0'
history: '0'
trends: '0'
value_type: TEXT
description: 'Get locks metrics for database "{#DBNAME}".'
preprocessing:
- type: JSONPATH
parameters:
- '$[''{#DBNAME}'']'
error_handler: DISCARD_VALUE
master_item:
key: 'db.odbc.select[pgsql.locks,,"Database={$PG.DATABASE};{$PG.CONNSTRING}"]'
tags:
- tag: component
value: raw
- tag: database
value: '{#DBNAME}'
- uuid: 0abfbce470824232a7516747f6f2714a
name: 'DB [{#DBNAME}]: Num of rowexclusive locks'
type: DEPENDENT
key: 'pgsql.locks.rowexclusive["{#DBNAME}"]'
delay: '0'
history: 7d
description: 'Number of rowexclusive locks for this database.'
preprocessing:
- type: JSONPATH
parameters:
- $.rowexclusive
master_item:
key: 'pgsql.locks.get_metrics["{#DBNAME}"]'
tags:
- tag: component
value: locks
- tag: database
value: '{#DBNAME}'
- uuid: 24347f06596f4fc1af2753fbdd0b720c
name: 'DB [{#DBNAME}]: Num of rowshare locks'
type: DEPENDENT
key: 'pgsql.locks.rowshare["{#DBNAME}"]'
delay: '0'
history: 7d
description: 'Number of rowshare locks for this database.'
preprocessing:
- type: JSONPATH
parameters:
- '$[''{#DBNAME}''].rowshare'
error_handler: DISCARD_VALUE
master_item:
key: 'pgsql.locks.get_metrics["{#DBNAME}"]'
tags:
- tag: component
value: locks
- tag: database
value: '{#DBNAME}'
- uuid: dedcbbc9ee234e778b48947561077850
name: 'DB [{#DBNAME}]: Num of sharerowexclusive locks'
type: DEPENDENT
key: 'pgsql.locks.sharerowexclusive["{#DBNAME}"]'
delay: '0'
history: 7d
description: 'Number of total sharerowexclusive for this database.'
preprocessing:
- type: JSONPATH
parameters:
- $.sharerowexclusive
master_item:
key: 'pgsql.locks.get_metrics["{#DBNAME}"]'
tags:
- tag: component
value: locks
- tag: database
value: '{#DBNAME}'
- uuid: acaaf4e4ae97426589ea7fe351da0a48
name: 'DB [{#DBNAME}]: Num of shareupdateexclusive locks'
type: DEPENDENT
key: 'pgsql.locks.shareupdateexclusive["{#DBNAME}"]'
delay: '0'
history: 7d
description: 'Number of shareupdateexclusive locks for this database.'
preprocessing:
- type: JSONPATH
parameters:
- $.shareupdateexclusive
master_item:
key: 'pgsql.locks.get_metrics["{#DBNAME}"]'
tags:
- tag: component
value: locks
- tag: database
value: '{#DBNAME}'
- uuid: 03df53fbfc2f4ac2a5d0793e0ed14f4c
name: 'DB [{#DBNAME}]: Num of share locks'
type: DEPENDENT
key: 'pgsql.locks.share["{#DBNAME}"]'
delay: '0'
history: 7d
description: 'Number of share locks for this database.'
preprocessing:
- type: JSONPATH
parameters:
- $.share
master_item:
key: 'pgsql.locks.get_metrics["{#DBNAME}"]'
tags:
- tag: component
value: locks
- tag: database
value: '{#DBNAME}'
- uuid: 02f319126deb4de19d95443304d97c0d
name: 'DB [{#DBNAME}]: Num of locks total'
type: DEPENDENT
key: 'pgsql.locks.total["{#DBNAME}"]'
delay: '0'
history: 7d
description: 'Total number of locks in this database.'
preprocessing:
- type: JSONPATH
parameters:
- $.total
master_item:
key: 'pgsql.locks.get_metrics["{#DBNAME}"]'
tags:
- tag: component
value: locks
- tag: database
value: '{#DBNAME}'
- uuid: 16fd0bd835fd4db7b5ebb635780d9fe6
name: 'DB [{#DBNAME}]: Get queries'
type: DEPENDENT
key: 'pgsql.queries.get_metrics["{#DBNAME}"]'
delay: '0'
history: '0'
trends: '0'
value_type: TEXT
description: 'Get queries metrics for database "{#DBNAME}".'
preprocessing:
- type: JSONPATH
parameters:
- '$[''{#DBNAME}'']'
error_handler: DISCARD_VALUE
master_item:
key: 'db.odbc.select[pgsql.queries,,"Database={$PG.DATABASE};{$PG.CONNSTRING}"]'
tags:
- tag: component
value: raw
- tag: database
value: '{#DBNAME}'
- uuid: 100a8f6b18644a308f8117913862dcf4
name: 'DB [{#DBNAME}]: Queries slow maintenance count'
type: DEPENDENT
key: 'pgsql.queries.mro.slow_count["{#DBNAME}"]'
delay: '0'
history: 7d
description: 'Slow maintenance query count for this database.'
preprocessing:
- type: JSONPATH
parameters:
- $.mro_slow_count
master_item:
key: 'pgsql.queries.get_metrics["{#DBNAME}"]'
tags:
- tag: component
value: queries
- tag: database
value: '{#DBNAME}'
- uuid: f430eda6eae54a918a03b27f34709f54
name: 'DB [{#DBNAME}]: Queries max maintenance time'
type: DEPENDENT
key: 'pgsql.queries.mro.time_max["{#DBNAME}"]'
delay: '0'
history: 7d
units: s
description: 'Max maintenance query time for this database.'
preprocessing:
- type: JSONPATH
parameters:
- $.mro_time_max
master_item:
key: 'pgsql.queries.get_metrics["{#DBNAME}"]'
tags:
- tag: component
value: queries
- tag: database
value: '{#DBNAME}'
- uuid: 856a7e26192848e1aadb5bdff25cb92a
name: 'DB [{#DBNAME}]: Queries sum maintenance time'
type: DEPENDENT
key: 'pgsql.queries.mro.time_sum["{#DBNAME}"]'
delay: '0'
history: 7d
units: s
description: 'Sum maintenance query time for this database.'
preprocessing:
- type: JSONPATH
parameters:
- $.mro_time_sum
master_item:
key: 'pgsql.queries.get_metrics["{#DBNAME}"]'
tags:
- tag: component
value: queries
- tag: database
value: '{#DBNAME}'
- uuid: b324beea02f742c381d8241ba1e9382b
name: 'DB [{#DBNAME}]: Queries slow query count'
type: DEPENDENT
key: 'pgsql.queries.query.slow_count["{#DBNAME}"]'
delay: '0'
history: 7d
description: 'Slow query count for this database.'
preprocessing:
- type: JSONPATH
parameters:
- $.query_slow_count
master_item:
key: 'pgsql.queries.get_metrics["{#DBNAME}"]'
tags:
- tag: component
value: queries
- tag: database
value: '{#DBNAME}'
trigger_prototypes:
- uuid: bc790cd8e2c24638ad8a6552af1b9bbe
expression: 'min(/PostgreSQL by ODBC/pgsql.queries.query.slow_count["{#DBNAME}"],5m)>{$PG.SLOW_QUERIES.MAX.WARN:"{#DBNAME}"}'
name: 'DB [{#DBNAME}]: Too many slow queries'
event_name: 'DB [{#DBNAME}]: Too many slow queries (over {$PG.SLOW_QUERIES.MAX.WARN:"{#DBNAME}"} in 5m)'
priority: WARNING
description: 'The number of detected slow queries exceeds the limit of {$PG.SLOW_QUERIES.MAX.WARN:"{#DBNAME}"}.'
tags:
- tag: scope
value: performance
- uuid: 0c0717a146344ec4a7abf4e6c35cb7ae
name: 'DB [{#DBNAME}]: Queries max query time'
type: DEPENDENT
key: 'pgsql.queries.query.time_max["{#DBNAME}"]'
delay: '0'
history: 7d
units: s
description: 'Max query time for this database.'
preprocessing:
- type: JSONPATH
parameters:
- $.query_time_max
master_item:
key: 'pgsql.queries.get_metrics["{#DBNAME}"]'
tags:
- tag: component
value: queries
- tag: database
value: '{#DBNAME}'
- uuid: e2e686428e2b4f65b7dcbb9a6a3b0f93
name: 'DB [{#DBNAME}]: Queries sum query time'
type: DEPENDENT
key: 'pgsql.queries.query.time_sum["{#DBNAME}"]'
delay: '0'
history: 7d
units: s
description: 'Sum query time for this database.'
preprocessing:
- type: JSONPATH
parameters:
- $.query_time_sum
master_item:
key: 'pgsql.queries.get_metrics["{#DBNAME}"]'
tags:
- tag: component
value: queries
- tag: database
value: '{#DBNAME}'
- uuid: 06fb68c43e0144e8aa85c0acceeafbfc
name: 'DB [{#DBNAME}]: Queries slow transaction count'
type: DEPENDENT
key: 'pgsql.queries.tx.slow_count["{#DBNAME}"]'
delay: '0'
history: 7d
description: 'Slow transaction query count for this database.'
preprocessing:
- type: JSONPATH
parameters:
- $.tx_slow_count
master_item:
key: 'pgsql.queries.get_metrics["{#DBNAME}"]'
tags:
- tag: component
value: queries
- tag: database
value: '{#DBNAME}'
- uuid: 0eced9bbc0d94332a1ec9fb45913b931
name: 'DB [{#DBNAME}]: Queries max transaction time'
type: DEPENDENT
key: 'pgsql.queries.tx.time_max["{#DBNAME}"]'
delay: '0'
history: 7d
units: s
description: 'Max transaction query time for this database.'
preprocessing:
- type: JSONPATH
parameters:
- $.tx_time_max
master_item:
key: 'pgsql.queries.get_metrics["{#DBNAME}"]'
tags:
- tag: component
value: queries
- tag: database
value: '{#DBNAME}'
- uuid: a51a95891cd849de9eeaa6c4dbcbefbe
name: 'DB [{#DBNAME}]: Queries sum transaction time'
type: DEPENDENT
key: 'pgsql.queries.tx.time_sum["{#DBNAME}"]'
delay: '0'
history: 7d
units: s
description: 'Sum transaction query time for this database.'
preprocessing:
- type: JSONPATH
parameters:
- $.tx_time_sum
master_item:
key: 'pgsql.queries.get_metrics["{#DBNAME}"]'
tags:
- tag: component
value: queries
- tag: database
value: '{#DBNAME}'
graph_prototypes:
- uuid: 7b2e7e0542174a7a996bac8014f9a664
name: 'DB [{#DBNAME}]: Locks'
graph_items:
- drawtype: GRADIENT_LINE
color: 199C0D
item:
host: 'PostgreSQL by ODBC'
key: 'pgsql.locks.total["{#DBNAME}"]'
- sortorder: '1'
color: F63100
item:
host: 'PostgreSQL by ODBC'
key: 'pgsql.locks.accessexclusive["{#DBNAME}"]'
- sortorder: '2'
color: 00611C
item:
host: 'PostgreSQL by ODBC'
key: 'pgsql.locks.accessshare["{#DBNAME}"]'
- sortorder: '3'
color: F7941D
item:
host: 'PostgreSQL by ODBC'
key: 'pgsql.locks.exclusive["{#DBNAME}"]'
- sortorder: '4'
color: FC6EA3
item:
host: 'PostgreSQL by ODBC'
key: 'pgsql.locks.rowexclusive["{#DBNAME}"]'
- sortorder: '5'
color: 6C59DC
item:
host: 'PostgreSQL by ODBC'
key: 'pgsql.locks.rowshare["{#DBNAME}"]'
- sortorder: '6'
color: C7A72D
item:
host: 'PostgreSQL by ODBC'
key: 'pgsql.locks.sharerowexclusive["{#DBNAME}"]'
- sortorder: '7'
color: BA2A5D
item:
host: 'PostgreSQL by ODBC'
key: 'pgsql.locks.shareupdateexclusive["{#DBNAME}"]'
- sortorder: '8'
color: F230E0
item:
host: 'PostgreSQL by ODBC'
key: 'pgsql.locks.share["{#DBNAME}"]'
- uuid: 70065416f33d4a3a9046576a344e965a
name: 'DB [{#DBNAME}]: Number of bloating tables'
graph_items:
- drawtype: GRADIENT_LINE
color: 199C0D
item:
host: 'PostgreSQL by ODBC'
key: 'db.odbc.select[pgsql.db.bloating_tables,,"Database={#DBNAME};{$PG.CONNSTRING}"]'
- uuid: f9162816d4f740dd8e4863c726b64105
name: 'DB [{#DBNAME}]: pg_stat_database metrics'
graph_items:
- color: 199C0D
item:
host: 'PostgreSQL by ODBC'
key: 'pgsql.dbstat.blks_hit.rate["{#DBNAME}"]'
- sortorder: '1'
color: F63100
item:
host: 'PostgreSQL by ODBC'
key: 'pgsql.dbstat.blks_read.rate["{#DBNAME}"]'
- sortorder: '2'
color: 00611C
item:
host: 'PostgreSQL by ODBC'
key: 'pgsql.dbstat.conflicts.rate["{#DBNAME}"]'
- sortorder: '3'
color: F7941D
item:
host: 'PostgreSQL by ODBC'
key: 'pgsql.dbstat.deadlocks.rate["{#DBNAME}"]'
- sortorder: '4'
color: FC6EA3
item:
host: 'PostgreSQL by ODBC'
key: 'pgsql.dbstat.temp_bytes.rate["{#DBNAME}"]'
- sortorder: '5'
color: 6C59DC
item:
host: 'PostgreSQL by ODBC'
key: 'pgsql.dbstat.temp_files.rate["{#DBNAME}"]'
- sortorder: '6'
color: C7A72D
item:
host: 'PostgreSQL by ODBC'
key: 'pgsql.dbstat.tup_deleted.rate["{#DBNAME}"]'
- sortorder: '7'
color: BA2A5D
item:
host: 'PostgreSQL by ODBC'
key: 'pgsql.dbstat.tup_fetched.rate["{#DBNAME}"]'
- sortorder: '8'
color: F230E0
item:
host: 'PostgreSQL by ODBC'
key: 'pgsql.dbstat.tup_inserted.rate["{#DBNAME}"]'
- sortorder: '9'
color: 5CCD18
item:
host: 'PostgreSQL by ODBC'
key: 'pgsql.dbstat.tup_returned.rate["{#DBNAME}"]'
- sortorder: '10'
color: BB2A02
item:
host: 'PostgreSQL by ODBC'
key: 'pgsql.dbstat.tup_updated.rate["{#DBNAME}"]'
- sortorder: '11'
color: AC41A5
item:
host: 'PostgreSQL by ODBC'
key: 'pgsql.dbstat.xact_commit.rate["{#DBNAME}"]'
- sortorder: '12'
color: 89ABF8
item:
host: 'PostgreSQL by ODBC'
key: 'pgsql.dbstat.xact_rollback.rate["{#DBNAME}"]'
- uuid: 79b2ba5736054e8a93e70d7af063a0b9
name: 'DB [{#DBNAME}]: Queries'
ymin_type_1: FIXED
graph_items:
- color: 199C0D
yaxisside: RIGHT
item:
host: 'PostgreSQL by ODBC'
key: 'pgsql.queries.mro.time_max["{#DBNAME}"]'
- sortorder: '1'
color: F63100
yaxisside: RIGHT
item:
host: 'PostgreSQL by ODBC'
key: 'pgsql.queries.query.time_max["{#DBNAME}"]'
- sortorder: '2'
color: 00611C
yaxisside: RIGHT
item:
host: 'PostgreSQL by ODBC'
key: 'pgsql.queries.tx.time_max["{#DBNAME}"]'
- sortorder: '3'
drawtype: GRADIENT_LINE
color: F7941D
item:
host: 'PostgreSQL by ODBC'
key: 'pgsql.queries.mro.time_sum["{#DBNAME}"]'
- sortorder: '4'
drawtype: GRADIENT_LINE
color: FC6EA3
item:
host: 'PostgreSQL by ODBC'
key: 'pgsql.queries.query.time_sum["{#DBNAME}"]'
- sortorder: '5'
drawtype: GRADIENT_LINE
color: 6C59DC
item:
host: 'PostgreSQL by ODBC'
key: 'pgsql.queries.tx.time_sum["{#DBNAME}"]'
- uuid: 7ee8911784824e8380dd07235779a5ea
name: 'DB [{#DBNAME}]: Size'
graph_items:
- drawtype: GRADIENT_LINE
color: 199C0D
item:
host: 'PostgreSQL by ODBC'
key: 'db.odbc.select[pgsql.db.size,,"Database={#DBNAME};{$PG.CONNSTRING}"]'
- uuid: 88a09d63e9214cf1bf8ee82ae485f442
name: 'DB [{#DBNAME}]: Slow queries'
ymin_type_1: FIXED
graph_items:
- color: 199C0D
item:
host: 'PostgreSQL by ODBC'
key: 'pgsql.queries.mro.slow_count["{#DBNAME}"]'
- sortorder: '1'
color: F63100
item:
host: 'PostgreSQL by ODBC'
key: 'pgsql.queries.query.slow_count["{#DBNAME}"]'
- sortorder: '2'
color: 00611C
item:
host: 'PostgreSQL by ODBC'
key: 'pgsql.queries.tx.slow_count["{#DBNAME}"]'
- uuid: 46a6f3cdfff244a28cb712c4186afc7f
name: 'Replication discovery'
type: ODBC
key: 'db.odbc.select[pgsql.replication.process.discovery,,"Database={$PG.DATABASE};{$PG.CONNSTRING}"]'
delay: 15m
params: |
SELECT json_build_object('data',COALESCE(json_agg(json_build_object('{#APPLICATION_NAME}',application_name)), '[]'))
FROM pg_stat_replication
username: '{$PG.USER}'
password: '{$PG.PASSWORD}'
filter:
evaltype: AND
conditions:
- macro: '{#APPLICATION_NAME}'
value: '{$PG.LLD.FILTER.APPLICATION}'
formulaid: A
description: 'Discovers replication lag metrics.'
item_prototypes:
- uuid: 9e7797789d2c47efb9af2c86f8c6a93e
name: 'Application [{#APPLICATION_NAME}]: Get replication'
type: DEPENDENT
key: 'pgsql.replication.get_metrics["{#APPLICATION_NAME}"]'
delay: '0'
history: '0'
trends: '0'
value_type: TEXT
description: 'Collect metrics from the "pg_stat_replication" about the application "{#APPLICATION_NAME}" that is connected to this WAL sender, which contains information about the WAL sender process, showing statistics about replication to that sender''s connected standby server.'
preprocessing:
- type: JSONPATH
parameters:
- '$[''{#APPLICATION_NAME}'']'
error_handler: DISCARD_VALUE
master_item:
key: 'db.odbc.select[pgsql.replication.process,,"Database={$PG.DATABASE};{$PG.CONNSTRING}"]'
tags:
- tag: application
value: '{#APPLICATION_NAME}'
- tag: component
value: raw
- uuid: 86109b6d1b084de186dcda5d455da992
name: 'Application [{#APPLICATION_NAME}]: Replication flush lag'
type: DEPENDENT
key: 'pgsql.replication.process.flush_lag["{#APPLICATION_NAME}"]'
delay: '0'
history: 7d
value_type: FLOAT
units: s
description: 'Time elapsed between flushing recent WAL locally and receiving notification that this standby server has written and flushed it (but not yet applied it). This can be used to gauge the delay that synchronous_commit level on incurred while committing if this server was configured as a synchronous standby.'
preprocessing:
- type: JSONPATH
parameters:
- $.flush_lag
master_item:
key: 'pgsql.replication.get_metrics["{#APPLICATION_NAME}"]'
tags:
- tag: application
value: '{#APPLICATION_NAME}'
- tag: component
value: replication
- uuid: 2cad17fa29c24f0da0fffe962c337f13
name: 'Application [{#APPLICATION_NAME}]: Replication replay lag'
type: DEPENDENT
key: 'pgsql.replication.process.replay_lag["{#APPLICATION_NAME}"]'
delay: '0'
history: 7d
value_type: FLOAT
units: s
description: 'Time elapsed between flushing recent WAL locally and receiving notification that this standby server has written, flushed and applied it. This can be used to gauge the delay that synchronous_commit level remote_apply incurred while committing if this server was configured as a synchronous standby.'
preprocessing:
- type: JSONPATH
parameters:
- $.replay_lag
master_item:
key: 'pgsql.replication.get_metrics["{#APPLICATION_NAME}"]'
tags:
- tag: application
value: '{#APPLICATION_NAME}'
- tag: component
value: replication
- uuid: f5f62a5cac254d5eb891beadd6ca950d
name: 'Application [{#APPLICATION_NAME}]: Replication write lag'
type: DEPENDENT
key: 'pgsql.replication.process.write_lag["{#APPLICATION_NAME}"]'
delay: '0'
history: 7d
value_type: FLOAT
units: s
description: 'Time elapsed between flushing recent WAL locally and receiving notification that this standby server has written it (but not yet flushed it or applied it). This can be used to gauge the delay that synchronous_commit level remote_write incurred while committing if this server was configured as a synchronous standby.'
preprocessing:
- type: JSONPATH
parameters:
- $.write_lag
master_item:
key: 'pgsql.replication.get_metrics["{#APPLICATION_NAME}"]'
tags:
- tag: application
value: '{#APPLICATION_NAME}'
- tag: component
value: replication
graph_prototypes:
- uuid: 52b70e3a3691467d8ca7a420d2f7f3c5
name: 'Application [{#APPLICATION_NAME}]: Replication lag'
graph_items:
- color: 199C0D
item:
host: 'PostgreSQL by ODBC'
key: 'pgsql.replication.process.flush_lag["{#APPLICATION_NAME}"]'
- sortorder: '1'
color: F63100
item:
host: 'PostgreSQL by ODBC'
key: 'pgsql.replication.process.replay_lag["{#APPLICATION_NAME}"]'
- sortorder: '2'
color: 00611C
item:
host: 'PostgreSQL by ODBC'
key: 'pgsql.replication.process.write_lag["{#APPLICATION_NAME}"]'
preprocessing:
- type: DISCARD_UNCHANGED_HEARTBEAT
parameters:
- 3h
tags:
- tag: class
value: database
- tag: target
value: postgresql
macros:
- macro: '{$PG.CONFLICTS.MAX.WARN}'
value: '0'
description: 'Maximum number of recovery conflicts for trigger expression.'
- macro: '{$PG.CONNSTRING}'
value: Servername=localhost;Port=5432;Driver=/usr/lib64/psqlodbcw.so
description: 'Connection string for the PostgreSQL instance.'
- macro: '{$PG.CONN_TOTAL_PCT.MAX.WARN}'
value: '90'
description: 'Maximum percentage of current connections for trigger expression.'
- macro: '{$PG.DATABASE}'
value: postgres
description: 'Default PostgreSQL database for the connection.'
- macro: '{$PG.DEADLOCKS.MAX.WARN}'
value: '0'
description: 'Maximum number of detected deadlocks for trigger expression.'
- macro: '{$PG.LLD.FILTER.APPLICATION}'
value: .+
description: 'Filter of discoverable applications.'
- macro: '{$PG.LLD.FILTER.DBNAME}'
value: .+
description: 'Filter of discoverable databases.'
- macro: '{$PG.PASSWORD}'
value: '<Put the password here>'
description: 'PostgreSQL user password.'
- macro: '{$PG.QUERY_ETIME.MAX.WARN}'
value: '30'
description: 'Execution time limit for count of slow queries.'
- macro: '{$PG.SLOW_QUERIES.MAX.WARN}'
value: '5'
description: 'Slow queries count threshold for a trigger.'
- macro: '{$PG.USER}'
value: zbx_monitor
description: 'PostgreSQL username.'
dashboards:
- uuid: 6f15f8b6e90b4d09b9e1d4fb323ac438
name: 'PostgreSQL databases'
pages:
- widgets:
- type: graphprototype
width: '12'
height: '5'
fields:
- type: INTEGER
name: columns
value: '1'
- type: INTEGER
name: rows
value: '1'
- type: GRAPH_PROTOTYPE
name: graphid
value:
host: 'PostgreSQL by ODBC'
name: 'DB [{#DBNAME}]: pg_stat_database metrics'
- type: graphprototype
x: '12'
width: '12'
height: '5'
fields:
- type: INTEGER
name: columns
value: '1'
- type: INTEGER
name: rows
value: '1'
- type: GRAPH_PROTOTYPE
name: graphid
value:
host: 'PostgreSQL by ODBC'
name: 'DB [{#DBNAME}]: Locks'
- type: graphprototype
'y': '5'
width: '12'
height: '5'
fields:
- type: INTEGER
name: columns
value: '1'
- type: INTEGER
name: rows
value: '1'
- type: GRAPH_PROTOTYPE
name: graphid
value:
host: 'PostgreSQL by ODBC'
name: 'DB [{#DBNAME}]: Size'
- type: graphprototype
x: '12'
'y': '5'
width: '12'
height: '5'
fields:
- type: INTEGER
name: columns
value: '1'
- type: INTEGER
name: rows
value: '1'
- type: GRAPH_PROTOTYPE
name: graphid
value:
host: 'PostgreSQL by ODBC'
name: 'DB [{#DBNAME}]: Number of bloating tables'
- type: graphprototype
'y': '10'
width: '12'
height: '5'
fields:
- type: INTEGER
name: columns
value: '1'
- type: INTEGER
name: rows
value: '1'
- type: GRAPH_PROTOTYPE
name: graphid
value:
host: 'PostgreSQL by ODBC'
name: 'DB [{#DBNAME}]: Queries'
- type: graphprototype
x: '12'
'y': '10'
width: '12'
height: '5'
fields:
- type: INTEGER
name: columns
value: '1'
- type: INTEGER
name: rows
value: '1'
- type: GRAPH_PROTOTYPE
name: graphid
value:
host: 'PostgreSQL by ODBC'
name: 'DB [{#DBNAME}]: Slow queries'
valuemaps:
- uuid: 6e5062ae5345454f95cb8608b35eddf4
name: 'PostgreSQL recovery role'
mappings:
- value: '0'
newvalue: Master
- value: '1'
newvalue: Standby
- uuid: 75393338fb514612a5f0ba57cec318b3
name: 'PostgreSQL replication status'
mappings:
- value: '0'
newvalue: Down
- value: '1'
newvalue: Up
- value: '2'
newvalue: Master
- uuid: f2af00a32d1e471a98b9e4e6148f68f3
name: 'Service state'
mappings:
- value: '0'
newvalue: Down
- value: '1'
newvalue: Up