PostgreSQL, also known as Postgres, is a free and open-source relational database management system emphasizing extensibility and technical standards compliance. It is designed to handle a range of workloads, from single machines to data warehouses or Web services with many concurrent users.
Source: https://git.zabbix.com/projects/ZBX/repos/zabbix/browse/templates/db/postgresql?at=release/6.4
This template is designed for the deployment of PostgreSQL monitoring by Zabbix via Zabbix agent and uses user parameters to run SQL queries with the psql command-line tool.
Zabbix version: 6.4 and higher.
This template has been tested on:
Zabbix should be configured according to the instructions in the Templates out of the box section.
Note:
pg_isready and psql utilities to be installed on the same host with Zabbix agent.<password> at your discretion) with proper access rights to your PostgreSQL instance.For PostgreSQL version 10 and above:
CREATE USER zbx_monitor WITH PASSWORD '<PASSWORD>' INHERIT;
GRANT pg_monitor TO zbx_monitor;
For PostgreSQL version 9.6 and below:
CREATE USER zbx_monitor WITH PASSWORD '<PASSWORD>';
GRANT SELECT ON pg_stat_database TO zbx_monitor;
-- To collect WAL metrics, the user must have a `superuser` role.
ALTER USER zbx_monitor WITH SUPERUSER;
postgresql/ directory to the zabbix user home directory - /var/lib/zabbix/. The postgresql/ directory contains the files with SQL queries needed to obtain metrics from PostgreSQL instance.If the home directory of the zabbix user doesn't exist, create it first:
mkdir -m u=rwx,g=rwx,o= -p /var/lib/zabbix
chown zabbix:zabbix /var/lib/zabbix
template_db_postgresql.conf file, containing user parameters, to the Zabbix agent configuration directory /etc/zabbix/zabbix_agentd.d/ and restart Zabbix agent service.Note: if you want to use SSL/TLS encryption to protect communications with the remote PostgreSQL instance, you can modify the connection string in user parameters. For example, to enable required encryption in transport mode without identity checks you could append ?sslmode=required to the end of the connection string for all keys that use psql:
UserParameter=pgsql.bgwriter[*], psql -qtAX postgresql://"$3":"$4"@"$1":"$2"/"$5"?sslmode=required -f "/var/lib/zabbix/postgresql/pgsql.bgwriter.sql"
Consult the PostgreSQL documentation about protection modes and client connection parameters.
Also, it is assumed that you set up the PostgreSQL instance to work in the desired encryption mode. Check the PostgreSQL documentation for details.
pg_hba.conf configuration file to allow connections for the user zbx_monitor. For example, you could add one of the following rows to allow local TCP connections from the same host:# TYPE DATABASE USER ADDRESS METHOD
host all zbx_monitor localhost trust
host all zbx_monitor 127.0.0.1/32 md5
host all zbx_monitor ::1/128 scram-sha-256
For more information please read the PostgreSQL documentation https://www.postgresql.org/docs/current/auth-pg-hba-conf.html.
Specify the host name or IP address in the {$PG.HOST} macro. Adjust the port number with {$PG.PORT} macro if needed.
Set the password that you specified in step 1 in the macro {$PG.PASSWORD}.
| Name | Description | Default |
|---|---|---|
| {$PG.CACHE_HITRATIO.MIN.WARN} | Minimum cache hit ratio percentage for trigger expression. |
90 |
| {$PG.CHECKPOINTS_REQ.MAX.WARN} | Maximum required checkpoint occurrences for trigger expression. |
5 |
| {$PG.CONFLICTS.MAX.WARN} | Maximum number of recovery conflicts for trigger expression. |
0 |
| {$PG.CONN_TOTAL_PCT.MAX.WARN} | Maximum percentage of current connections for trigger expression. |
90 |
| {$PG.DATABASE} | Default PostgreSQL database for the connection. |
postgres |
| {$PG.DEADLOCKS.MAX.WARN} | Maximum number of detected deadlocks for trigger expression. |
0 |
| {$PG.FROZENXID_PCT_STOP.MIN.HIGH} | Minimum frozen XID before stop percentage for trigger expression. |
75 |
| {$PG.HOST} | Hostname or IP of PostgreSQL host. |
localhost |
| {$PG.LLD.FILTER.DBNAME} | Filter of discoverable databases. |
.+ |
| {$PG.LOCKS.MAX.WARN} | Maximum number of locks for trigger expression. |
100 |
| {$PG.PING_TIME.MAX.WARN} | Maximum time of connection response for trigger expression. |
1s |
| {$PG.PORT} | PostgreSQL service port. |
5432 |
| {$PG.QUERY_ETIME.MAX.WARN} | Execution time limit for count of slow queries. |
30 |
| {$PG.REPL_LAG.MAX.WARN} | Maximum replication lag time for trigger expression. |
10m |
| {$PG.SLOW_QUERIES.MAX.WARN} | Slow queries count threshold for a trigger. |
5 |
| {$PG.USER} | PostgreSQL username. |
zbx_monitor |
| {$PG.PASSWORD} | PostgreSQL user password. |
<Put the password here> |
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Bgwriter: Buffers allocated per second | Number of buffers allocated per second. |
Dependent item | pgsql.bgwriter.buffers_alloc.rate Preprocessing
|
| Bgwriter: Buffers written directly by a backend per second | Number of buffers written directly by a backend per second. |
Dependent item | pgsql.bgwriter.buffers_backend.rate Preprocessing
|
| Bgwriter: Times a backend executed its own fsync per second | 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). |
Dependent item | pgsql.bgwriter.buffers_backend_fsync.rate Preprocessing
|
| Checkpoint: Buffers written during checkpoints per second | Number of buffers written during checkpoints per second. |
Dependent item | pgsql.bgwriter.buffers_checkpoint.rate Preprocessing
|
| Checkpoint: Buffers written by the background writer per second | Number of buffers written by the background writer per second. |
Dependent item | pgsql.bgwriter.buffers_clean.rate Preprocessing
|
| Checkpoint: Requested per second | Number of requested checkpoints that have been performed per second. |
Dependent item | pgsql.bgwriter.checkpoints_req.rate Preprocessing
|
| Checkpoint: Scheduled per second | Number of scheduled checkpoints that have been performed per second. |
Dependent item | pgsql.bgwriter.checkpoints_timed.rate Preprocessing
|
| Checkpoint: Checkpoint sync time per second | Total amount of time per second that has been spent in the portion of checkpoint processing where files are synchronized to disk. |
Dependent item | pgsql.bgwriter.checkpoint_sync_time.rate Preprocessing
|
| Checkpoint: Checkpoint write time per second | Total amount of time per second that has been spent in the portion of checkpoint processing where files are written to disk. |
Dependent item | pgsql.bgwriter.checkpoint_write_time.rate Preprocessing
|
| Bgwriter: Number of bgwriter cleaning scan stopped per second | Number of times the background writer stopped a cleaning scan because it had written too many buffers per second. |
Dependent item | pgsql.bgwriter.maxwritten_clean.rate Preprocessing
|
| PostgreSQL: Get bgwriter | Collect all metrics from pg_stat_bgwriter: https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-BGWRITER-VIEW |
Zabbix agent | pgsql.bgwriter["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| PostgreSQL: Cache hit ratio, % | Cache hit ratio. |
Zabbix agent | pgsql.cache.hit["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| PostgreSQL: Config hash | PostgreSQL configuration hash. |
Zabbix agent | pgsql.config.hash["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] Preprocessing
|
| Connections sum: Active | Total number of connections executing a query. |
Dependent item | pgsql.connections.sum.active Preprocessing
|
| Connections sum: Idle | Total number of connections waiting for a new client command. |
Dependent item | pgsql.connections.sum.idle Preprocessing
|
| Connections sum: Idle in transaction | Total number of connections in a transaction state but not executing a query. |
Dependent item | pgsql.connections.sum.idle_in_transaction Preprocessing
|
| Connections sum: Prepared | Total number of prepared transactions: https://www.postgresql.org/docs/current/sql-prepare-transaction.html |
Dependent item | pgsql.connections.sum.prepared Preprocessing
|
| Connections sum: Total | Total number of connections. |
Dependent item | pgsql.connections.sum.total Preprocessing
|
| Connections sum: Total, % | Total number of connections, in percentage. |
Dependent item | pgsql.connections.sum.total_pct Preprocessing
|
| Connections sum: Waiting | Total number of waiting connections: https://www.postgresql.org/docs/current/monitoring-stats.html#WAIT-EVENT-TABLE |
Dependent item | pgsql.connections.sum.waiting Preprocessing
|
| PostgreSQL: Get connections sum | Collect all metrics from pg_stat_activity: https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-ACTIVITY-VIEW |
Zabbix agent | pgsql.connections.sum["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| PostgreSQL: Get dbstat | Collect all metrics from pg_stat_database per database: https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-DATABASE-VIEW |
Zabbix agent | pgsql.dbstat["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| PostgreSQL: Get locks | Collect all metrics from pg_locks per database: https://www.postgresql.org/docs/current/explicit-locking.html#LOCKING-TABLES |
Zabbix agent | pgsql.locks["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| PostgreSQL: Ping time | Used to get the |
Zabbix agent | pgsql.ping.time["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] Preprocessing
|
| PostgreSQL: Ping | Used to test a connection to see if it is alive. It is set to 0 if the instance doesn't accept the connections. |
Zabbix agent | pgsql.ping["{$PG.HOST}","{$PG.PORT}"] Preprocessing
|
| PostgreSQL: Get queries | Collect all metrics by query execution time. |
Zabbix agent | pgsql.queries["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}","{$PG.QUERY_ETIME.MAX.WARN}"] |
| PostgreSQL: Replication: Standby count | Number of standby servers. |
Zabbix agent | pgsql.replication.count["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| PostgreSQL: Replication: Lag in seconds | Replication lag with master, in seconds. |
Zabbix agent | pgsql.replication.lag.sec["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| PostgreSQL: Replication: Recovery role | Replication role: 1 — recovery is still in progress (standby mode), 0 — master mode. |
Zabbix agent | pgsql.replication.recovery_role["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| PostgreSQL: Replication: Status | Replication status: 0 — streaming is down, 1 — streaming is up, 2 — master mode. |
Zabbix agent | pgsql.replication.status["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Transactions: Max active transaction time | Current max active transaction time. |
Dependent item | pgsql.transactions.active Preprocessing
|
| Transactions: Max idle transaction time | Current max idle transaction time. |
Dependent item | pgsql.transactions.idle Preprocessing
|
| Transactions: Max prepared transaction time | Current max prepared transaction time. |
Dependent item | pgsql.transactions.prepared Preprocessing
|
| Transactions: Max waiting transaction time | Current max waiting transaction time. |
Dependent item | pgsql.transactions.waiting Preprocessing
|
| PostgreSQL: Get transactions | Collect metrics by transaction execution time. |
Zabbix agent | pgsql.transactions["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| PostgreSQL: Uptime | Time since the server started. |
Zabbix agent | pgsql.uptime["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| PostgreSQL: Version | PostgreSQL version. |
Zabbix agent | pgsql.version["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] Preprocessing
|
| WAL: Segments count | Number of WAL segments. |
Dependent item | pgsql.wal.count Preprocessing
|
| PostgreSQL: Get WAL | Collect write-ahead log (WAL) metrics. |
Zabbix agent | pgsql.wal.stat["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| WAL: Bytes written | WAL write, in bytes. |
Dependent item | pgsql.wal.write Preprocessing
|
| Name | Description | Expression | Severity | Dependencies and additional info |
|---|---|---|---|---|
| PostgreSQL: Required checkpoints occur too frequently | Checkpoints are points in the sequence of transactions at which it is guaranteed that the heap and index data files have been updated with all information written before that checkpoint. At checkpoint time, all dirty data pages are flushed to disk and a special checkpoint record is written to the log file. |
last(/PostgreSQL by Zabbix agent/pgsql.bgwriter.checkpoints_req.rate) > {$PG.CHECKPOINTS_REQ.MAX.WARN} |
Average | |
| PostgreSQL: Failed to get items | Zabbix has not received any data for items for the last 30 minutes. |
nodata(/PostgreSQL by Zabbix agent/pgsql.bgwriter["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"],30m) = 1 |
Warning | Depends on:
|
| PostgreSQL: Cache hit ratio too low | Cache hit ratio is lower than {$PG.CACHE_HITRATIO.MIN.WARN} for 5m. |
max(/PostgreSQL by Zabbix agent/pgsql.cache.hit["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"],5m) < {$PG.CACHE_HITRATIO.MIN.WARN} |
Warning | |
| PostgreSQL: Configuration has changed | PostgreSQL configuration has changed. |
last(/PostgreSQL by Zabbix agent/pgsql.config.hash["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"],#1)<>last(/PostgreSQL by Zabbix agent/pgsql.config.hash["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"],#2) and length(last(/PostgreSQL by Zabbix agent/pgsql.config.hash["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]))>0 |
Info | |
| PostgreSQL: Total number of connections is too high | 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). |
min(/PostgreSQL by Zabbix agent/pgsql.connections.sum.total_pct,5m) > {$PG.CONN_TOTAL_PCT.MAX.WARN} |
Average | |
| PostgreSQL: Response too long | Response is taking too long (over {$PG.PING_TIME.MAX.WARN} for 5m). |
min(/PostgreSQL by Zabbix agent/pgsql.ping.time["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"],5m) > {$PG.PING_TIME.MAX.WARN} |
Average | Depends on:
|
| PostgreSQL: Service is down | Last test of a connection was unsuccessful. |
last(/PostgreSQL by Zabbix agent/pgsql.ping["{$PG.HOST}","{$PG.PORT}"]) = 0 |
High | |
| PostgreSQL: Streaming lag with master is too high | Replication lag with master is higher than {$PG.REPL_LAG.MAX.WARN} for 5m. |
min(/PostgreSQL by Zabbix agent/pgsql.replication.lag.sec["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"],5m) > {$PG.REPL_LAG.MAX.WARN} |
Average | |
| PostgreSQL: Replication is down | Replication is enabled and data streaming was down for 5m. |
max(/PostgreSQL by Zabbix agent/pgsql.replication.status["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"],5m)=0 |
Average | |
| PostgreSQL: Service has been restarted | PostgreSQL uptime is less than 10 minutes. |
last(/PostgreSQL by Zabbix agent/pgsql.uptime["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]) < 10m |
Average | |
| PostgreSQL: Version has changed | last(/PostgreSQL by Zabbix agent/pgsql.version["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"],#1)<>last(/PostgreSQL by Zabbix agent/pgsql.version["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"],#2) and length(last(/PostgreSQL by Zabbix agent/pgsql.version["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]))>0 |
Info |
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Database discovery | Discovers databases (DB) in the database management system (DBMS), except: - templates; - default "postgres" DB; - DBs that do not allow connections. |
Zabbix agent | pgsql.discovery.db["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| DB [{#DBNAME}]: Get dbstat | Get dbstat metrics for database "{#DBNAME}". |
Dependent item | pgsql.dbstat.get_metrics["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Get queries | Get queries metrics for database "{#DBNAME}". |
Dependent item | pgsql.queries.get_metrics["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Database size | Database size. |
Zabbix agent | pgsql.db.size["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}","{#DBNAME}"] |
| DB [{#DBNAME}]: Blocks hit per second | Total number of times per second disk blocks were found already in the buffer cache, so that a read was not necessary. |
Dependent item | pgsql.dbstat.blks_hit.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Disk blocks read per second | Total number of disk blocks read per second in this database. |
Dependent item | pgsql.dbstat.blks_read.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Detected conflicts per second | Total number of queries canceled due to conflicts with recovery in this database per second. |
Dependent item | pgsql.dbstat.conflicts.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Detected deadlocks per second | Total number of detected deadlocks in this database per second. |
Dependent item | pgsql.dbstat.deadlocks.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Temp_bytes written per second | Total amount of data written to temporary files by queries in this database. |
Dependent item | pgsql.dbstat.temp_bytes.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Temp_files created per second | Total number of temporary files created by queries in this database. |
Dependent item | pgsql.dbstat.temp_files.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Tuples deleted per second | Total number of rows deleted by queries in this database per second. |
Dependent item | pgsql.dbstat.tup_deleted.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Tuples fetched per second | Total number of rows fetched by queries in this database per second. |
Dependent item | pgsql.dbstat.tup_fetched.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Tuples inserted per second | Total number of rows inserted by queries in this database per second. |
Dependent item | pgsql.dbstat.tup_inserted.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Tuples returned per second | Number of rows returned by queries in this database per second. |
Dependent item | pgsql.dbstat.tup_returned.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Tuples updated per second | Total number of rows updated by queries in this database per second. |
Dependent item | pgsql.dbstat.tup_updated.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Commits per second | Number of transactions in this database that have been committed per second. |
Dependent item | pgsql.dbstat.xact_commit.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Rollbacks per second | Total number of transactions in this database that have been rolled back. |
Dependent item | pgsql.dbstat.xact_rollback.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Frozen XID before autovacuum, % | Preventing Transaction ID Wraparound Failures: https://www.postgresql.org/docs/current/routine-vacuuming.html#VACUUM-FOR-WRAPAROUND |
Dependent item | pgsql.frozenxid.prc_before_av["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Frozen XID before stop, % | Preventing Transaction ID Wraparound Failures: https://www.postgresql.org/docs/current/routine-vacuuming.html#VACUUM-FOR-WRAPAROUND |
Dependent item | pgsql.frozenxid.prc_before_stop["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Get frozen XID | Zabbix agent | pgsql.frozenxid["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{#DBNAME}"] | |
| DB [{#DBNAME}]: Num of locks total | Total number of locks in this database. |
Dependent item | pgsql.locks.total["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries slow maintenance count | Slow maintenance query count for this database. |
Dependent item | pgsql.queries.mro.slow_count["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries max maintenance time | Max maintenance query time for this database. |
Dependent item | pgsql.queries.mro.time_max["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries sum maintenance time | Sum maintenance query time for this database. |
Dependent item | pgsql.queries.mro.time_sum["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries slow query count | Slow query count for this database. |
Dependent item | pgsql.queries.query.slow_count["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries max query time | Max query time for this database. |
Dependent item | pgsql.queries.query.time_max["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries sum query time | Sum query time for this database. |
Dependent item | pgsql.queries.query.time_sum["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries slow transaction count | Slow transaction query count for this database. |
Dependent item | pgsql.queries.tx.slow_count["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries max transaction time | Max transaction query time for this database. |
Dependent item | pgsql.queries.tx.time_max["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries sum transaction time | Sum transaction query time for this database. |
Dependent item | pgsql.queries.tx.time_sum["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Index scans per second | Number of index scans in the database per second. |
Dependent item | pgsql.scans.idx.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Sequential scans per second | Number of sequential scans in this database per second. |
Dependent item | pgsql.scans.seq.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Get scans | Number of scans done for table/index in this database. |
Zabbix agent | pgsql.scans["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{#DBNAME}"] |
| Name | Description | Expression | Severity | Dependencies and additional info |
|---|---|---|---|---|
| DB [{#DBNAME}]: Too many recovery conflicts | 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. |
min(/PostgreSQL by Zabbix agent/pgsql.dbstat.conflicts.rate["{#DBNAME}"],5m) > {$PG.CONFLICTS.MAX.WARN:"{#DBNAME}"} |
Average | |
| DB [{#DBNAME}]: Deadlock occurred | Number of deadlocks detected per second exceeds {$PG.DEADLOCKS.MAX.WARN:"{#DBNAME}"} for 5m. |
min(/PostgreSQL by Zabbix agent/pgsql.dbstat.deadlocks.rate["{#DBNAME}"],5m) > {$PG.DEADLOCKS.MAX.WARN:"{#DBNAME}"} |
High | |
| DB [{#DBNAME}]: VACUUM FREEZE is required to prevent wraparound | Preventing Transaction ID Wraparound Failures: |
last(/PostgreSQL by Zabbix agent/pgsql.frozenxid.prc_before_stop["{#DBNAME}"])<{$PG.FROZENXID_PCT_STOP.MIN.HIGH:"{#DBNAME}"} |
Average | |
| DB [{#DBNAME}]: Number of locks is too high | min(/PostgreSQL by Zabbix agent/pgsql.locks.total["{#DBNAME}"],5m)>{$PG.LOCKS.MAX.WARN:"{#DBNAME}"} |
Warning | ||
| DB [{#DBNAME}]: Too many slow queries | The number of detected slow queries exceeds the limit of {$PG.SLOW_QUERIES.MAX.WARN:"{#DBNAME}"}. |
min(/PostgreSQL by Zabbix agent/pgsql.queries.query.slow_count["{#DBNAME}"],5m)>{$PG.SLOW_QUERIES.MAX.WARN:"{#DBNAME}"} |
Warning |
Please report any issues with the template at https://support.zabbix.com
You can also provide feedback, discuss the template, or ask for help at ZABBIX forums
Source: https://git.zabbix.com/projects/ZBX/repos/zabbix/browse/templates/db/postgresql?at=release/6.2
For Zabbix version: 6.2 and higher
Templates to monitor PostgreSQL by Zabbix.
This template was tested on PostgreSQL versions 9.6, 10 and 11 on Linux and Windows.
See Zabbix template operation for basic instructions.
Install Zabbix agent and create a read-only zbx_monitor user with proper access to your PostgreSQL server.
For PostgreSQL version 10 and above:
CREATE USER zbx_monitor WITH PASSWORD '<PASSWORD>' INHERIT;
GRANT pg_monitor TO zbx_monitor;
For PostgreSQL version 9.6 and below:
CREATE USER zbx_monitor WITH PASSWORD '<PASSWORD>';
GRANT SELECT ON pg_stat_database TO zbx_monitor;
-- To collect WAL metrics, the user must have a `superuser` role.
ALTER USER zbx_monitor WITH SUPERUSER;
Copy postgresql/ to Zabbix agent home directory /var/lib/zabbix/. The postgresql/ directory contains the files needed to obtain metrics from PostgreSQL.
Copy template_db_postgresql.conf to Zabbix agent configuration directory /etc/zabbix/zabbix_agentd.d/ and restart Zabbix agent service.
Edit pg_hba.conf to allow connections from Zabbix agent https://www.postgresql.org/docs/current/auth-pg-hba-conf.html.
Add rows (for example):
host all zbx_monitor 127.0.0.1/32 trust
host all zbx_monitor 0.0.0.0/0 md5
host all zbx_monitor ::0/0 md5
Import template file to Zabbix and link it to the target host
Set {$PG.HOST}, {$PG.PORT}, {$PG.USER}, {$PG.PASSWORD} and {$PG.DB} macros values.
If PostgreSQL is installed from the PGDG repository, then add the path to pg_isready to the PATH environment variable for zabbix user.
| Name | Description | Default |
|---|---|---|
| {$PG.CACHE_HITRATIO.MIN.WARN} | - |
90 |
| {$PG.CHECKPOINTS_REQ.MAX.WARN} | - |
5 |
| {$PG.CONFLICTS.MAX.WARN} | - |
0 |
| {$PG.CONN_IDLE_IN_TRANS.MAX.WARN} | - |
5 |
| {$PG.CONN_TOTAL_PCT.MAX.WARN} | - |
90 |
| {$PG.CONN_WAIT.MAX.WARN} | - |
0 |
| {$PG.DB} | - |
postgres |
| {$PG.DEADLOCKS.MAX.WARN} | - |
0 |
| {$PG.FROZENXID_PCT_STOP.MIN.HIGH} | - |
75 |
| {$PG.HOST} | - |
127.0.0.1 |
| {$PG.LLD.FILTER.DBNAME} | - |
(.*) |
| {$PG.LOCKS.MAX.WARN} | - |
100 |
| {$PG.PASSWORD} | Please set user's password in this macro. |
`` |
| {$PG.PING_TIME.MAX.WARN} | - |
1s |
| {$PG.PORT} | - |
5432 |
| {$PG.QUERY_ETIME.MAX.WARN} | - |
30 |
| {$PG.REPL_LAG.MAX.WARN} | - |
10m |
| {$PG.SLOW_QUERIES.MAX.WARN} | - |
5 |
| {$PG.TRANS_ACTIVE.MAX.WARN} | - |
30s |
| {$PG.TRANS_IDLE.MAX.WARN} | - |
30s |
| {$PG.TRANS_WAIT.MAX.WARN} | - |
30s |
| {$PG.USER} | - |
zbx_monitor |
There are no template links in this template.
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Database discovery | - |
ZABBIX_PASSIVE | pgsql.discovery.db["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DB}"] Filter: - {#DBNAME} MATCHES_REGEX |
| Group | Name | Description | Type | Key and additional info |
|---|---|---|---|---|
| PostgreSQL | Bgwriter: Buffers allocated per second | Number of buffers allocated |
DEPENDENT | pgsql.bgwriter.buffers_alloc.rate Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | Bgwriter: Buffers written directly by a backend per second | Number of buffers written directly by a backend |
DEPENDENT | pgsql.bgwriter.buffers_backend.rate Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | Bgwriter: Buffers backend fsync per second | Number of times a backend had to execute its own fsync call (normally the background writer handles those even when the backend does its own write) |
DEPENDENT | pgsql.bgwriter.buffers_backend_fsync.rate Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | Bgwriter: Buffers written during checkpoints per second | Number of buffers written during checkpoints |
DEPENDENT | pgsql.bgwriter.buffers_checkpoint.rate Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | Bgwriter: Buffers written by the background writer per second | Number of buffers written by the background writer |
DEPENDENT | pgsql.bgwriter.buffers_clean.rate Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | Bgwriter: Requested checkpoints per second | Number of requested checkpoints that have been performed |
DEPENDENT | pgsql.bgwriter.checkpoints_req.rate Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | Bgwriter: Scheduled checkpoints per second | Number of scheduled checkpoints that have been performed |
DEPENDENT | pgsql.bgwriter.checkpoints_timed.rate Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | Bgwriter: Checkpoint sync time | Total amount of time that has been spent in the portion of checkpoint processing where files are synchronized to disk |
DEPENDENT | pgsql.bgwriter.checkpoint_sync_time Preprocessing: - JSONPATH: - MULTIPLIER: - CHANGE_PER_SECOND |
| PostgreSQL | Bgwriter: Checkpoint write time | Total amount of time that has been spent in the portion of checkpoint processing where files are written to disk, in milliseconds |
DEPENDENT | pgsql.bgwriter.checkpoint_write_time Preprocessing: - JSONPATH: - MULTIPLIER: - CHANGE_PER_SECOND |
| PostgreSQL | Bgwriter: Max written per second | Number of times the background writer stopped a cleaning scan because it had written too many buffers |
DEPENDENT | pgsql.bgwriter.maxwritten_clean.rate Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | Status: Cache hit ratio % | Cache hit ratio |
ZABBIX_PASSIVE | pgsql.cache.hit["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DB}"] |
| PostgreSQL | Status: Config hash | PostgreSQL configuration hash |
ZABBIX_PASSIVE | pgsql.config.hash["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DB}"] Preprocessing: - DISCARD_UNCHANGED_HEARTBEAT: |
| PostgreSQL | Connections sum: Active | Total number of connections executing a query |
DEPENDENT | pgsql.connections.sum.active Preprocessing: - JSONPATH: |
| PostgreSQL | Connections sum: Idle | Total number of connections waiting for a new client command |
DEPENDENT | pgsql.connections.sum.idle Preprocessing: - JSONPATH: |
| PostgreSQL | Connections sum: Idle in transaction | Total number of connections in a transaction state, but not executing a query |
DEPENDENT | pgsql.connections.sum.idle_in_transaction Preprocessing: - JSONPATH: |
| PostgreSQL | Connections sum: Prepared | Total number of prepared transactions https://www.postgresql.org/docs/current/sql-prepare-transaction.html |
DEPENDENT | pgsql.connections.sum.prepared Preprocessing: - JSONPATH: |
| PostgreSQL | Connections sum: Total | Total number of connections |
DEPENDENT | pgsql.connections.sum.total Preprocessing: - JSONPATH: |
| PostgreSQL | Connections sum: Total % | Total number of connections in percentage |
DEPENDENT | pgsql.connections.sum.total_pct Preprocessing: - JSONPATH: |
| PostgreSQL | Connections sum: Waiting | Total number of waiting connections https://www.postgresql.org/docs/current/monitoring-stats.html#WAIT-EVENT-TABLE |
DEPENDENT | pgsql.connections.sum.waiting Preprocessing: - JSONPATH: |
| PostgreSQL | Status: Ping time | - |
ZABBIX_PASSIVE | pgsql.ping.time["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DB}"] Preprocessing: - REGEX: - MULTIPLIER: |
| PostgreSQL | Status: Ping | - |
ZABBIX_PASSIVE | pgsql.ping["{$PG.HOST}","{$PG.PORT}"] Preprocessing: - JAVASCRIPT: - DISCARD_UNCHANGED_HEARTBEAT: |
| PostgreSQL | Replication: standby count | Number of standby servers |
ZABBIX_PASSIVE | pgsql.replication.count["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DB}"] |
| PostgreSQL | Replication: lag in seconds | Replication lag with Master in seconds |
ZABBIX_PASSIVE | pgsql.replication.lag.sec["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DB}"] |
| PostgreSQL | Replication: recovery role | Replication role: 1 — recovery is still in progress (standby mode), 0 — master mode. |
ZABBIX_PASSIVE | pgsql.replication.recovery_role["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DB}"] |
| PostgreSQL | Replication: status | Replication status: 0 — streaming is down, 1 — streaming is up, 2 — master mode |
ZABBIX_PASSIVE | pgsql.replication.status["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DB}"] |
| PostgreSQL | Transactions: Max active transaction time | Current max active transaction time |
DEPENDENT | pgsql.transactions.active Preprocessing: - JSONPATH: |
| PostgreSQL | Transactions: Max idle transaction time | Current max idle transaction time |
DEPENDENT | pgsql.transactions.idle Preprocessing: - JSONPATH: |
| PostgreSQL | Transactions: Max prepared transaction time | Current max prepared transaction time |
DEPENDENT | pgsql.transactions.prepared Preprocessing: - JSONPATH: |
| PostgreSQL | Transactions: Max waiting transaction time | Current max waiting transaction time |
DEPENDENT | pgsql.transactions.waiting Preprocessing: - JSONPATH: |
| PostgreSQL | Status: Uptime | - |
ZABBIX_PASSIVE | pgsql.uptime["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DB}"] |
| PostgreSQL | Status: Version | PostgreSQL version |
ZABBIX_PASSIVE | pgsql.version["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DB}"] Preprocessing: - DISCARD_UNCHANGED_HEARTBEAT: |
| PostgreSQL | WAL: Segments count | Number of WAL segments |
DEPENDENT | pgsql.wal.count Preprocessing: - JSONPATH: |
| PostgreSQL | WAL: Bytes written | WAL write in bytes |
DEPENDENT | pgsql.wal.write Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | DB {#DBNAME}: Database size | Database size |
ZABBIX_PASSIVE | pgsql.db.size["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DB}","{#DBNAME}"] |
| PostgreSQL | DB {#DBNAME}: Blocks hit per second | Total number of times disk blocks were found already in the buffer cache, so that a read was not necessary |
DEPENDENT | pgsql.dbstat.blks_hit.rate["{#DBNAME}"] Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | DB {#DBNAME}: Disk blocks read per second | Total number of disk blocks read in this database |
DEPENDENT | pgsql.dbstat.blks_read.rate["{#DBNAME}"] Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | DB {#DBNAME}: Detected conflicts per second | Total number of queries canceled due to conflicts with recovery in this database |
DEPENDENT | pgsql.dbstat.conflicts.rate["{#DBNAME}"] Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | DB {#DBNAME}: Detected deadlocks per second | Total number of detected deadlocks in this database |
DEPENDENT | pgsql.dbstat.deadlocks.rate["{#DBNAME}"] Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | DB {#DBNAME}: Temp_bytes written per second | Total amount of data written to temporary files by queries in this database |
DEPENDENT | pgsql.dbstat.temp_bytes.rate["{#DBNAME}"] Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | DB {#DBNAME}: Temp_files created per second | Total number of temporary files created by queries in this database |
DEPENDENT | pgsql.dbstat.temp_files.rate["{#DBNAME}"] Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | DB {#DBNAME}: Tuples deleted per second | Total number of rows deleted by queries in this database |
DEPENDENT | pgsql.dbstat.tup_deleted.rate["{#DBNAME}"] Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | DB {#DBNAME}: Tuples fetched per second | Total number of rows fetched by queries in this database |
DEPENDENT | pgsql.dbstat.tup_fetched.rate["{#DBNAME}"] Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | DB {#DBNAME}: Tuples inserted per second | Total number of rows inserted by queries in this database |
DEPENDENT | pgsql.dbstat.tup_inserted.rate["{#DBNAME}"] Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | DB {#DBNAME}: Tuples returned per second | Total number of rows updated by queries in this database |
DEPENDENT | pgsql.dbstat.tup_returned.rate["{#DBNAME}"] Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | DB {#DBNAME}: Tuples updated per second | Total number of rows updated by queries in this database |
DEPENDENT | pgsql.dbstat.tup_updated.rate["{#DBNAME}"] Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | DB {#DBNAME}: Commits per second | Number of transactions in this database that have been committed |
DEPENDENT | pgsql.dbstat.xact_commit.rate["{#DBNAME}"] Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | DB {#DBNAME}: Rollbacks per second | Total number of transactions in this database that have been rolled back |
DEPENDENT | pgsql.dbstat.xact_rollback.rate["{#DBNAME}"] Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | DB {#DBNAME}: Frozen XID before avtovacuum % | reventing Transaction ID Wraparound Failures https://www.postgresql.org/docs/current/routine-vacuuming.html#VACUUM-FOR-WRAPAROUND |
DEPENDENT | pgsql.frozenxid.prc_before_av["{#DBNAME}"] Preprocessing: - JSONPATH: |
| PostgreSQL | DB {#DBNAME}: Frozen XID before stop % | Preventing Transaction ID Wraparound Failures https://www.postgresql.org/docs/current/routine-vacuuming.html#VACUUM-FOR-WRAPAROUND |
DEPENDENT | pgsql.frozenxid.prc_before_stop["{#DBNAME}"] Preprocessing: - JSONPATH: |
| PostgreSQL | DB {#DBNAME}: Locks total | Total number of locks in the database |
DEPENDENT | pgsql.locks.total["{#DBNAME}"] Preprocessing: - JSONPATH: |
| PostgreSQL | DB {#DBNAME}: Queries slow maintenance count | Slow maintenance query count |
DEPENDENT | pgsql.queries.mro.slow_count["{#DBNAME}"] Preprocessing: - JSONPATH: |
| PostgreSQL | DB {#DBNAME}: Queries max maintenance time | Max maintenance query time |
DEPENDENT | pgsql.queries.mro.time_max["{#DBNAME}"] Preprocessing: - JSONPATH: |
| PostgreSQL | DB {#DBNAME}: Queries sum maintenance time | Sum maintenance query time |
DEPENDENT | pgsql.queries.mro.time_sum["{#DBNAME}"] Preprocessing: - JSONPATH: |
| PostgreSQL | DB {#DBNAME}: Queries slow query count | Slow query count |
DEPENDENT | pgsql.queries.query.slow_count["{#DBNAME}"] Preprocessing: - JSONPATH: |
| PostgreSQL | DB {#DBNAME}: Queries max query time | Max query time |
DEPENDENT | pgsql.queries.query.time_max["{#DBNAME}"] Preprocessing: - JSONPATH: |
| PostgreSQL | DB {#DBNAME}: Queries sum query time | Sum query time |
DEPENDENT | pgsql.queries.query.time_sum["{#DBNAME}"] Preprocessing: - JSONPATH: |
| PostgreSQL | DB {#DBNAME}: Queries slow transaction count | Slow transaction query count |
DEPENDENT | pgsql.queries.tx.slow_count["{#DBNAME}"] Preprocessing: - JSONPATH: |
| PostgreSQL | DB {#DBNAME}: Queries max transaction time | Max transaction query time |
DEPENDENT | pgsql.queries.tx.time_max["{#DBNAME}"] Preprocessing: - JSONPATH: |
| PostgreSQL | DB {#DBNAME}: Queries sum transaction time | Sum transaction query time |
DEPENDENT | pgsql.queries.tx.time_sum["{#DBNAME}"] Preprocessing: - JSONPATH: |
| PostgreSQL | DB {#DBNAME}: Index scans per second | Number of index scans in the database |
DEPENDENT | pgsql.scans.idx.rate["{#DBNAME}"] Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | DB {#DBNAME}: Sequential scans per second | Number of sequential scans in the database |
DEPENDENT | pgsql.scans.seq.rate["{#DBNAME}"] Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| Zabbix raw items | PostgreSQL: Get bgwriter | Statistics about the background writer process's activity |
ZABBIX_PASSIVE | pgsql.bgwriter["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DB}"] |
| Zabbix raw items | PostgreSQL: Get connections sum | Collect all metrics from pg_stat_activity https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-ACTIVITY-VIEW |
ZABBIX_PASSIVE | pgsql.connections.sum["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DB}"] |
| Zabbix raw items | PostgreSQL: Get dbstat | Collect all metrics from pg_stat_database per database https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-DATABASE-VIEW |
ZABBIX_PASSIVE | pgsql.dbstat["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DB}"] |
| Zabbix raw items | PostgreSQL: Get locks | Collect all metrics from pg_locks per database https://www.postgresql.org/docs/current/explicit-locking.html#LOCKING-TABLES |
ZABBIX_PASSIVE | pgsql.locks["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DB}"] |
| Zabbix raw items | PostgreSQL: Get queries | Collect all metrics by query execution time |
ZABBIX_PASSIVE | pgsql.queries["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DB}","{$PG.QUERY_ETIME.MAX.WARN}"] |
| Zabbix raw items | PostgreSQL: Get transactions | Collect metrics by transaction execution time |
ZABBIX_PASSIVE | pgsql.transactions["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DB}"] |
| Zabbix raw items | PostgreSQL: Get WAL | Master item to collect WAL metrics |
ZABBIX_PASSIVE | pgsql.wal.stat["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DB}"] |
| Zabbix raw items | DB {#DBNAME}: Get frozen XID | - |
ZABBIX_PASSIVE | pgsql.frozenxid["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{#DBNAME}"] |
| Zabbix raw items | DB {#DBNAME}: Get scans | Number of scans done for table/index in the database |
ZABBIX_PASSIVE | pgsql.scans["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{#DBNAME}"] |
| Name | Description | Expression | Severity | Dependencies and additional info |
|---|---|---|---|---|
| PostgreSQL: Required checkpoints occurs too frequently | Checkpoints are points in the sequence of transactions at which it is guaranteed that the heap and index data files have been updated with all information written before that checkpoint. At checkpoint time, all dirty data pages are flushed to disk and a special checkpoint record is written to the log file. https://www.postgresql.org/docs/current/wal-configuration.html |
last(/PostgreSQL by Zabbix agent/pgsql.bgwriter.checkpoints_req.rate) > {$PG.CHECKPOINTS_REQ.MAX.WARN} |
AVERAGE | |
| PostgreSQL: Cache hit ratio too low | - |
max(/PostgreSQL by Zabbix agent/pgsql.cache.hit["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DB}"],5m) < {$PG.CACHE_HITRATIO.MIN.WARN} |
WARNING | |
| PostgreSQL: Configuration has changed | - |
last(/PostgreSQL by Zabbix agent/pgsql.config.hash["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DB}"],#1)<>last(/PostgreSQL by Zabbix agent/pgsql.config.hash["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DB}"],#2) and length(last(/PostgreSQL by Zabbix agent/pgsql.config.hash["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DB}"]))>0 |
INFO | |
| PostgreSQL: Total number of connections is too high | - |
min(/PostgreSQL by Zabbix agent/pgsql.connections.sum.total_pct,5m) > {$PG.CONN_TOTAL_PCT.MAX.WARN} |
AVERAGE | |
| PostgreSQL: Response too long | - |
min(/PostgreSQL by Zabbix agent/pgsql.ping.time["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DB}"],5m) > {$PG.PING_TIME.MAX.WARN} |
AVERAGE | Depends on: - PostgreSQL: Service is down |
| PostgreSQL: Service is down | - |
last(/PostgreSQL by Zabbix agent/pgsql.ping["{$PG.HOST}","{$PG.PORT}"]) = 0 |
HIGH | |
| PostgreSQL: Streaming lag with {#MASTER} is too high | - |
min(/PostgreSQL by Zabbix agent/pgsql.replication.lag.sec["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DB}"],5m) > {$PG.REPL_LAG.MAX.WARN} |
AVERAGE | |
| PostgreSQL: Replication is down | - |
max(/PostgreSQL by Zabbix agent/pgsql.replication.status["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DB}"],5m)=0 |
AVERAGE | |
| PostgreSQL: Service has been restarted | PostgreSQL uptime is less than 10 minutes |
last(/PostgreSQL by Zabbix agent/pgsql.uptime["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DB}"]) < 10m |
INFO | |
| PostgreSQL: Version has changed | - |
last(/PostgreSQL by Zabbix agent/pgsql.version["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DB}"],#1)<>last(/PostgreSQL by Zabbix agent/pgsql.version["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DB}"],#2) and length(last(/PostgreSQL by Zabbix agent/pgsql.version["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DB}"]))>0 |
INFO | |
| DB {#DBNAME}: Too many recovery conflicts | 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 |
min(/PostgreSQL by Zabbix agent/pgsql.dbstat.conflicts.rate["{#DBNAME}"],5m) > {$PG.CONFLICTS.MAX.WARN:"{#DBNAME}"} |
AVERAGE | |
| DB {#DBNAME}: Deadlock occurred | - |
min(/PostgreSQL by Zabbix agent/pgsql.dbstat.deadlocks.rate["{#DBNAME}"],5m) > {$PG.DEADLOCKS.MAX.WARN:"{#DBNAME}"} |
HIGH | |
| DB {#DBNAME}: VACUUM FREEZE is required to prevent wraparound | Preventing Transaction ID Wraparound Failures https://www.postgresql.org/docs/current/routine-vacuuming.html#VACUUM-FOR-WRAPAROUND |
last(/PostgreSQL by Zabbix agent/pgsql.frozenxid.prc_before_stop["{#DBNAME}"])<{$PG.FROZENXID_PCT_STOP.MIN.HIGH:"{#DBNAME}"} |
AVERAGE | |
| DB {#DBNAME}: Number of locks is too high | - |
min(/PostgreSQL by Zabbix agent/pgsql.locks.total["{#DBNAME}"],5m)>{$PG.LOCKS.MAX.WARN:"{#DBNAME}"} |
WARNING | |
| DB {#DBNAME}: Too many slow queries | - |
min(/PostgreSQL by Zabbix agent/pgsql.queries.query.slow_count["{#DBNAME}"],5m)>{$PG.SLOW_QUERIES.MAX.WARN:"{#DBNAME}"} |
WARNING | |
| PostgreSQL: Failed to get items | Zabbix has not received data for items for the last 30 minutes |
nodata(/PostgreSQL by Zabbix agent/pgsql.bgwriter["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DB}"],30m) = 1 |
WARNING | Depends on: - PostgreSQL: Service is down |
Please report any issues with the template at https://support.zabbix.com
You can also provide feedback, discuss the template or ask for help with it at ZABBIX forums.
Source: https://git.zabbix.com/projects/ZBX/repos/zabbix/browse/templates/db/postgresql?at=release/6.0
This template is designed for the deployment of PostgreSQL monitoring by Zabbix via Zabbix agent and uses user parameters to run SQL queries with the psql command-line tool.
Zabbix version: 6.0 and higher.
This template has been tested on:
Zabbix should be configured according to the instructions in the Templates out of the box section.
Note:
pg_isready and psql utilities to be installed on the same host with Zabbix agent.<password> at your discretion) with proper access rights to your PostgreSQL instance.For PostgreSQL version 10 and above:
CREATE USER zbx_monitor WITH PASSWORD '<PASSWORD>' INHERIT;
GRANT pg_monitor TO zbx_monitor;
For PostgreSQL version 9.6 and below:
CREATE USER zbx_monitor WITH PASSWORD '<PASSWORD>';
GRANT SELECT ON pg_stat_database TO zbx_monitor;
-- To collect WAL metrics, the user must have a `superuser` role.
ALTER USER zbx_monitor WITH SUPERUSER;
postgresql/ directory to the zabbix user home directory - /var/lib/zabbix/. The postgresql/ directory contains the files with SQL queries needed to obtain metrics from PostgreSQL instance.If the home directory of the zabbix user doesn't exist, create it first:
mkdir -m u=rwx,g=rwx,o= -p /var/lib/zabbix
chown zabbix:zabbix /var/lib/zabbix
template_db_postgresql.conf file, containing user parameters, to the Zabbix agent configuration directory /etc/zabbix/zabbix_agentd.d/ and restart Zabbix agent service.Note: if you want to use SSL/TLS encryption to protect communications with the remote PostgreSQL instance, you can modify the connection string in user parameters. For example, to enable required encryption in transport mode without identity checks you could append ?sslmode=required to the end of the connection string for all keys that use psql:
UserParameter=pgsql.bgwriter[*], psql -qtAX postgresql://"$3":"$4"@"$1":"$2"/"$5"?sslmode=required -f "/var/lib/zabbix/postgresql/pgsql.bgwriter.sql"
Consult the PostgreSQL documentation about protection modes and client connection parameters.
Also, it is assumed that you set up the PostgreSQL instance to work in the desired encryption mode. Check the PostgreSQL documentation for details.
pg_hba.conf configuration file to allow connections for the user zbx_monitor. For example, you could add one of the following rows to allow local TCP connections from the same host:# TYPE DATABASE USER ADDRESS METHOD
host all zbx_monitor localhost trust
host all zbx_monitor 127.0.0.1/32 md5
host all zbx_monitor ::1/128 scram-sha-256
For more information please read the PostgreSQL documentation https://www.postgresql.org/docs/current/auth-pg-hba-conf.html.
Specify the host name or IP address in the {$PG.HOST} macro. Adjust the port number with {$PG.PORT} macro if needed.
Set the password that you specified in step 1 in the macro {$PG.PASSWORD}.
| Name | Description | Default |
|---|---|---|
| {$PG.CACHE_HITRATIO.MIN.WARN} | Minimum cache hit ratio percentage for trigger expression. |
90 |
| {$PG.CHECKPOINTS_REQ.MAX.WARN} | Maximum required checkpoint occurrences for trigger expression. |
5 |
| {$PG.CONFLICTS.MAX.WARN} | Maximum number of recovery conflicts for trigger expression. |
0 |
| {$PG.CONN_TOTAL_PCT.MAX.WARN} | Maximum percentage of current connections for trigger expression. |
90 |
| {$PG.DATABASE} | Default PostgreSQL database for the connection. |
postgres |
| {$PG.DEADLOCKS.MAX.WARN} | Maximum number of detected deadlocks for trigger expression. |
0 |
| {$PG.FROZENXID_PCT_STOP.MIN.HIGH} | Minimum frozen XID before stop percentage for trigger expression. |
75 |
| {$PG.HOST} | Hostname or IP of PostgreSQL host. |
localhost |
| {$PG.LLD.FILTER.DBNAME} | Filter of discoverable databases. |
.+ |
| {$PG.LOCKS.MAX.WARN} | Maximum number of locks for trigger expression. |
100 |
| {$PG.PING_TIME.MAX.WARN} | Maximum time of connection response for trigger expression. |
1s |
| {$PG.PORT} | PostgreSQL service port. |
5432 |
| {$PG.QUERY_ETIME.MAX.WARN} | Execution time limit for count of slow queries. |
30 |
| {$PG.REPL_LAG.MAX.WARN} | Maximum replication lag time for trigger expression. |
10m |
| {$PG.SLOW_QUERIES.MAX.WARN} | Slow queries count threshold for a trigger. |
5 |
| {$PG.USER} | PostgreSQL username. |
zbx_monitor |
| {$PG.PASSWORD} | PostgreSQL user password. |
<Put the password here> |
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Bgwriter: Buffers allocated per second | Number of buffers allocated per second. |
Dependent item | pgsql.bgwriter.buffers_alloc.rate Preprocessing
|
| Bgwriter: Buffers written directly by a backend per second | Number of buffers written directly by a backend per second. |
Dependent item | pgsql.bgwriter.buffers_backend.rate Preprocessing
|
| Bgwriter: Times a backend executed its own fsync per second | 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). |
Dependent item | pgsql.bgwriter.buffers_backend_fsync.rate Preprocessing
|
| Checkpoint: Buffers written during checkpoints per second | Number of buffers written during checkpoints per second. |
Dependent item | pgsql.bgwriter.buffers_checkpoint.rate Preprocessing
|
| Checkpoint: Buffers written by the background writer per second | Number of buffers written by the background writer per second. |
Dependent item | pgsql.bgwriter.buffers_clean.rate Preprocessing
|
| Checkpoint: Requested per second | Number of requested checkpoints that have been performed per second. |
Dependent item | pgsql.bgwriter.checkpoints_req.rate Preprocessing
|
| Checkpoint: Scheduled per second | Number of scheduled checkpoints that have been performed per second. |
Dependent item | pgsql.bgwriter.checkpoints_timed.rate Preprocessing
|
| Checkpoint: Checkpoint sync time per second | Total amount of time per second that has been spent in the portion of checkpoint processing where files are synchronized to disk. |
Dependent item | pgsql.bgwriter.checkpoint_sync_time.rate Preprocessing
|
| Checkpoint: Checkpoint write time per second | Total amount of time per second that has been spent in the portion of checkpoint processing where files are written to disk. |
Dependent item | pgsql.bgwriter.checkpoint_write_time.rate Preprocessing
|
| Bgwriter: Number of bgwriter cleaning scan stopped per second | Number of times the background writer stopped a cleaning scan because it had written too many buffers per second. |
Dependent item | pgsql.bgwriter.maxwritten_clean.rate Preprocessing
|
| PostgreSQL: Get bgwriter | Collect all metrics from pg_stat_bgwriter: https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-BGWRITER-VIEW |
Zabbix agent | pgsql.bgwriter["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| PostgreSQL: Cache hit ratio, % | Cache hit ratio. |
Zabbix agent | pgsql.cache.hit["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| PostgreSQL: Config hash | PostgreSQL configuration hash. |
Zabbix agent | pgsql.config.hash["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] Preprocessing
|
| Connections sum: Active | Total number of connections executing a query. |
Dependent item | pgsql.connections.sum.active Preprocessing
|
| Connections sum: Idle | Total number of connections waiting for a new client command. |
Dependent item | pgsql.connections.sum.idle Preprocessing
|
| Connections sum: Idle in transaction | Total number of connections in a transaction state but not executing a query. |
Dependent item | pgsql.connections.sum.idle_in_transaction Preprocessing
|
| Connections sum: Prepared | Total number of prepared transactions: https://www.postgresql.org/docs/current/sql-prepare-transaction.html |
Dependent item | pgsql.connections.sum.prepared Preprocessing
|
| Connections sum: Total | Total number of connections. |
Dependent item | pgsql.connections.sum.total Preprocessing
|
| Connections sum: Total, % | Total number of connections, in percentage. |
Dependent item | pgsql.connections.sum.total_pct Preprocessing
|
| Connections sum: Waiting | Total number of waiting connections: https://www.postgresql.org/docs/current/monitoring-stats.html#WAIT-EVENT-TABLE |
Dependent item | pgsql.connections.sum.waiting Preprocessing
|
| PostgreSQL: Get connections sum | Collect all metrics from pg_stat_activity: https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-ACTIVITY-VIEW |
Zabbix agent | pgsql.connections.sum["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| PostgreSQL: Get dbstat | Collect all metrics from pg_stat_database per database: https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-DATABASE-VIEW |
Zabbix agent | pgsql.dbstat["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| PostgreSQL: Get locks | Collect all metrics from pg_locks per database: https://www.postgresql.org/docs/current/explicit-locking.html#LOCKING-TABLES |
Zabbix agent | pgsql.locks["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| PostgreSQL: Ping time | Used to get the |
Zabbix agent | pgsql.ping.time["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] Preprocessing
|
| PostgreSQL: Ping | Used to test a connection to see if it is alive. It is set to 0 if the instance doesn't accept the connections. |
Zabbix agent | pgsql.ping["{$PG.HOST}","{$PG.PORT}"] Preprocessing
|
| PostgreSQL: Get queries | Collect all metrics by query execution time. |
Zabbix agent | pgsql.queries["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}","{$PG.QUERY_ETIME.MAX.WARN}"] |
| PostgreSQL: Replication: Standby count | Number of standby servers. |
Zabbix agent | pgsql.replication.count["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| PostgreSQL: Replication: Lag in seconds | Replication lag with master, in seconds. |
Zabbix agent | pgsql.replication.lag.sec["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| PostgreSQL: Replication: Recovery role | Replication role: 1 — recovery is still in progress (standby mode), 0 — master mode. |
Zabbix agent | pgsql.replication.recovery_role["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| PostgreSQL: Replication: Status | Replication status: 0 — streaming is down, 1 — streaming is up, 2 — master mode. |
Zabbix agent | pgsql.replication.status["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Transactions: Max active transaction time | Current max active transaction time. |
Dependent item | pgsql.transactions.active Preprocessing
|
| Transactions: Max idle transaction time | Current max idle transaction time. |
Dependent item | pgsql.transactions.idle Preprocessing
|
| Transactions: Max prepared transaction time | Current max prepared transaction time. |
Dependent item | pgsql.transactions.prepared Preprocessing
|
| Transactions: Max waiting transaction time | Current max waiting transaction time. |
Dependent item | pgsql.transactions.waiting Preprocessing
|
| PostgreSQL: Get transactions | Collect metrics by transaction execution time. |
Zabbix agent | pgsql.transactions["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| PostgreSQL: Uptime | Time since the server started. |
Zabbix agent | pgsql.uptime["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| PostgreSQL: Version | PostgreSQL version. |
Zabbix agent | pgsql.version["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] Preprocessing
|
| WAL: Segments count | Number of WAL segments. |
Dependent item | pgsql.wal.count Preprocessing
|
| PostgreSQL: Get WAL | Collect write-ahead log (WAL) metrics. |
Zabbix agent | pgsql.wal.stat["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| WAL: Bytes written | WAL write, in bytes. |
Dependent item | pgsql.wal.write Preprocessing
|
| Name | Description | Expression | Severity | Dependencies and additional info |
|---|---|---|---|---|
| PostgreSQL: Required checkpoints occur too frequently | Checkpoints are points in the sequence of transactions at which it is guaranteed that the heap and index data files have been updated with all information written before that checkpoint. At checkpoint time, all dirty data pages are flushed to disk and a special checkpoint record is written to the log file. |
last(/PostgreSQL by Zabbix agent/pgsql.bgwriter.checkpoints_req.rate) > {$PG.CHECKPOINTS_REQ.MAX.WARN} |
Average | |
| PostgreSQL: Failed to get items | Zabbix has not received any data for items for the last 30 minutes. |
nodata(/PostgreSQL by Zabbix agent/pgsql.bgwriter["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"],30m) = 1 |
Warning | Depends on:
|
| PostgreSQL: Cache hit ratio too low | Cache hit ratio is lower than {$PG.CACHE_HITRATIO.MIN.WARN} for 5m. |
max(/PostgreSQL by Zabbix agent/pgsql.cache.hit["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"],5m) < {$PG.CACHE_HITRATIO.MIN.WARN} |
Warning | |
| PostgreSQL: Configuration has changed | PostgreSQL configuration has changed. |
last(/PostgreSQL by Zabbix agent/pgsql.config.hash["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"],#1)<>last(/PostgreSQL by Zabbix agent/pgsql.config.hash["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"],#2) and length(last(/PostgreSQL by Zabbix agent/pgsql.config.hash["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]))>0 |
Info | |
| PostgreSQL: Total number of connections is too high | 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). |
min(/PostgreSQL by Zabbix agent/pgsql.connections.sum.total_pct,5m) > {$PG.CONN_TOTAL_PCT.MAX.WARN} |
Average | |
| PostgreSQL: Response too long | Response is taking too long (over {$PG.PING_TIME.MAX.WARN} for 5m). |
min(/PostgreSQL by Zabbix agent/pgsql.ping.time["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"],5m) > {$PG.PING_TIME.MAX.WARN} |
Average | Depends on:
|
| PostgreSQL: Service is down | Last test of a connection was unsuccessful. |
last(/PostgreSQL by Zabbix agent/pgsql.ping["{$PG.HOST}","{$PG.PORT}"]) = 0 |
High | |
| PostgreSQL: Streaming lag with master is too high | Replication lag with master is higher than {$PG.REPL_LAG.MAX.WARN} for 5m. |
min(/PostgreSQL by Zabbix agent/pgsql.replication.lag.sec["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"],5m) > {$PG.REPL_LAG.MAX.WARN} |
Average | |
| PostgreSQL: Replication is down | Replication is enabled and data streaming was down for 5m. |
max(/PostgreSQL by Zabbix agent/pgsql.replication.status["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"],5m)=0 |
Average | |
| PostgreSQL: Service has been restarted | PostgreSQL uptime is less than 10 minutes. |
last(/PostgreSQL by Zabbix agent/pgsql.uptime["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]) < 10m |
Average | |
| PostgreSQL: Version has changed | last(/PostgreSQL by Zabbix agent/pgsql.version["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"],#1)<>last(/PostgreSQL by Zabbix agent/pgsql.version["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"],#2) and length(last(/PostgreSQL by Zabbix agent/pgsql.version["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]))>0 |
Info |
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Database discovery | Discovers databases (DB) in the database management system (DBMS), except: - templates; - default "postgres" DB; - DBs that do not allow connections. |
Zabbix agent | pgsql.discovery.db["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| DB [{#DBNAME}]: Get dbstat | Get dbstat metrics for database "{#DBNAME}". |
Dependent item | pgsql.dbstat.get_metrics["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Get queries | Get queries metrics for database "{#DBNAME}". |
Dependent item | pgsql.queries.get_metrics["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Database size | Database size. |
Zabbix agent | pgsql.db.size["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}","{#DBNAME}"] |
| DB [{#DBNAME}]: Blocks hit per second | Total number of times per second disk blocks were found already in the buffer cache, so that a read was not necessary. |
Dependent item | pgsql.dbstat.blks_hit.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Disk blocks read per second | Total number of disk blocks read per second in this database. |
Dependent item | pgsql.dbstat.blks_read.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Detected conflicts per second | Total number of queries canceled due to conflicts with recovery in this database per second. |
Dependent item | pgsql.dbstat.conflicts.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Detected deadlocks per second | Total number of detected deadlocks in this database per second. |
Dependent item | pgsql.dbstat.deadlocks.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Temp_bytes written per second | Total amount of data written to temporary files by queries in this database. |
Dependent item | pgsql.dbstat.temp_bytes.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Temp_files created per second | Total number of temporary files created by queries in this database. |
Dependent item | pgsql.dbstat.temp_files.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Tuples deleted per second | Total number of rows deleted by queries in this database per second. |
Dependent item | pgsql.dbstat.tup_deleted.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Tuples fetched per second | Total number of rows fetched by queries in this database per second. |
Dependent item | pgsql.dbstat.tup_fetched.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Tuples inserted per second | Total number of rows inserted by queries in this database per second. |
Dependent item | pgsql.dbstat.tup_inserted.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Tuples returned per second | Number of rows returned by queries in this database per second. |
Dependent item | pgsql.dbstat.tup_returned.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Tuples updated per second | Total number of rows updated by queries in this database per second. |
Dependent item | pgsql.dbstat.tup_updated.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Commits per second | Number of transactions in this database that have been committed per second. |
Dependent item | pgsql.dbstat.xact_commit.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Rollbacks per second | Total number of transactions in this database that have been rolled back. |
Dependent item | pgsql.dbstat.xact_rollback.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Frozen XID before autovacuum, % | Preventing Transaction ID Wraparound Failures: https://www.postgresql.org/docs/current/routine-vacuuming.html#VACUUM-FOR-WRAPAROUND |
Dependent item | pgsql.frozenxid.prc_before_av["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Frozen XID before stop, % | Preventing Transaction ID Wraparound Failures: https://www.postgresql.org/docs/current/routine-vacuuming.html#VACUUM-FOR-WRAPAROUND |
Dependent item | pgsql.frozenxid.prc_before_stop["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Get frozen XID | Zabbix agent | pgsql.frozenxid["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{#DBNAME}"] | |
| DB [{#DBNAME}]: Num of locks total | Total number of locks in this database. |
Dependent item | pgsql.locks.total["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries slow maintenance count | Slow maintenance query count for this database. |
Dependent item | pgsql.queries.mro.slow_count["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries max maintenance time | Max maintenance query time for this database. |
Dependent item | pgsql.queries.mro.time_max["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries sum maintenance time | Sum maintenance query time for this database. |
Dependent item | pgsql.queries.mro.time_sum["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries slow query count | Slow query count for this database. |
Dependent item | pgsql.queries.query.slow_count["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries max query time | Max query time for this database. |
Dependent item | pgsql.queries.query.time_max["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries sum query time | Sum query time for this database. |
Dependent item | pgsql.queries.query.time_sum["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries slow transaction count | Slow transaction query count for this database. |
Dependent item | pgsql.queries.tx.slow_count["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries max transaction time | Max transaction query time for this database. |
Dependent item | pgsql.queries.tx.time_max["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries sum transaction time | Sum transaction query time for this database. |
Dependent item | pgsql.queries.tx.time_sum["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Index scans per second | Number of index scans in the database per second. |
Dependent item | pgsql.scans.idx.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Sequential scans per second | Number of sequential scans in this database per second. |
Dependent item | pgsql.scans.seq.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Get scans | Number of scans done for table/index in this database. |
Zabbix agent | pgsql.scans["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{#DBNAME}"] |
| Name | Description | Expression | Severity | Dependencies and additional info |
|---|---|---|---|---|
| DB [{#DBNAME}]: Too many recovery conflicts | 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. |
min(/PostgreSQL by Zabbix agent/pgsql.dbstat.conflicts.rate["{#DBNAME}"],5m) > {$PG.CONFLICTS.MAX.WARN:"{#DBNAME}"} |
Average | |
| DB [{#DBNAME}]: Deadlock occurred | Number of deadlocks detected per second exceeds {$PG.DEADLOCKS.MAX.WARN:"{#DBNAME}"} for 5m. |
min(/PostgreSQL by Zabbix agent/pgsql.dbstat.deadlocks.rate["{#DBNAME}"],5m) > {$PG.DEADLOCKS.MAX.WARN:"{#DBNAME}"} |
High | |
| DB [{#DBNAME}]: VACUUM FREEZE is required to prevent wraparound | Preventing Transaction ID Wraparound Failures: |
last(/PostgreSQL by Zabbix agent/pgsql.frozenxid.prc_before_stop["{#DBNAME}"])<{$PG.FROZENXID_PCT_STOP.MIN.HIGH:"{#DBNAME}"} |
Average | |
| DB [{#DBNAME}]: Number of locks is too high | min(/PostgreSQL by Zabbix agent/pgsql.locks.total["{#DBNAME}"],5m)>{$PG.LOCKS.MAX.WARN:"{#DBNAME}"} |
Warning | ||
| DB [{#DBNAME}]: Too many slow queries | The number of detected slow queries exceeds the limit of {$PG.SLOW_QUERIES.MAX.WARN:"{#DBNAME}"}. |
min(/PostgreSQL by Zabbix agent/pgsql.queries.query.slow_count["{#DBNAME}"],5m)>{$PG.SLOW_QUERIES.MAX.WARN:"{#DBNAME}"} |
Warning |
Please report any issues with the template at https://support.zabbix.com
You can also provide feedback, discuss the template, or ask for help at ZABBIX forums
Source: https://git.zabbix.com/projects/ZBX/repos/zabbix/browse/templates/db/postgresql?at=release/5.4
For Zabbix version: 5.4 and higher
Templates to monitor PostgreSQL by Zabbix.
This template was tested on PostgreSQL versions 9.6, 10 and 11 on Linux and Windows.
See Zabbix template operation for basic instructions.
Install Zabbix agent and create a read-only zbx_monitor user with proper access to your PostgreSQL server.
For PostgreSQL version 10 and above:
CREATE USER zbx_monitor WITH PASSWORD '<PASSWORD>' INHERIT;
GRANT pg_monitor TO zbx_monitor;
For PostgreSQL version 9.6 and below:
CREATE USER zbx_monitor WITH PASSWORD '<PASSWORD>';
GRANT SELECT ON pg_stat_database TO zbx_monitor;
-- To collect WAL metrics, the user must have a `superuser` role.
ALTER USER zbx_monitor WITH SUPERUSER;
Copy postgresql/ to Zabbix agent home directory /var/lib/zabbix/. The postgresql/ directory contains the files needed to obtain metrics from PostgreSQL.
Copy template_db_postgresql.conf to Zabbix agent configuration directory /etc/zabbix/zabbix_agentd.d/ and restart Zabbix agent service.
Edit pg_hba.conf to allow connections from Zabbix agent https://www.postgresql.org/docs/current/auth-pg-hba-conf.html.
Add rows (for example):
host all zbx_monitor 127.0.0.1/32 trust
host all zbx_monitor 0.0.0.0/0 md5
host all zbx_monitor ::0/0 md5
Import template file to Zabbix and link it to the target host
Set {$PG.HOST}, {$PG.PORT}, {$PG.USER}, {$PG.PASSWORD} and {$PG.DB} macros values.
If PostgreSQL is installed from the PGDG repository, then add the path to pg_isready to the PATH environment variable for zabbix user.
| Name | Description | Default |
|---|---|---|
| {$PG.CACHE_HITRATIO.MIN.WARN} | - |
90 |
| {$PG.CHECKPOINTS_REQ.MAX.WARN} | - |
5 |
| {$PG.CONFLICTS.MAX.WARN} | - |
0 |
| {$PG.CONN_IDLE_IN_TRANS.MAX.WARN} | - |
5 |
| {$PG.CONN_TOTAL_PCT.MAX.WARN} | - |
90 |
| {$PG.CONN_WAIT.MAX.WARN} | - |
0 |
| {$PG.DB} | - |
postgres |
| {$PG.DEADLOCKS.MAX.WARN} | - |
0 |
| {$PG.FROZENXID_PCT_STOP.MIN.HIGH} | - |
75 |
| {$PG.HOST} | - |
127.0.0.1 |
| {$PG.LLD.FILTER.DBNAME} | - |
(.*) |
| {$PG.LOCKS.MAX.WARN} | - |
100 |
| {$PG.PASSWORD} | Please set user's password in this macro. |
`` |
| {$PG.PING_TIME.MAX.WARN} | - |
1s |
| {$PG.PORT} | - |
5432 |
| {$PG.QUERY_ETIME.MAX.WARN} | - |
30 |
| {$PG.REPL_LAG.MAX.WARN} | - |
10m |
| {$PG.SLOW_QUERIES.MAX.WARN} | - |
5 |
| {$PG.TRANS_ACTIVE.MAX.WARN} | - |
30s |
| {$PG.TRANS_IDLE.MAX.WARN} | - |
30s |
| {$PG.TRANS_WAIT.MAX.WARN} | - |
30s |
| {$PG.USER} | - |
zbx_monitor |
There are no template links in this template.
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Database discovery | - |
ZABBIX_PASSIVE | pgsql.discovery.db["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DB}"] Filter: - {#DBNAME} MATCHES_REGEX |
| Group | Name | Description | Type | Key and additional info |
|---|---|---|---|---|
| PostgreSQL | Bgwriter: Buffers allocated per second | Number of buffers allocated |
DEPENDENT | pgsql.bgwriter.buffers_alloc.rate Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | Bgwriter: Buffers written directly by a backend per second | Number of buffers written directly by a backend |
DEPENDENT | pgsql.bgwriter.buffers_backend.rate Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | Bgwriter: Buffers backend fsync per second | Number of times a backend had to execute its own fsync call (normally the background writer handles those even when the backend does its own write) |
DEPENDENT | pgsql.bgwriter.buffers_backend_fsync.rate Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | Bgwriter: Buffers written during checkpoints per second | Number of buffers written during checkpoints |
DEPENDENT | pgsql.bgwriter.buffers_checkpoint.rate Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | Bgwriter: Buffers written by the background writer per second | Number of buffers written by the background writer |
DEPENDENT | pgsql.bgwriter.buffers_clean.rate Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | Bgwriter: Requested checkpoints per second | Number of requested checkpoints that have been performed |
DEPENDENT | pgsql.bgwriter.checkpoints_req.rate Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | Bgwriter: Scheduled checkpoints per second | Number of scheduled checkpoints that have been performed |
DEPENDENT | pgsql.bgwriter.checkpoints_timed.rate Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | Bgwriter: Checkpoint sync time | Total amount of time that has been spent in the portion of checkpoint processing where files are synchronized to disk |
DEPENDENT | pgsql.bgwriter.checkpoint_sync_time Preprocessing: - JSONPATH: - MULTIPLIER: - CHANGE_PER_SECOND |
| PostgreSQL | Bgwriter: Checkpoint write time | Total amount of time that has been spent in the portion of checkpoint processing where files are written to disk, in milliseconds |
DEPENDENT | pgsql.bgwriter.checkpoint_write_time Preprocessing: - JSONPATH: - MULTIPLIER: - CHANGE_PER_SECOND |
| PostgreSQL | Bgwriter: Max written per second | Number of times the background writer stopped a cleaning scan because it had written too many buffers |
DEPENDENT | pgsql.bgwriter.maxwritten_clean.rate Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | Status: Cache hit ratio % | Cache hit ratio |
ZABBIX_PASSIVE | pgsql.cache.hit["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DB}"] |
| PostgreSQL | Status: Config hash | PostgreSQL configuration hash |
ZABBIX_PASSIVE | pgsql.config.hash["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DB}"] Preprocessing: - DISCARD_UNCHANGED_HEARTBEAT: |
| PostgreSQL | Connections sum: Active | Total number of connections executing a query |
DEPENDENT | pgsql.connections.sum.active Preprocessing: - JSONPATH: |
| PostgreSQL | Connections sum: Idle | Total number of connections waiting for a new client command |
DEPENDENT | pgsql.connections.sum.idle Preprocessing: - JSONPATH: |
| PostgreSQL | Connections sum: Idle in transaction | Total number of connections in a transaction state, but not executing a query |
DEPENDENT | pgsql.connections.sum.idle_in_transaction Preprocessing: - JSONPATH: |
| PostgreSQL | Connections sum: Prepared | Total number of prepared transactions https://www.postgresql.org/docs/current/sql-prepare-transaction.html |
DEPENDENT | pgsql.connections.sum.prepared Preprocessing: - JSONPATH: |
| PostgreSQL | Connections sum: Total | Total number of connections |
DEPENDENT | pgsql.connections.sum.total Preprocessing: - JSONPATH: |
| PostgreSQL | Connections sum: Total % | Total number of connections in percentage |
DEPENDENT | pgsql.connections.sum.total_pct Preprocessing: - JSONPATH: |
| PostgreSQL | Connections sum: Waiting | Total number of waiting connections https://www.postgresql.org/docs/current/monitoring-stats.html#WAIT-EVENT-TABLE |
DEPENDENT | pgsql.connections.sum.waiting Preprocessing: - JSONPATH: |
| PostgreSQL | Status: Ping time | - |
ZABBIX_PASSIVE | pgsql.ping.time["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DB}"] Preprocessing: - REGEX: - MULTIPLIER: |
| PostgreSQL | Status: Ping | - |
ZABBIX_PASSIVE | pgsql.ping["{$PG.HOST}","{$PG.PORT}"] Preprocessing: - JAVASCRIPT: - DISCARD_UNCHANGED_HEARTBEAT: |
| PostgreSQL | Replication: standby count | Number of standby servers |
ZABBIX_PASSIVE | pgsql.replication.count["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DB}"] |
| PostgreSQL | Replication: lag in seconds | Replication lag with Master in seconds |
ZABBIX_PASSIVE | pgsql.replication.lag.sec["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DB}"] |
| PostgreSQL | Replication: recovery role | Replication role: 1 — recovery is still in progress (standby mode), 0 — master mode. |
ZABBIX_PASSIVE | pgsql.replication.recovery_role["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DB}"] |
| PostgreSQL | Replication: status | Replication status: 0 — streaming is down, 1 — streaming is up, 2 — master mode |
ZABBIX_PASSIVE | pgsql.replication.status["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DB}"] |
| PostgreSQL | Transactions: Max active transaction time | Current max active transaction time |
DEPENDENT | pgsql.transactions.active Preprocessing: - JSONPATH: |
| PostgreSQL | Transactions: Max idle transaction time | Current max idle transaction time |
DEPENDENT | pgsql.transactions.idle Preprocessing: - JSONPATH: |
| PostgreSQL | Transactions: Max prepared transaction time | Current max prepared transaction time |
DEPENDENT | pgsql.transactions.prepared Preprocessing: - JSONPATH: |
| PostgreSQL | Transactions: Max waiting transaction time | Current max waiting transaction time |
DEPENDENT | pgsql.transactions.waiting Preprocessing: - JSONPATH: |
| PostgreSQL | Status: Uptime | - |
ZABBIX_PASSIVE | pgsql.uptime["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DB}"] |
| PostgreSQL | Status: Version | PostgreSQL version |
ZABBIX_PASSIVE | pgsql.version["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DB}"] Preprocessing: - DISCARD_UNCHANGED_HEARTBEAT: |
| PostgreSQL | WAL: Segments count | Number of WAL segments |
DEPENDENT | pgsql.wal.count Preprocessing: - JSONPATH: |
| PostgreSQL | WAL: Bytes written | WAL write in bytes |
DEPENDENT | pgsql.wal.write Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | DB {#DBNAME}: Database size | Database size |
ZABBIX_PASSIVE | pgsql.db.size["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DB}","{#DBNAME}"] |
| PostgreSQL | DB {#DBNAME}: Blocks hit per second | Total number of times disk blocks were found already in the buffer cache, so that a read was not necessary |
DEPENDENT | pgsql.dbstat.blks_hit.rate["{#DBNAME}"] Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | DB {#DBNAME}: Disk blocks read per second | Total number of disk blocks read in this database |
DEPENDENT | pgsql.dbstat.blks_read.rate["{#DBNAME}"] Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | DB {#DBNAME}: Detected conflicts per second | Total number of queries canceled due to conflicts with recovery in this database |
DEPENDENT | pgsql.dbstat.conflicts.rate["{#DBNAME}"] Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | DB {#DBNAME}: Detected deadlocks per second | Total number of detected deadlocks in this database |
DEPENDENT | pgsql.dbstat.deadlocks.rate["{#DBNAME}"] Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | DB {#DBNAME}: Temp_bytes written per second | Total amount of data written to temporary files by queries in this database |
DEPENDENT | pgsql.dbstat.temp_bytes.rate["{#DBNAME}"] Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | DB {#DBNAME}: Temp_files created per second | Total number of temporary files created by queries in this database |
DEPENDENT | pgsql.dbstat.temp_files.rate["{#DBNAME}"] Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | DB {#DBNAME}: Tuples deleted per second | Total number of rows deleted by queries in this database |
DEPENDENT | pgsql.dbstat.tup_deleted.rate["{#DBNAME}"] Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | DB {#DBNAME}: Tuples fetched per second | Total number of rows fetched by queries in this database |
DEPENDENT | pgsql.dbstat.tup_fetched.rate["{#DBNAME}"] Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | DB {#DBNAME}: Tuples inserted per second | Total number of rows inserted by queries in this database |
DEPENDENT | pgsql.dbstat.tup_inserted.rate["{#DBNAME}"] Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | DB {#DBNAME}: Tuples returned per second | Total number of rows updated by queries in this database |
DEPENDENT | pgsql.dbstat.tup_returned.rate["{#DBNAME}"] Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | DB {#DBNAME}: Tuples updated per second | Total number of rows updated by queries in this database |
DEPENDENT | pgsql.dbstat.tup_updated.rate["{#DBNAME}"] Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | DB {#DBNAME}: Commits per second | Number of transactions in this database that have been committed |
DEPENDENT | pgsql.dbstat.xact_commit.rate["{#DBNAME}"] Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | DB {#DBNAME}: Rollbacks per second | Total number of transactions in this database that have been rolled back |
DEPENDENT | pgsql.dbstat.xact_rollback.rate["{#DBNAME}"] Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | DB {#DBNAME}: Frozen XID before avtovacuum % | reventing Transaction ID Wraparound Failures https://www.postgresql.org/docs/current/routine-vacuuming.html#VACUUM-FOR-WRAPAROUND |
DEPENDENT | pgsql.frozenxid.prc_before_av["{#DBNAME}"] Preprocessing: - JSONPATH: |
| PostgreSQL | DB {#DBNAME}: Frozen XID before stop % | Preventing Transaction ID Wraparound Failures https://www.postgresql.org/docs/current/routine-vacuuming.html#VACUUM-FOR-WRAPAROUND |
DEPENDENT | pgsql.frozenxid.prc_before_stop["{#DBNAME}"] Preprocessing: - JSONPATH: |
| PostgreSQL | DB {#DBNAME}: Locks total | Total number of locks in the database |
DEPENDENT | pgsql.locks.total["{#DBNAME}"] Preprocessing: - JSONPATH: |
| PostgreSQL | DB {#DBNAME}: Queries slow maintenance count | Slow maintenance query count |
DEPENDENT | pgsql.queries.mro.slow_count["{#DBNAME}"] Preprocessing: - JSONPATH: |
| PostgreSQL | DB {#DBNAME}: Queries max maintenance time | Max maintenance query time |
DEPENDENT | pgsql.queries.mro.time_max["{#DBNAME}"] Preprocessing: - JSONPATH: |
| PostgreSQL | DB {#DBNAME}: Queries sum maintenance time | Sum maintenance query time |
DEPENDENT | pgsql.queries.mro.time_sum["{#DBNAME}"] Preprocessing: - JSONPATH: |
| PostgreSQL | DB {#DBNAME}: Queries slow query count | Slow query count |
DEPENDENT | pgsql.queries.query.slow_count["{#DBNAME}"] Preprocessing: - JSONPATH: |
| PostgreSQL | DB {#DBNAME}: Queries max query time | Max query time |
DEPENDENT | pgsql.queries.query.time_max["{#DBNAME}"] Preprocessing: - JSONPATH: |
| PostgreSQL | DB {#DBNAME}: Queries sum query time | Sum query time |
DEPENDENT | pgsql.queries.query.time_sum["{#DBNAME}"] Preprocessing: - JSONPATH: |
| PostgreSQL | DB {#DBNAME}: Queries slow transaction count | Slow transaction query count |
DEPENDENT | pgsql.queries.tx.slow_count["{#DBNAME}"] Preprocessing: - JSONPATH: |
| PostgreSQL | DB {#DBNAME}: Queries max transaction time | Max transaction query time |
DEPENDENT | pgsql.queries.tx.time_max["{#DBNAME}"] Preprocessing: - JSONPATH: |
| PostgreSQL | DB {#DBNAME}: Queries sum transaction time | Sum transaction query time |
DEPENDENT | pgsql.queries.tx.time_sum["{#DBNAME}"] Preprocessing: - JSONPATH: |
| PostgreSQL | DB {#DBNAME}: Index scans per second | Number of index scans in the database |
DEPENDENT | pgsql.scans.idx.rate["{#DBNAME}"] Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | DB {#DBNAME}: Sequential scans per second | Number of sequential scans in the database |
DEPENDENT | pgsql.scans.seq.rate["{#DBNAME}"] Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| Zabbix_raw_items | PostgreSQL: Get bgwriter | Statistics about the background writer process's activity |
ZABBIX_PASSIVE | pgsql.bgwriter["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DB}"] |
| Zabbix_raw_items | PostgreSQL: Get connections sum | Collect all metrics from pg_stat_activity https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-ACTIVITY-VIEW |
ZABBIX_PASSIVE | pgsql.connections.sum["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DB}"] |
| Zabbix_raw_items | PostgreSQL: Get dbstat | Collect all metrics from pg_stat_database per database https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-DATABASE-VIEW |
ZABBIX_PASSIVE | pgsql.dbstat["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DB}"] |
| Zabbix_raw_items | PostgreSQL: Get locks | Collect all metrics from pg_locks per database https://www.postgresql.org/docs/current/explicit-locking.html#LOCKING-TABLES |
ZABBIX_PASSIVE | pgsql.locks["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DB}"] |
| Zabbix_raw_items | PostgreSQL: Get queries | Collect all metrics by query execution time |
ZABBIX_PASSIVE | pgsql.queries["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DB}","{$PG.QUERY_ETIME.MAX.WARN}"] |
| Zabbix_raw_items | PostgreSQL: Get transactions | Collect metrics by transaction execution time |
ZABBIX_PASSIVE | pgsql.transactions["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DB}"] |
| Zabbix_raw_items | PostgreSQL: Get WAL | Master item to collect WAL metrics |
ZABBIX_PASSIVE | pgsql.wal.stat["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DB}"] |
| Zabbix_raw_items | DB {#DBNAME}: Get frozen XID | - |
ZABBIX_PASSIVE | pgsql.frozenxid["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{#DBNAME}"] |
| Zabbix_raw_items | DB {#DBNAME}: Get scans | Number of scans done for table/index in the database |
ZABBIX_PASSIVE | pgsql.scans["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{#DBNAME}"] |
| Name | Description | Expression | Severity | Dependencies and additional info |
|---|---|---|---|---|
| PostgreSQL: Required checkpoints occurs too frequently (over {$PG.CHECKPOINTS_REQ.MAX.WARN}) | Checkpoints are points in the sequence of transactions at which it is guaranteed that the heap and index data files have been updated with all information written before that checkpoint. At checkpoint time, all dirty data pages are flushed to disk and a special checkpoint record is written to the log file. https://www.postgresql.org/docs/current/wal-configuration.html |
last(/PostgreSQL by user parameters/pgsql.bgwriter.checkpoints_req.rate) > {$PG.CHECKPOINTS_REQ.MAX.WARN} |
AVERAGE | |
| PostgreSQL: Cache hit ratio too low (under {$PG.CACHE_HITRATIO.MIN.WARN} in 5m) | - |
max(/PostgreSQL by user parameters/pgsql.cache.hit["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DB}"],5m) < {$PG.CACHE_HITRATIO.MIN.WARN} |
WARNING | |
| PostgreSQL: Configuration has changed | - |
last(/PostgreSQL by user parameters/pgsql.config.hash["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DB}"],#1)<>last(/PostgreSQL by user parameters/pgsql.config.hash["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DB}"],#2) and length(last(/PostgreSQL by user parameters/pgsql.config.hash["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DB}"]))>0 |
INFO | |
| PostgreSQL: Total number of connections is too high (over {$PG.CONN_TOTAL_PCT.MAX.WARN} in 5m) | - |
min(/PostgreSQL by user parameters/pgsql.connections.sum.total_pct,5m) > {$PG.CONN_TOTAL_PCT.MAX.WARN} |
AVERAGE | |
| PostgreSQL: Response too long (over {$PG.PING_TIME.MAX.WARN}) | - |
min(/PostgreSQL by user parameters/pgsql.ping.time["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DB}"],5m) > {$PG.PING_TIME.MAX.WARN} |
AVERAGE | Depends on: - PostgreSQL: Service is down |
| PostgreSQL: Service is down | - |
last(/PostgreSQL by user parameters/pgsql.ping["{$PG.HOST}","{$PG.PORT}"]) = 0 |
HIGH | |
| PostgreSQL: Streaming lag with {#MASTER} is too high (over {$PG.REPL_LAG.MAX.WARN} in 5m) | - |
min(/PostgreSQL by user parameters/pgsql.replication.lag.sec["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DB}"],5m) > {$PG.REPL_LAG.MAX.WARN} |
AVERAGE | |
| PostgreSQL: Replication is down | - |
max(/PostgreSQL by user parameters/pgsql.replication.status["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DB}"],5m)=0 |
AVERAGE | |
| PostgreSQL: Service has been restarted (uptime < 10m) | PostgreSQL uptime is less than 10 minutes |
last(/PostgreSQL by user parameters/pgsql.uptime["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DB}"]) < 10m |
INFO | |
| PostgreSQL: Version has changed (new version value received: {ITEM.VALUE}) | - |
last(/PostgreSQL by user parameters/pgsql.version["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DB}"],#1)<>last(/PostgreSQL by user parameters/pgsql.version["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DB}"],#2) and length(last(/PostgreSQL by user parameters/pgsql.version["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DB}"]))>0 |
INFO | |
| DB {#DBNAME}: Too many recovery conflicts (over {$PG.CONFLICTS.MAX.WARN:"{#DBNAME}"} in 5m) | 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 |
min(/PostgreSQL by user parameters/pgsql.dbstat.conflicts.rate["{#DBNAME}"],5m) > {$PG.CONFLICTS.MAX.WARN:"{#DBNAME}"} |
AVERAGE | |
| DB {#DBNAME}: Deadlock occurred (over {$PG.DEADLOCKS.MAX.WARN:"{#DBNAME}"} in 5m) | - |
min(/PostgreSQL by user parameters/pgsql.dbstat.deadlocks.rate["{#DBNAME}"],5m) > {$PG.DEADLOCKS.MAX.WARN:"{#DBNAME}"} |
HIGH | |
| DB {#DBNAME}: VACUUM FREEZE is required to prevent wraparound (frozen XID less than {$PG.FROZENXID_PCT_STOP.MIN.HIGH:"{#DBNAME}"} %) | Preventing Transaction ID Wraparound Failures https://www.postgresql.org/docs/current/routine-vacuuming.html#VACUUM-FOR-WRAPAROUND |
last(/PostgreSQL by user parameters/pgsql.frozenxid.prc_before_stop["{#DBNAME}"])<{$PG.FROZENXID_PCT_STOP.MIN.HIGH:"{#DBNAME}"} |
AVERAGE | |
| DB {#DBNAME}: Number of locks is too high (over {$PG.LOCKS.MAX.WARN:"{#DBNAME}"} in 5m) | - |
min(/PostgreSQL by user parameters/pgsql.locks.total["{#DBNAME}"],5m)>{$PG.LOCKS.MAX.WARN:"{#DBNAME}"} |
WARNING | |
| DB {#DBNAME}: Too many slow queries (over {$PG.SLOW_QUERIES.MAX.WARN:"{#DBNAME}"} in 5m) | - |
min(/PostgreSQL by user parameters/pgsql.queries.query.slow_count["{#DBNAME}"],5m)>{$PG.SLOW_QUERIES.MAX.WARN:"{#DBNAME}"} |
WARNING | |
| PostgreSQL: Failed to get items (no data for 30m) | Zabbix has not received data for items for the last 30 minutes |
nodata(/PostgreSQL by user parameters/pgsql.bgwriter["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DB}"],30m) = 1 |
WARNING | Depends on: - PostgreSQL: Service is down |
Please report any issues with the template at https://support.zabbix.com
You can also provide a feedback, discuss the template or ask for help with it at ZABBIX forums.
Source: https://git.zabbix.com/projects/ZBX/repos/zabbix/browse/templates/db/postgresql?at=release/5.0
For Zabbix version: 5.0 and higher
Templates to monitor PostgreSQL by Zabbix.
This template was tested on PostgreSQL versions 9.6, 10 and 11 on Linux and Windows.
See Zabbix template operation for basic instructions.
Install Zabbix agent and create a read-only zbx_monitor user with proper access to your PostgreSQL server.
For PostgreSQL version 10 and above:
CREATE USER zbx_monitor WITH PASSWORD '<PASSWORD>' INHERIT;
GRANT pg_monitor TO zbx_monitor;
For PostgreSQL version 9.6 and below:
CREATE USER zbx_monitor WITH PASSWORD '<PASSWORD>';
GRANT SELECT ON pg_stat_database TO zbx_monitor;
-- To collect WAL metrics, the user must have a `superuser` role.
ALTER USER zbx_monitor WITH SUPERUSER;
Copy postgresql/ to Zabbix agent home directory /var/lib/zabbix/. The postgresql/ directory contains the files needed to obtain metrics from PostgreSQL.
Copy template_db_postgresql.conf to Zabbix agent configuration directory /etc/zabbix/zabbix_agentd.d/ and restart Zabbix agent service.
Edit pg_hba.conf to allow connections from Zabbix agent https://www.postgresql.org/docs/current/auth-pg-hba-conf.html.
Add rows (for example):
host all zbx_monitor 127.0.0.1/32 trust
host all zbx_monitor 0.0.0.0/0 md5
host all zbx_monitor ::0/0 md5
Import template file to Zabbix and link it to the target host
Set {$PG.HOST}, {$PG.PORT}, {$PG.USER}, {$PG.PASSWORD} and {$PG.DB} macros values.
If PostgreSQL is installed from the PGDG repository, then add the path to pg_isready to the PATH environment variable for zabbix user.
| Name | Description | Default |
|---|---|---|
| {$PG.CACHE_HITRATIO.MIN.WARN} | - |
90 |
| {$PG.CHECKPOINTS_REQ.MAX.WARN} | - |
5 |
| {$PG.CONFLICTS.MAX.WARN} | - |
0 |
| {$PG.CONN_IDLE_IN_TRANS.MAX.WARN} | - |
5 |
| {$PG.CONN_TOTAL_PCT.MAX.WARN} | - |
90 |
| {$PG.CONN_WAIT.MAX.WARN} | - |
0 |
| {$PG.DB} | - |
postgres |
| {$PG.DEADLOCKS.MAX.WARN} | - |
0 |
| {$PG.FROZENXID_PCT_STOP.MIN.HIGH} | - |
75 |
| {$PG.HOST} | - |
127.0.0.1 |
| {$PG.LLD.FILTER.DBNAME} | - |
(.*) |
| {$PG.LOCKS.MAX.WARN} | - |
100 |
| {$PG.PASSWORD} | Please set user's password in this macro. |
`` |
| {$PG.PING_TIME.MAX.WARN} | - |
1s |
| {$PG.PORT} | - |
5432 |
| {$PG.QUERY_ETIME.MAX.WARN} | - |
30 |
| {$PG.REPL_LAG.MAX.WARN} | - |
10m |
| {$PG.SLOW_QUERIES.MAX.WARN} | - |
5 |
| {$PG.TRANS_ACTIVE.MAX.WARN} | - |
30s |
| {$PG.TRANS_IDLE.MAX.WARN} | - |
30s |
| {$PG.TRANS_WAIT.MAX.WARN} | - |
30s |
| {$PG.USER} | - |
zbx_monitor |
There are no template links in this template.
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Database discovery | - |
ZABBIX_PASSIVE | pgsql.discovery.db["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DB}"] Filter: - A: {#DBNAME} MATCHES_REGEX |
| Group | Name | Description | Type | Key and additional info |
|---|---|---|---|---|
| PostgreSQL | Bgwriter: Buffers allocated per second | Number of buffers allocated |
DEPENDENT | pgsql.bgwriter.buffers_alloc.rate Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | Bgwriter: Buffers written directly by a backend per second | Number of buffers written directly by a backend |
DEPENDENT | pgsql.bgwriter.buffers_backend.rate Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | Bgwriter: Buffers backend fsync per second | Number of times a backend had to execute its own fsync call (normally the background writer handles those even when the backend does its own write) |
DEPENDENT | pgsql.bgwriter.buffers_backend_fsync.rate Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | Bgwriter: Buffers written during checkpoints per second | Number of buffers written during checkpoints |
DEPENDENT | pgsql.bgwriter.buffers_checkpoint.rate Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | Bgwriter: Buffers written by the background writer per second | Number of buffers written by the background writer |
DEPENDENT | pgsql.bgwriter.buffers_clean.rate Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | Bgwriter: Requested checkpoints per second | Number of requested checkpoints that have been performed |
DEPENDENT | pgsql.bgwriter.checkpoints_req.rate Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | Bgwriter: Scheduled checkpoints per second | Number of scheduled checkpoints that have been performed |
DEPENDENT | pgsql.bgwriter.checkpoints_timed.rate Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | Bgwriter: Checkpoint sync time | Total amount of time that has been spent in the portion of checkpoint processing where files are synchronized to disk |
DEPENDENT | pgsql.bgwriter.checkpoint_sync_time Preprocessing: - JSONPATH: - MULTIPLIER: - CHANGE_PER_SECOND |
| PostgreSQL | Bgwriter: Checkpoint write time | Total amount of time that has been spent in the portion of checkpoint processing where files are written to disk, in milliseconds |
DEPENDENT | pgsql.bgwriter.checkpoint_write_time Preprocessing: - JSONPATH: - MULTIPLIER: - CHANGE_PER_SECOND |
| PostgreSQL | Bgwriter: Max written per second | Number of times the background writer stopped a cleaning scan because it had written too many buffers |
DEPENDENT | pgsql.bgwriter.maxwritten_clean.rate Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | Status: Cache hit ratio % | Cache hit ratio |
ZABBIX_PASSIVE | pgsql.cache.hit["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DB}"] |
| PostgreSQL | Status: Config hash | PostgreSQL configuration hash |
ZABBIX_PASSIVE | pgsql.config.hash["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DB}"] Preprocessing: - DISCARD_UNCHANGED_HEARTBEAT: |
| PostgreSQL | Connections sum: Active | Total number of connections executing a query |
DEPENDENT | pgsql.connections.sum.active Preprocessing: - JSONPATH: |
| PostgreSQL | Connections sum: Idle | Total number of connections waiting for a new client command |
DEPENDENT | pgsql.connections.sum.idle Preprocessing: - JSONPATH: |
| PostgreSQL | Connections sum: Idle in transaction | Total number of connections in a transaction state, but not executing a query |
DEPENDENT | pgsql.connections.sum.idle_in_transaction Preprocessing: - JSONPATH: |
| PostgreSQL | Connections sum: Prepared | Total number of prepared transactions https://www.postgresql.org/docs/current/sql-prepare-transaction.html |
DEPENDENT | pgsql.connections.sum.prepared Preprocessing: - JSONPATH: |
| PostgreSQL | Connections sum: Total | Total number of connections |
DEPENDENT | pgsql.connections.sum.total Preprocessing: - JSONPATH: |
| PostgreSQL | Connections sum: Total % | Total number of connections in percentage |
DEPENDENT | pgsql.connections.sum.total_pct Preprocessing: - JSONPATH: |
| PostgreSQL | Connections sum: Waiting | Total number of waiting connections https://www.postgresql.org/docs/current/monitoring-stats.html#WAIT-EVENT-TABLE |
DEPENDENT | pgsql.connections.sum.waiting Preprocessing: - JSONPATH: |
| PostgreSQL | Status: Ping time | - |
ZABBIX_PASSIVE | pgsql.ping.time["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DB}"] Preprocessing: - REGEX: - MULTIPLIER: |
| PostgreSQL | Status: Ping | - |
ZABBIX_PASSIVE | pgsql.ping["{$PG.HOST}","{$PG.PORT}"] Preprocessing: - JAVASCRIPT: - DISCARD_UNCHANGED_HEARTBEAT: |
| PostgreSQL | Replication: standby count | Number of standby servers |
ZABBIX_PASSIVE | pgsql.replication.count["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DB}"] |
| PostgreSQL | Replication: lag in seconds | Replication lag with Master in seconds |
ZABBIX_PASSIVE | pgsql.replication.lag.sec["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DB}"] |
| PostgreSQL | Replication: recovery role | Replication role: 1 — recovery is still in progress (standby mode), 0 — master mode. |
ZABBIX_PASSIVE | pgsql.replication.recovery_role["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DB}"] |
| PostgreSQL | Replication: status | Replication status: 0 — streaming is down, 1 — streaming is up, 2 — master mode |
ZABBIX_PASSIVE | pgsql.replication.status["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DB}"] |
| PostgreSQL | Transactions: Max active transaction time | Current max active transaction time |
DEPENDENT | pgsql.transactions.active Preprocessing: - JSONPATH: |
| PostgreSQL | Transactions: Max idle transaction time | Current max idle transaction time |
DEPENDENT | pgsql.transactions.idle Preprocessing: - JSONPATH: |
| PostgreSQL | Transactions: Max prepared transaction time | Current max prepared transaction time |
DEPENDENT | pgsql.transactions.prepared Preprocessing: - JSONPATH: |
| PostgreSQL | Transactions: Max waiting transaction time | Current max waiting transaction time |
DEPENDENT | pgsql.transactions.waiting Preprocessing: - JSONPATH: |
| PostgreSQL | Status: Uptime | - |
ZABBIX_PASSIVE | pgsql.uptime["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DB}"] |
| PostgreSQL | Status: Version | PostgreSQL version |
ZABBIX_PASSIVE | pgsql.version["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DB}"] Preprocessing: - DISCARD_UNCHANGED_HEARTBEAT: |
| PostgreSQL | WAL: Segments count | Number of WAL segments |
DEPENDENT | pgsql.wal.count Preprocessing: - JSONPATH: |
| PostgreSQL | WAL: Bytes written | WAL write in bytes |
DEPENDENT | pgsql.wal.write Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | DB {#DBNAME}: Database size | Database size |
ZABBIX_PASSIVE | pgsql.db.size["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DB}","{#DBNAME}"] |
| PostgreSQL | DB {#DBNAME}: Blocks hit per second | Total number of times disk blocks were found already in the buffer cache, so that a read was not necessary |
DEPENDENT | pgsql.dbstat.blks_hit.rate["{#DBNAME}"] Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | DB {#DBNAME}: Disk blocks read per second | Total number of disk blocks read in this database |
DEPENDENT | pgsql.dbstat.blks_read.rate["{#DBNAME}"] Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | DB {#DBNAME}: Detected conflicts per second | Total number of queries canceled due to conflicts with recovery in this database |
DEPENDENT | pgsql.dbstat.conflicts.rate["{#DBNAME}"] Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | DB {#DBNAME}: Detected deadlocks per second | Total number of detected deadlocks in this database |
DEPENDENT | pgsql.dbstat.deadlocks.rate["{#DBNAME}"] Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | DB {#DBNAME}: Temp_bytes written per second | Total amount of data written to temporary files by queries in this database |
DEPENDENT | pgsql.dbstat.temp_bytes.rate["{#DBNAME}"] Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | DB {#DBNAME}: Temp_files created per second | Total number of temporary files created by queries in this database |
DEPENDENT | pgsql.dbstat.temp_files.rate["{#DBNAME}"] Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | DB {#DBNAME}: Tuples deleted per second | Total number of rows deleted by queries in this database |
DEPENDENT | pgsql.dbstat.tup_deleted.rate["{#DBNAME}"] Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | DB {#DBNAME}: Tuples fetched per second | Total number of rows fetched by queries in this database |
DEPENDENT | pgsql.dbstat.tup_fetched.rate["{#DBNAME}"] Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | DB {#DBNAME}: Tuples inserted per second | Total number of rows inserted by queries in this database |
DEPENDENT | pgsql.dbstat.tup_inserted.rate["{#DBNAME}"] Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | DB {#DBNAME}: Tuples returned per second | Total number of rows updated by queries in this database |
DEPENDENT | pgsql.dbstat.tup_returned.rate["{#DBNAME}"] Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | DB {#DBNAME}: Tuples updated per second | Total number of rows updated by queries in this database |
DEPENDENT | pgsql.dbstat.tup_updated.rate["{#DBNAME}"] Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | DB {#DBNAME}: Commits per second | Number of transactions in this database that have been committed |
DEPENDENT | pgsql.dbstat.xact_commit.rate["{#DBNAME}"] Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | DB {#DBNAME}: Rollbacks per second | Total number of transactions in this database that have been rolled back |
DEPENDENT | pgsql.dbstat.xact_rollback.rate["{#DBNAME}"] Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | DB {#DBNAME}: Frozen XID before avtovacuum % | reventing Transaction ID Wraparound Failures https://www.postgresql.org/docs/current/routine-vacuuming.html#VACUUM-FOR-WRAPAROUND |
DEPENDENT | pgsql.frozenxid.prc_before_av["{#DBNAME}"] Preprocessing: - JSONPATH: |
| PostgreSQL | DB {#DBNAME}: Frozen XID before stop % | Preventing Transaction ID Wraparound Failures https://www.postgresql.org/docs/current/routine-vacuuming.html#VACUUM-FOR-WRAPAROUND |
DEPENDENT | pgsql.frozenxid.prc_before_stop["{#DBNAME}"] Preprocessing: - JSONPATH: |
| PostgreSQL | DB {#DBNAME}: Locks total | Total number of locks in the database |
DEPENDENT | pgsql.locks.total["{#DBNAME}"] Preprocessing: - JSONPATH: |
| PostgreSQL | DB {#DBNAME}: Queries slow maintenance count | Slow maintenance query count |
DEPENDENT | pgsql.queries.mro.slow_count["{#DBNAME}"] Preprocessing: - JSONPATH: |
| PostgreSQL | DB {#DBNAME}: Queries max maintenance time | Max maintenance query time |
DEPENDENT | pgsql.queries.mro.time_max["{#DBNAME}"] Preprocessing: - JSONPATH: |
| PostgreSQL | DB {#DBNAME}: Queries sum maintenance time | Sum maintenance query time |
DEPENDENT | pgsql.queries.mro.time_sum["{#DBNAME}"] Preprocessing: - JSONPATH: |
| PostgreSQL | DB {#DBNAME}: Queries slow query count | Slow query count |
DEPENDENT | pgsql.queries.query.slow_count["{#DBNAME}"] Preprocessing: - JSONPATH: |
| PostgreSQL | DB {#DBNAME}: Queries max query time | Max query time |
DEPENDENT | pgsql.queries.query.time_max["{#DBNAME}"] Preprocessing: - JSONPATH: |
| PostgreSQL | DB {#DBNAME}: Queries sum query time | Sum query time |
DEPENDENT | pgsql.queries.query.time_sum["{#DBNAME}"] Preprocessing: - JSONPATH: |
| PostgreSQL | DB {#DBNAME}: Queries slow transaction count | Slow transaction query count |
DEPENDENT | pgsql.queries.tx.slow_count["{#DBNAME}"] Preprocessing: - JSONPATH: |
| PostgreSQL | DB {#DBNAME}: Queries max transaction time | Max transaction query time |
DEPENDENT | pgsql.queries.tx.time_max["{#DBNAME}"] Preprocessing: - JSONPATH: |
| PostgreSQL | DB {#DBNAME}: Queries sum transaction time | Sum transaction query time |
DEPENDENT | pgsql.queries.tx.time_sum["{#DBNAME}"] Preprocessing: - JSONPATH: |
| PostgreSQL | DB {#DBNAME}: Index scans per second | Number of index scans in the database |
DEPENDENT | pgsql.scans.idx.rate["{#DBNAME}"] Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | DB {#DBNAME}: Sequential scans per second | Number of sequential scans in the database |
DEPENDENT | pgsql.scans.seq.rate["{#DBNAME}"] Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| Zabbix_raw_items | PostgreSQL: Get bgwriter | Statistics about the background writer process's activity |
ZABBIX_PASSIVE | pgsql.bgwriter["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DB}"] |
| Zabbix_raw_items | PostgreSQL: Get connections sum | Collect all metrics from pg_stat_activity https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-ACTIVITY-VIEW |
ZABBIX_PASSIVE | pgsql.connections.sum["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DB}"] |
| Zabbix_raw_items | PostgreSQL: Get dbstat | Collect all metrics from pg_stat_database per database https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-DATABASE-VIEW |
ZABBIX_PASSIVE | pgsql.dbstat["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DB}"] |
| Zabbix_raw_items | PostgreSQL: Get locks | Collect all metrics from pg_locks per database https://www.postgresql.org/docs/current/explicit-locking.html#LOCKING-TABLES |
ZABBIX_PASSIVE | pgsql.locks["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DB}"] |
| Zabbix_raw_items | PostgreSQL: Get queries | Collect all metrics by query execution time |
ZABBIX_PASSIVE | pgsql.queries["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DB}","{$PG.QUERY_ETIME.MAX.WARN}"] |
| Zabbix_raw_items | PostgreSQL: Get transactions | Collect metrics by transaction execution time |
ZABBIX_PASSIVE | pgsql.transactions["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DB}"] |
| Zabbix_raw_items | PostgreSQL: Get WAL | Master item to collect WAL metrics |
ZABBIX_PASSIVE | pgsql.wal.stat["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DB}"] |
| Zabbix_raw_items | DB {#DBNAME}: Get frozen XID | - |
ZABBIX_PASSIVE | pgsql.frozenxid["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{#DBNAME}"] |
| Zabbix_raw_items | DB {#DBNAME}: Get scans | Number of scans done for table/index in the database |
ZABBIX_PASSIVE | pgsql.scans["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{#DBNAME}"] |
| Name | Description | Expression | Severity | Dependencies and additional info |
|---|---|---|---|---|
| PostgreSQL: Required checkpoints occurs too frequently (over {$PG.CHECKPOINTS_REQ.MAX.WARN}) | Checkpoints are points in the sequence of transactions at which it is guaranteed that the heap and index data files have been updated with all information written before that checkpoint. At checkpoint time, all dirty data pages are flushed to disk and a special checkpoint record is written to the log file. https://www.postgresql.org/docs/current/wal-configuration.html |
{TEMPLATE_NAME:pgsql.bgwriter.checkpoints_req.rate.last()} > {$PG.CHECKPOINTS_REQ.MAX.WARN} |
AVERAGE | |
| PostgreSQL: Cache hit ratio too low (under {$PG.CACHE_HITRATIO.MIN.WARN} in 5m) | - |
{TEMPLATE_NAME:pgsql.cache.hit["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DB}"].max(5m)} < {$PG.CACHE_HITRATIO.MIN.WARN} |
WARNING | |
| PostgreSQL: Configuration has changed | - |
{TEMPLATE_NAME:pgsql.config.hash["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DB}"].diff()}=1 and {TEMPLATE_NAME:pgsql.config.hash["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DB}"].strlen()}>0 |
INFO | |
| PostgreSQL: Total number of connections is too high (over {$PG.CONN_TOTAL_PCT.MAX.WARN} in 5m) | - |
{TEMPLATE_NAME:pgsql.connections.sum.total_pct.min(5m)} > {$PG.CONN_TOTAL_PCT.MAX.WARN} |
AVERAGE | |
| PostgreSQL: Response too long (over {$PG.PING_TIME.MAX.WARN}) | - |
{TEMPLATE_NAME:pgsql.ping.time["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DB}"].min(5m)} > {$PG.PING_TIME.MAX.WARN} |
AVERAGE | Depends on: - PostgreSQL: Service is down |
| PostgreSQL: Service is down | - |
{TEMPLATE_NAME:pgsql.ping["{$PG.HOST}","{$PG.PORT}"].last()} = 0 |
HIGH | |
| PostgreSQL: Streaming lag with {#MASTER} is too high (over {$PG.REPL_LAG.MAX.WARN} in 5m) | - |
{TEMPLATE_NAME:pgsql.replication.lag.sec["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DB}"].min(5m)} > {$PG.REPL_LAG.MAX.WARN} |
AVERAGE | |
| PostgreSQL: Replication is down | - |
{TEMPLATE_NAME:pgsql.replication.status["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DB}"].max(5m)}=0 |
AVERAGE | |
| PostgreSQL: Service has been restarted (uptime < 10m) | PostgreSQL uptime is less than 10 minutes |
{TEMPLATE_NAME:pgsql.uptime["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DB}"].last()} < 10m |
INFO | |
| PostgreSQL: Version has changed (new version value received: {ITEM.VALUE}) | - |
{TEMPLATE_NAME:pgsql.version["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DB}"].diff()}=1 and {TEMPLATE_NAME:pgsql.version["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DB}"].strlen()}>0 |
INFO | |
| DB {#DBNAME}: Too many recovery conflicts (over {$PG.CONFLICTS.MAX.WARN:"{#DBNAME}"} in 5m) | 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 |
{TEMPLATE_NAME:pgsql.dbstat.conflicts.rate["{#DBNAME}"].min(5m)} > {$PG.CONFLICTS.MAX.WARN:"{#DBNAME}"} |
AVERAGE | |
| DB {#DBNAME}: Deadlock occurred (over {$PG.DEADLOCKS.MAX.WARN:"{#DBNAME}"} in 5m) | - |
{TEMPLATE_NAME:pgsql.dbstat.deadlocks.rate["{#DBNAME}"].min(5m)} > {$PG.DEADLOCKS.MAX.WARN:"{#DBNAME}"} |
HIGH | |
| DB {#DBNAME}: VACUUM FREEZE is required to prevent wraparound (frozen XID less than {$PG.FROZENXID_PCT_STOP.MIN.HIGH:"{#DBNAME}"} %) | Preventing Transaction ID Wraparound Failures https://www.postgresql.org/docs/current/routine-vacuuming.html#VACUUM-FOR-WRAPAROUND |
{TEMPLATE_NAME:pgsql.frozenxid.prc_before_stop["{#DBNAME}"].last()}<{$PG.FROZENXID_PCT_STOP.MIN.HIGH:"{#DBNAME}"} |
AVERAGE | |
| DB {#DBNAME}: Number of locks is too high (over {$PG.LOCKS.MAX.WARN:"{#DBNAME}"} in 5m) | - |
{TEMPLATE_NAME:pgsql.locks.total["{#DBNAME}"].min(5m)}>{$PG.LOCKS.MAX.WARN:"{#DBNAME}"} |
WARNING | |
| DB {#DBNAME}: Too many slow queries (over {$PG.SLOW_QUERIES.MAX.WARN:"{#DBNAME}"} in 5m) | - |
{TEMPLATE_NAME:pgsql.queries.query.slow_count["{#DBNAME}"].min(5m)}>{$PG.SLOW_QUERIES.MAX.WARN:"{#DBNAME}"} |
WARNING | |
| PostgreSQL: Failed to get items (no data for 30m) | Zabbix has not received data for items for the last 30 minutes |
{TEMPLATE_NAME:pgsql.bgwriter["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DB}"].nodata(30m)} = 1 |
WARNING | Depends on: - PostgreSQL: Service is down |
Please report any issues with the template at https://support.zabbix.com
You can also provide a feedback, discuss the template or ask for help with it at ZABBIX forums.
This template is designed for the deployment of PostgreSQL monitoring by Zabbix via Zabbix agent 2 and uses a loadable plugin to run SQL queries.
Zabbix version: 7.4 and higher.
This template has been tested on:
Zabbix should be configured according to the instructions in the Templates out of the box section.
Deploy Zabbix agent 2 with the PostgreSQL plugin. Starting with Zabbix versions 6.0.10 / 6.2.4 / 6.4 PostgreSQL metrics are moved to a loadable plugin and require installation of a separate package or compilation of the plugin from sources.
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;
pg_hba.conf configuration file to allow connections for the user zbx_monitor. For example, you could add one of the following rows to allow local TCP connections from the same host:# TYPE DATABASE USER ADDRESS METHOD
host all zbx_monitor localhost trust
host all zbx_monitor 127.0.0.1/32 md5
host all zbx_monitor ::1/128 scram-sha-256
For more information please read the PostgreSQL documentation https://www.postgresql.org/docs/current/auth-pg-hba-conf.html.
{$PG.CONNSTRING.AGENT2} macro as URI, such as <protocol(host:port)>, or specify the named session - <sessionname>.Note: if you want to use SSL/TLS encryption to protect communications with the remote PostgreSQL instance, a named session must be used. In that case, the instance URI should be specified in the Plugins.PostgreSQL.Sessions.*.Uri parameter in the PostgreSQL plugin configuration files alongside all the encryption parameters (type, certificate/key filepaths if needed etc.).
You can check the PostgreSQL plugin documentation for details about agent plugin parameters and named sessions.
Also, it is assumed that you set up the PostgreSQL instance to work in the desired encryption mode. Check the PostgreSQL documentation for details.
Note: plugin TLS certificate validation relies on checking the Subject Alternative Names (SAN) instead of the Common Name (CN), check the cryptography package documentation for details.
For example, to enable required encryption in transport mode without identity checks you could create the file /etc/zabbix/zabbix_agent2.d/postgresql_myconn.conf with the following configuration for the named session myconn (replace <instanceip> with the address of the PostgreSQL instance):
Plugins.PostgreSQL.Sessions.myconn.Uri=tcp://<instanceip>:5432
Plugins.PostgreSQL.Sessions.myconn.TLSConnect=required
Then set the {$PG.CONNSTRING.AGENT2} macro to myconn to use this named session.
{$PG.PASSWORD}.| Name | Description | Default |
|---|---|---|
| {$PG.CONNSTRING.AGENT2} | URI or named session of the PostgreSQL instance. |
tcp://localhost:5432 |
| {$PG.USER} | PostgreSQL username. |
zbx_monitor |
| {$PG.PASSWORD} | PostgreSQL user password. |
|
| {$PG.DATABASE} | Default PostgreSQL database for the connection. |
postgres |
| {$PG.LLD.FILTER.DBNAME} | Filter of discoverable databases. |
.+ |
| {$PG.LLD.FILTER.APPLICATION} | Filter of discoverable applications. |
.+ |
| {$PG.DEADLOCKS.MAX.WARN} | Maximum number of detected deadlocks for trigger expression. |
0 |
| {$PG.CONN_TOTAL_PCT.MAX.WARN} | Maximum percentage of current connections for trigger expression. |
90 |
| {$PG.CONFLICTS.MAX.WARN} | Maximum number of recovery conflicts for trigger expression. |
0 |
| {$PG.QUERY_ETIME.MAX.WARN} | Execution time limit for count of slow queries. |
30 |
| {$PG.SLOW_QUERIES.MAX.WARN} | Slow queries count threshold for a trigger. |
5 |
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Get bgwriter | Collect all metrics from pg_stat_bgwriter: https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-BGWRITER-VIEW |
Zabbix agent | pgsql.bgwriter["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Get archive | Collect archive status metrics. |
Zabbix agent | pgsql.archive["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Get dbstat | Collect all metrics from pg_stat_database per database: https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-DATABASE-VIEW |
Zabbix agent | pgsql.dbstat["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Get dbstat sum | 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 |
Zabbix agent | pgsql.dbstat.sum["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Get connections sum | Collect all metrics from pg_stat_activity: https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-ACTIVITY-VIEW |
Zabbix agent | pgsql.connections["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Get WAL | Collect write-ahead log (WAL) metrics. |
Zabbix agent | pgsql.wal.stat["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Get locks | Collect all metrics from pg_locks per database: https://www.postgresql.org/docs/current/explicit-locking.html#LOCKING-TABLES |
Zabbix agent | pgsql.locks["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Custom queries | Execute custom queries from file *.sql (check for option Plugins.Postgres.CustomQueriesPath at agent configuration). |
Zabbix agent | pgsql.custom.query["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}",""] |
| Get replication | 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. |
Zabbix agent | pgsql.replication.process["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Get queries | Collect all metrics by query execution time. |
Zabbix agent | pgsql.queries["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}","{$PG.QUERY_ETIME.MAX.WARN}"] |
| Version | PostgreSQL version. |
Zabbix agent | pgsql.version["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] Preprocessing
|
| WAL: Bytes written | WAL write, in bytes. |
Dependent item | pgsql.wal.write Preprocessing
|
| WAL: Bytes received | WAL receive, in bytes. |
Dependent item | pgsql.wal.receive Preprocessing
|
| WAL: Segments count | Number of WAL segments. |
Dependent item | pgsql.wal.count Preprocessing
|
| Bgwriter: Buffers allocated per second | Number of buffers allocated per second. |
Dependent item | pgsql.bgwriter.buffers_alloc.rate Preprocessing
|
| Bgwriter: Buffers written directly by a backend per second | Number of buffers written directly by a backend per second. Available in PostgreSQL versions prior to 17. |
Dependent item | pgsql.bgwriter.buffers_backend.rate Preprocessing
|
| Bgwriter: Number of bgwriter cleaning scan stopped per second | Number of times the background writer stopped a cleaning scan because it had written too many buffers per second. |
Dependent item | pgsql.bgwriter.maxwritten_clean.rate Preprocessing
|
| Bgwriter: Times a backend executed its own fsync per second | 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). Available in PostgreSQL versions prior to 17. |
Dependent item | pgsql.bgwriter.buffers_backend_fsync.rate Preprocessing
|
| Checkpoint: Buffers written by the background writer per second | Number of buffers written by the background writer per second. |
Dependent item | pgsql.bgwriter.buffers_clean.rate Preprocessing
|
| Checkpoint: Buffers written during checkpoints per second | Number of buffers written during checkpoints per second. |
Dependent item | pgsql.bgwriter.buffers_checkpoint.rate Preprocessing
|
| Checkpoint: Scheduled per second | Number of scheduled checkpoints that have been performed per second. |
Dependent item | pgsql.bgwriter.checkpoints_timed.rate Preprocessing
|
| Checkpoint: Requested per second | Number of requested checkpoints that have been performed per second. |
Dependent item | pgsql.bgwriter.checkpoints_req.rate Preprocessing
|
| Checkpoint: Checkpoint write time per second | Total amount of time per second that has been spent in the portion of checkpoint processing where files are written to disk. |
Dependent item | pgsql.bgwriter.checkpoint_write_time.rate Preprocessing
|
| Checkpoint: Checkpoint sync time per second | Total amount of time per second that has been spent in the portion of checkpoint processing where files are synchronized to disk. |
Dependent item | pgsql.bgwriter.checkpoint_sync_time.rate Preprocessing
|
| Archive: Count of archived files | Count of archived files. |
Dependent item | pgsql.archive.count_archived_files Preprocessing
|
| Archive: Count of failed attempts to archive files | Count of failed attempts to archive files. |
Dependent item | pgsql.archive.failed_trying_to_archive Preprocessing
|
| Archive: Count of files in archive_status need to archive | Count of files to archive. |
Dependent item | pgsql.archive.count_files_to_archive Preprocessing
|
| Archive: Size of files need to archive | Size of files to archive. |
Dependent item | pgsql.archive.size_files_to_archive Preprocessing
|
| Dbstat: Blocks read time | Time spent reading data file blocks by backends. |
Dependent item | pgsql.dbstat.sum.blk_read_time Preprocessing
|
| Dbstat: Blocks write time | Time spent writing data file blocks by backends. |
Dependent item | pgsql.dbstat.sum.blk_write_time Preprocessing
|
| Dbstat: Checksum failures per second | Number of data page checksum failures per second detected (or on a shared object), or NULL if data checksums are not enabled. This metric is available since PostgreSQL 12. |
Dependent item | pgsql.dbstat.sum.checksum_failures.rate Preprocessing
|
| Dbstat: Committed transactions per second | Number of transactions that have been committed per second. |
Dependent item | pgsql.dbstat.sum.xact_commit.rate Preprocessing
|
| Dbstat: Conflicts per second | Number of queries canceled per second due to conflicts with recovery (conflicts occur only on standby servers; see pg_stat_database_conflicts for details). |
Dependent item | pgsql.dbstat.sum.conflicts.rate Preprocessing
|
| Dbstat: Deadlocks per second | Number of deadlocks detected per second. |
Dependent item | pgsql.dbstat.sum.deadlocks.rate Preprocessing
|
| Dbstat: Disk blocks read per second | Number of disk blocks read per second. |
Dependent item | pgsql.dbstat.sum.blks_read.rate Preprocessing
|
| Dbstat: Hit blocks read per second | Number of times per second disk blocks were found already in the buffer cache |
Dependent item | pgsql.dbstat.sum.blks_hit.rate Preprocessing
|
| Dbstat: Number temp bytes per second | Total amount of data written per second to temporary files by queries. |
Dependent item | pgsql.dbstat.sum.temp_bytes.rate Preprocessing
|
| Dbstat: Number temp files per second | Number of temporary files created by queries per second. |
Dependent item | pgsql.dbstat.sum.temp_files.rate Preprocessing
|
| Dbstat: Roll backed transactions per second | Number of transactions that have been rolled back per second. |
Dependent item | pgsql.dbstat.sum.xact_rollback.rate Preprocessing
|
| Dbstat: Rows deleted per second | Number of rows deleted by queries per second. |
Dependent item | pgsql.dbstat.sum.tup_deleted.rate Preprocessing
|
| Dbstat: Rows fetched per second | Number of rows fetched by queries per second. |
Dependent item | pgsql.dbstat.sum.tup_fetched.rate Preprocessing
|
| Dbstat: Rows inserted per second | Number of rows inserted by queries per second. |
Dependent item | pgsql.dbstat.sum.tup_inserted.rate Preprocessing
|
| Dbstat: Rows returned per second | Number of rows returned by queries per second. |
Dependent item | pgsql.dbstat.sum.tup_returned.rate Preprocessing
|
| Dbstat: Rows updated per second | Number of rows updated by queries per second. |
Dependent item | pgsql.dbstat.sum.tup_updated.rate Preprocessing
|
| Dbstat: Backends connected | Number of connected backends. |
Dependent item | pgsql.dbstat.sum.numbackends Preprocessing
|
| Connections sum: Active | Total number of connections executing a query. |
Dependent item | pgsql.connections.sum.active Preprocessing
|
| Connections sum: Fastpath function call | Total number of connections executing a fast-path function. |
Dependent item | pgsql.connections.sum.fastpath_function_call Preprocessing
|
| Connections sum: Idle | Total number of connections waiting for a new client command. |
Dependent item | pgsql.connections.sum.idle Preprocessing
|
| Connections sum: Idle in transaction | Total number of connections in a transaction state but not executing a query. |
Dependent item | pgsql.connections.sum.idle_in_transaction Preprocessing
|
| Connections sum: Prepared | Total number of prepared transactions: https://www.postgresql.org/docs/current/sql-prepare-transaction.html |
Dependent item | pgsql.connections.sum.prepared Preprocessing
|
| Connections sum: Total | Total number of connections. |
Dependent item | pgsql.connections.sum.total Preprocessing
|
| Connections sum: Total, % | Total number of connections, in percentage. |
Dependent item | pgsql.connections.sum.total_pct Preprocessing
|
| Connections sum: Waiting | Total number of waiting connections: https://www.postgresql.org/docs/current/monitoring-stats.html#WAIT-EVENT-TABLE |
Dependent item | pgsql.connections.sum.waiting Preprocessing
|
| Connections sum: Idle in transaction (aborted) | 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. |
Dependent item | pgsql.connections.sum.idle_in_transaction_aborted Preprocessing
|
| Connections sum: Disabled | Total number of disabled connections. |
Dependent item | pgsql.connections.sum.disabled Preprocessing
|
| Age of oldest xid | Age of oldest xid. |
Zabbix agent | pgsql.oldest.xid["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Count of autovacuum workers | Number of autovacuum workers. |
Zabbix agent | pgsql.autovacuum.count["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Cache hit ratio, % | Cache hit ratio. |
Calculated | pgsql.cache.hit |
| Uptime | Time since the server started. |
Zabbix agent | pgsql.uptime["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Replication: Lag in bytes | Replication lag with master, in bytes. |
Zabbix agent | pgsql.replication.lag.b["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Replication: Lag in seconds | Replication lag with master, in seconds. |
Zabbix agent | pgsql.replication.lag.sec["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Replication: Recovery role | Replication role: 1 — recovery is still in progress (standby mode), 0 — master mode. |
Zabbix agent | pgsql.replication.recovery_role["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Replication: Standby count | Number of standby servers. |
Zabbix agent | pgsql.replication.count["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Replication: Status | Replication status: 0 — streaming is down, 1 — streaming is up, 2 — master mode. |
Zabbix agent | pgsql.replication.status["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Ping | Used to test a connection to see if it is alive. It is set to 0 if the query is unsuccessful. |
Zabbix agent | pgsql.ping["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] Preprocessing
|
| Name | Description | Expression | Severity | Dependencies and additional info |
|---|---|---|---|---|
| PostgreSQL: Version has changed | last(/PostgreSQL by Zabbix agent 2/pgsql.version["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"],#1)<>last(/PostgreSQL by Zabbix agent 2/pgsql.version["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"],#2) and length(last(/PostgreSQL by Zabbix agent 2/pgsql.version["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]))>0 |
Info | ||
| PostgreSQL: Dbstat: Checksum failures detected | Data page checksum failures were detected on that DB instance: |
last(/PostgreSQL by Zabbix agent 2/pgsql.dbstat.sum.checksum_failures.rate)>0 |
Average | |
| PostgreSQL: Total number of connections is too high | 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). |
min(/PostgreSQL by Zabbix agent 2/pgsql.connections.sum.total_pct,5m) > {$PG.CONN_TOTAL_PCT.MAX.WARN} |
Average | |
| PostgreSQL: Oldest xid is too big | last(/PostgreSQL by Zabbix agent 2/pgsql.oldest.xid["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]) > 18000000 |
Average | ||
| PostgreSQL: Service has been restarted | PostgreSQL uptime is less than 10 minutes. |
last(/PostgreSQL by Zabbix agent 2/pgsql.uptime["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]) < 10m |
Average | |
| PostgreSQL: Service is down | Last test of a connection was unsuccessful. |
last(/PostgreSQL by Zabbix agent 2/pgsql.ping["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"])=0 |
High |
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Replication discovery | Discovers replication lag metrics. |
Zabbix agent | pgsql.replication.process.discovery["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Application [{#APPLICATION_NAME}]: Get replication | 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. |
Dependent item | pgsql.replication.get_metrics["{#APPLICATION_NAME}"] Preprocessing
|
| Application [{#APPLICATION_NAME}]: Replication flush lag | Dependent item | pgsql.replication.process.flush_lag["{#APPLICATION_NAME}"] Preprocessing
|
|
| Application [{#APPLICATION_NAME}]: Replication replay lag | Dependent item | pgsql.replication.process.replay_lag["{#APPLICATION_NAME}"] Preprocessing
|
|
| Application [{#APPLICATION_NAME}]: Replication write lag | Dependent item | pgsql.replication.process.write_lag["{#APPLICATION_NAME}"] Preprocessing
|
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Database discovery | Discovers databases (DB) in the database management system (DBMS), except: - templates; - DBs that do not allow connections. |
Zabbix agent | pgsql.db.discovery["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| DB [{#DBNAME}]: Get dbstat | Get dbstat metrics for database "{#DBNAME}". |
Dependent item | pgsql.dbstat.get_metrics["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Get locks | Get locks metrics for database "{#DBNAME}". |
Dependent item | pgsql.locks.get_metrics["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Get queries | Get queries metrics for database "{#DBNAME}". |
Dependent item | pgsql.queries.get_metrics["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Database age | Database age. |
Zabbix agent | pgsql.db.age["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{#DBNAME}"] |
| DB [{#DBNAME}]: Bloating tables | Number of bloating tables. |
Zabbix agent | pgsql.db.bloating_tables["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{#DBNAME}"] |
| DB [{#DBNAME}]: Database size | Database size. |
Zabbix agent | pgsql.db.size["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{#DBNAME}"] |
| DB [{#DBNAME}]: Blocks hit per second | Total number of times per second disk blocks were found already in the buffer cache, so that a read was not necessary. |
Dependent item | pgsql.dbstat.blks_hit.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Disk blocks read per second | Total number of disk blocks read per second in this database. |
Dependent item | pgsql.dbstat.blks_read.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Detected conflicts per second | Total number of queries canceled due to conflicts with recovery in this database per second. |
Dependent item | pgsql.dbstat.conflicts.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Detected deadlocks per second | Total number of detected deadlocks in this database per second. |
Dependent item | pgsql.dbstat.deadlocks.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Temp_bytes written per second | Total amount of data written to temporary files by queries in this database. |
Dependent item | pgsql.dbstat.temp_bytes.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Temp_files created per second | Total number of temporary files created by queries in this database. |
Dependent item | pgsql.dbstat.temp_files.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Tuples deleted per second | Total number of rows deleted by queries in this database per second. |
Dependent item | pgsql.dbstat.tup_deleted.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Tuples fetched per second | Total number of rows fetched by queries in this database per second. |
Dependent item | pgsql.dbstat.tup_fetched.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Tuples inserted per second | Total number of rows inserted by queries in this database per second. |
Dependent item | pgsql.dbstat.tup_inserted.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Tuples returned per second | Number of rows returned by queries in this database per second. |
Dependent item | pgsql.dbstat.tup_returned.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Tuples updated per second | Total number of rows updated by queries in this database per second. |
Dependent item | pgsql.dbstat.tup_updated.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Commits per second | Number of transactions in this database that have been committed per second. |
Dependent item | pgsql.dbstat.xact_commit.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Rollbacks per second | Total number of transactions in this database that have been rolled back. |
Dependent item | pgsql.dbstat.xact_rollback.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Backends connected | Number of backends currently connected to this database. |
Dependent item | pgsql.dbstat.numbackends["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Checksum failures | Number of data page checksum failures detected in this database. |
Dependent item | pgsql.dbstat.checksum_failures.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Disk blocks read time per second | Time spent reading data file blocks by backends per second. |
Dependent item | pgsql.dbstat.blk_read_time.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Disk blocks write time | Time spent writing data file blocks by backends per second. |
Dependent item | pgsql.dbstat.blk_write_time.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Num of accessexclusive locks | Number of accessexclusive locks for this database. |
Dependent item | pgsql.locks.accessexclusive["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Num of accessshare locks | Number of accessshare locks for this database. |
Dependent item | pgsql.locks.accessshare["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Num of exclusive locks | Number of exclusive locks for this database. |
Dependent item | pgsql.locks.exclusive["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Num of rowexclusive locks | Number of rowexclusive locks for this database. |
Dependent item | pgsql.locks.rowexclusive["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Num of rowshare locks | Number of rowshare locks for this database. |
Dependent item | pgsql.locks.rowshare["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Num of sharerowexclusive locks | Number of total sharerowexclusive for this database. |
Dependent item | pgsql.locks.sharerowexclusive["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Num of shareupdateexclusive locks | Number of shareupdateexclusive locks for this database. |
Dependent item | pgsql.locks.shareupdateexclusive["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Num of share locks | Number of share locks for this database. |
Dependent item | pgsql.locks.share["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Num of locks total | Total number of locks in this database. |
Dependent item | pgsql.locks.total["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries max maintenance time | Max maintenance query time for this database. |
Dependent item | pgsql.queries.mro.time_max["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries max query time | Max query time for this database. |
Dependent item | pgsql.queries.query.time_max["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries max transaction time | Max transaction query time for this database. |
Dependent item | pgsql.queries.tx.time_max["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries slow maintenance count | Slow maintenance query count for this database. |
Dependent item | pgsql.queries.mro.slow_count["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries slow query count | Slow query count for this database. |
Dependent item | pgsql.queries.query.slow_count["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries slow transaction count | Slow transaction query count for this database. |
Dependent item | pgsql.queries.tx.slow_count["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries sum maintenance time | Sum maintenance query time for this database. |
Dependent item | pgsql.queries.mro.time_sum["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries sum query time | Sum query time for this database. |
Dependent item | pgsql.queries.query.time_sum["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries sum transaction time | Sum transaction query time for this database. |
Dependent item | pgsql.queries.tx.time_sum["{#DBNAME}"] Preprocessing
|
| Name | Description | Expression | Severity | Dependencies and additional info |
|---|---|---|---|---|
| PostgreSQL: DB [{#DBNAME}]: Too many recovery conflicts | 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. |
min(/PostgreSQL by Zabbix agent 2/pgsql.dbstat.conflicts.rate["{#DBNAME}"],5m) > {$PG.CONFLICTS.MAX.WARN:"{#DBNAME}"} |
Average | |
| PostgreSQL: DB [{#DBNAME}]: Deadlock occurred | Number of deadlocks detected per second exceeds {$PG.DEADLOCKS.MAX.WARN:"{#DBNAME}"} for 5m. |
min(/PostgreSQL by Zabbix agent 2/pgsql.dbstat.deadlocks.rate["{#DBNAME}"],5m) > {$PG.DEADLOCKS.MAX.WARN:"{#DBNAME}"} |
High | |
| PostgreSQL: DB [{#DBNAME}]: Checksum failures detected | Data page checksum failures were detected on that database: |
last(/PostgreSQL by Zabbix agent 2/pgsql.dbstat.checksum_failures.rate["{#DBNAME}"])>0 |
Average | |
| PostgreSQL: DB [{#DBNAME}]: Too many slow queries | The number of detected slow queries exceeds the limit of {$PG.SLOW_QUERIES.MAX.WARN:"{#DBNAME}"}. |
min(/PostgreSQL by Zabbix agent 2/pgsql.queries.query.slow_count["{#DBNAME}"],5m)>{$PG.SLOW_QUERIES.MAX.WARN:"{#DBNAME}"} |
Warning |
Please report any issues with the template at https://support.zabbix.com
You can also provide feedback, discuss the template, or ask for help at ZABBIX forums
This template is designed for the deployment of PostgreSQL monitoring by Zabbix via Zabbix agent 2 and uses a loadable plugin to run SQL queries.
Zabbix version: 7.2 and higher.
This template has been tested on:
Zabbix should be configured according to the instructions in the Templates out of the box section.
Deploy Zabbix agent 2 with the PostgreSQL plugin. Starting with Zabbix versions 6.0.10 / 6.2.4 / 6.4 PostgreSQL metrics are moved to a loadable plugin and require installation of a separate package or compilation of the plugin from sources.
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;
pg_hba.conf configuration file to allow connections for the user zbx_monitor. For example, you could add one of the following rows to allow local TCP connections from the same host:# TYPE DATABASE USER ADDRESS METHOD
host all zbx_monitor localhost trust
host all zbx_monitor 127.0.0.1/32 md5
host all zbx_monitor ::1/128 scram-sha-256
For more information please read the PostgreSQL documentation https://www.postgresql.org/docs/current/auth-pg-hba-conf.html.
{$PG.CONNSTRING.AGENT2} macro as URI, such as <protocol(host:port)>, or specify the named session - <sessionname>.Note: if you want to use SSL/TLS encryption to protect communications with the remote PostgreSQL instance, a named session must be used. In that case, the instance URI should be specified in the Plugins.PostgreSQL.Sessions.*.Uri parameter in the PostgreSQL plugin configuration files alongside all the encryption parameters (type, certificate/key filepaths if needed etc.).
You can check the PostgreSQL plugin documentation for details about agent plugin parameters and named sessions.
Also, it is assumed that you set up the PostgreSQL instance to work in the desired encryption mode. Check the PostgreSQL documentation for details.
Note: plugin TLS certificate validation relies on checking the Subject Alternative Names (SAN) instead of the Common Name (CN), check the cryptography package documentation for details.
For example, to enable required encryption in transport mode without identity checks you could create the file /etc/zabbix/zabbix_agent2.d/postgresql_myconn.conf with the following configuration for the named session myconn (replace <instanceip> with the address of the PostgreSQL instance):
Plugins.PostgreSQL.Sessions.myconn.Uri=tcp://<instanceip>:5432
Plugins.PostgreSQL.Sessions.myconn.TLSConnect=required
Then set the {$PG.CONNSTRING.AGENT2} macro to myconn to use this named session.
{$PG.PASSWORD}.| Name | Description | Default |
|---|---|---|
| {$PG.PASSWORD} | PostgreSQL user password. |
<Put the password here> |
| {$PG.CONNSTRING.AGENT2} | URI or named session of the PostgreSQL instance. |
tcp://localhost:5432 |
| {$PG.USER} | PostgreSQL username. |
zbx_monitor |
| {$PG.LLD.FILTER.DBNAME} | Filter of discoverable databases. |
.+ |
| {$PG.CONN_TOTAL_PCT.MAX.WARN} | Maximum percentage of current connections for trigger expression. |
90 |
| {$PG.DATABASE} | Default PostgreSQL database for the connection. |
postgres |
| {$PG.DEADLOCKS.MAX.WARN} | Maximum number of detected deadlocks for trigger expression. |
0 |
| {$PG.LLD.FILTER.APPLICATION} | Filter of discoverable applications. |
.+ |
| {$PG.CONFLICTS.MAX.WARN} | Maximum number of recovery conflicts for trigger expression. |
0 |
| {$PG.QUERY_ETIME.MAX.WARN} | Execution time limit for count of slow queries. |
30 |
| {$PG.SLOW_QUERIES.MAX.WARN} | Slow queries count threshold for a trigger. |
5 |
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Get bgwriter | Collect all metrics from pg_stat_bgwriter: https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-BGWRITER-VIEW |
Zabbix agent | pgsql.bgwriter["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Get archive | Collect archive status metrics. |
Zabbix agent | pgsql.archive["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Get dbstat | Collect all metrics from pg_stat_database per database: https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-DATABASE-VIEW |
Zabbix agent | pgsql.dbstat["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Get dbstat sum | 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 |
Zabbix agent | pgsql.dbstat.sum["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Get connections sum | Collect all metrics from pg_stat_activity: https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-ACTIVITY-VIEW |
Zabbix agent | pgsql.connections["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Get WAL | Collect write-ahead log (WAL) metrics. |
Zabbix agent | pgsql.wal.stat["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Get locks | Collect all metrics from pg_locks per database: https://www.postgresql.org/docs/current/explicit-locking.html#LOCKING-TABLES |
Zabbix agent | pgsql.locks["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Custom queries | Execute custom queries from file *.sql (check for option Plugins.Postgres.CustomQueriesPath at agent configuration). |
Zabbix agent | pgsql.custom.query["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}",""] |
| Get replication | 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. |
Zabbix agent | pgsql.replication.process["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Get queries | Collect all metrics by query execution time. |
Zabbix agent | pgsql.queries["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}","{$PG.QUERY_ETIME.MAX.WARN}"] |
| Version | PostgreSQL version. |
Zabbix agent | pgsql.version["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] Preprocessing
|
| WAL: Bytes written | WAL write, in bytes. |
Dependent item | pgsql.wal.write Preprocessing
|
| WAL: Bytes received | WAL receive, in bytes. |
Dependent item | pgsql.wal.receive Preprocessing
|
| WAL: Segments count | Number of WAL segments. |
Dependent item | pgsql.wal.count Preprocessing
|
| Bgwriter: Buffers allocated per second | Number of buffers allocated per second. |
Dependent item | pgsql.bgwriter.buffers_alloc.rate Preprocessing
|
| Bgwriter: Buffers written directly by a backend per second | Number of buffers written directly by a backend per second. Available in PostgreSQL versions prior to 17. |
Dependent item | pgsql.bgwriter.buffers_backend.rate Preprocessing
|
| Bgwriter: Number of bgwriter cleaning scan stopped per second | Number of times the background writer stopped a cleaning scan because it had written too many buffers per second. |
Dependent item | pgsql.bgwriter.maxwritten_clean.rate Preprocessing
|
| Bgwriter: Times a backend executed its own fsync per second | 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). Available in PostgreSQL versions prior to 17. |
Dependent item | pgsql.bgwriter.buffers_backend_fsync.rate Preprocessing
|
| Checkpoint: Buffers written by the background writer per second | Number of buffers written by the background writer per second. |
Dependent item | pgsql.bgwriter.buffers_clean.rate Preprocessing
|
| Checkpoint: Buffers written during checkpoints per second | Number of buffers written during checkpoints per second. |
Dependent item | pgsql.bgwriter.buffers_checkpoint.rate Preprocessing
|
| Checkpoint: Scheduled per second | Number of scheduled checkpoints that have been performed per second. |
Dependent item | pgsql.bgwriter.checkpoints_timed.rate Preprocessing
|
| Checkpoint: Requested per second | Number of requested checkpoints that have been performed per second. |
Dependent item | pgsql.bgwriter.checkpoints_req.rate Preprocessing
|
| Checkpoint: Checkpoint write time per second | Total amount of time per second that has been spent in the portion of checkpoint processing where files are written to disk. |
Dependent item | pgsql.bgwriter.checkpoint_write_time.rate Preprocessing
|
| Checkpoint: Checkpoint sync time per second | Total amount of time per second that has been spent in the portion of checkpoint processing where files are synchronized to disk. |
Dependent item | pgsql.bgwriter.checkpoint_sync_time.rate Preprocessing
|
| Archive: Count of archived files | Count of archived files. |
Dependent item | pgsql.archive.count_archived_files Preprocessing
|
| Archive: Count of failed attempts to archive files | Count of failed attempts to archive files. |
Dependent item | pgsql.archive.failed_trying_to_archive Preprocessing
|
| Archive: Count of files in archive_status need to archive | Count of files to archive. |
Dependent item | pgsql.archive.count_files_to_archive Preprocessing
|
| Archive: Size of files need to archive | Size of files to archive. |
Dependent item | pgsql.archive.size_files_to_archive Preprocessing
|
| Dbstat: Blocks read time | Time spent reading data file blocks by backends. |
Dependent item | pgsql.dbstat.sum.blk_read_time Preprocessing
|
| Dbstat: Blocks write time | Time spent writing data file blocks by backends. |
Dependent item | pgsql.dbstat.sum.blk_write_time Preprocessing
|
| Dbstat: Checksum failures per second | Number of data page checksum failures per second detected (or on a shared object), or NULL if data checksums are not enabled. This metric is available since PostgreSQL 12. |
Dependent item | pgsql.dbstat.sum.checksum_failures.rate Preprocessing
|
| Dbstat: Committed transactions per second | Number of transactions that have been committed per second. |
Dependent item | pgsql.dbstat.sum.xact_commit.rate Preprocessing
|
| Dbstat: Conflicts per second | Number of queries canceled per second due to conflicts with recovery (conflicts occur only on standby servers; see pg_stat_database_conflicts for details). |
Dependent item | pgsql.dbstat.sum.conflicts.rate Preprocessing
|
| Dbstat: Deadlocks per second | Number of deadlocks detected per second. |
Dependent item | pgsql.dbstat.sum.deadlocks.rate Preprocessing
|
| Dbstat: Disk blocks read per second | Number of disk blocks read per second. |
Dependent item | pgsql.dbstat.sum.blks_read.rate Preprocessing
|
| Dbstat: Hit blocks read per second | Number of times per second disk blocks were found already in the buffer cache |
Dependent item | pgsql.dbstat.sum.blks_hit.rate Preprocessing
|
| Dbstat: Number temp bytes per second | Total amount of data written per second to temporary files by queries. |
Dependent item | pgsql.dbstat.sum.temp_bytes.rate Preprocessing
|
| Dbstat: Number temp files per second | Number of temporary files created by queries per second. |
Dependent item | pgsql.dbstat.sum.temp_files.rate Preprocessing
|
| Dbstat: Roll backed transactions per second | Number of transactions that have been rolled back per second. |
Dependent item | pgsql.dbstat.sum.xact_rollback.rate Preprocessing
|
| Dbstat: Rows deleted per second | Number of rows deleted by queries per second. |
Dependent item | pgsql.dbstat.sum.tup_deleted.rate Preprocessing
|
| Dbstat: Rows fetched per second | Number of rows fetched by queries per second. |
Dependent item | pgsql.dbstat.sum.tup_fetched.rate Preprocessing
|
| Dbstat: Rows inserted per second | Number of rows inserted by queries per second. |
Dependent item | pgsql.dbstat.sum.tup_inserted.rate Preprocessing
|
| Dbstat: Rows returned per second | Number of rows returned by queries per second. |
Dependent item | pgsql.dbstat.sum.tup_returned.rate Preprocessing
|
| Dbstat: Rows updated per second | Number of rows updated by queries per second. |
Dependent item | pgsql.dbstat.sum.tup_updated.rate Preprocessing
|
| Dbstat: Backends connected | Number of connected backends. |
Dependent item | pgsql.dbstat.sum.numbackends Preprocessing
|
| Connections sum: Active | Total number of connections executing a query. |
Dependent item | pgsql.connections.sum.active Preprocessing
|
| Connections sum: Fastpath function call | Total number of connections executing a fast-path function. |
Dependent item | pgsql.connections.sum.fastpath_function_call Preprocessing
|
| Connections sum: Idle | Total number of connections waiting for a new client command. |
Dependent item | pgsql.connections.sum.idle Preprocessing
|
| Connections sum: Idle in transaction | Total number of connections in a transaction state but not executing a query. |
Dependent item | pgsql.connections.sum.idle_in_transaction Preprocessing
|
| Connections sum: Prepared | Total number of prepared transactions: https://www.postgresql.org/docs/current/sql-prepare-transaction.html |
Dependent item | pgsql.connections.sum.prepared Preprocessing
|
| Connections sum: Total | Total number of connections. |
Dependent item | pgsql.connections.sum.total Preprocessing
|
| Connections sum: Total, % | Total number of connections, in percentage. |
Dependent item | pgsql.connections.sum.total_pct Preprocessing
|
| Connections sum: Waiting | Total number of waiting connections: https://www.postgresql.org/docs/current/monitoring-stats.html#WAIT-EVENT-TABLE |
Dependent item | pgsql.connections.sum.waiting Preprocessing
|
| Connections sum: Idle in transaction (aborted) | 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. |
Dependent item | pgsql.connections.sum.idle_in_transaction_aborted Preprocessing
|
| Connections sum: Disabled | Total number of disabled connections. |
Dependent item | pgsql.connections.sum.disabled Preprocessing
|
| Age of oldest xid | Age of oldest xid. |
Zabbix agent | pgsql.oldest.xid["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Count of autovacuum workers | Number of autovacuum workers. |
Zabbix agent | pgsql.autovacuum.count["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Cache hit ratio, % | Cache hit ratio. |
Calculated | pgsql.cache.hit |
| Uptime | Time since the server started. |
Zabbix agent | pgsql.uptime["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Replication: Lag in bytes | Replication lag with master, in bytes. |
Zabbix agent | pgsql.replication.lag.b["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Replication: Lag in seconds | Replication lag with master, in seconds. |
Zabbix agent | pgsql.replication.lag.sec["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Replication: Recovery role | Replication role: 1 — recovery is still in progress (standby mode), 0 — master mode. |
Zabbix agent | pgsql.replication.recovery_role["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Replication: Standby count | Number of standby servers. |
Zabbix agent | pgsql.replication.count["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Replication: Status | Replication status: 0 — streaming is down, 1 — streaming is up, 2 — master mode. |
Zabbix agent | pgsql.replication.status["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Ping | Used to test a connection to see if it is alive. It is set to 0 if the query is unsuccessful. |
Zabbix agent | pgsql.ping["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] Preprocessing
|
| Name | Description | Expression | Severity | Dependencies and additional info |
|---|---|---|---|---|
| PostgreSQL: Version has changed | last(/PostgreSQL by Zabbix agent 2/pgsql.version["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"],#1)<>last(/PostgreSQL by Zabbix agent 2/pgsql.version["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"],#2) and length(last(/PostgreSQL by Zabbix agent 2/pgsql.version["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]))>0 |
Info | ||
| PostgreSQL: Dbstat: Checksum failures detected | Data page checksum failures were detected on that DB instance: |
last(/PostgreSQL by Zabbix agent 2/pgsql.dbstat.sum.checksum_failures.rate)>0 |
Average | |
| PostgreSQL: Total number of connections is too high | 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). |
min(/PostgreSQL by Zabbix agent 2/pgsql.connections.sum.total_pct,5m) > {$PG.CONN_TOTAL_PCT.MAX.WARN} |
Average | |
| PostgreSQL: Oldest xid is too big | last(/PostgreSQL by Zabbix agent 2/pgsql.oldest.xid["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]) > 18000000 |
Average | ||
| PostgreSQL: Service has been restarted | PostgreSQL uptime is less than 10 minutes. |
last(/PostgreSQL by Zabbix agent 2/pgsql.uptime["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]) < 10m |
Average | |
| PostgreSQL: Service is down | Last test of a connection was unsuccessful. |
last(/PostgreSQL by Zabbix agent 2/pgsql.ping["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"])=0 |
High |
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Replication discovery | Discovers replication lag metrics. |
Zabbix agent | pgsql.replication.process.discovery["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Application [{#APPLICATION_NAME}]: Get replication | 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. |
Dependent item | pgsql.replication.get_metrics["{#APPLICATION_NAME}"] Preprocessing
|
| Application [{#APPLICATION_NAME}]: Replication flush lag | Dependent item | pgsql.replication.process.flush_lag["{#APPLICATION_NAME}"] Preprocessing
|
|
| Application [{#APPLICATION_NAME}]: Replication replay lag | Dependent item | pgsql.replication.process.replay_lag["{#APPLICATION_NAME}"] Preprocessing
|
|
| Application [{#APPLICATION_NAME}]: Replication write lag | Dependent item | pgsql.replication.process.write_lag["{#APPLICATION_NAME}"] Preprocessing
|
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Database discovery | Discovers databases (DB) in the database management system (DBMS), except: - templates; - DBs that do not allow connections. |
Zabbix agent | pgsql.db.discovery["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| DB [{#DBNAME}]: Get dbstat | Get dbstat metrics for database "{#DBNAME}". |
Dependent item | pgsql.dbstat.get_metrics["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Get locks | Get locks metrics for database "{#DBNAME}". |
Dependent item | pgsql.locks.get_metrics["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Get queries | Get queries metrics for database "{#DBNAME}". |
Dependent item | pgsql.queries.get_metrics["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Database age | Database age. |
Zabbix agent | pgsql.db.age["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{#DBNAME}"] |
| DB [{#DBNAME}]: Bloating tables | Number of bloating tables. |
Zabbix agent | pgsql.db.bloating_tables["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{#DBNAME}"] |
| DB [{#DBNAME}]: Database size | Database size. |
Zabbix agent | pgsql.db.size["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{#DBNAME}"] |
| DB [{#DBNAME}]: Blocks hit per second | Total number of times per second disk blocks were found already in the buffer cache, so that a read was not necessary. |
Dependent item | pgsql.dbstat.blks_hit.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Disk blocks read per second | Total number of disk blocks read per second in this database. |
Dependent item | pgsql.dbstat.blks_read.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Detected conflicts per second | Total number of queries canceled due to conflicts with recovery in this database per second. |
Dependent item | pgsql.dbstat.conflicts.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Detected deadlocks per second | Total number of detected deadlocks in this database per second. |
Dependent item | pgsql.dbstat.deadlocks.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Temp_bytes written per second | Total amount of data written to temporary files by queries in this database. |
Dependent item | pgsql.dbstat.temp_bytes.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Temp_files created per second | Total number of temporary files created by queries in this database. |
Dependent item | pgsql.dbstat.temp_files.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Tuples deleted per second | Total number of rows deleted by queries in this database per second. |
Dependent item | pgsql.dbstat.tup_deleted.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Tuples fetched per second | Total number of rows fetched by queries in this database per second. |
Dependent item | pgsql.dbstat.tup_fetched.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Tuples inserted per second | Total number of rows inserted by queries in this database per second. |
Dependent item | pgsql.dbstat.tup_inserted.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Tuples returned per second | Number of rows returned by queries in this database per second. |
Dependent item | pgsql.dbstat.tup_returned.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Tuples updated per second | Total number of rows updated by queries in this database per second. |
Dependent item | pgsql.dbstat.tup_updated.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Commits per second | Number of transactions in this database that have been committed per second. |
Dependent item | pgsql.dbstat.xact_commit.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Rollbacks per second | Total number of transactions in this database that have been rolled back. |
Dependent item | pgsql.dbstat.xact_rollback.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Backends connected | Number of backends currently connected to this database. |
Dependent item | pgsql.dbstat.numbackends["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Checksum failures | Number of data page checksum failures detected in this database. |
Dependent item | pgsql.dbstat.checksum_failures.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Disk blocks read time per second | Time spent reading data file blocks by backends per second. |
Dependent item | pgsql.dbstat.blk_read_time.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Disk blocks write time | Time spent writing data file blocks by backends per second. |
Dependent item | pgsql.dbstat.blk_write_time.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Num of accessexclusive locks | Number of accessexclusive locks for this database. |
Dependent item | pgsql.locks.accessexclusive["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Num of accessshare locks | Number of accessshare locks for this database. |
Dependent item | pgsql.locks.accessshare["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Num of exclusive locks | Number of exclusive locks for this database. |
Dependent item | pgsql.locks.exclusive["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Num of rowexclusive locks | Number of rowexclusive locks for this database. |
Dependent item | pgsql.locks.rowexclusive["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Num of rowshare locks | Number of rowshare locks for this database. |
Dependent item | pgsql.locks.rowshare["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Num of sharerowexclusive locks | Number of total sharerowexclusive for this database. |
Dependent item | pgsql.locks.sharerowexclusive["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Num of shareupdateexclusive locks | Number of shareupdateexclusive locks for this database. |
Dependent item | pgsql.locks.shareupdateexclusive["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Num of share locks | Number of share locks for this database. |
Dependent item | pgsql.locks.share["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Num of locks total | Total number of locks in this database. |
Dependent item | pgsql.locks.total["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries max maintenance time | Max maintenance query time for this database. |
Dependent item | pgsql.queries.mro.time_max["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries max query time | Max query time for this database. |
Dependent item | pgsql.queries.query.time_max["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries max transaction time | Max transaction query time for this database. |
Dependent item | pgsql.queries.tx.time_max["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries slow maintenance count | Slow maintenance query count for this database. |
Dependent item | pgsql.queries.mro.slow_count["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries slow query count | Slow query count for this database. |
Dependent item | pgsql.queries.query.slow_count["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries slow transaction count | Slow transaction query count for this database. |
Dependent item | pgsql.queries.tx.slow_count["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries sum maintenance time | Sum maintenance query time for this database. |
Dependent item | pgsql.queries.mro.time_sum["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries sum query time | Sum query time for this database. |
Dependent item | pgsql.queries.query.time_sum["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries sum transaction time | Sum transaction query time for this database. |
Dependent item | pgsql.queries.tx.time_sum["{#DBNAME}"] Preprocessing
|
| Name | Description | Expression | Severity | Dependencies and additional info |
|---|---|---|---|---|
| PostgreSQL: DB [{#DBNAME}]: Too many recovery conflicts | 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. |
min(/PostgreSQL by Zabbix agent 2/pgsql.dbstat.conflicts.rate["{#DBNAME}"],5m) > {$PG.CONFLICTS.MAX.WARN:"{#DBNAME}"} |
Average | |
| PostgreSQL: DB [{#DBNAME}]: Deadlock occurred | Number of deadlocks detected per second exceeds {$PG.DEADLOCKS.MAX.WARN:"{#DBNAME}"} for 5m. |
min(/PostgreSQL by Zabbix agent 2/pgsql.dbstat.deadlocks.rate["{#DBNAME}"],5m) > {$PG.DEADLOCKS.MAX.WARN:"{#DBNAME}"} |
High | |
| PostgreSQL: DB [{#DBNAME}]: Checksum failures detected | Data page checksum failures were detected on that database: |
last(/PostgreSQL by Zabbix agent 2/pgsql.dbstat.checksum_failures.rate["{#DBNAME}"])>0 |
Average | |
| PostgreSQL: DB [{#DBNAME}]: Too many slow queries | The number of detected slow queries exceeds the limit of {$PG.SLOW_QUERIES.MAX.WARN:"{#DBNAME}"}. |
min(/PostgreSQL by Zabbix agent 2/pgsql.queries.query.slow_count["{#DBNAME}"],5m)>{$PG.SLOW_QUERIES.MAX.WARN:"{#DBNAME}"} |
Warning |
Please report any issues with the template at https://support.zabbix.com
You can also provide feedback, discuss the template, or ask for help at ZABBIX forums
This template is designed for the deployment of PostgreSQL monitoring by Zabbix via Zabbix agent 2 and uses a loadable plugin to run SQL queries.
Zabbix version: 7.0 and higher.
This template has been tested on:
Zabbix should be configured according to the instructions in the Templates out of the box section.
Deploy Zabbix agent 2 with the PostgreSQL plugin. Starting with Zabbix versions 6.0.10 / 6.2.4 / 6.4 PostgreSQL metrics are moved to a loadable plugin and require installation of a separate package or compilation of the plugin from sources.
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;
pg_hba.conf configuration file to allow connections for the user zbx_monitor. For example, you could add one of the following rows to allow local TCP connections from the same host:# TYPE DATABASE USER ADDRESS METHOD
host all zbx_monitor localhost trust
host all zbx_monitor 127.0.0.1/32 md5
host all zbx_monitor ::1/128 scram-sha-256
For more information please read the PostgreSQL documentation https://www.postgresql.org/docs/current/auth-pg-hba-conf.html.
{$PG.CONNSTRING.AGENT2} macro as URI, such as <protocol(host:port)>, or specify the named session - <sessionname>.Note: if you want to use SSL/TLS encryption to protect communications with the remote PostgreSQL instance, a named session must be used. In that case, the instance URI should be specified in the Plugins.PostgreSQL.Sessions.*.Uri parameter in the PostgreSQL plugin configuration files alongside all the encryption parameters (type, certificate/key filepaths if needed etc.).
You can check the PostgreSQL plugin documentation for details about agent plugin parameters and named sessions.
Also, it is assumed that you set up the PostgreSQL instance to work in the desired encryption mode. Check the PostgreSQL documentation for details.
Note: plugin TLS certificate validation relies on checking the Subject Alternative Names (SAN) instead of the Common Name (CN), check the cryptography package documentation for details.
For example, to enable required encryption in transport mode without identity checks you could create the file /etc/zabbix/zabbix_agent2.d/postgresql_myconn.conf with the following configuration for the named session myconn (replace <instanceip> with the address of the PostgreSQL instance):
Plugins.PostgreSQL.Sessions.myconn.Uri=tcp://<instanceip>:5432
Plugins.PostgreSQL.Sessions.myconn.TLSConnect=required
Then set the {$PG.CONNSTRING.AGENT2} macro to myconn to use this named session.
{$PG.PASSWORD}.| Name | Description | Default |
|---|---|---|
| {$PG.PASSWORD} | PostgreSQL user password. |
<Put the password here> |
| {$PG.CONNSTRING.AGENT2} | URI or named session of the PostgreSQL instance. |
tcp://localhost:5432 |
| {$PG.USER} | PostgreSQL username. |
zbx_monitor |
| {$PG.LLD.FILTER.DBNAME} | Filter of discoverable databases. |
.+ |
| {$PG.CONN_TOTAL_PCT.MAX.WARN} | Maximum percentage of current connections for trigger expression. |
90 |
| {$PG.DATABASE} | Default PostgreSQL database for the connection. |
postgres |
| {$PG.DEADLOCKS.MAX.WARN} | Maximum number of detected deadlocks for trigger expression. |
0 |
| {$PG.LLD.FILTER.APPLICATION} | Filter of discoverable applications. |
.+ |
| {$PG.CONFLICTS.MAX.WARN} | Maximum number of recovery conflicts for trigger expression. |
0 |
| {$PG.QUERY_ETIME.MAX.WARN} | Execution time limit for count of slow queries. |
30 |
| {$PG.SLOW_QUERIES.MAX.WARN} | Slow queries count threshold for a trigger. |
5 |
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Get bgwriter | Collect all metrics from pg_stat_bgwriter: https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-BGWRITER-VIEW |
Zabbix agent | pgsql.bgwriter["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Get archive | Collect archive status metrics. |
Zabbix agent | pgsql.archive["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Get dbstat | Collect all metrics from pg_stat_database per database: https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-DATABASE-VIEW |
Zabbix agent | pgsql.dbstat["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Get dbstat sum | 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 |
Zabbix agent | pgsql.dbstat.sum["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Get connections sum | Collect all metrics from pg_stat_activity: https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-ACTIVITY-VIEW |
Zabbix agent | pgsql.connections["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Get WAL | Collect write-ahead log (WAL) metrics. |
Zabbix agent | pgsql.wal.stat["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Get locks | Collect all metrics from pg_locks per database: https://www.postgresql.org/docs/current/explicit-locking.html#LOCKING-TABLES |
Zabbix agent | pgsql.locks["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Custom queries | Execute custom queries from file *.sql (check for option Plugins.Postgres.CustomQueriesPath at agent configuration). |
Zabbix agent | pgsql.custom.query["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}",""] |
| Get replication | 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. |
Zabbix agent | pgsql.replication.process["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Get queries | Collect all metrics by query execution time. |
Zabbix agent | pgsql.queries["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}","{$PG.QUERY_ETIME.MAX.WARN}"] |
| Version | PostgreSQL version. |
Zabbix agent | pgsql.version["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] Preprocessing
|
| WAL: Bytes written | WAL write, in bytes. |
Dependent item | pgsql.wal.write Preprocessing
|
| WAL: Bytes received | WAL receive, in bytes. |
Dependent item | pgsql.wal.receive Preprocessing
|
| WAL: Segments count | Number of WAL segments. |
Dependent item | pgsql.wal.count Preprocessing
|
| Bgwriter: Buffers allocated per second | Number of buffers allocated per second. |
Dependent item | pgsql.bgwriter.buffers_alloc.rate Preprocessing
|
| Bgwriter: Buffers written directly by a backend per second | Number of buffers written directly by a backend per second. Available in PostgreSQL versions prior to 17. |
Dependent item | pgsql.bgwriter.buffers_backend.rate Preprocessing
|
| Bgwriter: Number of bgwriter cleaning scan stopped per second | Number of times the background writer stopped a cleaning scan because it had written too many buffers per second. |
Dependent item | pgsql.bgwriter.maxwritten_clean.rate Preprocessing
|
| Bgwriter: Times a backend executed its own fsync per second | 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). Available in PostgreSQL versions prior to 17. |
Dependent item | pgsql.bgwriter.buffers_backend_fsync.rate Preprocessing
|
| Checkpoint: Buffers written by the background writer per second | Number of buffers written by the background writer per second. |
Dependent item | pgsql.bgwriter.buffers_clean.rate Preprocessing
|
| Checkpoint: Buffers written during checkpoints per second | Number of buffers written during checkpoints per second. |
Dependent item | pgsql.bgwriter.buffers_checkpoint.rate Preprocessing
|
| Checkpoint: Scheduled per second | Number of scheduled checkpoints that have been performed per second. |
Dependent item | pgsql.bgwriter.checkpoints_timed.rate Preprocessing
|
| Checkpoint: Requested per second | Number of requested checkpoints that have been performed per second. |
Dependent item | pgsql.bgwriter.checkpoints_req.rate Preprocessing
|
| Checkpoint: Checkpoint write time per second | Total amount of time per second that has been spent in the portion of checkpoint processing where files are written to disk. |
Dependent item | pgsql.bgwriter.checkpoint_write_time.rate Preprocessing
|
| Checkpoint: Checkpoint sync time per second | Total amount of time per second that has been spent in the portion of checkpoint processing where files are synchronized to disk. |
Dependent item | pgsql.bgwriter.checkpoint_sync_time.rate Preprocessing
|
| Archive: Count of archived files | Count of archived files. |
Dependent item | pgsql.archive.count_archived_files Preprocessing
|
| Archive: Count of failed attempts to archive files | Count of failed attempts to archive files. |
Dependent item | pgsql.archive.failed_trying_to_archive Preprocessing
|
| Archive: Count of files in archive_status need to archive | Count of files to archive. |
Dependent item | pgsql.archive.count_files_to_archive Preprocessing
|
| Archive: Size of files need to archive | Size of files to archive. |
Dependent item | pgsql.archive.size_files_to_archive Preprocessing
|
| Dbstat: Blocks read time | Time spent reading data file blocks by backends. |
Dependent item | pgsql.dbstat.sum.blk_read_time Preprocessing
|
| Dbstat: Blocks write time | Time spent writing data file blocks by backends. |
Dependent item | pgsql.dbstat.sum.blk_write_time Preprocessing
|
| Dbstat: Checksum failures per second | Number of data page checksum failures per second detected (or on a shared object), or NULL if data checksums are not enabled. This metric is available since PostgreSQL 12. |
Dependent item | pgsql.dbstat.sum.checksum_failures.rate Preprocessing
|
| Dbstat: Committed transactions per second | Number of transactions that have been committed per second. |
Dependent item | pgsql.dbstat.sum.xact_commit.rate Preprocessing
|
| Dbstat: Conflicts per second | Number of queries canceled per second due to conflicts with recovery (conflicts occur only on standby servers; see pg_stat_database_conflicts for details). |
Dependent item | pgsql.dbstat.sum.conflicts.rate Preprocessing
|
| Dbstat: Deadlocks per second | Number of deadlocks detected per second. |
Dependent item | pgsql.dbstat.sum.deadlocks.rate Preprocessing
|
| Dbstat: Disk blocks read per second | Number of disk blocks read per second. |
Dependent item | pgsql.dbstat.sum.blks_read.rate Preprocessing
|
| Dbstat: Hit blocks read per second | Number of times per second disk blocks were found already in the buffer cache |
Dependent item | pgsql.dbstat.sum.blks_hit.rate Preprocessing
|
| Dbstat: Number temp bytes per second | Total amount of data written per second to temporary files by queries. |
Dependent item | pgsql.dbstat.sum.temp_bytes.rate Preprocessing
|
| Dbstat: Number temp files per second | Number of temporary files created by queries per second. |
Dependent item | pgsql.dbstat.sum.temp_files.rate Preprocessing
|
| Dbstat: Roll backed transactions per second | Number of transactions that have been rolled back per second. |
Dependent item | pgsql.dbstat.sum.xact_rollback.rate Preprocessing
|
| Dbstat: Rows deleted per second | Number of rows deleted by queries per second. |
Dependent item | pgsql.dbstat.sum.tup_deleted.rate Preprocessing
|
| Dbstat: Rows fetched per second | Number of rows fetched by queries per second. |
Dependent item | pgsql.dbstat.sum.tup_fetched.rate Preprocessing
|
| Dbstat: Rows inserted per second | Number of rows inserted by queries per second. |
Dependent item | pgsql.dbstat.sum.tup_inserted.rate Preprocessing
|
| Dbstat: Rows returned per second | Number of rows returned by queries per second. |
Dependent item | pgsql.dbstat.sum.tup_returned.rate Preprocessing
|
| Dbstat: Rows updated per second | Number of rows updated by queries per second. |
Dependent item | pgsql.dbstat.sum.tup_updated.rate Preprocessing
|
| Dbstat: Backends connected | Number of connected backends. |
Dependent item | pgsql.dbstat.sum.numbackends Preprocessing
|
| Connections sum: Active | Total number of connections executing a query. |
Dependent item | pgsql.connections.sum.active Preprocessing
|
| Connections sum: Fastpath function call | Total number of connections executing a fast-path function. |
Dependent item | pgsql.connections.sum.fastpath_function_call Preprocessing
|
| Connections sum: Idle | Total number of connections waiting for a new client command. |
Dependent item | pgsql.connections.sum.idle Preprocessing
|
| Connections sum: Idle in transaction | Total number of connections in a transaction state but not executing a query. |
Dependent item | pgsql.connections.sum.idle_in_transaction Preprocessing
|
| Connections sum: Prepared | Total number of prepared transactions: https://www.postgresql.org/docs/current/sql-prepare-transaction.html |
Dependent item | pgsql.connections.sum.prepared Preprocessing
|
| Connections sum: Total | Total number of connections. |
Dependent item | pgsql.connections.sum.total Preprocessing
|
| Connections sum: Total, % | Total number of connections, in percentage. |
Dependent item | pgsql.connections.sum.total_pct Preprocessing
|
| Connections sum: Waiting | Total number of waiting connections: https://www.postgresql.org/docs/current/monitoring-stats.html#WAIT-EVENT-TABLE |
Dependent item | pgsql.connections.sum.waiting Preprocessing
|
| Connections sum: Idle in transaction (aborted) | 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. |
Dependent item | pgsql.connections.sum.idle_in_transaction_aborted Preprocessing
|
| Connections sum: Disabled | Total number of disabled connections. |
Dependent item | pgsql.connections.sum.disabled Preprocessing
|
| Age of oldest xid | Age of oldest xid. |
Zabbix agent | pgsql.oldest.xid["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Count of autovacuum workers | Number of autovacuum workers. |
Zabbix agent | pgsql.autovacuum.count["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Cache hit ratio, % | Cache hit ratio. |
Calculated | pgsql.cache.hit |
| Uptime | Time since the server started. |
Zabbix agent | pgsql.uptime["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Replication: Lag in bytes | Replication lag with master, in bytes. |
Zabbix agent | pgsql.replication.lag.b["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Replication: Lag in seconds | Replication lag with master, in seconds. |
Zabbix agent | pgsql.replication.lag.sec["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Replication: Recovery role | Replication role: 1 — recovery is still in progress (standby mode), 0 — master mode. |
Zabbix agent | pgsql.replication.recovery_role["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Replication: Standby count | Number of standby servers. |
Zabbix agent | pgsql.replication.count["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Replication: Status | Replication status: 0 — streaming is down, 1 — streaming is up, 2 — master mode. |
Zabbix agent | pgsql.replication.status["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Ping | Used to test a connection to see if it is alive. It is set to 0 if the query is unsuccessful. |
Zabbix agent | pgsql.ping["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] Preprocessing
|
| Name | Description | Expression | Severity | Dependencies and additional info |
|---|---|---|---|---|
| PostgreSQL: Version has changed | last(/PostgreSQL by Zabbix agent 2/pgsql.version["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"],#1)<>last(/PostgreSQL by Zabbix agent 2/pgsql.version["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"],#2) and length(last(/PostgreSQL by Zabbix agent 2/pgsql.version["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]))>0 |
Info | ||
| PostgreSQL: Dbstat: Checksum failures detected | Data page checksum failures were detected on that DB instance: |
last(/PostgreSQL by Zabbix agent 2/pgsql.dbstat.sum.checksum_failures.rate)>0 |
Average | |
| PostgreSQL: Total number of connections is too high | 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). |
min(/PostgreSQL by Zabbix agent 2/pgsql.connections.sum.total_pct,5m) > {$PG.CONN_TOTAL_PCT.MAX.WARN} |
Average | |
| PostgreSQL: Oldest xid is too big | last(/PostgreSQL by Zabbix agent 2/pgsql.oldest.xid["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]) > 18000000 |
Average | ||
| PostgreSQL: Service has been restarted | PostgreSQL uptime is less than 10 minutes. |
last(/PostgreSQL by Zabbix agent 2/pgsql.uptime["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]) < 10m |
Average | |
| PostgreSQL: Service is down | Last test of a connection was unsuccessful. |
last(/PostgreSQL by Zabbix agent 2/pgsql.ping["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"])=0 |
High |
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Replication discovery | Discovers replication lag metrics. |
Zabbix agent | pgsql.replication.process.discovery["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Application [{#APPLICATION_NAME}]: Get replication | 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. |
Dependent item | pgsql.replication.get_metrics["{#APPLICATION_NAME}"] Preprocessing
|
| Application [{#APPLICATION_NAME}]: Replication flush lag | Dependent item | pgsql.replication.process.flush_lag["{#APPLICATION_NAME}"] Preprocessing
|
|
| Application [{#APPLICATION_NAME}]: Replication replay lag | Dependent item | pgsql.replication.process.replay_lag["{#APPLICATION_NAME}"] Preprocessing
|
|
| Application [{#APPLICATION_NAME}]: Replication write lag | Dependent item | pgsql.replication.process.write_lag["{#APPLICATION_NAME}"] Preprocessing
|
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Database discovery | Discovers databases (DB) in the database management system (DBMS), except: - templates; - DBs that do not allow connections. |
Zabbix agent | pgsql.db.discovery["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| DB [{#DBNAME}]: Get dbstat | Get dbstat metrics for database "{#DBNAME}". |
Dependent item | pgsql.dbstat.get_metrics["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Get locks | Get locks metrics for database "{#DBNAME}". |
Dependent item | pgsql.locks.get_metrics["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Get queries | Get queries metrics for database "{#DBNAME}". |
Dependent item | pgsql.queries.get_metrics["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Database age | Database age. |
Zabbix agent | pgsql.db.age["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{#DBNAME}"] |
| DB [{#DBNAME}]: Bloating tables | Number of bloating tables. |
Zabbix agent | pgsql.db.bloating_tables["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{#DBNAME}"] |
| DB [{#DBNAME}]: Database size | Database size. |
Zabbix agent | pgsql.db.size["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{#DBNAME}"] |
| DB [{#DBNAME}]: Blocks hit per second | Total number of times per second disk blocks were found already in the buffer cache, so that a read was not necessary. |
Dependent item | pgsql.dbstat.blks_hit.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Disk blocks read per second | Total number of disk blocks read per second in this database. |
Dependent item | pgsql.dbstat.blks_read.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Detected conflicts per second | Total number of queries canceled due to conflicts with recovery in this database per second. |
Dependent item | pgsql.dbstat.conflicts.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Detected deadlocks per second | Total number of detected deadlocks in this database per second. |
Dependent item | pgsql.dbstat.deadlocks.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Temp_bytes written per second | Total amount of data written to temporary files by queries in this database. |
Dependent item | pgsql.dbstat.temp_bytes.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Temp_files created per second | Total number of temporary files created by queries in this database. |
Dependent item | pgsql.dbstat.temp_files.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Tuples deleted per second | Total number of rows deleted by queries in this database per second. |
Dependent item | pgsql.dbstat.tup_deleted.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Tuples fetched per second | Total number of rows fetched by queries in this database per second. |
Dependent item | pgsql.dbstat.tup_fetched.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Tuples inserted per second | Total number of rows inserted by queries in this database per second. |
Dependent item | pgsql.dbstat.tup_inserted.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Tuples returned per second | Number of rows returned by queries in this database per second. |
Dependent item | pgsql.dbstat.tup_returned.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Tuples updated per second | Total number of rows updated by queries in this database per second. |
Dependent item | pgsql.dbstat.tup_updated.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Commits per second | Number of transactions in this database that have been committed per second. |
Dependent item | pgsql.dbstat.xact_commit.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Rollbacks per second | Total number of transactions in this database that have been rolled back. |
Dependent item | pgsql.dbstat.xact_rollback.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Backends connected | Number of backends currently connected to this database. |
Dependent item | pgsql.dbstat.numbackends["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Checksum failures | Number of data page checksum failures detected in this database. |
Dependent item | pgsql.dbstat.checksum_failures.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Disk blocks read time per second | Time spent reading data file blocks by backends per second. |
Dependent item | pgsql.dbstat.blk_read_time.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Disk blocks write time | Time spent writing data file blocks by backends per second. |
Dependent item | pgsql.dbstat.blk_write_time.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Num of accessexclusive locks | Number of accessexclusive locks for this database. |
Dependent item | pgsql.locks.accessexclusive["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Num of accessshare locks | Number of accessshare locks for this database. |
Dependent item | pgsql.locks.accessshare["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Num of exclusive locks | Number of exclusive locks for this database. |
Dependent item | pgsql.locks.exclusive["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Num of rowexclusive locks | Number of rowexclusive locks for this database. |
Dependent item | pgsql.locks.rowexclusive["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Num of rowshare locks | Number of rowshare locks for this database. |
Dependent item | pgsql.locks.rowshare["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Num of sharerowexclusive locks | Number of total sharerowexclusive for this database. |
Dependent item | pgsql.locks.sharerowexclusive["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Num of shareupdateexclusive locks | Number of shareupdateexclusive locks for this database. |
Dependent item | pgsql.locks.shareupdateexclusive["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Num of share locks | Number of share locks for this database. |
Dependent item | pgsql.locks.share["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Num of locks total | Total number of locks in this database. |
Dependent item | pgsql.locks.total["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries max maintenance time | Max maintenance query time for this database. |
Dependent item | pgsql.queries.mro.time_max["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries max query time | Max query time for this database. |
Dependent item | pgsql.queries.query.time_max["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries max transaction time | Max transaction query time for this database. |
Dependent item | pgsql.queries.tx.time_max["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries slow maintenance count | Slow maintenance query count for this database. |
Dependent item | pgsql.queries.mro.slow_count["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries slow query count | Slow query count for this database. |
Dependent item | pgsql.queries.query.slow_count["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries slow transaction count | Slow transaction query count for this database. |
Dependent item | pgsql.queries.tx.slow_count["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries sum maintenance time | Sum maintenance query time for this database. |
Dependent item | pgsql.queries.mro.time_sum["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries sum query time | Sum query time for this database. |
Dependent item | pgsql.queries.query.time_sum["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries sum transaction time | Sum transaction query time for this database. |
Dependent item | pgsql.queries.tx.time_sum["{#DBNAME}"] Preprocessing
|
| Name | Description | Expression | Severity | Dependencies and additional info |
|---|---|---|---|---|
| PostgreSQL: DB [{#DBNAME}]: Too many recovery conflicts | 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. |
min(/PostgreSQL by Zabbix agent 2/pgsql.dbstat.conflicts.rate["{#DBNAME}"],5m) > {$PG.CONFLICTS.MAX.WARN:"{#DBNAME}"} |
Average | |
| PostgreSQL: DB [{#DBNAME}]: Deadlock occurred | Number of deadlocks detected per second exceeds {$PG.DEADLOCKS.MAX.WARN:"{#DBNAME}"} for 5m. |
min(/PostgreSQL by Zabbix agent 2/pgsql.dbstat.deadlocks.rate["{#DBNAME}"],5m) > {$PG.DEADLOCKS.MAX.WARN:"{#DBNAME}"} |
High | |
| PostgreSQL: DB [{#DBNAME}]: Checksum failures detected | Data page checksum failures were detected on that database: |
last(/PostgreSQL by Zabbix agent 2/pgsql.dbstat.checksum_failures.rate["{#DBNAME}"])>0 |
Average | |
| PostgreSQL: DB [{#DBNAME}]: Too many slow queries | The number of detected slow queries exceeds the limit of {$PG.SLOW_QUERIES.MAX.WARN:"{#DBNAME}"}. |
min(/PostgreSQL by Zabbix agent 2/pgsql.queries.query.slow_count["{#DBNAME}"],5m)>{$PG.SLOW_QUERIES.MAX.WARN:"{#DBNAME}"} |
Warning |
Please report any issues with the template at https://support.zabbix.com
You can also provide feedback, discuss the template, or ask for help at ZABBIX forums
This template is designed for the deployment of PostgreSQL monitoring by Zabbix via Zabbix agent 2 and uses a loadable plugin to run SQL queries.
Zabbix version: 6.4 and higher.
This template has been tested on:
Zabbix should be configured according to the instructions in the Templates out of the box section.
Deploy Zabbix agent 2 with the PostgreSQL plugin. Starting with Zabbix versions 6.0.10 / 6.2.4 / 6.4 PostgreSQL metrics are moved to a loadable plugin and require installation of a separate package or compilation of the plugin from sources.
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;
pg_hba.conf configuration file to allow connections for the user zbx_monitor. For example, you could add one of the following rows to allow local TCP connections from the same host:# TYPE DATABASE USER ADDRESS METHOD
host all zbx_monitor localhost trust
host all zbx_monitor 127.0.0.1/32 md5
host all zbx_monitor ::1/128 scram-sha-256
For more information please read the PostgreSQL documentation https://www.postgresql.org/docs/current/auth-pg-hba-conf.html.
{$PG.CONNSTRING} macro as URI, such as <protocol(host:port)>, or specify the named session - <sessionname>.Note: if you want to use SSL/TLS encryption to protect communications with the remote PostgreSQL instance, a named session must be used. In that case, the instance URI should be specified in the Plugins.PostgreSQL.Sessions.*.Uri parameter in the PostgreSQL plugin configuration files alongside all the encryption parameters (type, cerfiticate/key filepaths if needed etc.).
You can check the PostgreSQL plugin documentation for details about agent plugin parameters and named sessions.
Also, it is assumed that you set up the PostgreSQL instance to work in the desired encryption mode. Check the PostgreSQL documentation for details.
Note: plugin TLS certificate validation relies on checking the Subject Alternative Names (SAN) instead of the Common Name (CN), check the cryptography package documentation for details.
For example, to enable required encryption in transport mode without identity checks you could create the file /etc/zabbix/zabbix_agent2.d/postgresql_myconn.conf with the following configuration for the named session myconn (replace <instanceip> with the address of the PostgreSQL instance):
Plugins.PostgreSQL.Sessions.myconn.Uri=tcp://<instanceip>:5432
Plugins.PostgreSQL.Sessions.myconn.TLSConnect=required
Then set the {$PG.CONNSTRING} macro to myconn to use this named session.
{$PG.PASSWORD}.| Name | Description | Default |
|---|---|---|
| {$PG.PASSWORD} | PostgreSQL user password. |
<Put the password here> |
| {$PG.CONNSTRING} | URI or named session of the PostgreSQL instance. |
tcp://localhost:5432 |
| {$PG.USER} | PostgreSQL username. |
zbx_monitor |
| {$PG.LLD.FILTER.DBNAME} | Filter of discoverable databases. |
.+ |
| {$PG.CONN_TOTAL_PCT.MAX.WARN} | Maximum percentage of current connections for trigger expression. |
90 |
| {$PG.DATABASE} | Default PostgreSQL database for the connection. |
postgres |
| {$PG.DEADLOCKS.MAX.WARN} | Maximum number of detected deadlocks for trigger expression. |
0 |
| {$PG.LLD.FILTER.APPLICATION} | Filter of discoverable applications. |
.+ |
| {$PG.CONFLICTS.MAX.WARN} | Maximum number of recovery conflicts for trigger expression. |
0 |
| {$PG.QUERY_ETIME.MAX.WARN} | Execution time limit for count of slow queries. |
30 |
| {$PG.SLOW_QUERIES.MAX.WARN} | Slow queries count threshold for a trigger. |
5 |
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| PostgreSQL: Get bgwriter | Collect all metrics from pg_stat_bgwriter: https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-BGWRITER-VIEW |
Zabbix agent | pgsql.bgwriter["{$PG.CONNSTRING}","{$PG.USER}","{$PG.PASSWORD}"] |
| PostgreSQL: Get archive | Collect archive status metrics. |
Zabbix agent | pgsql.archive["{$PG.CONNSTRING}","{$PG.USER}","{$PG.PASSWORD}"] |
| PostgreSQL: Get dbstat | Collect all metrics from pg_stat_database per database: https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-DATABASE-VIEW |
Zabbix agent | pgsql.dbstat["{$PG.CONNSTRING}","{$PG.USER}","{$PG.PASSWORD}"] |
| PostgreSQL: Get dbstat sum | 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 |
Zabbix agent | pgsql.dbstat.sum["{$PG.CONNSTRING}","{$PG.USER}","{$PG.PASSWORD}"] |
| PostgreSQL: Get connections sum | Collect all metrics from pg_stat_activity: https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-ACTIVITY-VIEW |
Zabbix agent | pgsql.connections["{$PG.CONNSTRING}","{$PG.USER}","{$PG.PASSWORD}"] |
| PostgreSQL: Get WAL | Collect write-ahead log (WAL) metrics. |
Zabbix agent | pgsql.wal.stat["{$PG.CONNSTRING}","{$PG.USER}","{$PG.PASSWORD}"] |
| PostgreSQL: Get locks | Collect all metrics from pg_locks per database: https://www.postgresql.org/docs/current/explicit-locking.html#LOCKING-TABLES |
Zabbix agent | pgsql.locks["{$PG.CONNSTRING}","{$PG.USER}","{$PG.PASSWORD}"] |
| PostgreSQL: Custom queries | Execute custom queries from file *.sql (check for option Plugins.Postgres.CustomQueriesPath at agent configuration). |
Zabbix agent | pgsql.custom.query["{$PG.CONNSTRING}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}",""] |
| PostgreSQL: Get replication | 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. |
Zabbix agent | pgsql.replication.process["{$PG.CONNSTRING}","{$PG.USER}","{$PG.PASSWORD}"] |
| PostgreSQL: Get queries | Collect all metrics by query execution time. |
Zabbix agent | pgsql.queries["{$PG.CONNSTRING}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}","{$PG.QUERY_ETIME.MAX.WARN}"] |
| PostgreSQL: Version | PostgreSQL version. |
Zabbix agent | pgsql.version["{$PG.CONNSTRING}","{$PG.USER}","{$PG.PASSWORD}"] Preprocessing
|
| WAL: Bytes written | WAL write, in bytes. |
Dependent item | pgsql.wal.write Preprocessing
|
| WAL: Bytes received | WAL receive, in bytes. |
Dependent item | pgsql.wal.receive Preprocessing
|
| WAL: Segments count | Number of WAL segments. |
Dependent item | pgsql.wal.count Preprocessing
|
| Bgwriter: Buffers allocated per second | Number of buffers allocated per second. |
Dependent item | pgsql.bgwriter.buffers_alloc.rate Preprocessing
|
| Bgwriter: Buffers written directly by a backend per second | Number of buffers written directly by a backend per second. |
Dependent item | pgsql.bgwriter.buffers_backend.rate Preprocessing
|
| Bgwriter: Number of bgwriter cleaning scan stopped per second | Number of times the background writer stopped a cleaning scan because it had written too many buffers per second. |
Dependent item | pgsql.bgwriter.maxwritten_clean.rate Preprocessing
|
| Bgwriter: Times a backend executed its own fsync per second | 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). |
Dependent item | pgsql.bgwriter.buffers_backend_fsync.rate Preprocessing
|
| Checkpoint: Buffers written by the background writer per second | Number of buffers written by the background writer per second. |
Dependent item | pgsql.bgwriter.buffers_clean.rate Preprocessing
|
| Checkpoint: Buffers written during checkpoints per second | Number of buffers written during checkpoints per second. |
Dependent item | pgsql.bgwriter.buffers_checkpoint.rate Preprocessing
|
| Checkpoint: Scheduled per second | Number of scheduled checkpoints that have been performed per second. |
Dependent item | pgsql.bgwriter.checkpoints_timed.rate Preprocessing
|
| Checkpoint: Requested per second | Number of requested checkpoints that have been performed per second. |
Dependent item | pgsql.bgwriter.checkpoints_req.rate Preprocessing
|
| Checkpoint: Checkpoint write time per second | Total amount of time per second that has been spent in the portion of checkpoint processing where files are written to disk. |
Dependent item | pgsql.bgwriter.checkpoint_write_time.rate Preprocessing
|
| Checkpoint: Checkpoint sync time per second | Total amount of time per second that has been spent in the portion of checkpoint processing where files are synchronized to disk. |
Dependent item | pgsql.bgwriter.checkpoint_sync_time.rate Preprocessing
|
| Archive: Count of archived files | Count of archived files. |
Dependent item | pgsql.archive.count_archived_files Preprocessing
|
| Archive: Count of failed attempts to archive files | Count of failed attempts to archive files. |
Dependent item | pgsql.archive.failed_trying_to_archive Preprocessing
|
| Archive: Count of files in archive_status need to archive | Count of files to archive. |
Dependent item | pgsql.archive.count_files_to_archive Preprocessing
|
| Archive: Size of files need to archive | Size of files to archive. |
Dependent item | pgsql.archive.size_files_to_archive Preprocessing
|
| Dbstat: Blocks read time | Time spent reading data file blocks by backends. |
Dependent item | pgsql.dbstat.sum.blk_read_time Preprocessing
|
| Dbstat: Blocks write time | Time spent writing data file blocks by backends. |
Dependent item | pgsql.dbstat.sum.blk_write_time Preprocessing
|
| Dbstat: Checksum failures per second | Number of data page checksum failures per second detected (or on a shared object), or NULL if data checksums are not enabled. This metric is available since PostgreSQL 12. |
Dependent item | pgsql.dbstat.sum.checksum_failures.rate Preprocessing
|
| Dbstat: Committed transactions per second | Number of transactions that have been committed per second. |
Dependent item | pgsql.dbstat.sum.xact_commit.rate Preprocessing
|
| Dbstat: Conflicts per second | Number of queries canceled per second due to conflicts with recovery (conflicts occur only on standby servers; see pg_stat_database_conflicts for details). |
Dependent item | pgsql.dbstat.sum.conflicts.rate Preprocessing
|
| Dbstat: Deadlocks per second | Number of deadlocks detected per second. |
Dependent item | pgsql.dbstat.sum.deadlocks.rate Preprocessing
|
| Dbstat: Disk blocks read per second | Number of disk blocks read per second. |
Dependent item | pgsql.dbstat.sum.blks_read.rate Preprocessing
|
| Dbstat: Hit blocks read per second | Number of times per second disk blocks were found already in the buffer cache |
Dependent item | pgsql.dbstat.sum.blks_hit.rate Preprocessing
|
| Dbstat: Number temp bytes per second | Total amount of data written per second to temporary files by queries. |
Dependent item | pgsql.dbstat.sum.temp_bytes.rate Preprocessing
|
| Dbstat: Number temp files per second | Number of temporary files created by queries per second. |
Dependent item | pgsql.dbstat.sum.temp_files.rate Preprocessing
|
| Dbstat: Roll backed transactions per second | Number of transactions that have been rolled back per second. |
Dependent item | pgsql.dbstat.sum.xact_rollback.rate Preprocessing
|
| Dbstat: Rows deleted per second | Number of rows deleted by queries per second. |
Dependent item | pgsql.dbstat.sum.tup_deleted.rate Preprocessing
|
| Dbstat: Rows fetched per second | Number of rows fetched by queries per second. |
Dependent item | pgsql.dbstat.sum.tup_fetched.rate Preprocessing
|
| Dbstat: Rows inserted per second | Number of rows inserted by queries per second. |
Dependent item | pgsql.dbstat.sum.tup_inserted.rate Preprocessing
|
| Dbstat: Rows returned per second | Number of rows returned by queries per second. |
Dependent item | pgsql.dbstat.sum.tup_returned.rate Preprocessing
|
| Dbstat: Rows updated per second | Number of rows updated by queries per second. |
Dependent item | pgsql.dbstat.sum.tup_updated.rate Preprocessing
|
| Dbstat: Backends connected | Number of connected backends. |
Dependent item | pgsql.dbstat.sum.numbackends Preprocessing
|
| Connections sum: Active | Total number of connections executing a query. |
Dependent item | pgsql.connections.sum.active Preprocessing
|
| Connections sum: Fastpath function call | Total number of connections executing a fast-path function. |
Dependent item | pgsql.connections.sum.fastpath_function_call Preprocessing
|
| Connections sum: Idle | Total number of connections waiting for a new client command. |
Dependent item | pgsql.connections.sum.idle Preprocessing
|
| Connections sum: Idle in transaction | Total number of connections in a transaction state but not executing a query. |
Dependent item | pgsql.connections.sum.idle_in_transaction Preprocessing
|
| Connections sum: Prepared | Total number of prepared transactions: https://www.postgresql.org/docs/current/sql-prepare-transaction.html |
Dependent item | pgsql.connections.sum.prepared Preprocessing
|
| Connections sum: Total | Total number of connections. |
Dependent item | pgsql.connections.sum.total Preprocessing
|
| Connections sum: Total, % | Total number of connections, in percentage. |
Dependent item | pgsql.connections.sum.total_pct Preprocessing
|
| Connections sum: Waiting | Total number of waiting connections: https://www.postgresql.org/docs/current/monitoring-stats.html#WAIT-EVENT-TABLE |
Dependent item | pgsql.connections.sum.waiting Preprocessing
|
| Connections sum: Idle in transaction (aborted) | 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. |
Dependent item | pgsql.connections.sum.idle_in_transaction_aborted Preprocessing
|
| Connections sum: Disabled | Total number of disabled connections. |
Dependent item | pgsql.connections.sum.disabled Preprocessing
|
| PostgreSQL: Age of oldest xid | Age of oldest xid. |
Zabbix agent | pgsql.oldest.xid["{$PG.CONNSTRING}","{$PG.USER}","{$PG.PASSWORD}"] |
| PostgreSQL: Count of autovacuum workers | Number of autovacuum workers. |
Zabbix agent | pgsql.autovacuum.count["{$PG.CONNSTRING}","{$PG.USER}","{$PG.PASSWORD}"] |
| PostgreSQL: Cache hit ratio, % | Cache hit ratio. |
Calculated | pgsql.cache.hit |
| PostgreSQL: Uptime | Time since the server started. |
Zabbix agent | pgsql.uptime["{$PG.CONNSTRING}","{$PG.USER}","{$PG.PASSWORD}"] |
| PostgreSQL: Replication: Lag in bytes | Replication lag with master, in bytes. |
Zabbix agent | pgsql.replication.lag.b["{$PG.CONNSTRING}","{$PG.USER}","{$PG.PASSWORD}"] |
| PostgreSQL: Replication: Lag in seconds | Replication lag with master, in seconds. |
Zabbix agent | pgsql.replication.lag.sec["{$PG.CONNSTRING}","{$PG.USER}","{$PG.PASSWORD}"] |
| PostgreSQL: Replication: Recovery role | Replication role: 1 — recovery is still in progress (standby mode), 0 — master mode. |
Zabbix agent | pgsql.replication.recovery_role["{$PG.CONNSTRING}","{$PG.USER}","{$PG.PASSWORD}"] |
| PostgreSQL: Replication: Standby count | Number of standby servers. |
Zabbix agent | pgsql.replication.count["{$PG.CONNSTRING}","{$PG.USER}","{$PG.PASSWORD}"] |
| PostgreSQL: Replication: Status | Replication status: 0 — streaming is down, 1 — streaming is up, 2 — master mode. |
Zabbix agent | pgsql.replication.status["{$PG.CONNSTRING}","{$PG.USER}","{$PG.PASSWORD}"] |
| PostgreSQL: Ping | Used to test a connection to see if it is alive. It is set to 0 if the query is unsuccessful. |
Zabbix agent | pgsql.ping["{$PG.CONNSTRING}","{$PG.USER}","{$PG.PASSWORD}"] Preprocessing
|
| Name | Description | Expression | Severity | Dependencies and additional info |
|---|---|---|---|---|
| PostgreSQL: Version has changed | last(/PostgreSQL by Zabbix agent 2/pgsql.version["{$PG.CONNSTRING}","{$PG.USER}","{$PG.PASSWORD}"],#1)<>last(/PostgreSQL by Zabbix agent 2/pgsql.version["{$PG.CONNSTRING}","{$PG.USER}","{$PG.PASSWORD}"],#2) and length(last(/PostgreSQL by Zabbix agent 2/pgsql.version["{$PG.CONNSTRING}","{$PG.USER}","{$PG.PASSWORD}"]))>0 |
Info | ||
| Dbstat: Checksum failures detected | Data page checksum failures were detected on that DB instance: |
last(/PostgreSQL by Zabbix agent 2/pgsql.dbstat.sum.checksum_failures.rate)>0 |
Average | |
| PostgreSQL: Total number of connections is too high | 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). |
min(/PostgreSQL by Zabbix agent 2/pgsql.connections.sum.total_pct,5m) > {$PG.CONN_TOTAL_PCT.MAX.WARN} |
Average | |
| PostgreSQL: Oldest xid is too big | last(/PostgreSQL by Zabbix agent 2/pgsql.oldest.xid["{$PG.CONNSTRING}","{$PG.USER}","{$PG.PASSWORD}"]) > 18000000 |
Average | ||
| PostgreSQL: Service has been restarted | PostgreSQL uptime is less than 10 minutes. |
last(/PostgreSQL by Zabbix agent 2/pgsql.uptime["{$PG.CONNSTRING}","{$PG.USER}","{$PG.PASSWORD}"]) < 10m |
Average | |
| PostgreSQL: Service is down | Last test of a connection was unsuccessful. |
last(/PostgreSQL by Zabbix agent 2/pgsql.ping["{$PG.CONNSTRING}","{$PG.USER}","{$PG.PASSWORD}"])=0 |
High |
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Replication discovery | Discovers replication lag metrics. |
Zabbix agent | pgsql.replication.process.discovery["{$PG.CONNSTRING}","{$PG.USER}","{$PG.PASSWORD}"] |
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Application [{#APPLICATION_NAME}]: Get replication | 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. |
Dependent item | pgsql.replication.get_metrics["{#APPLICATION_NAME}"] Preprocessing
|
| Application [{#APPLICATION_NAME}]: Replication flush lag | Dependent item | pgsql.replication.process.flush_lag["{#APPLICATION_NAME}"] Preprocessing
|
|
| Application [{#APPLICATION_NAME}]: Replication replay lag | Dependent item | pgsql.replication.process.replay_lag["{#APPLICATION_NAME}"] Preprocessing
|
|
| Application [{#APPLICATION_NAME}]: Replication write lag | Dependent item | pgsql.replication.process.write_lag["{#APPLICATION_NAME}"] Preprocessing
|
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Database discovery | Discovers databases (DB) in the database management system (DBMS), except: - templates; - DBs that do not allow connections. |
Zabbix agent | pgsql.db.discovery["{$PG.CONNSTRING}","{$PG.USER}","{$PG.PASSWORD}"] |
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| DB [{#DBNAME}]: Get dbstat | Get dbstat metrics for database "{#DBNAME}". |
Dependent item | pgsql.dbstat.get_metrics["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Get locks | Get locks metrics for database "{#DBNAME}". |
Dependent item | pgsql.locks.get_metrics["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Get queries | Get queries metrics for database "{#DBNAME}". |
Dependent item | pgsql.queries.get_metrics["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Database age | Database age. |
Zabbix agent | pgsql.db.age["{$PG.CONNSTRING}","{$PG.USER}","{$PG.PASSWORD}","{#DBNAME}"] |
| DB [{#DBNAME}]: Bloating tables | Number of bloating tables. |
Zabbix agent | pgsql.db.bloating_tables["{$PG.CONNSTRING}","{$PG.USER}","{$PG.PASSWORD}","{#DBNAME}"] |
| DB [{#DBNAME}]: Database size | Database size. |
Zabbix agent | pgsql.db.size["{$PG.CONNSTRING}","{$PG.USER}","{$PG.PASSWORD}","{#DBNAME}"] |
| DB [{#DBNAME}]: Blocks hit per second | Total number of times per second disk blocks were found already in the buffer cache, so that a read was not necessary. |
Dependent item | pgsql.dbstat.blks_hit.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Disk blocks read per second | Total number of disk blocks read per second in this database. |
Dependent item | pgsql.dbstat.blks_read.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Detected conflicts per second | Total number of queries canceled due to conflicts with recovery in this database per second. |
Dependent item | pgsql.dbstat.conflicts.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Detected deadlocks per second | Total number of detected deadlocks in this database per second. |
Dependent item | pgsql.dbstat.deadlocks.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Temp_bytes written per second | Total amount of data written to temporary files by queries in this database. |
Dependent item | pgsql.dbstat.temp_bytes.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Temp_files created per second | Total number of temporary files created by queries in this database. |
Dependent item | pgsql.dbstat.temp_files.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Tuples deleted per second | Total number of rows deleted by queries in this database per second. |
Dependent item | pgsql.dbstat.tup_deleted.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Tuples fetched per second | Total number of rows fetched by queries in this database per second. |
Dependent item | pgsql.dbstat.tup_fetched.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Tuples inserted per second | Total number of rows inserted by queries in this database per second. |
Dependent item | pgsql.dbstat.tup_inserted.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Tuples returned per second | Number of rows returned by queries in this database per second. |
Dependent item | pgsql.dbstat.tup_returned.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Tuples updated per second | Total number of rows updated by queries in this database per second. |
Dependent item | pgsql.dbstat.tup_updated.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Commits per second | Number of transactions in this database that have been committed per second. |
Dependent item | pgsql.dbstat.xact_commit.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Rollbacks per second | Total number of transactions in this database that have been rolled back. |
Dependent item | pgsql.dbstat.xact_rollback.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Backends connected | Number of backends currently connected to this database. |
Dependent item | pgsql.dbstat.numbackends["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Checksum failures | Number of data page checksum failures detected in this database. |
Dependent item | pgsql.dbstat.checksum_failures.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Disk blocks read time per second | Time spent reading data file blocks by backends per second. |
Dependent item | pgsql.dbstat.blk_read_time.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Disk blocks write time | Time spent writing data file blocks by backends per second. |
Dependent item | pgsql.dbstat.blk_write_time.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Num of accessexclusive locks | Number of accessexclusive locks for this database. |
Dependent item | pgsql.locks.accessexclusive["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Num of accessshare locks | Number of accessshare locks for this database. |
Dependent item | pgsql.locks.accessshare["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Num of exclusive locks | Number of exclusive locks for this database. |
Dependent item | pgsql.locks.exclusive["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Num of rowexclusive locks | Number of rowexclusive locks for this database. |
Dependent item | pgsql.locks.rowexclusive["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Num of rowshare locks | Number of rowshare locks for this database. |
Dependent item | pgsql.locks.rowshare["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Num of sharerowexclusive locks | Number of total sharerowexclusive for this database. |
Dependent item | pgsql.locks.sharerowexclusive["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Num of shareupdateexclusive locks | Number of shareupdateexclusive locks for this database. |
Dependent item | pgsql.locks.shareupdateexclusive["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Num of share locks | Number of share locks for this database. |
Dependent item | pgsql.locks.share["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Num of locks total | Total number of locks in this database. |
Dependent item | pgsql.locks.total["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries max maintenance time | Max maintenance query time for this database. |
Dependent item | pgsql.queries.mro.time_max["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries max query time | Max query time for this database. |
Dependent item | pgsql.queries.query.time_max["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries max transaction time | Max transaction query time for this database. |
Dependent item | pgsql.queries.tx.time_max["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries slow maintenance count | Slow maintenance query count for this database. |
Dependent item | pgsql.queries.mro.slow_count["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries slow query count | Slow query count for this database. |
Dependent item | pgsql.queries.query.slow_count["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries slow transaction count | Slow transaction query count for this database. |
Dependent item | pgsql.queries.tx.slow_count["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries sum maintenance time | Sum maintenance query time for this database. |
Dependent item | pgsql.queries.mro.time_sum["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries sum query time | Sum query time for this database. |
Dependent item | pgsql.queries.query.time_sum["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries sum transaction time | Sum transaction query time for this database. |
Dependent item | pgsql.queries.tx.time_sum["{#DBNAME}"] Preprocessing
|
| Name | Description | Expression | Severity | Dependencies and additional info |
|---|---|---|---|---|
| DB [{#DBNAME}]: Too many recovery conflicts | 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. |
min(/PostgreSQL by Zabbix agent 2/pgsql.dbstat.conflicts.rate["{#DBNAME}"],5m) > {$PG.CONFLICTS.MAX.WARN:"{#DBNAME}"} |
Average | |
| DB [{#DBNAME}]: Deadlock occurred | Number of deadlocks detected per second exceeds {$PG.DEADLOCKS.MAX.WARN:"{#DBNAME}"} for 5m. |
min(/PostgreSQL by Zabbix agent 2/pgsql.dbstat.deadlocks.rate["{#DBNAME}"],5m) > {$PG.DEADLOCKS.MAX.WARN:"{#DBNAME}"} |
High | |
| DB [{#DBNAME}]: Checksum failures detected | Data page checksum failures were detected on that database: |
last(/PostgreSQL by Zabbix agent 2/pgsql.dbstat.checksum_failures.rate["{#DBNAME}"])>0 |
Average | |
| DB [{#DBNAME}]: Too many slow queries | The number of detected slow queries exceeds the limit of {$PG.SLOW_QUERIES.MAX.WARN:"{#DBNAME}"}. |
min(/PostgreSQL by Zabbix agent 2/pgsql.queries.query.slow_count["{#DBNAME}"],5m)>{$PG.SLOW_QUERIES.MAX.WARN:"{#DBNAME}"} |
Warning |
Please report any issues with the template at https://support.zabbix.com
You can also provide feedback, discuss the template, or ask for help at ZABBIX forums
For Zabbix version: 6.2 and higher. The template is developed to monitor DBMS PostgreSQL and its forks.
This template has been tested on:
See Zabbix template operation for basic instructions.
Deploy Zabbix agent2 with Postgres plugin. Starting with Zabbix versions 6.0.10 / 6.2.4 / 6.4 postgres metrics moved to a loadable plugin and requires separate package installation or compilation of a plugin from sources.
Create PostgreSQL user to monitor (<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;
pg_hba.conf to allow connections from Zabbix agent:# TYPE DATABASE USER ADDRESS METHOD
host all zbx_monitor localhost md5
For more information please read the PostgreSQL documentation https://www.postgresql.org/docs/current/auth-pg-hba-conf.html.
Set in the {$PG.URI} macro the system data source name of the PostgreSQL instance such as <protocol(host:port)>.
Set the user name and password in host macros ({$PG.USER} and {$PG.PASSWORD}) if you want to override parameters from the Zabbix agent configuration file.
No specific Zabbix configuration is required.
| Name | Description | Default |
|---|---|---|
| {$PG.CONFLICTS.MAX.WARN} | - |
0 |
| {$PG.CONN_TOTAL_PCT.MAX.WARN} | - |
90 |
| {$PG.DATABASE} | - |
postgres |
| {$PG.DEADLOCKS.MAX.WARN} | - |
0 |
| {$PG.LLD.FILTER.APPLICATION} | - |
(.+) |
| {$PG.LLD.FILTER.DBNAME} | - |
(.+) |
| {$PG.PASSWORD} | - |
postgres |
| {$PG.QUERY_ETIME.MAX.WARN} | Execution time limit for count of slow queries. |
30 |
| {$PG.SLOW_QUERIES.MAX.WARN} | Slow queries count threshold for a trigger. |
5 |
| {$PG.URI} | - |
tcp://localhost:5432 |
| {$PG.USER} | - |
postgres |
There are no template links in this template.
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Database discovery | - |
ZABBIX_PASSIVE | pgsql.db.discovery["{$PG.URI}","{$PG.USER}","{$PG.PASSWORD}"] Filter: AND- {#DBNAME} MATCHES_REGEX |
| Replication Discovery | - |
ZABBIX_PASSIVE | pgsql.replication.process.discovery["{$PG.URI}","{$PG.USER}","{$PG.PASSWORD}"] Filter: AND- {#APPLICATION_NAME} MATCHES_REGEX |
| Group | Name | Description | Type | Key and additional info |
|---|---|---|---|---|
| PostgreSQL | PostgreSQL: Custom queries | Execute custom queries from file *.sql (check for option Plugins.Postgres.CustomQueriesPath at agent configuration) |
ZABBIX_PASSIVE | pgsql.custom.query["{$PG.URI}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}",""] |
| PostgreSQL | WAL: Bytes written | WAL write in bytes |
DEPENDENT | pgsql.wal.write Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | WAL: Bytes received | WAL receive in bytes |
DEPENDENT | pgsql.wal.receive Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | WAL: Segments count | Number of WAL segments |
DEPENDENT | pgsql.wal.count Preprocessing: - JSONPATH: |
| PostgreSQL | Bgwriter: Buffers allocated | Number of buffers allocated |
DEPENDENT | pgsql.bgwriter.buffers_alloc.rate Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | Bgwriter: Buffers written directly by a backend | Number of buffers written directly by a backend |
DEPENDENT | pgsql.bgwriter.buffers_backend.rate Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | Bgwriter: Number of bgwriter stopped | Number of times the background writer stopped a cleaning scan because it had written too many buffers |
DEPENDENT | pgsql.bgwriter.maxwritten_clean.rate Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | Bgwriter: Times a backend execute its own fsync | Number of times a backend had to execute its own fsync call (normally the background writer handles those even when the backend does its own write) |
DEPENDENT | pgsql.bgwriter.buffers_backend_fsync.rate Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | Checkpoint: Buffers background written | Number of buffers written by the background writer |
DEPENDENT | pgsql.bgwriter.buffers_clean.rate Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | Checkpoint: Buffers checkpoints written | Number of buffers written during checkpoints |
DEPENDENT | pgsql.bgwriter.buffers_checkpoint.rate Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | Checkpoint: By timeout | Number of scheduled checkpoints that have been performed |
DEPENDENT | pgsql.bgwriter.checkpoints_timed.rate Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | Checkpoint: Requested | Number of requested checkpoints that have been performed |
DEPENDENT | pgsql.bgwriter.checkpoints_req.rate Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | Checkpoint: Checkpoint write time | Total amount of time that has been spent in the portion of checkpoint processing where files are written to disk, in milliseconds |
DEPENDENT | pgsql.bgwriter.checkpoint_write_time.rate Preprocessing: - JSONPATH: - MULTIPLIER: - CHANGE_PER_SECOND |
| PostgreSQL | Checkpoint: Checkpoint write time | Total amount of time that has been spent in the portion of checkpoint processing where files are synchronized to disk, in milliseconds |
DEPENDENT | pgsql.bgwriter.checkpoint_sync_time.rate Preprocessing: - JSONPATH: - MULTIPLIER: - CHANGE_PER_SECOND |
| PostgreSQL | Checkpoint: Checkpoint sync time | Total amount of time that has been spent in the portion of checkpoint processing where files are synchronized to disk |
DEPENDENT | pgsql.bgwriter.checkpoint_sync_time.rate Preprocessing: - JSONPATH: - MULTIPLIER: - CHANGE_PER_SECOND |
| PostgreSQL | Archive: Count of archive files | Collect all metrics from pg_stat_activity https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-ARCHIVER-VIEW |
DEPENDENT | pgsql.archive.count_archived_files Preprocessing: - JSONPATH: |
| PostgreSQL | Archive: Count of attempts to archive files | Collect all metrics from pg_stat_activity https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-ARCHIVER-VIEW |
DEPENDENT | pgsql.archive.failed_trying_to_archive Preprocessing: - JSONPATH: |
| PostgreSQL | Archive: Count of files in archive_status need to archive | - |
DEPENDENT | pgsql.archive.count_files_to_archive Preprocessing: - JSONPATH: |
| PostgreSQL | Archive: Count of files need to archive | Size of files to archive |
DEPENDENT | pgsql.archive.size_files_to_archive Preprocessing: - JSONPATH: |
| PostgreSQL | Dbstat: Blocks read time | Time spent reading data file blocks by backends, in milliseconds |
DEPENDENT | pgsql.dbstat.sum.blk_read_time Preprocessing: - JSONPATH: - MULTIPLIER: |
| PostgreSQL | Dbstat: Blocks write time | Time spent writing data file blocks by backends, in milliseconds |
DEPENDENT | pgsql.dbstat.sum.blk_write_time Preprocessing: - JSONPATH: - MULTIPLIER: |
| PostgreSQL | Dbstat: Checksum failures | Number of data page checksum failures detected (or on a shared object), or NULL if data checksums are not enabled. This metric included in PostgreSQL 12 |
DEPENDENT | pgsql.dbstat.sum.checksum_failures.rate Preprocessing: - JSONPATH: - MATCHES_REGEX: - CHANGE_PER_SECOND ⛔️ON_FAIL: |
| PostgreSQL | Dbstat: Committed transactions | Number of transactions that have been committed |
DEPENDENT | pgsql.dbstat.sum.xact_commit.rate Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | Dbstat: Conflicts | Number of queries canceled due to conflicts with recovery. (Conflicts occur only on standby servers; see pg_stat_database_conflicts for details.) |
DEPENDENT | pgsql.dbstat.sum.conflicts.rate Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | Dbstat: Deadlocks | Number of deadlocks detected |
DEPENDENT | pgsql.dbstat.sum.deadlocks.rate Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | Dbstat: Disk blocks read | Number of disk blocks read |
DEPENDENT | pgsql.dbstat.sum.blks_read.rate Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | Dbstat: Hit blocks read | Number of times disk blocks were found already in the buffer cache |
DEPENDENT | pgsql.dbstat.sum.blks_hit.rate Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | Dbstat: Number temp bytes | Total amount of data written to temporary files by queries |
DEPENDENT | pgsql.dbstat.sum.temp_bytes.rate Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | Dbstat: Number temp bytes | Number of temporary files created by queries |
DEPENDENT | pgsql.dbstat.sum.temp_files.rate Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | Dbstat: Roll backed transactions | Number of transactions that have been rolled back |
DEPENDENT | pgsql.dbstat.sum.xact_rollback.rate Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | Dbstat: Rows deleted | Number of rows deleted by queries |
DEPENDENT | pgsql.dbstat.sum.tup_deleted.rate Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | Dbstat: Rows fetched | Number of rows fetched by queries |
DEPENDENT | pgsql.dbstat.sum.tup_fetched.rate Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | Dbstat: Rows inserted | Number of rows inserted by queries |
DEPENDENT | pgsql.dbstat.sum.tup_inserted.rate Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | Dbstat: Rows returned | Number of rows returned by queries |
DEPENDENT | pgsql.dbstat.sum.tup_returned.rate Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | Dbstat: Rows updated | Number of rows updated by queries |
DEPENDENT | pgsql.dbstat.sum.tup_updated.rate Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | Dbstat: Backends connected | Number of connected backends |
DEPENDENT | pgsql.dbstat.sum.numbackends Preprocessing: - JSONPATH: |
| PostgreSQL | Connections sum: Active | Total number of connections executing a query |
DEPENDENT | pgsql.connections.active Preprocessing: - JSONPATH: |
| PostgreSQL | Connections sum: Fastpath function call | Total number of connections executing a fast-path function |
DEPENDENT | pgsql.connections.fastpath_function_call Preprocessing: - JSONPATH: |
| PostgreSQL | Connections sum: Idle | Total number of connections waiting for a new client command |
DEPENDENT | pgsql.connections.idle Preprocessing: - JSONPATH: |
| PostgreSQL | Connections sum: Idle in transaction | Total number of connections in a transaction state, but not executing a query |
DEPENDENT | pgsql.connections.idle_in_transaction Preprocessing: - JSONPATH: |
| PostgreSQL | Connections sum: Prepared | Total number of prepared transactions https://www.postgresql.org/docs/current/sql-prepare-transaction.html |
DEPENDENT | pgsql.connections.prepared Preprocessing: - JSONPATH: |
| PostgreSQL | Connections sum: Total | Total number of connections |
DEPENDENT | pgsql.connections.total Preprocessing: - JSONPATH: |
| PostgreSQL | Connections sum: Total % | Total number of connections in percentage |
DEPENDENT | pgsql.connections.total_pct Preprocessing: - JSONPATH: |
| PostgreSQL | Connections sum: Waiting | Total number of waiting connections https://www.postgresql.org/docs/current/monitoring-stats.html#WAIT-EVENT-TABLE |
DEPENDENT | pgsql.connections.waiting Preprocessing: - JSONPATH: |
| PostgreSQL | Connections sum: Idle in transaction (aborted) | Total number of connections in a transaction state, but not executing a query and one of the statements in the transaction caused an error. |
DEPENDENT | pgsql.connections.idle_in_transaction_aborted Preprocessing: - JSONPATH: |
| PostgreSQL | Connections sum: Disabled | Total number of disabled connections |
DEPENDENT | pgsql.connections.disabled Preprocessing: - JSONPATH: |
| PostgreSQL | PostgreSQL: Age of oldest xid | Age of oldest xid. |
ZABBIX_PASSIVE | pgsql.oldest.xid["{$PG.URI}","{$PG.USER}","{$PG.PASSWORD}"] |
| PostgreSQL | Autovacuum: Count of autovacuum workers | Number of autovacuum workers. |
ZABBIX_PASSIVE | pgsql.autovacuum.count["{$PG.URI}","{$PG.USER}","{$PG.PASSWORD}"] |
| PostgreSQL | PostgreSQL: Cache hit | - |
CALCULATED | pgsql.cache.hit["{$PG.URI}","{$PG.USER}","{$PG.PASSWORD}"] Expression: last(//pgsql.dbstat.sum.blks_hit.rate) * 100 / (last(//pgsql.dbstat.sum.blks_hit.rate) + last(//pgsql.dbstat.sum.blks_read.rate)) |
| PostgreSQL | PostgreSQL: Uptime | - |
ZABBIX_PASSIVE | pgsql.uptime["{$PG.URI}","{$PG.USER}","{$PG.PASSWORD}"] |
| PostgreSQL | Replication: Lag in bytes | Replication lag with Master in byte. |
ZABBIX_PASSIVE | pgsql.replication.lag.b["{$PG.URI}","{$PG.USER}","{$PG.PASSWORD}"] |
| PostgreSQL | Replication: Lag in seconds | Replication lag with Master in seconds. |
ZABBIX_PASSIVE | pgsql.replication.lag.sec["{$PG.URI}","{$PG.USER}","{$PG.PASSWORD}"] |
| PostgreSQL | Replication: Recovery role | Replication role: 1 — recovery is still in progress (standby mode), 0 — master mode. |
ZABBIX_PASSIVE | pgsql.replication.recovery_role["{$PG.URI}","{$PG.USER}","{$PG.PASSWORD}"] |
| PostgreSQL | Replication: Standby count | Number of standby servers |
ZABBIX_PASSIVE | pgsql.replication.count["{$PG.URI}","{$PG.USER}","{$PG.PASSWORD}"] |
| PostgreSQL | Replication: Status | Replication status: 0 — streaming is down, 1 — streaming is up, 2 — master mode |
ZABBIX_PASSIVE | pgsql.replication.status["{$PG.URI}","{$PG.USER}","{$PG.PASSWORD}"] |
| PostgreSQL | PostgreSQL: Ping | - |
ZABBIX_PASSIVE | pgsql.ping["{$PG.URI}","{$PG.USER}","{$PG.PASSWORD}"] Preprocessing: - DISCARD_UNCHANGED_HEARTBEAT: |
| PostgreSQL | Application {#APPLICATION_NAME}: Replication flush lag | DEPENDENT | pgsql.replication.process.flush_lag["{#APPLICATION_NAME}"] Preprocessing: - JSONPATH: |
|
| PostgreSQL | Application {#APPLICATION_NAME}: Replication replay lag | DEPENDENT | pgsql.replication.process.replay_lag["{#APPLICATION_NAME}"] Preprocessing: - JSONPATH: |
|
| PostgreSQL | Application {#APPLICATION_NAME}: Replication write lag | DEPENDENT | pgsql.replication.process.write_lag["{#APPLICATION_NAME}"] Preprocessing: - JSONPATH: |
|
| PostgreSQL | DB {#DBNAME}: Database age | Database age |
ZABBIX_PASSIVE | pgsql.db.age["{$PG.URI}","{$PG.USER}","{$PG.PASSWORD}","{#DBNAME}"] |
| PostgreSQL | DB {#DBNAME}: Get bloating tables | Number of bloating tables |
ZABBIX_PASSIVE | pgsql.db.bloating_tables["{$PG.URI}","{$PG.USER}","{$PG.PASSWORD}","{#DBNAME}"] |
| PostgreSQL | DB {#DBNAME}: Database size | Database size |
ZABBIX_PASSIVE | pgsql.db.size["{$PG.URI}","{$PG.USER}","{$PG.PASSWORD}","{#DBNAME}"] |
| PostgreSQL | DB {#DBNAME}: Blocks hit per second | Total number of times disk blocks were found already in the buffer cache, so that a read was not necessary |
DEPENDENT | pgsql.dbstat.blks_hit.rate["{#DBNAME}"] Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | DB {#DBNAME}: Disk blocks read per second | Total number of disk blocks read in this database |
DEPENDENT | pgsql.dbstat.blks_read.rate["{#DBNAME}"] Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | DB {#DBNAME}: Detected conflicts per second | Total number of queries canceled due to conflicts with recovery in this database |
DEPENDENT | pgsql.dbstat.conflicts.rate["{#DBNAME}"] Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | DB {#DBNAME}: Detected deadlocks per second | Total number of detected deadlocks in this database |
DEPENDENT | pgsql.dbstat.deadlocks.rate["{#DBNAME}"] Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | DB {#DBNAME}: Temp_bytes written per second | Total amount of data written to temporary files by queries in this database |
DEPENDENT | pgsql.dbstat.temp_bytes.rate["{#DBNAME}"] Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | DB {#DBNAME}: Temp_files created per second | Total number of temporary files created by queries in this database |
DEPENDENT | pgsql.dbstat.temp_files.rate["{#DBNAME}"] Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | DB {#DBNAME}: Tuples deleted per second | Total number of rows deleted by queries in this database |
DEPENDENT | pgsql.dbstat.tup_deleted.rate["{#DBNAME}"] Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | DB {#DBNAME}: Tuples fetched per second | Total number of rows fetched by queries in this database |
DEPENDENT | pgsql.dbstat.tup_fetched.rate["{#DBNAME}"] Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | DB {#DBNAME}: Tuples inserted per second | Total number of rows inserted by queries in this database |
DEPENDENT | pgsql.dbstat.tup_inserted.rate["{#DBNAME}"] Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | DB {#DBNAME}: Tuples returned per second | Number of rows returned by queries in this database |
DEPENDENT | pgsql.dbstat.tup_returned.rate["{#DBNAME}"] Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | DB {#DBNAME}: Tuples updated per second | Total number of rows updated by queries in this database |
DEPENDENT | pgsql.dbstat.tup_updated.rate["{#DBNAME}"] Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | DB {#DBNAME}: Commits per second | Number of transactions in this database that have been committed |
DEPENDENT | pgsql.dbstat.xact_commit.rate["{#DBNAME}"] Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | DB {#DBNAME}: Rollbacks per second | Total number of transactions in this database that have been rolled back |
DEPENDENT | pgsql.dbstat.xact_rollback.rate["{#DBNAME}"] Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | DB {#DBNAME}: Backends connected | Number of backends currently connected to this database |
DEPENDENT | pgsql.dbstat.numbackends["{#DBNAME}"] Preprocessing: - JSONPATH: |
| PostgreSQL | DB {#DBNAME}: Checksum failures | Number of data page checksum failures detected in this database |
DEPENDENT | pgsql.dbstat.checksum_failures.rate["{#DBNAME}"] Preprocessing: - JSONPATH: - MATCHES_REGEX: - CHANGE_PER_SECOND ⛔️ON_FAIL: |
| PostgreSQL | DB {#DBNAME}: Disk blocks read time | Time spent reading data file blocks by backends, in milliseconds |
DEPENDENT | pgsql.dbstat.blk_read_time.rate["{#DBNAME}"] Preprocessing: - JSONPATH: - MULTIPLIER: - CHANGE_PER_SECOND |
| PostgreSQL | DB {#DBNAME}: Disk blocks write time | Time spent writing data file blocks by backends, in milliseconds |
DEPENDENT | pgsql.dbstat.blk_write_time.rate["{#DBNAME}"] Preprocessing: - JSONPATH: - MULTIPLIER: - CHANGE_PER_SECOND |
| PostgreSQL | DB {#DBNAME}: Num of accessexclusive locks | Number of accessexclusive locks for each database |
DEPENDENT | pgsql.locks.accessexclusive["{#DBNAME}"] Preprocessing: - JSONPATH: |
| PostgreSQL | DB {#DBNAME}: Num of accessshare locks | Number of accessshare locks for each database |
DEPENDENT | pgsql.locks.accessshare["{#DBNAME}"] Preprocessing: - JSONPATH: |
| PostgreSQL | DB {#DBNAME}: Num of exclusive locks | Number of exclusive locks for each database |
DEPENDENT | pgsql.locks.exclusive["{#DBNAME}"] Preprocessing: - JSONPATH: |
| PostgreSQL | DB {#DBNAME}: Num of rowexclusive locks | Number of rowexclusive locks for each database |
DEPENDENT | pgsql.locks.rowexclusive["{#DBNAME}"] Preprocessing: - JSONPATH: |
| PostgreSQL | DB {#DBNAME}: Num of rowshare locks | Number of rowshare locks for each database |
DEPENDENT | pgsql.locks.rowshare["{#DBNAME}"] Preprocessing: - JSONPATH: |
| PostgreSQL | DB {#DBNAME}: Num of sharerowexclusive locks | Number of total sharerowexclusive for each database |
DEPENDENT | pgsql.locks.sharerowexclusive["{#DBNAME}"] Preprocessing: - JSONPATH: |
| PostgreSQL | DB {#DBNAME}: Num of shareupdateexclusive locks | Number of shareupdateexclusive locks for each database |
DEPENDENT | pgsql.locks.shareupdateexclusive["{#DBNAME}"] Preprocessing: - JSONPATH: |
| PostgreSQL | DB {#DBNAME}: Num of share locks | Number of share locks for each database |
DEPENDENT | pgsql.locks.share["{#DBNAME}"] Preprocessing: - JSONPATH: |
| PostgreSQL | DB {#DBNAME}: Num of total locks | Number of total locks for each database |
DEPENDENT | pgsql.locks.total["{#DBNAME}"] Preprocessing: - JSONPATH: |
| PostgreSQL | DB {#DBNAME}: Queries max maintenance time | Max maintenance query time |
DEPENDENT | pgsql.queries.mro.time_max["{#DBNAME}"] Preprocessing: - JSONPATH: |
| PostgreSQL | DB {#DBNAME}: Queries max query time | Max query time |
DEPENDENT | pgsql.queries.query.time_max["{#DBNAME}"] Preprocessing: - JSONPATH: |
| PostgreSQL | DB {#DBNAME}: Queries max transaction time | Max transaction query time |
DEPENDENT | pgsql.queries.tx.time_max["{#DBNAME}"] Preprocessing: - JSONPATH: |
| PostgreSQL | DB {#DBNAME}: Queries slow maintenance count | Slow maintenance query count |
DEPENDENT | pgsql.queries.mro.slow_count["{#DBNAME}"] Preprocessing: - JSONPATH: |
| PostgreSQL | DB {#DBNAME}: Queries slow query count | Slow query count |
DEPENDENT | pgsql.queries.query.slow_count["{#DBNAME}"] Preprocessing: - JSONPATH: |
| PostgreSQL | DB {#DBNAME}: Queries slow transaction count | Slow transaction query count |
DEPENDENT | pgsql.queries.tx.slow_count["{#DBNAME}"] Preprocessing: - JSONPATH: |
| PostgreSQL | DB {#DBNAME}: Queries sum maintenance time | Sum maintenance query time |
DEPENDENT | pgsql.queries.mro.time_sum["{#DBNAME}"] Preprocessing: - JSONPATH: |
| PostgreSQL | DB {#DBNAME}: Queries sum query time | Sum query time |
DEPENDENT | pgsql.queries.query.time_sum["{#DBNAME}"] Preprocessing: - JSONPATH: |
| PostgreSQL | DB {#DBNAME}: Queries sum transaction time | Sum transaction query time |
DEPENDENT | pgsql.queries.tx.time_sum["{#DBNAME}"] Preprocessing: - JSONPATH: |
| Zabbix raw items | PostgreSQL: Get bgwriter | https://www.postgresql.org/docs/12/monitoring-stats.html#PG-STAT-BGWRITER-VIEW |
ZABBIX_PASSIVE | pgsql.bgwriter["{$PG.URI}","{$PG.USER}","{$PG.PASSWORD}"] |
| Zabbix raw items | PostgreSQL: Get archive | Collect archive status metrics |
ZABBIX_PASSIVE | pgsql.archive["{$PG.URI}","{$PG.USER}","{$PG.PASSWORD}"] |
| Zabbix raw items | PostgreSQL: Get dbstat | Collect all metrics from pg_stat_database per database https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-DATABASE-VIEW |
ZABBIX_PASSIVE | pgsql.dbstat["{$PG.URI}","{$PG.USER}","{$PG.PASSWORD}"] |
| Zabbix raw items | PostgreSQL: Get dbstat sum | Collect all metrics from pg_stat_database per database https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-DATABASE-VIEW |
ZABBIX_PASSIVE | pgsql.dbstat.sum["{$PG.URI}","{$PG.USER}","{$PG.PASSWORD}"] |
| Zabbix raw items | PostgreSQL: Get connections | Collect all metrics from pg_stat_activity https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-ACTIVITY-VIEW |
ZABBIX_PASSIVE | pgsql.connections["{$PG.URI}","{$PG.USER}","{$PG.PASSWORD}"] |
| Zabbix raw items | PostgreSQL: Get WAL | Collect WAL metrics |
ZABBIX_PASSIVE | pgsql.wal.stat["{$PG.URI}","{$PG.USER}","{$PG.PASSWORD}"] |
| Zabbix raw items | PostgreSQL: Get locks | Collect all metrics from pg_locks per database https://www.postgresql.org/docs/current/explicit-locking.html#LOCKING-TABLES |
ZABBIX_PASSIVE | pgsql.locks["{$PG.URI}","{$PG.USER}","{$PG.PASSWORD}"] |
| Zabbix raw items | PostgreSQL: Get replication | 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. |
ZABBIX_PASSIVE | pgsql.replication.process["{$PG.URI}","{$PG.USER}","{$PG.PASSWORD}"] |
| Zabbix raw items | PostgreSQL: Get queries | Collect all metrics by query execution time |
ZABBIX_PASSIVE | pgsql.queries["{$PG.URI}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}","{$PG.QUERY_ETIME.MAX.WARN}"] |
| Name | Description | Expression | Severity | Dependencies and additional info |
|---|---|---|---|---|
| Dbstat: Checksum failures detected | Data page checksum failures were detected on that DB instance. https://www.postgresql.org/docs/current/checksums.html |
last(/PostgreSQL by Zabbix agent 2/pgsql.dbstat.sum.checksum_failures.rate)>0 |
AVERAGE | |
| Connections sum: Total number of connections is too high | - |
min(/PostgreSQL by Zabbix agent 2/pgsql.connections.total_pct,5m) > {$PG.CONN_TOTAL_PCT.MAX.WARN} |
AVERAGE | |
| PostgreSQL: Oldest xid is too big | - |
last(/PostgreSQL by Zabbix agent 2/pgsql.oldest.xid["{$PG.URI}","{$PG.USER}","{$PG.PASSWORD}"]) > 18000000 |
AVERAGE | |
| PostgreSQL: Service has been restarted | - |
last(/PostgreSQL by Zabbix agent 2/pgsql.uptime["{$PG.URI}","{$PG.USER}","{$PG.PASSWORD}"]) < 600 |
AVERAGE | |
| PostgreSQL: Service is down | - |
last(/PostgreSQL by Zabbix agent 2/pgsql.ping["{$PG.URI}","{$PG.USER}","{$PG.PASSWORD}"])=0 |
HIGH | |
| DB {#DBNAME}: Too many recovery conflicts | 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 |
min(/PostgreSQL by Zabbix agent 2/pgsql.dbstat.conflicts.rate["{#DBNAME}"],5m) > {$PG.CONFLICTS.MAX.WARN:"{#DBNAME}"} |
AVERAGE | |
| DB {#DBNAME}: Deadlock occurred | - |
min(/PostgreSQL by Zabbix agent 2/pgsql.dbstat.deadlocks.rate["{#DBNAME}"],5m) > {$PG.DEADLOCKS.MAX.WARN:"{#DBNAME}"} |
HIGH | |
| DB {#DBNAME}: Checksum failures detected | Data page checksum failures were detected on that database. https://www.postgresql.org/docs/current/checksums.html |
last(/PostgreSQL by Zabbix agent 2/pgsql.dbstat.checksum_failures.rate["{#DBNAME}"])>0 |
AVERAGE | |
| DB {#DBNAME}: Too many slow queries | - |
min(/PostgreSQL by Zabbix agent 2/pgsql.queries.query.slow_count["{#DBNAME}"],5m)>{$PG.SLOW_QUERIES.MAX.WARN:"{#DBNAME}"} |
WARNING |
Please report any issues with the template at https://support.zabbix.com.
You can also provide feedback, discuss the template, or ask for help at ZABBIX forums.
This template is designed for the deployment of PostgreSQL monitoring by Zabbix via Zabbix agent 2 and uses a loadable plugin to run SQL queries.
Zabbix version: 6.0 and higher.
This template has been tested on:
Zabbix should be configured according to the instructions in the Templates out of the box section.
Deploy Zabbix agent 2 with the PostgreSQL plugin. Starting with Zabbix versions 6.0.10 / 6.2.4 / 6.4 PostgreSQL metrics are moved to a loadable plugin and require installation of a separate package or compilation of the plugin from sources.
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;
pg_hba.conf configuration file to allow connections for the user zbx_monitor. For example, you could add one of the following rows to allow local TCP connections from the same host:# TYPE DATABASE USER ADDRESS METHOD
host all zbx_monitor localhost trust
host all zbx_monitor 127.0.0.1/32 md5
host all zbx_monitor ::1/128 scram-sha-256
For more information please read the PostgreSQL documentation https://www.postgresql.org/docs/current/auth-pg-hba-conf.html.
{$PG.CONNSTRING.AGENT2} macro as URI, such as <protocol(host:port)>, or specify the named session - <sessionname>.Note: if you want to use SSL/TLS encryption to protect communications with the remote PostgreSQL instance, a named session must be used. In that case, the instance URI should be specified in the Plugins.PostgreSQL.Sessions.*.Uri parameter in the PostgreSQL plugin configuration files alongside all the encryption parameters (type, cerfiticate/key filepaths if needed etc.).
You can check the PostgreSQL plugin documentation for details about agent plugin parameters and named sessions.
Also, it is assumed that you set up the PostgreSQL instance to work in the desired encryption mode. Check the PostgreSQL documentation for details.
Note: plugin TLS certificate validation relies on checking the Subject Alternative Names (SAN) instead of the Common Name (CN), check the cryptography package documentation for details.
For example, to enable required encryption in transport mode without identity checks you could create the file /etc/zabbix/zabbix_agent2.d/postgresql_myconn.conf with the following configuration for the named session myconn (replace <instanceip> with the address of the PostgreSQL instance):
Plugins.PostgreSQL.Sessions.myconn.Uri=tcp://<instanceip>:5432
Plugins.PostgreSQL.Sessions.myconn.TLSConnect=required
Then set the {$PG.CONNSTRING.AGENT2} macro to myconn to use this named session.
{$PG.PASSWORD}.| Name | Description | Default |
|---|---|---|
| {$PG.PASSWORD} | PostgreSQL user password. |
<Put the password here> |
| {$PG.CONNSTRING.AGENT2} | URI or named session of the PostgreSQL instance. |
tcp://localhost:5432 |
| {$PG.USER} | PostgreSQL username. |
zbx_monitor |
| {$PG.LLD.FILTER.DBNAME} | Filter of discoverable databases. |
.+ |
| {$PG.CONN_TOTAL_PCT.MAX.WARN} | Maximum percentage of current connections for trigger expression. |
90 |
| {$PG.DATABASE} | Default PostgreSQL database for the connection. |
postgres |
| {$PG.DEADLOCKS.MAX.WARN} | Maximum number of detected deadlocks for trigger expression. |
0 |
| {$PG.LLD.FILTER.APPLICATION} | Filter of discoverable applications. |
.+ |
| {$PG.CONFLICTS.MAX.WARN} | Maximum number of recovery conflicts for trigger expression. |
0 |
| {$PG.QUERY_ETIME.MAX.WARN} | Execution time limit for count of slow queries. |
30 |
| {$PG.SLOW_QUERIES.MAX.WARN} | Slow queries count threshold for a trigger. |
5 |
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| PostgreSQL: Get bgwriter | Collect all metrics from pg_stat_bgwriter: https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-BGWRITER-VIEW |
Zabbix agent | pgsql.bgwriter["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| PostgreSQL: Get archive | Collect archive status metrics. |
Zabbix agent | pgsql.archive["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| PostgreSQL: Get dbstat | Collect all metrics from pg_stat_database per database: https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-DATABASE-VIEW |
Zabbix agent | pgsql.dbstat["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| PostgreSQL: Get dbstat sum | 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 |
Zabbix agent | pgsql.dbstat.sum["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| PostgreSQL: Get connections sum | Collect all metrics from pg_stat_activity: https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-ACTIVITY-VIEW |
Zabbix agent | pgsql.connections["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| PostgreSQL: Get WAL | Collect write-ahead log (WAL) metrics. |
Zabbix agent | pgsql.wal.stat["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| PostgreSQL: Get locks | Collect all metrics from pg_locks per database: https://www.postgresql.org/docs/current/explicit-locking.html#LOCKING-TABLES |
Zabbix agent | pgsql.locks["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| PostgreSQL: Custom queries | Execute custom queries from file *.sql (check for option Plugins.Postgres.CustomQueriesPath at agent configuration). |
Zabbix agent | pgsql.custom.query["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}",""] |
| PostgreSQL: Get replication | 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. |
Zabbix agent | pgsql.replication.process["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| PostgreSQL: Get queries | Collect all metrics by query execution time. |
Zabbix agent | pgsql.queries["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}","{$PG.QUERY_ETIME.MAX.WARN}"] |
| PostgreSQL: Version | PostgreSQL version. |
Zabbix agent | pgsql.version["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] Preprocessing
|
| WAL: Bytes written | WAL write, in bytes. |
Dependent item | pgsql.wal.write Preprocessing
|
| WAL: Bytes received | WAL receive, in bytes. |
Dependent item | pgsql.wal.receive Preprocessing
|
| WAL: Segments count | Number of WAL segments. |
Dependent item | pgsql.wal.count Preprocessing
|
| Bgwriter: Buffers allocated per second | Number of buffers allocated per second. |
Dependent item | pgsql.bgwriter.buffers_alloc.rate Preprocessing
|
| Bgwriter: Buffers written directly by a backend per second | Number of buffers written directly by a backend per second. |
Dependent item | pgsql.bgwriter.buffers_backend.rate Preprocessing
|
| Bgwriter: Number of bgwriter cleaning scan stopped per second | Number of times the background writer stopped a cleaning scan because it had written too many buffers per second. |
Dependent item | pgsql.bgwriter.maxwritten_clean.rate Preprocessing
|
| Bgwriter: Times a backend executed its own fsync per second | 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). |
Dependent item | pgsql.bgwriter.buffers_backend_fsync.rate Preprocessing
|
| Checkpoint: Buffers written by the background writer per second | Number of buffers written by the background writer per second. |
Dependent item | pgsql.bgwriter.buffers_clean.rate Preprocessing
|
| Checkpoint: Buffers written during checkpoints per second | Number of buffers written during checkpoints per second. |
Dependent item | pgsql.bgwriter.buffers_checkpoint.rate Preprocessing
|
| Checkpoint: Scheduled per second | Number of scheduled checkpoints that have been performed per second. |
Dependent item | pgsql.bgwriter.checkpoints_timed.rate Preprocessing
|
| Checkpoint: Requested per second | Number of requested checkpoints that have been performed per second. |
Dependent item | pgsql.bgwriter.checkpoints_req.rate Preprocessing
|
| Checkpoint: Checkpoint write time per second | Total amount of time per second that has been spent in the portion of checkpoint processing where files are written to disk. |
Dependent item | pgsql.bgwriter.checkpoint_write_time.rate Preprocessing
|
| Checkpoint: Checkpoint sync time per second | Total amount of time per second that has been spent in the portion of checkpoint processing where files are synchronized to disk. |
Dependent item | pgsql.bgwriter.checkpoint_sync_time.rate Preprocessing
|
| Archive: Count of archived files | Count of archived files. |
Dependent item | pgsql.archive.count_archived_files Preprocessing
|
| Archive: Count of failed attempts to archive files | Count of failed attempts to archive files. |
Dependent item | pgsql.archive.failed_trying_to_archive Preprocessing
|
| Archive: Count of files in archive_status need to archive | Count of files to archive. |
Dependent item | pgsql.archive.count_files_to_archive Preprocessing
|
| Archive: Size of files need to archive | Size of files to archive. |
Dependent item | pgsql.archive.size_files_to_archive Preprocessing
|
| Dbstat: Blocks read time | Time spent reading data file blocks by backends. |
Dependent item | pgsql.dbstat.sum.blk_read_time Preprocessing
|
| Dbstat: Blocks write time | Time spent writing data file blocks by backends. |
Dependent item | pgsql.dbstat.sum.blk_write_time Preprocessing
|
| Dbstat: Checksum failures per second | Number of data page checksum failures per second detected (or on a shared object), or NULL if data checksums are not enabled. This metric is available since PostgreSQL 12. |
Dependent item | pgsql.dbstat.sum.checksum_failures.rate Preprocessing
|
| Dbstat: Committed transactions per second | Number of transactions that have been committed per second. |
Dependent item | pgsql.dbstat.sum.xact_commit.rate Preprocessing
|
| Dbstat: Conflicts per second | Number of queries canceled per second due to conflicts with recovery (conflicts occur only on standby servers; see pg_stat_database_conflicts for details). |
Dependent item | pgsql.dbstat.sum.conflicts.rate Preprocessing
|
| Dbstat: Deadlocks per second | Number of deadlocks detected per second. |
Dependent item | pgsql.dbstat.sum.deadlocks.rate Preprocessing
|
| Dbstat: Disk blocks read per second | Number of disk blocks read per second. |
Dependent item | pgsql.dbstat.sum.blks_read.rate Preprocessing
|
| Dbstat: Hit blocks read per second | Number of times per second disk blocks were found already in the buffer cache |
Dependent item | pgsql.dbstat.sum.blks_hit.rate Preprocessing
|
| Dbstat: Number temp bytes per second | Total amount of data written per second to temporary files by queries. |
Dependent item | pgsql.dbstat.sum.temp_bytes.rate Preprocessing
|
| Dbstat: Number temp files per second | Number of temporary files created by queries per second. |
Dependent item | pgsql.dbstat.sum.temp_files.rate Preprocessing
|
| Dbstat: Roll backed transactions per second | Number of transactions that have been rolled back per second. |
Dependent item | pgsql.dbstat.sum.xact_rollback.rate Preprocessing
|
| Dbstat: Rows deleted per second | Number of rows deleted by queries per second. |
Dependent item | pgsql.dbstat.sum.tup_deleted.rate Preprocessing
|
| Dbstat: Rows fetched per second | Number of rows fetched by queries per second. |
Dependent item | pgsql.dbstat.sum.tup_fetched.rate Preprocessing
|
| Dbstat: Rows inserted per second | Number of rows inserted by queries per second. |
Dependent item | pgsql.dbstat.sum.tup_inserted.rate Preprocessing
|
| Dbstat: Rows returned per second | Number of rows returned by queries per second. |
Dependent item | pgsql.dbstat.sum.tup_returned.rate Preprocessing
|
| Dbstat: Rows updated per second | Number of rows updated by queries per second. |
Dependent item | pgsql.dbstat.sum.tup_updated.rate Preprocessing
|
| Dbstat: Backends connected | Number of connected backends. |
Dependent item | pgsql.dbstat.sum.numbackends Preprocessing
|
| Connections sum: Active | Total number of connections executing a query. |
Dependent item | pgsql.connections.sum.active Preprocessing
|
| Connections sum: Fastpath function call | Total number of connections executing a fast-path function. |
Dependent item | pgsql.connections.sum.fastpath_function_call Preprocessing
|
| Connections sum: Idle | Total number of connections waiting for a new client command. |
Dependent item | pgsql.connections.sum.idle Preprocessing
|
| Connections sum: Idle in transaction | Total number of connections in a transaction state but not executing a query. |
Dependent item | pgsql.connections.sum.idle_in_transaction Preprocessing
|
| Connections sum: Prepared | Total number of prepared transactions: https://www.postgresql.org/docs/current/sql-prepare-transaction.html |
Dependent item | pgsql.connections.sum.prepared Preprocessing
|
| Connections sum: Total | Total number of connections. |
Dependent item | pgsql.connections.sum.total Preprocessing
|
| Connections sum: Total, % | Total number of connections, in percentage. |
Dependent item | pgsql.connections.sum.total_pct Preprocessing
|
| Connections sum: Waiting | Total number of waiting connections: https://www.postgresql.org/docs/current/monitoring-stats.html#WAIT-EVENT-TABLE |
Dependent item | pgsql.connections.sum.waiting Preprocessing
|
| Connections sum: Idle in transaction (aborted) | 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. |
Dependent item | pgsql.connections.sum.idle_in_transaction_aborted Preprocessing
|
| Connections sum: Disabled | Total number of disabled connections. |
Dependent item | pgsql.connections.sum.disabled Preprocessing
|
| PostgreSQL: Age of oldest xid | Age of oldest xid. |
Zabbix agent | pgsql.oldest.xid["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| PostgreSQL: Count of autovacuum workers | Number of autovacuum workers. |
Zabbix agent | pgsql.autovacuum.count["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| PostgreSQL: Cache hit ratio, % | Cache hit ratio. |
Calculated | pgsql.cache.hit |
| PostgreSQL: Uptime | Time since the server started. |
Zabbix agent | pgsql.uptime["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| PostgreSQL: Replication: Lag in bytes | Replication lag with master, in bytes. |
Zabbix agent | pgsql.replication.lag.b["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| PostgreSQL: Replication: Lag in seconds | Replication lag with master, in seconds. |
Zabbix agent | pgsql.replication.lag.sec["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| PostgreSQL: Replication: Recovery role | Replication role: 1 — recovery is still in progress (standby mode), 0 — master mode. |
Zabbix agent | pgsql.replication.recovery_role["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| PostgreSQL: Replication: Standby count | Number of standby servers. |
Zabbix agent | pgsql.replication.count["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| PostgreSQL: Replication: Status | Replication status: 0 — streaming is down, 1 — streaming is up, 2 — master mode. |
Zabbix agent | pgsql.replication.status["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| PostgreSQL: Ping | Used to test a connection to see if it is alive. It is set to 0 if the query is unsuccessful. |
Zabbix agent | pgsql.ping["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] Preprocessing
|
| Name | Description | Expression | Severity | Dependencies and additional info |
|---|---|---|---|---|
| PostgreSQL: Version has changed | last(/PostgreSQL by Zabbix agent 2/pgsql.version["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"],#1)<>last(/PostgreSQL by Zabbix agent 2/pgsql.version["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"],#2) and length(last(/PostgreSQL by Zabbix agent 2/pgsql.version["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]))>0 |
Info | ||
| Dbstat: Checksum failures detected | Data page checksum failures were detected on that DB instance: |
last(/PostgreSQL by Zabbix agent 2/pgsql.dbstat.sum.checksum_failures.rate)>0 |
Average | |
| PostgreSQL: Total number of connections is too high | 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). |
min(/PostgreSQL by Zabbix agent 2/pgsql.connections.sum.total_pct,5m) > {$PG.CONN_TOTAL_PCT.MAX.WARN} |
Average | |
| PostgreSQL: Oldest xid is too big | last(/PostgreSQL by Zabbix agent 2/pgsql.oldest.xid["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]) > 18000000 |
Average | ||
| PostgreSQL: Service has been restarted | PostgreSQL uptime is less than 10 minutes. |
last(/PostgreSQL by Zabbix agent 2/pgsql.uptime["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]) < 10m |
Average | |
| PostgreSQL: Service is down | Last test of a connection was unsuccessful. |
last(/PostgreSQL by Zabbix agent 2/pgsql.ping["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"])=0 |
High |
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Replication discovery | Discovers replication lag metrics. |
Zabbix agent | pgsql.replication.process.discovery["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Application [{#APPLICATION_NAME}]: Get replication | 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. |
Dependent item | pgsql.replication.get_metrics["{#APPLICATION_NAME}"] Preprocessing
|
| Application [{#APPLICATION_NAME}]: Replication flush lag | Dependent item | pgsql.replication.process.flush_lag["{#APPLICATION_NAME}"] Preprocessing
|
|
| Application [{#APPLICATION_NAME}]: Replication replay lag | Dependent item | pgsql.replication.process.replay_lag["{#APPLICATION_NAME}"] Preprocessing
|
|
| Application [{#APPLICATION_NAME}]: Replication write lag | Dependent item | pgsql.replication.process.write_lag["{#APPLICATION_NAME}"] Preprocessing
|
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Database discovery | Discovers databases (DB) in the database management system (DBMS), except: - templates; - DBs that do not allow connections. |
Zabbix agent | pgsql.db.discovery["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| DB [{#DBNAME}]: Get dbstat | Get dbstat metrics for database "{#DBNAME}". |
Dependent item | pgsql.dbstat.get_metrics["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Get locks | Get locks metrics for database "{#DBNAME}". |
Dependent item | pgsql.locks.get_metrics["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Get queries | Get queries metrics for database "{#DBNAME}". |
Dependent item | pgsql.queries.get_metrics["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Database age | Database age. |
Zabbix agent | pgsql.db.age["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{#DBNAME}"] |
| DB [{#DBNAME}]: Bloating tables | Number of bloating tables. |
Zabbix agent | pgsql.db.bloating_tables["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{#DBNAME}"] |
| DB [{#DBNAME}]: Database size | Database size. |
Zabbix agent | pgsql.db.size["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{#DBNAME}"] |
| DB [{#DBNAME}]: Blocks hit per second | Total number of times per second disk blocks were found already in the buffer cache, so that a read was not necessary. |
Dependent item | pgsql.dbstat.blks_hit.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Disk blocks read per second | Total number of disk blocks read per second in this database. |
Dependent item | pgsql.dbstat.blks_read.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Detected conflicts per second | Total number of queries canceled due to conflicts with recovery in this database per second. |
Dependent item | pgsql.dbstat.conflicts.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Detected deadlocks per second | Total number of detected deadlocks in this database per second. |
Dependent item | pgsql.dbstat.deadlocks.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Temp_bytes written per second | Total amount of data written to temporary files by queries in this database. |
Dependent item | pgsql.dbstat.temp_bytes.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Temp_files created per second | Total number of temporary files created by queries in this database. |
Dependent item | pgsql.dbstat.temp_files.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Tuples deleted per second | Total number of rows deleted by queries in this database per second. |
Dependent item | pgsql.dbstat.tup_deleted.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Tuples fetched per second | Total number of rows fetched by queries in this database per second. |
Dependent item | pgsql.dbstat.tup_fetched.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Tuples inserted per second | Total number of rows inserted by queries in this database per second. |
Dependent item | pgsql.dbstat.tup_inserted.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Tuples returned per second | Number of rows returned by queries in this database per second. |
Dependent item | pgsql.dbstat.tup_returned.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Tuples updated per second | Total number of rows updated by queries in this database per second. |
Dependent item | pgsql.dbstat.tup_updated.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Commits per second | Number of transactions in this database that have been committed per second. |
Dependent item | pgsql.dbstat.xact_commit.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Rollbacks per second | Total number of transactions in this database that have been rolled back. |
Dependent item | pgsql.dbstat.xact_rollback.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Backends connected | Number of backends currently connected to this database. |
Dependent item | pgsql.dbstat.numbackends["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Checksum failures | Number of data page checksum failures detected in this database. |
Dependent item | pgsql.dbstat.checksum_failures.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Disk blocks read time per second | Time spent reading data file blocks by backends per second. |
Dependent item | pgsql.dbstat.blk_read_time.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Disk blocks write time | Time spent writing data file blocks by backends per second. |
Dependent item | pgsql.dbstat.blk_write_time.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Num of accessexclusive locks | Number of accessexclusive locks for this database. |
Dependent item | pgsql.locks.accessexclusive["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Num of accessshare locks | Number of accessshare locks for this database. |
Dependent item | pgsql.locks.accessshare["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Num of exclusive locks | Number of exclusive locks for this database. |
Dependent item | pgsql.locks.exclusive["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Num of rowexclusive locks | Number of rowexclusive locks for this database. |
Dependent item | pgsql.locks.rowexclusive["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Num of rowshare locks | Number of rowshare locks for this database. |
Dependent item | pgsql.locks.rowshare["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Num of sharerowexclusive locks | Number of total sharerowexclusive for this database. |
Dependent item | pgsql.locks.sharerowexclusive["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Num of shareupdateexclusive locks | Number of shareupdateexclusive locks for this database. |
Dependent item | pgsql.locks.shareupdateexclusive["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Num of share locks | Number of share locks for this database. |
Dependent item | pgsql.locks.share["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Num of locks total | Total number of locks in this database. |
Dependent item | pgsql.locks.total["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries max maintenance time | Max maintenance query time for this database. |
Dependent item | pgsql.queries.mro.time_max["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries max query time | Max query time for this database. |
Dependent item | pgsql.queries.query.time_max["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries max transaction time | Max transaction query time for this database. |
Dependent item | pgsql.queries.tx.time_max["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries slow maintenance count | Slow maintenance query count for this database. |
Dependent item | pgsql.queries.mro.slow_count["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries slow query count | Slow query count for this database. |
Dependent item | pgsql.queries.query.slow_count["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries slow transaction count | Slow transaction query count for this database. |
Dependent item | pgsql.queries.tx.slow_count["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries sum maintenance time | Sum maintenance query time for this database. |
Dependent item | pgsql.queries.mro.time_sum["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries sum query time | Sum query time for this database. |
Dependent item | pgsql.queries.query.time_sum["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries sum transaction time | Sum transaction query time for this database. |
Dependent item | pgsql.queries.tx.time_sum["{#DBNAME}"] Preprocessing
|
| Name | Description | Expression | Severity | Dependencies and additional info |
|---|---|---|---|---|
| DB [{#DBNAME}]: Too many recovery conflicts | 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. |
min(/PostgreSQL by Zabbix agent 2/pgsql.dbstat.conflicts.rate["{#DBNAME}"],5m) > {$PG.CONFLICTS.MAX.WARN:"{#DBNAME}"} |
Average | |
| DB [{#DBNAME}]: Deadlock occurred | Number of deadlocks detected per second exceeds {$PG.DEADLOCKS.MAX.WARN:"{#DBNAME}"} for 5m. |
min(/PostgreSQL by Zabbix agent 2/pgsql.dbstat.deadlocks.rate["{#DBNAME}"],5m) > {$PG.DEADLOCKS.MAX.WARN:"{#DBNAME}"} |
High | |
| DB [{#DBNAME}]: Checksum failures detected | Data page checksum failures were detected on that database: |
last(/PostgreSQL by Zabbix agent 2/pgsql.dbstat.checksum_failures.rate["{#DBNAME}"])>0 |
Average | |
| DB [{#DBNAME}]: Too many slow queries | The number of detected slow queries exceeds the limit of {$PG.SLOW_QUERIES.MAX.WARN:"{#DBNAME}"}. |
min(/PostgreSQL by Zabbix agent 2/pgsql.queries.query.slow_count["{#DBNAME}"],5m)>{$PG.SLOW_QUERIES.MAX.WARN:"{#DBNAME}"} |
Warning |
Please report any issues with the template at https://support.zabbix.com
You can also provide feedback, discuss the template, or ask for help at ZABBIX forums
For Zabbix version: 5.4 and higher
The template is developed for monitoring DBMS PostgreSQL and its forks.
This template was tested on:
See Zabbix template operation for basic instructions.
1. Create PostgreSQL user for monitoring (<password> at your discretion):
CREATE USER 'zbx_monitor' WITH PASSWORD '<PASSWORD>' INHERIT;
GRANT EXECUTE ON FUNCTION pg_catalog.pg_ls_dir(text) TO zbx_monitor;
GRANT EXECUTE ON FUNCTION pg_catalog.pg_stat_file(text) TO zbx_monitor;
GRANT EXECUTE ON FUNCTION pg_catalog.pg_ls_waldir() TO zbx_monitor;
2. Edit pg_hba.conf to allow connections from Zabbix agent:
# TYPE DATABASE USER ADDRESS METHOD
host all zbx_monitor localhost md5
For more information please read the PostgreSQL documentation https://www.postgresql.org/docs/current/auth-pg-hba-conf.html.
3. Set in the {$PG.URI} macro the system data source name of the PostgreSQL instance such as <protocol(host:port)>.
4. Set the user name and password in host macros ({$PG.USER} and {$PG.PASSWORD}) if you want to override parameters from the Zabbix agent configuration file.
No specific Zabbix configuration is required.
| Name | Description | Default |
|---|---|---|
| {$PG.CONFLICTS.MAX.WARN} | - |
0 |
| {$PG.CONN_TOTAL_PCT.MAX.WARN} | - |
90 |
| {$PG.DATABASE} | - |
postgres |
| {$PG.DEADLOCKS.MAX.WARN} | - |
0 |
| {$PG.LLD.FILTER.APPLICATION} | - |
(.+) |
| {$PG.LLD.FILTER.DBNAME} | - |
(.+) |
| {$PG.PASSWORD} | - |
postgres |
| {$PG.QUERY_ETIME.MAX.WARN} | Execution time limit for count of slow queries. |
30 |
| {$PG.SLOW_QUERIES.MAX.WARN} | Slow queries count threshold for a trigger. |
5 |
| {$PG.URI} | - |
tcp://localhost:5432 |
| {$PG.USER} | - |
postgres |
There are no template links in this template.
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Database discovery | - |
ZABBIX_PASSIVE | pgsql.db.discovery["{$PG.URI}","{$PG.USER}","{$PG.PASSWORD}"] Filter: AND- {#DBNAME} MATCHES_REGEX |
| Replication Discovery | - |
ZABBIX_PASSIVE | pgsql.replication.process.discovery["{$PG.URI}","{$PG.USER}","{$PG.PASSWORD}"] Filter: AND- {#APPLICATION_NAME} MATCHES_REGEX |
| Group | Name | Description | Type | Key and additional info |
|---|---|---|---|---|
| PostgreSQL | PostgreSQL: Custom queries | Execute custom queries from file *.sql (check for option Plugins.Postgres.CustomQueriesPath at agent configuration) |
ZABBIX_PASSIVE | pgsql.custom.query["{$PG.URI}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}",""] |
| PostgreSQL | WAL: Bytes written | WAL write in bytes |
DEPENDENT | pgsql.wal.write Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | WAL: Bytes received | WAL receive in bytes |
DEPENDENT | pgsql.wal.receive Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | WAL: Segments count | Number of WAL segments |
DEPENDENT | pgsql.wal.count Preprocessing: - JSONPATH: |
| PostgreSQL | Bgwriter: Buffers allocated | Number of buffers allocated |
DEPENDENT | pgsql.bgwriter.buffers_alloc.rate Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | Bgwriter: Buffers written directly by a backend | Number of buffers written directly by a backend |
DEPENDENT | pgsql.bgwriter.buffers_backend.rate Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | Bgwriter: Number of bgwriter stopped | Number of times the background writer stopped a cleaning scan because it had written too many buffers |
DEPENDENT | pgsql.bgwriter.maxwritten_clean.rate Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | Bgwriter: Times a backend execute its own fsync | Number of times a backend had to execute its own fsync call (normally the background writer handles those even when the backend does its own write) |
DEPENDENT | pgsql.bgwriter.buffers_backend_fsync.rate Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | Checkpoint: Buffers background written | Number of buffers written by the background writer |
DEPENDENT | pgsql.bgwriter.buffers_clean.rate Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | Checkpoint: Buffers checkpoints written | Number of buffers written during checkpoints |
DEPENDENT | pgsql.bgwriter.buffers_checkpoint.rate Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | Checkpoint: By timeout | Number of scheduled checkpoints that have been performed |
DEPENDENT | pgsql.bgwriter.checkpoints_timed.rate Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | Checkpoint: Requested | Number of requested checkpoints that have been performed |
DEPENDENT | pgsql.bgwriter.checkpoints_req.rate Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | Checkpoint: Checkpoint write time | Total amount of time that has been spent in the portion of checkpoint processing where files are written to disk, in milliseconds |
DEPENDENT | pgsql.bgwriter.checkpoint_write_time.rate Preprocessing: - JSONPATH: - MULTIPLIER: - CHANGE_PER_SECOND |
| PostgreSQL | Checkpoint: Checkpoint write time | Total amount of time that has been spent in the portion of checkpoint processing where files are synchronized to disk, in milliseconds |
DEPENDENT | pgsql.bgwriter.checkpoint_sync_time.rate Preprocessing: - JSONPATH: - MULTIPLIER: - CHANGE_PER_SECOND |
| PostgreSQL | Checkpoint: Checkpoint sync time | Total amount of time that has been spent in the portion of checkpoint processing where files are synchronized to disk |
DEPENDENT | pgsql.bgwriter.checkpoint_sync_time.rate Preprocessing: - JSONPATH: - MULTIPLIER: - CHANGE_PER_SECOND |
| PostgreSQL | Archive: Count of archive files | Collect all metrics from pg_stat_activity https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-ARCHIVER-VIEW |
DEPENDENT | pgsql.archive.count_archived_files Preprocessing: - JSONPATH: |
| PostgreSQL | Archive: Count of attempts to archive files | Collect all metrics from pg_stat_activity https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-ARCHIVER-VIEW |
DEPENDENT | pgsql.archive.failed_trying_to_archive Preprocessing: - JSONPATH: |
| PostgreSQL | Archive: Count of files in archive_status need to archive | - |
DEPENDENT | pgsql.archive.count_files_to_archive Preprocessing: - JSONPATH: |
| PostgreSQL | Archive: Count of files need to archive | Size of files to archive |
DEPENDENT | pgsql.archive.size_files_to_archive Preprocessing: - JSONPATH: |
| PostgreSQL | Dbstat: Blocks read time | Time spent reading data file blocks by backends, in milliseconds |
DEPENDENT | pgsql.dbstat.sum.blk_read_time Preprocessing: - JSONPATH: - MULTIPLIER: |
| PostgreSQL | Dbstat: Blocks write time | Time spent writing data file blocks by backends, in milliseconds |
DEPENDENT | pgsql.dbstat.sum.blk_write_time Preprocessing: - JSONPATH: - MULTIPLIER: |
| PostgreSQL | Dbstat: Checksum failures | Number of data page checksum failures detected (or on a shared object), or NULL if data checksums are not enabled. This metric included in PostgreSQL 12 |
DEPENDENT | pgsql.dbstat.sum.checksum_failures.rate Preprocessing: - JSONPATH: - MATCHES_REGEX: - CHANGE_PER_SECOND ⛔️ON_FAIL: |
| PostgreSQL | Dbstat: Committed transactions | Number of transactions that have been committed |
DEPENDENT | pgsql.dbstat.sum.xact_commit.rate Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | Dbstat: Conflicts | Number of queries canceled due to conflicts with recovery. (Conflicts occur only on standby servers; see pg_stat_database_conflicts for details.) |
DEPENDENT | pgsql.dbstat.sum.conflicts.rate Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | Dbstat: Deadlocks | Number of deadlocks detected |
DEPENDENT | pgsql.dbstat.sum.deadlocks.rate Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | Dbstat: Disk blocks read | Number of disk blocks read |
DEPENDENT | pgsql.dbstat.sum.blks_read.rate Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | Dbstat: Hit blocks read | Number of times disk blocks were found already in the buffer cache |
DEPENDENT | pgsql.dbstat.sum.blks_hit.rate Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | Dbstat: Number temp bytes | Total amount of data written to temporary files by queries |
DEPENDENT | pgsql.dbstat.sum.temp_bytes.rate Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | Dbstat: Number temp bytes | Number of temporary files created by queries |
DEPENDENT | pgsql.dbstat.sum.temp_files.rate Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | Dbstat: Roll backed transactions | Number of transactions that have been rolled back |
DEPENDENT | pgsql.dbstat.sum.xact_rollback.rate Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | Dbstat: Rows deleted | Number of rows deleted by queries |
DEPENDENT | pgsql.dbstat.sum.tup_deleted.rate Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | Dbstat: Rows fetched | Number of rows fetched by queries |
DEPENDENT | pgsql.dbstat.sum.tup_fetched.rate Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | Dbstat: Rows inserted | Number of rows inserted by queries |
DEPENDENT | pgsql.dbstat.sum.tup_inserted.rate Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | Dbstat: Rows returned | Number of rows returned by queries |
DEPENDENT | pgsql.dbstat.sum.tup_returned.rate Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | Dbstat: Rows updated | Number of rows updated by queries |
DEPENDENT | pgsql.dbstat.sum.tup_updated.rate Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | Dbstat: Backends connected | Number of connected backends |
DEPENDENT | pgsql.dbstat.sum.numbackends Preprocessing: - JSONPATH: |
| PostgreSQL | Connections sum: Active | Total number of connections executing a query |
DEPENDENT | pgsql.connections.active Preprocessing: - JSONPATH: |
| PostgreSQL | Connections sum: Fastpath function call | Total number of connections executing a fast-path function |
DEPENDENT | pgsql.connections.fastpath_function_call Preprocessing: - JSONPATH: |
| PostgreSQL | Connections sum: Idle | Total number of connections waiting for a new client command |
DEPENDENT | pgsql.connections.idle Preprocessing: - JSONPATH: |
| PostgreSQL | Connections sum: Idle in transaction | Total number of connections in a transaction state, but not executing a query |
DEPENDENT | pgsql.connections.idle_in_transaction Preprocessing: - JSONPATH: |
| PostgreSQL | Connections sum: Prepared | Total number of prepared transactions https://www.postgresql.org/docs/current/sql-prepare-transaction.html |
DEPENDENT | pgsql.connections.prepared Preprocessing: - JSONPATH: |
| PostgreSQL | Connections sum: Total | Total number of connections |
DEPENDENT | pgsql.connections.total Preprocessing: - JSONPATH: |
| PostgreSQL | Connections sum: Total % | Total number of connections in percentage |
DEPENDENT | pgsql.connections.total_pct Preprocessing: - JSONPATH: |
| PostgreSQL | Connections sum: Waiting | Total number of waiting connections https://www.postgresql.org/docs/current/monitoring-stats.html#WAIT-EVENT-TABLE |
DEPENDENT | pgsql.connections.waiting Preprocessing: - JSONPATH: |
| PostgreSQL | Connections sum: Idle in transaction (aborted) | Total number of connections in a transaction state, but not executing a query and one of the statements in the transaction caused an error. |
DEPENDENT | pgsql.connections.idle_in_transaction_aborted Preprocessing: - JSONPATH: |
| PostgreSQL | Connections sum: Disabled | Total number of disabled connections |
DEPENDENT | pgsql.connections.disabled Preprocessing: - JSONPATH: |
| PostgreSQL | PostgreSQL: Age of oldest xid | Age of oldest xid. |
ZABBIX_PASSIVE | pgsql.oldest.xid["{$PG.URI}","{$PG.USER}","{$PG.PASSWORD}"] |
| PostgreSQL | Autovacuum: Count of autovacuum workers | Number of autovacuum workers. |
ZABBIX_PASSIVE | pgsql.autovacuum.count["{$PG.URI}","{$PG.USER}","{$PG.PASSWORD}"] |
| PostgreSQL | PostgreSQL: Cache hit | - |
CALCULATED | pgsql.cache.hit["{$PG.URI}","{$PG.USER}","{$PG.PASSWORD}"] Expression: last(//pgsql.dbstat.sum.blks_hit.rate) * 100 / (last(//pgsql.dbstat.sum.blks_hit.rate) + last(//pgsql.dbstat.sum.blks_read.rate)) |
| PostgreSQL | PostgreSQL: Uptime | - |
ZABBIX_PASSIVE | pgsql.uptime["{$PG.URI}","{$PG.USER}","{$PG.PASSWORD}"] |
| PostgreSQL | Replication: Lag in bytes | Replication lag with Master in byte. |
ZABBIX_PASSIVE | pgsql.replication.lag.b["{$PG.URI}","{$PG.USER}","{$PG.PASSWORD}"] |
| PostgreSQL | Replication: Lag in seconds | Replication lag with Master in seconds. |
ZABBIX_PASSIVE | pgsql.replication.lag.sec["{$PG.URI}","{$PG.USER}","{$PG.PASSWORD}"] |
| PostgreSQL | Replication: Recovery role | Replication role: 1 — recovery is still in progress (standby mode), 0 — master mode. |
ZABBIX_PASSIVE | pgsql.replication.recovery_role["{$PG.URI}","{$PG.USER}","{$PG.PASSWORD}"] |
| PostgreSQL | Replication: Standby count | Number of standby servers |
ZABBIX_PASSIVE | pgsql.replication.count["{$PG.URI}","{$PG.USER}","{$PG.PASSWORD}"] |
| PostgreSQL | Replication: Status | Replication status: 0 — streaming is down, 1 — streaming is up, 2 — master mode |
ZABBIX_PASSIVE | pgsql.replication.status["{$PG.URI}","{$PG.USER}","{$PG.PASSWORD}"] |
| PostgreSQL | PostgreSQL: Ping | - |
ZABBIX_PASSIVE | pgsql.ping["{$PG.URI}","{$PG.USER}","{$PG.PASSWORD}"] Preprocessing: - DISCARD_UNCHANGED_HEARTBEAT: |
| PostgreSQL | Application {#APPLICATION_NAME}: Replication flush lag | DEPENDENT | pgsql.replication.process.flush_lag["{#APPLICATION_NAME}"] Preprocessing: - JSONPATH: |
|
| PostgreSQL | Application {#APPLICATION_NAME}: Replication replay lag | DEPENDENT | pgsql.replication.process.replay_lag["{#APPLICATION_NAME}"] Preprocessing: - JSONPATH: |
|
| PostgreSQL | Application {#APPLICATION_NAME}: Replication write lag | DEPENDENT | pgsql.replication.process.write_lag["{#APPLICATION_NAME}"] Preprocessing: - JSONPATH: |
|
| PostgreSQL | DB {#DBNAME}: Database age | Database age |
ZABBIX_PASSIVE | pgsql.db.age["{$PG.URI}","{$PG.USER}","{$PG.PASSWORD}","{#DBNAME}"] |
| PostgreSQL | DB {#DBNAME}: Get bloating tables | Number of bloating tables |
ZABBIX_PASSIVE | pgsql.db.bloating_tables["{$PG.URI}","{$PG.USER}","{$PG.PASSWORD}","{#DBNAME}"] |
| PostgreSQL | DB {#DBNAME}: Database size | Database size |
ZABBIX_PASSIVE | pgsql.db.size["{$PG.URI}","{$PG.USER}","{$PG.PASSWORD}","{#DBNAME}"] |
| PostgreSQL | DB {#DBNAME}: Blocks hit per second | Total number of times disk blocks were found already in the buffer cache, so that a read was not necessary |
DEPENDENT | pgsql.dbstat.blks_hit.rate["{#DBNAME}"] Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | DB {#DBNAME}: Disk blocks read per second | Total number of disk blocks read in this database |
DEPENDENT | pgsql.dbstat.blks_read.rate["{#DBNAME}"] Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | DB {#DBNAME}: Detected conflicts per second | Total number of queries canceled due to conflicts with recovery in this database |
DEPENDENT | pgsql.dbstat.conflicts.rate["{#DBNAME}"] Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | DB {#DBNAME}: Detected deadlocks per second | Total number of detected deadlocks in this database |
DEPENDENT | pgsql.dbstat.deadlocks.rate["{#DBNAME}"] Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | DB {#DBNAME}: Temp_bytes written per second | Total amount of data written to temporary files by queries in this database |
DEPENDENT | pgsql.dbstat.temp_bytes.rate["{#DBNAME}"] Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | DB {#DBNAME}: Temp_files created per second | Total number of temporary files created by queries in this database |
DEPENDENT | pgsql.dbstat.temp_files.rate["{#DBNAME}"] Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | DB {#DBNAME}: Tuples deleted per second | Total number of rows deleted by queries in this database |
DEPENDENT | pgsql.dbstat.tup_deleted.rate["{#DBNAME}"] Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | DB {#DBNAME}: Tuples fetched per second | Total number of rows fetched by queries in this database |
DEPENDENT | pgsql.dbstat.tup_fetched.rate["{#DBNAME}"] Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | DB {#DBNAME}: Tuples inserted per second | Total number of rows inserted by queries in this database |
DEPENDENT | pgsql.dbstat.tup_inserted.rate["{#DBNAME}"] Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | DB {#DBNAME}: Tuples returned per second | Number of rows returned by queries in this database |
DEPENDENT | pgsql.dbstat.tup_returned.rate["{#DBNAME}"] Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | DB {#DBNAME}: Tuples updated per second | Total number of rows updated by queries in this database |
DEPENDENT | pgsql.dbstat.tup_updated.rate["{#DBNAME}"] Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | DB {#DBNAME}: Commits per second | Number of transactions in this database that have been committed |
DEPENDENT | pgsql.dbstat.xact_commit.rate["{#DBNAME}"] Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | DB {#DBNAME}: Rollbacks per second | Total number of transactions in this database that have been rolled back |
DEPENDENT | pgsql.dbstat.xact_rollback.rate["{#DBNAME}"] Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | DB {#DBNAME}: Backends connected | Number of backends currently connected to this database |
DEPENDENT | pgsql.dbstat.numbackends["{#DBNAME}"] Preprocessing: - JSONPATH: |
| PostgreSQL | DB {#DBNAME}: Checksum failures | Number of data page checksum failures detected in this database |
DEPENDENT | pgsql.dbstat.checksum_failures.rate["{#DBNAME}"] Preprocessing: - JSONPATH: - MATCHES_REGEX: - CHANGE_PER_SECOND ⛔️ON_FAIL: |
| PostgreSQL | DB {#DBNAME}: Disk blocks read time | Time spent reading data file blocks by backends, in milliseconds |
DEPENDENT | pgsql.dbstat.blk_read_time.rate["{#DBNAME}"] Preprocessing: - JSONPATH: - MULTIPLIER: - CHANGE_PER_SECOND |
| PostgreSQL | DB {#DBNAME}: Disk blocks write time | Time spent writing data file blocks by backends, in milliseconds |
DEPENDENT | pgsql.dbstat.blk_write_time.rate["{#DBNAME}"] Preprocessing: - JSONPATH: - MULTIPLIER: - CHANGE_PER_SECOND |
| PostgreSQL | DB {#DBNAME}: Num of accessexclusive locks | Number of accessexclusive locks for each database |
DEPENDENT | pgsql.locks.accessexclusive["{#DBNAME}"] Preprocessing: - JSONPATH: |
| PostgreSQL | DB {#DBNAME}: Num of accessshare locks | Number of accessshare locks for each database |
DEPENDENT | pgsql.locks.accessshare["{#DBNAME}"] Preprocessing: - JSONPATH: |
| PostgreSQL | DB {#DBNAME}: Num of exclusive locks | Number of exclusive locks for each database |
DEPENDENT | pgsql.locks.exclusive["{#DBNAME}"] Preprocessing: - JSONPATH: |
| PostgreSQL | DB {#DBNAME}: Num of rowexclusive locks | Number of rowexclusive locks for each database |
DEPENDENT | pgsql.locks.rowexclusive["{#DBNAME}"] Preprocessing: - JSONPATH: |
| PostgreSQL | DB {#DBNAME}: Num of rowshare locks | Number of rowshare locks for each database |
DEPENDENT | pgsql.locks.rowshare["{#DBNAME}"] Preprocessing: - JSONPATH: |
| PostgreSQL | DB {#DBNAME}: Num of sharerowexclusive locks | Number of total sharerowexclusive for each database |
DEPENDENT | pgsql.locks.sharerowexclusive["{#DBNAME}"] Preprocessing: - JSONPATH: |
| PostgreSQL | DB {#DBNAME}: Num of shareupdateexclusive locks | Number of shareupdateexclusive locks for each database |
DEPENDENT | pgsql.locks.shareupdateexclusive["{#DBNAME}"] Preprocessing: - JSONPATH: |
| PostgreSQL | DB {#DBNAME}: Num of share locks | Number of share locks for each database |
DEPENDENT | pgsql.locks.share["{#DBNAME}"] Preprocessing: - JSONPATH: |
| PostgreSQL | DB {#DBNAME}: Num of total locks | Number of total locks for each database |
DEPENDENT | pgsql.locks.total["{#DBNAME}"] Preprocessing: - JSONPATH: |
| PostgreSQL | DB {#DBNAME}: Queries max maintenance time | Max maintenance query time |
DEPENDENT | pgsql.queries.mro.time_max["{#DBNAME}"] Preprocessing: - JSONPATH: |
| PostgreSQL | DB {#DBNAME}: Queries max query time | Max query time |
DEPENDENT | pgsql.queries.query.time_max["{#DBNAME}"] Preprocessing: - JSONPATH: |
| PostgreSQL | DB {#DBNAME}: Queries max transaction time | Max transaction query time |
DEPENDENT | pgsql.queries.tx.time_max["{#DBNAME}"] Preprocessing: - JSONPATH: |
| PostgreSQL | DB {#DBNAME}: Queries slow maintenance count | Slow maintenance query count |
DEPENDENT | pgsql.queries.mro.slow_count["{#DBNAME}"] Preprocessing: - JSONPATH: |
| PostgreSQL | DB {#DBNAME}: Queries slow query count | Slow query count |
DEPENDENT | pgsql.queries.query.slow_count["{#DBNAME}"] Preprocessing: - JSONPATH: |
| PostgreSQL | DB {#DBNAME}: Queries slow transaction count | Slow transaction query count |
DEPENDENT | pgsql.queries.tx.slow_count["{#DBNAME}"] Preprocessing: - JSONPATH: |
| PostgreSQL | DB {#DBNAME}: Queries sum maintenance time | Sum maintenance query time |
DEPENDENT | pgsql.queries.mro.time_sum["{#DBNAME}"] Preprocessing: - JSONPATH: |
| PostgreSQL | DB {#DBNAME}: Queries sum query time | Sum query time |
DEPENDENT | pgsql.queries.query.time_sum["{#DBNAME}"] Preprocessing: - JSONPATH: |
| PostgreSQL | DB {#DBNAME}: Queries sum transaction time | Sum transaction query time |
DEPENDENT | pgsql.queries.tx.time_sum["{#DBNAME}"] Preprocessing: - JSONPATH: |
| Zabbix raw items | PostgreSQL: Get bgwriter | https://www.postgresql.org/docs/12/monitoring-stats.html#PG-STAT-BGWRITER-VIEW |
ZABBIX_PASSIVE | pgsql.bgwriter["{$PG.URI}","{$PG.USER}","{$PG.PASSWORD}"] |
| Zabbix raw items | PostgreSQL: Get archive | Collect archive status metrics |
ZABBIX_PASSIVE | pgsql.archive["{$PG.URI}","{$PG.USER}","{$PG.PASSWORD}"] |
| Zabbix raw items | PostgreSQL: Get dbstat | Collect all metrics from pg_stat_database per database https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-DATABASE-VIEW |
ZABBIX_PASSIVE | pgsql.dbstat["{$PG.URI}","{$PG.USER}","{$PG.PASSWORD}"] |
| Zabbix raw items | PostgreSQL: Get dbstat sum | Collect all metrics from pg_stat_database per database https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-DATABASE-VIEW |
ZABBIX_PASSIVE | pgsql.dbstat.sum["{$PG.URI}","{$PG.USER}","{$PG.PASSWORD}"] |
| Zabbix raw items | PostgreSQL: Get connections | Collect all metrics from pg_stat_activity https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-ACTIVITY-VIEW |
ZABBIX_PASSIVE | pgsql.connections["{$PG.URI}","{$PG.USER}","{$PG.PASSWORD}"] |
| Zabbix raw items | PostgreSQL: Get WAL | Collect WAL metrics |
ZABBIX_PASSIVE | pgsql.wal.stat["{$PG.URI}","{$PG.USER}","{$PG.PASSWORD}"] |
| Zabbix raw items | PostgreSQL: Get locks | Collect all metrics from pg_locks per database https://www.postgresql.org/docs/current/explicit-locking.html#LOCKING-TABLES |
ZABBIX_PASSIVE | pgsql.locks["{$PG.URI}","{$PG.USER}","{$PG.PASSWORD}"] |
| Zabbix raw items | PostgreSQL: Get replication | 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. |
ZABBIX_PASSIVE | pgsql.replication.process["{$PG.URI}","{$PG.USER}","{$PG.PASSWORD}"] |
| Zabbix raw items | PostgreSQL: Get queries | Collect all metrics by query execution time |
ZABBIX_PASSIVE | pgsql.queries["{$PG.URI}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}","{$PG.QUERY_ETIME.MAX.WARN}"] |
| Name | Description | Expression | Severity | Dependencies and additional info |
|---|---|---|---|---|
| Connections sum: Total number of connections is too high (over {$PG.CONN_TOTAL_PCT.MAX.WARN} in 5m) | - |
min(/PostgreSQL by Zabbix agent 2/pgsql.connections.total_pct,5m) > {$PG.CONN_TOTAL_PCT.MAX.WARN} |
AVERAGE | |
| PostgreSQL: Oldest xid is too big | - |
last(/PostgreSQL by Zabbix agent 2/pgsql.oldest.xid["{$PG.URI}","{$PG.USER}","{$PG.PASSWORD}"]) > 18000000 |
AVERAGE | |
| PostgreSQL: Service has been restarted (uptime={ITEM.LASTVALUE}) | - |
last(/PostgreSQL by Zabbix agent 2/pgsql.uptime["{$PG.URI}","{$PG.USER}","{$PG.PASSWORD}"]) < 600 |
AVERAGE | |
| PostgreSQL: Service is down | - |
last(/PostgreSQL by Zabbix agent 2/pgsql.ping["{$PG.URI}","{$PG.USER}","{$PG.PASSWORD}"])=0 |
HIGH | |
| DB {#DBNAME}: Too many recovery conflicts (over {$PG.CONFLICTS.MAX.WARN:"{#DBNAME}"} in 5m) | 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 |
min(/PostgreSQL by Zabbix agent 2/pgsql.dbstat.conflicts.rate["{#DBNAME}"],5m) > {$PG.CONFLICTS.MAX.WARN:"{#DBNAME}"} |
AVERAGE | |
| DB {#DBNAME}: Deadlock occurred (over {$PG.DEADLOCKS.MAX.WARN:"{#DBNAME}"} in 5m) | - |
min(/PostgreSQL by Zabbix agent 2/pgsql.dbstat.deadlocks.rate["{#DBNAME}"],5m) > {$PG.DEADLOCKS.MAX.WARN:"{#DBNAME}"} |
HIGH | |
| DB {#DBNAME}: Too many slow queries (over {$PG.SLOW_QUERIES.MAX.WARN:"{#DBNAME}"} in 5m) | - |
min(/PostgreSQL by Zabbix agent 2/pgsql.queries.query.slow_count["{#DBNAME}"],5m)>{$PG.SLOW_QUERIES.MAX.WARN:"{#DBNAME}"} |
WARNING |
Please report any issues with the template at https://support.zabbix.com
You can also provide feedback, discuss the template or ask for help with it at ZABBIX forums.
For Zabbix version: 5.0 and higher.
The template is developed to monitor DBMS PostgreSQL and its forks.
This template has been tested on:
See Zabbix template operation for basic instructions.
Deploy Zabbix agent2 with Postgres plugin.
Create PostgreSQL user to monitor (<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;
pg_hba.conf to allow connections from Zabbix agent:# TYPE DATABASE USER ADDRESS METHOD
host all zbx_monitor localhost md5
For more information please read the PostgreSQL documentation https://www.postgresql.org/docs/current/auth-pg-hba-conf.html.
Set in the {$PG.URI} macro the system data source name of the PostgreSQL instance such as <protocol(host:port)>.
Set the user name and password in host macros ({$PG.USER} and {$PG.PASSWORD}) if you want to override parameters from the Zabbix agent configuration file.
No specific Zabbix configuration is required.
| Name | Description | Default |
|---|---|---|
| {$PG.CONFLICTS.MAX.WARN} | - |
0 |
| {$PG.CONN_TOTAL_PCT.MAX.WARN} | - |
90 |
| {$PG.DATABASE} | - |
postgres |
| {$PG.DEADLOCKS.MAX.WARN} | - |
0 |
| {$PG.LLD.FILTER.APPLICATION} | - |
(.+) |
| {$PG.LLD.FILTER.DBNAME} | - |
(.+) |
| {$PG.PASSWORD} | - |
postgres |
| {$PG.QUERY_ETIME.MAX.WARN} | Execution time limit for count of slow queries. |
30 |
| {$PG.SLOW_QUERIES.MAX.WARN} | Slow queries count threshold for a trigger. |
5 |
| {$PG.URI} | - |
tcp://localhost:5432 |
| {$PG.USER} | - |
postgres |
There are no template links in this template.
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Replication Discovery | - |
ZABBIX_PASSIVE | pgsql.replication.process.discovery["{$PG.URI}","{$PG.USER}","{$PG.PASSWORD}"] Filter: AND- A: {#APPLICATION_NAME} MATCHES_REGEX |
| Database discovery | - |
ZABBIX_PASSIVE | pgsql.db.discovery["{$PG.URI}","{$PG.USER}","{$PG.PASSWORD}"] Filter: AND- A: {#DBNAME} MATCHES_REGEX |
| Group | Name | Description | Type | Key and additional info |
|---|---|---|---|---|
| PostgreSQL | PostgreSQL: Custom queries | Execute custom queries from file *.sql (check for option Plugins.Postgres.CustomQueriesPath at agent configuration) |
ZABBIX_PASSIVE | pgsql.custom.query["{$PG.URI}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}",""] |
| PostgreSQL | WAL: Bytes written | WAL write in bytes |
DEPENDENT | pgsql.wal.write Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | WAL: Bytes received | WAL receive in bytes |
DEPENDENT | pgsql.wal.receive Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | WAL: Segments count | Number of WAL segments |
DEPENDENT | pgsql.wal.count Preprocessing: - JSONPATH: |
| PostgreSQL | Bgwriter: Buffers allocated | Number of buffers allocated |
DEPENDENT | pgsql.bgwriter.buffers_alloc.rate Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | Bgwriter: Buffers written directly by a backend | Number of buffers written directly by a backend |
DEPENDENT | pgsql.bgwriter.buffers_backend.rate Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | Bgwriter: Number of bgwriter stopped | Number of times the background writer stopped a cleaning scan because it had written too many buffers |
DEPENDENT | pgsql.bgwriter.maxwritten_clean.rate Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | Bgwriter: Times a backend execute its own fsync | Number of times a backend had to execute its own fsync call (normally the background writer handles those even when the backend does its own write) |
DEPENDENT | pgsql.bgwriter.buffers_backend_fsync.rate Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | Checkpoint: Buffers background written | Number of buffers written by the background writer |
DEPENDENT | pgsql.bgwriter.buffers_clean.rate Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | Checkpoint: Buffers checkpoints written | Number of buffers written during checkpoints |
DEPENDENT | pgsql.bgwriter.buffers_checkpoint.rate Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | Checkpoint: By timeout | Number of scheduled checkpoints that have been performed |
DEPENDENT | pgsql.bgwriter.checkpoints_timed.rate Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | Checkpoint: Requested | Number of requested checkpoints that have been performed |
DEPENDENT | pgsql.bgwriter.checkpoints_req.rate Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | Checkpoint: Checkpoint write time | Total amount of time that has been spent in the portion of checkpoint processing where files are written to disk, in milliseconds |
DEPENDENT | pgsql.bgwriter.checkpoint_write_time.rate Preprocessing: - JSONPATH: - MULTIPLIER: - CHANGE_PER_SECOND |
| PostgreSQL | Checkpoint: Checkpoint write time | Total amount of time that has been spent in the portion of checkpoint processing where files are synchronized to disk, in milliseconds |
DEPENDENT | pgsql.bgwriter.checkpoint_sync_time.rate Preprocessing: - JSONPATH: - MULTIPLIER: - CHANGE_PER_SECOND |
| PostgreSQL | Checkpoint: Checkpoint sync time | Total amount of time that has been spent in the portion of checkpoint processing where files are synchronized to disk |
DEPENDENT | pgsql.bgwriter.checkpoint_sync_time.rate Preprocessing: - JSONPATH: - MULTIPLIER: - CHANGE_PER_SECOND |
| PostgreSQL | Archive: Count of archive files | Collect all metrics from pg_stat_activity https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-ARCHIVER-VIEW |
DEPENDENT | pgsql.archive.count_archived_files Preprocessing: - JSONPATH: |
| PostgreSQL | Archive: Count of attempts to archive files | Collect all metrics from pg_stat_activity https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-ARCHIVER-VIEW |
DEPENDENT | pgsql.archive.failed_trying_to_archive Preprocessing: - JSONPATH: |
| PostgreSQL | Archive: Count of files in archive_status need to archive | - |
DEPENDENT | pgsql.archive.count_files_to_archive Preprocessing: - JSONPATH: |
| PostgreSQL | Archive: Count of files need to archive | Size of files to archive |
DEPENDENT | pgsql.archive.size_files_to_archive Preprocessing: - JSONPATH: |
| PostgreSQL | Dbstat: Blocks read time | Time spent reading data file blocks by backends, in milliseconds |
DEPENDENT | pgsql.dbstat.sum.blk_read_time Preprocessing: - JSONPATH: - MULTIPLIER: |
| PostgreSQL | Dbstat: Blocks write time | Time spent writing data file blocks by backends, in milliseconds |
DEPENDENT | pgsql.dbstat.sum.blk_write_time Preprocessing: - JSONPATH: - MULTIPLIER: |
| PostgreSQL | Dbstat: Checksum failures | Number of data page checksum failures detected (or on a shared object), or NULL if data checksums are not enabled. This metric included in PostgreSQL 12 |
DEPENDENT | pgsql.dbstat.sum.checksum_failures.rate Preprocessing: - JSONPATH: - MATCHES_REGEX: - CHANGE_PER_SECOND |
| PostgreSQL | Dbstat: Committed transactions | Number of transactions that have been committed |
DEPENDENT | pgsql.dbstat.sum.xact_commit.rate Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | Dbstat: Conflicts | Number of queries canceled due to conflicts with recovery. (Conflicts occur only on standby servers; see pg_stat_database_conflicts for details.) |
DEPENDENT | pgsql.dbstat.sum.conflicts.rate Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | Dbstat: Deadlocks | Number of deadlocks detected |
DEPENDENT | pgsql.dbstat.sum.deadlocks.rate Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | Dbstat: Disk blocks read | Number of disk blocks read |
DEPENDENT | pgsql.dbstat.sum.blks_read.rate Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | Dbstat: Hit blocks read | Number of times disk blocks were found already in the buffer cache |
DEPENDENT | pgsql.dbstat.sum.blks_hit.rate Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | Dbstat: Number temp bytes | Total amount of data written to temporary files by queries |
DEPENDENT | pgsql.dbstat.sum.temp_bytes.rate Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | Dbstat: Number temp bytes | Number of temporary files created by queries |
DEPENDENT | pgsql.dbstat.sum.temp_files.rate Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | Dbstat: Roll backed transactions | Number of transactions that have been rolled back |
DEPENDENT | pgsql.dbstat.sum.xact_rollback.rate Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | Dbstat: Rows deleted | Number of rows deleted by queries |
DEPENDENT | pgsql.dbstat.sum.tup_deleted.rate Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | Dbstat: Rows fetched | Number of rows fetched by queries |
DEPENDENT | pgsql.dbstat.sum.tup_fetched.rate Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | Dbstat: Rows inserted | Number of rows inserted by queries |
DEPENDENT | pgsql.dbstat.sum.tup_inserted.rate Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | Dbstat: Rows returned | Number of rows returned by queries |
DEPENDENT | pgsql.dbstat.sum.tup_returned.rate Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | Dbstat: Rows updated | Number of rows updated by queries |
DEPENDENT | pgsql.dbstat.sum.tup_updated.rate Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | Dbstat: Backends connected | Number of connected backends |
DEPENDENT | pgsql.dbstat.sum.numbackends Preprocessing: - JSONPATH: |
| PostgreSQL | Connections sum: Active | Total number of connections executing a query |
DEPENDENT | pgsql.connections.active Preprocessing: - JSONPATH: |
| PostgreSQL | Connections sum: Fastpath function call | Total number of connections executing a fast-path function |
DEPENDENT | pgsql.connections.fastpath_function_call Preprocessing: - JSONPATH: |
| PostgreSQL | Connections sum: Idle | Total number of connections waiting for a new client command |
DEPENDENT | pgsql.connections.idle Preprocessing: - JSONPATH: |
| PostgreSQL | Connections sum: Idle in transaction | Total number of connections in a transaction state, but not executing a query |
DEPENDENT | pgsql.connections.idle_in_transaction Preprocessing: - JSONPATH: |
| PostgreSQL | Connections sum: Prepared | Total number of prepared transactions https://www.postgresql.org/docs/current/sql-prepare-transaction.html |
DEPENDENT | pgsql.connections.prepared Preprocessing: - JSONPATH: |
| PostgreSQL | Connections sum: Total | Total number of connections |
DEPENDENT | pgsql.connections.total Preprocessing: - JSONPATH: |
| PostgreSQL | Connections sum: Total % | Total number of connections in percentage |
DEPENDENT | pgsql.connections.total_pct Preprocessing: - JSONPATH: |
| PostgreSQL | Connections sum: Waiting | Total number of waiting connections https://www.postgresql.org/docs/current/monitoring-stats.html#WAIT-EVENT-TABLE |
DEPENDENT | pgsql.connections.waiting Preprocessing: - JSONPATH: |
| PostgreSQL | Connections sum: Idle in transaction (aborted) | Total number of connections in a transaction state, but not executing a query and one of the statements in the transaction caused an error. |
DEPENDENT | pgsql.connections.idle_in_transaction_aborted Preprocessing: - JSONPATH: |
| PostgreSQL | Connections sum: Disabled | Total number of disabled connections |
DEPENDENT | pgsql.connections.disabled Preprocessing: - JSONPATH: |
| PostgreSQL | PostgreSQL: Age of oldest xid | Age of oldest xid. |
ZABBIX_PASSIVE | pgsql.oldest.xid["{$PG.URI}","{$PG.USER}","{$PG.PASSWORD}"] |
| PostgreSQL | Autovacuum: Count of autovacuum workers | Number of autovacuum workers. |
ZABBIX_PASSIVE | pgsql.autovacuum.count["{$PG.URI}","{$PG.USER}","{$PG.PASSWORD}"] |
| PostgreSQL | PostgreSQL: Cache hit | - |
CALCULATED | pgsql.cache.hit["{$PG.URI}","{$PG.USER}","{$PG.PASSWORD}"] Expression: last("pgsql.dbstat.sum.blks_hit.rate") * 100 / (last("pgsql.dbstat.sum.blks_hit.rate") + last("pgsql.dbstat.sum.blks_read.rate")) |
| PostgreSQL | PostgreSQL: Uptime | - |
ZABBIX_PASSIVE | pgsql.uptime["{$PG.URI}","{$PG.USER}","{$PG.PASSWORD}"] |
| PostgreSQL | Replication: Lag in bytes | Replication lag with Master in byte. |
ZABBIX_PASSIVE | pgsql.replication.lag.b["{$PG.URI}","{$PG.USER}","{$PG.PASSWORD}"] |
| PostgreSQL | Replication: Lag in seconds | Replication lag with Master in seconds. |
ZABBIX_PASSIVE | pgsql.replication.lag.sec["{$PG.URI}","{$PG.USER}","{$PG.PASSWORD}"] |
| PostgreSQL | Replication: Recovery role | Replication role: 1 — recovery is still in progress (standby mode), 0 — master mode. |
ZABBIX_PASSIVE | pgsql.replication.recovery_role["{$PG.URI}","{$PG.USER}","{$PG.PASSWORD}"] |
| PostgreSQL | Replication: Standby count | Number of standby servers |
ZABBIX_PASSIVE | pgsql.replication.count["{$PG.URI}","{$PG.USER}","{$PG.PASSWORD}"] |
| PostgreSQL | Replication: Status | Replication status: 0 — streaming is down, 1 — streaming is up, 2 — master mode |
ZABBIX_PASSIVE | pgsql.replication.status["{$PG.URI}","{$PG.USER}","{$PG.PASSWORD}"] |
| PostgreSQL | PostgreSQL: Ping | - |
ZABBIX_PASSIVE | pgsql.ping["{$PG.URI}","{$PG.USER}","{$PG.PASSWORD}"] Preprocessing: - DISCARD_UNCHANGED_HEARTBEAT: |
| PostgreSQL | Application {#APPLICATION_NAME}: Replication flush lag | DEPENDENT | pgsql.replication.process.flush_lag["{#APPLICATION_NAME}"] Preprocessing: - JSONPATH: |
|
| PostgreSQL | Application {#APPLICATION_NAME}: Replication replay lag | DEPENDENT | pgsql.replication.process.replay_lag["{#APPLICATION_NAME}"] Preprocessing: - JSONPATH: |
|
| PostgreSQL | Application {#APPLICATION_NAME}: Replication write lag | DEPENDENT | pgsql.replication.process.write_lag["{#APPLICATION_NAME}"] Preprocessing: - JSONPATH: |
|
| PostgreSQL | DB {#DBNAME}: Database age | Database age |
ZABBIX_PASSIVE | pgsql.db.age["{$PG.URI}","{$PG.USER}","{$PG.PASSWORD}","{#DBNAME}"] |
| PostgreSQL | DB {#DBNAME}: Get bloating tables | Number of bloating tables |
ZABBIX_PASSIVE | pgsql.db.bloating_tables["{$PG.URI}","{$PG.USER}","{$PG.PASSWORD}","{#DBNAME}"] |
| PostgreSQL | DB {#DBNAME}: Database size | Database size |
ZABBIX_PASSIVE | pgsql.db.size["{$PG.URI}","{$PG.USER}","{$PG.PASSWORD}","{#DBNAME}"] |
| PostgreSQL | DB {#DBNAME}: Blocks hit per second | Total number of times disk blocks were found already in the buffer cache, so that a read was not necessary |
DEPENDENT | pgsql.dbstat.blks_hit.rate["{#DBNAME}"] Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | DB {#DBNAME}: Disk blocks read per second | Total number of disk blocks read in this database |
DEPENDENT | pgsql.dbstat.blks_read.rate["{#DBNAME}"] Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | DB {#DBNAME}: Detected conflicts per second | Total number of queries canceled due to conflicts with recovery in this database |
DEPENDENT | pgsql.dbstat.conflicts.rate["{#DBNAME}"] Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | DB {#DBNAME}: Detected deadlocks per second | Total number of detected deadlocks in this database |
DEPENDENT | pgsql.dbstat.deadlocks.rate["{#DBNAME}"] Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | DB {#DBNAME}: Temp_bytes written per second | Total amount of data written to temporary files by queries in this database |
DEPENDENT | pgsql.dbstat.temp_bytes.rate["{#DBNAME}"] Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | DB {#DBNAME}: Temp_files created per second | Total number of temporary files created by queries in this database |
DEPENDENT | pgsql.dbstat.temp_files.rate["{#DBNAME}"] Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | DB {#DBNAME}: Tuples deleted per second | Total number of rows deleted by queries in this database |
DEPENDENT | pgsql.dbstat.tup_deleted.rate["{#DBNAME}"] Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | DB {#DBNAME}: Tuples fetched per second | Total number of rows fetched by queries in this database |
DEPENDENT | pgsql.dbstat.tup_fetched.rate["{#DBNAME}"] Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | DB {#DBNAME}: Tuples inserted per second | Total number of rows inserted by queries in this database |
DEPENDENT | pgsql.dbstat.tup_inserted.rate["{#DBNAME}"] Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | DB {#DBNAME}: Tuples returned per second | Number of rows returned by queries in this database |
DEPENDENT | pgsql.dbstat.tup_returned.rate["{#DBNAME}"] Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | DB {#DBNAME}: Tuples updated per second | Total number of rows updated by queries in this database |
DEPENDENT | pgsql.dbstat.tup_updated.rate["{#DBNAME}"] Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | DB {#DBNAME}: Commits per second | Number of transactions in this database that have been committed |
DEPENDENT | pgsql.dbstat.xact_commit.rate["{#DBNAME}"] Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | DB {#DBNAME}: Rollbacks per second | Total number of transactions in this database that have been rolled back |
DEPENDENT | pgsql.dbstat.xact_rollback.rate["{#DBNAME}"] Preprocessing: - JSONPATH: - CHANGE_PER_SECOND |
| PostgreSQL | DB {#DBNAME}: Backends connected | Number of backends currently connected to this database |
DEPENDENT | pgsql.dbstat.numbackends["{#DBNAME}"] Preprocessing: - JSONPATH: |
| PostgreSQL | DB {#DBNAME}: Checksum failures | Number of data page checksum failures detected in this database |
DEPENDENT | pgsql.dbstat.checksum_failures.rate["{#DBNAME}"] Preprocessing: - JSONPATH: - MATCHES_REGEX: - CHANGE_PER_SECOND |
| PostgreSQL | DB {#DBNAME}: Disk blocks read time | Time spent reading data file blocks by backends, in milliseconds |
DEPENDENT | pgsql.dbstat.blk_read_time.rate["{#DBNAME}"] Preprocessing: - JSONPATH: - MULTIPLIER: - CHANGE_PER_SECOND |
| PostgreSQL | DB {#DBNAME}: Disk blocks write time | Time spent writing data file blocks by backends, in milliseconds |
DEPENDENT | pgsql.dbstat.blk_write_time.rate["{#DBNAME}"] Preprocessing: - JSONPATH: - MULTIPLIER: - CHANGE_PER_SECOND |
| PostgreSQL | DB {#DBNAME}: Num of accessexclusive locks | Number of accessexclusive locks for each database |
DEPENDENT | pgsql.locks.accessexclusive["{#DBNAME}"] Preprocessing: - JSONPATH: |
| PostgreSQL | DB {#DBNAME}: Num of accessshare locks | Number of accessshare locks for each database |
DEPENDENT | pgsql.locks.accessshare["{#DBNAME}"] Preprocessing: - JSONPATH: |
| PostgreSQL | DB {#DBNAME}: Num of exclusive locks | Number of exclusive locks for each database |
DEPENDENT | pgsql.locks.exclusive["{#DBNAME}"] Preprocessing: - JSONPATH: |
| PostgreSQL | DB {#DBNAME}: Num of rowexclusive locks | Number of rowexclusive locks for each database |
DEPENDENT | pgsql.locks.rowexclusive["{#DBNAME}"] Preprocessing: - JSONPATH: |
| PostgreSQL | DB {#DBNAME}: Num of rowshare locks | Number of rowshare locks for each database |
DEPENDENT | pgsql.locks.rowshare["{#DBNAME}"] Preprocessing: - JSONPATH: |
| PostgreSQL | DB {#DBNAME}: Num of sharerowexclusive locks | Number of total sharerowexclusive for each database |
DEPENDENT | pgsql.locks.sharerowexclusive["{#DBNAME}"] Preprocessing: - JSONPATH: |
| PostgreSQL | DB {#DBNAME}: Num of shareupdateexclusive locks | Number of shareupdateexclusive locks for each database |
DEPENDENT | pgsql.locks.shareupdateexclusive["{#DBNAME}"] Preprocessing: - JSONPATH: |
| PostgreSQL | DB {#DBNAME}: Num of share locks | Number of share locks for each database |
DEPENDENT | pgsql.locks.share["{#DBNAME}"] Preprocessing: - JSONPATH: |
| PostgreSQL | DB {#DBNAME}: Num of total locks | Number of total locks for each database |
DEPENDENT | pgsql.locks.total["{#DBNAME}"] Preprocessing: - JSONPATH: |
| PostgreSQL | DB {#DBNAME}: Queries max maintenance time | Max maintenance query time |
DEPENDENT | pgsql.queries.mro.time_max["{#DBNAME}"] Preprocessing: - JSONPATH: |
| PostgreSQL | DB {#DBNAME}: Queries max query time | Max query time |
DEPENDENT | pgsql.queries.query.time_max["{#DBNAME}"] Preprocessing: - JSONPATH: |
| PostgreSQL | DB {#DBNAME}: Queries max transaction time | Max transaction query time |
DEPENDENT | pgsql.queries.tx.time_max["{#DBNAME}"] Preprocessing: - JSONPATH: |
| PostgreSQL | DB {#DBNAME}: Queries slow maintenance count | Slow maintenance query count |
DEPENDENT | pgsql.queries.mro.slow_count["{#DBNAME}"] Preprocessing: - JSONPATH: |
| PostgreSQL | DB {#DBNAME}: Queries slow query count | Slow query count |
DEPENDENT | pgsql.queries.query.slow_count["{#DBNAME}"] Preprocessing: - JSONPATH: |
| PostgreSQL | DB {#DBNAME}: Queries slow transaction count | Slow transaction query count |
DEPENDENT | pgsql.queries.tx.slow_count["{#DBNAME}"] Preprocessing: - JSONPATH: |
| PostgreSQL | DB {#DBNAME}: Queries sum maintenance time | Sum maintenance query time |
DEPENDENT | pgsql.queries.mro.time_sum["{#DBNAME}"] Preprocessing: - JSONPATH: |
| PostgreSQL | DB {#DBNAME}: Queries sum query time | Sum query time |
DEPENDENT | pgsql.queries.query.time_sum["{#DBNAME}"] Preprocessing: - JSONPATH: |
| PostgreSQL | DB {#DBNAME}: Queries sum transaction time | Sum transaction query time |
DEPENDENT | pgsql.queries.tx.time_sum["{#DBNAME}"] Preprocessing: - JSONPATH: |
| Zabbix_raw_items | PostgreSQL: Get bgwriter | https://www.postgresql.org/docs/12/monitoring-stats.html#PG-STAT-BGWRITER-VIEW |
ZABBIX_PASSIVE | pgsql.bgwriter["{$PG.URI}","{$PG.USER}","{$PG.PASSWORD}"] |
| Zabbix_raw_items | PostgreSQL: Get archive | Collect archive status metrics |
ZABBIX_PASSIVE | pgsql.archive["{$PG.URI}","{$PG.USER}","{$PG.PASSWORD}"] |
| Zabbix_raw_items | PostgreSQL: Get dbstat | Collect all metrics from pg_stat_database per database https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-DATABASE-VIEW |
ZABBIX_PASSIVE | pgsql.dbstat["{$PG.URI}","{$PG.USER}","{$PG.PASSWORD}"] |
| Zabbix_raw_items | PostgreSQL: Get dbstat sum | Collect all metrics from pg_stat_database per database https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-DATABASE-VIEW |
ZABBIX_PASSIVE | pgsql.dbstat.sum["{$PG.URI}","{$PG.USER}","{$PG.PASSWORD}"] |
| Zabbix_raw_items | PostgreSQL: Get connections | Collect all metrics from pg_stat_activity https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-ACTIVITY-VIEW |
ZABBIX_PASSIVE | pgsql.connections["{$PG.URI}","{$PG.USER}","{$PG.PASSWORD}"] |
| Zabbix_raw_items | PostgreSQL: Get WAL | Collect WAL metrics |
ZABBIX_PASSIVE | pgsql.wal.stat["{$PG.URI}","{$PG.USER}","{$PG.PASSWORD}"] |
| Zabbix_raw_items | PostgreSQL: Get locks | Collect all metrics from pg_locks per database https://www.postgresql.org/docs/current/explicit-locking.html#LOCKING-TABLES |
ZABBIX_PASSIVE | pgsql.locks["{$PG.URI}","{$PG.USER}","{$PG.PASSWORD}"] |
| Zabbix_raw_items | PostgreSQL: Get replication | 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. |
ZABBIX_PASSIVE | pgsql.replication.process["{$PG.URI}","{$PG.USER}","{$PG.PASSWORD}"] |
| Zabbix_raw_items | PostgreSQL: Get queries | Collect all metrics by query execution time |
ZABBIX_PASSIVE | pgsql.queries["{$PG.URI}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}","{$PG.QUERY_ETIME.MAX.WARN}"] |
| Name | Description | Expression | Severity | Dependencies and additional info |
|---|---|---|---|---|
| Dbstat: Checksum failures detected | Data page checksum failures were detected on that DB instance. https://www.postgresql.org/docs/current/checksums.html |
{TEMPLATE_NAME:pgsql.dbstat.sum.checksum_failures.rate.last()}>0 |
AVERAGE | |
| Connections sum: Total number of connections is too high (over {$PG.CONN_TOTAL_PCT.MAX.WARN} in 5m) | - |
{TEMPLATE_NAME:pgsql.connections.total_pct.min(5m)} > {$PG.CONN_TOTAL_PCT.MAX.WARN} |
AVERAGE | |
| PostgreSQL: Oldest xid is too big | - |
{TEMPLATE_NAME:pgsql.oldest.xid["{$PG.URI}","{$PG.USER}","{$PG.PASSWORD}"].last()} > 18000000 |
AVERAGE | |
| PostgreSQL: Service has been restarted (uptime={ITEM.LASTVALUE}) | - |
{TEMPLATE_NAME:pgsql.uptime["{$PG.URI}","{$PG.USER}","{$PG.PASSWORD}"].last()} < 600 |
AVERAGE | |
| PostgreSQL: Service is down | - |
{TEMPLATE_NAME:pgsql.ping["{$PG.URI}","{$PG.USER}","{$PG.PASSWORD}"].last()}=0 |
HIGH | |
| DB {#DBNAME}: Too many recovery conflicts (over {$PG.CONFLICTS.MAX.WARN:"{#DBNAME}"} in 5m) | 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 |
{TEMPLATE_NAME:pgsql.dbstat.conflicts.rate["{#DBNAME}"].min(5m)} > {$PG.CONFLICTS.MAX.WARN:"{#DBNAME}"} |
AVERAGE | |
| DB {#DBNAME}: Deadlock occurred (over {$PG.DEADLOCKS.MAX.WARN:"{#DBNAME}"} in 5m) | - |
{TEMPLATE_NAME:pgsql.dbstat.deadlocks.rate["{#DBNAME}"].min(5m)} > {$PG.DEADLOCKS.MAX.WARN:"{#DBNAME}"} |
HIGH | |
| DB {#DBNAME}: Checksum failures detected | Data page checksum failures were detected on that database. https://www.postgresql.org/docs/current/checksums.html |
{TEMPLATE_NAME:pgsql.dbstat.checksum_failures.rate["{#DBNAME}"].last()}>0 |
AVERAGE | |
| DB {#DBNAME}: Too many slow queries (over {$PG.SLOW_QUERIES.MAX.WARN:"{#DBNAME}"} in 5m) | - |
{TEMPLATE_NAME:pgsql.queries.query.slow_count["{#DBNAME}"].min(5m)}>{$PG.SLOW_QUERIES.MAX.WARN:"{#DBNAME}"} |
WARNING |
Please report any issues with the template at https://support.zabbix.com.
Source: https://git.zabbix.com/projects/ZBX/repos/zabbix/browse/templates/db/postgresql_odbc?at=release/7.4
This template is designed for the effortless deployment of PostgreSQL monitoring by Zabbix via ODBC and doesn't require any external scripts.
Zabbix version: 7.4 and higher.
This template has been tested on:
Zabbix should be configured according to the instructions in the Templates out of the box section.
<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;
pg_hba.conf configuration file to allow TCP connections for the user zbx_monitor. For example, you could add one of the following rows to allow local connections from the same host:# TYPE DATABASE USER ADDRESS METHOD
host all zbx_monitor localhost trust
host all zbx_monitor 127.0.0.1/32 md5
host all zbx_monitor ::1/128 scram-sha-256
For more information please read the PostgreSQL documentation https://www.postgresql.org/docs/current/auth-pg-hba-conf.html.
Install the PostgreSQL ODBC driver. Check the Zabbix documentation for details about ODBC checks and recommended parameters page.
Set up the connection string with the {$PG.CONNSTRING.ODBC} 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.Note: 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 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
{$PG.PASSWORD}.| Name | Description | Default |
|---|---|---|
| {$PG.CONNSTRING.ODBC} | Connection string for the PostgreSQL instance. |
Macro too long. Please see the template. |
| {$PG.USER} | PostgreSQL username. |
zbx_monitor |
| {$PG.PASSWORD} | PostgreSQL user password. |
|
| {$PG.DATABASE} | Default PostgreSQL database for the connection. |
postgres |
| {$PG.LLD.FILTER.DBNAME} | Filter of discoverable databases. |
.+ |
| {$PG.LLD.FILTER.APPLICATION} | Filter of discoverable applications. |
.+ |
| {$PG.DEADLOCKS.MAX.WARN} | Maximum number of detected deadlocks for trigger expression. |
0 |
| {$PG.CONN_TOTAL_PCT.MAX.WARN} | Maximum percentage of current connections for trigger expression. |
90 |
| {$PG.CONFLICTS.MAX.WARN} | Maximum number of recovery conflicts for trigger expression. |
0 |
| {$PG.QUERY_ETIME.MAX.WARN} | Execution time limit for count of slow queries. |
30 |
| {$PG.SLOW_QUERIES.MAX.WARN} | Slow queries count threshold for a trigger. |
5 |
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Get archive | Collect archive status metrics. |
Database monitor | db.odbc.select[pgsql.archive,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] |
| Get dbstat | Collect all metrics from pg_stat_database per database: https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-DATABASE-VIEW |
Database monitor | db.odbc.select[pgsql.dbstat,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] |
| Get dbstat sum | 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 |
Database monitor | db.odbc.select[pgsql.dbstat.sum,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] |
| Get connections sum | Collect all metrics from pg_stat_activity: https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-ACTIVITY-VIEW |
Database monitor | db.odbc.select[pgsql.connections.sum,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] |
| Get WAL | Collect write-ahead log (WAL) metrics. |
Database monitor | db.odbc.select[pgsql.wal.stat,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] |
| Get locks | Collect all metrics from pg_locks per database: https://www.postgresql.org/docs/current/explicit-locking.html#LOCKING-TABLES |
Database monitor | db.odbc.select[pgsql.locks,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] |
| Get replication | 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. |
Database monitor | db.odbc.select[pgsql.replication.process,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] Preprocessing
|
| Get queries | Collect all metrics by query execution time. |
Database monitor | db.odbc.select[pgsql.queries,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] |
| Version | PostgreSQL version. |
Database monitor | db.odbc.select[pgsql.version,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] Preprocessing
|
| Version (numeric) | Reports the version number of the server as an integer. |
Database monitor | db.odbc.select[pgsql.version.num,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] Preprocessing
|
| Bgwriter LLD | LLD data for "bgwriter" metrics discovery. |
Dependent item | pgsql.bgwriter.lld Preprocessing
|
| WAL: Bytes written | WAL write, in bytes. |
Dependent item | pgsql.wal.write Preprocessing
|
| WAL: Bytes received | WAL receive, in bytes. |
Dependent item | pgsql.wal.receive Preprocessing
|
| WAL: Segments count | Number of WAL segments. |
Dependent item | pgsql.wal.count Preprocessing
|
| Archive: Count of archived files | Count of archived files. |
Dependent item | pgsql.archive.count_archived_files Preprocessing
|
| Archive: Count of failed attempts to archive files | Count of failed attempts to archive files. |
Dependent item | pgsql.archive.failed_trying_to_archive Preprocessing
|
| Archive: Count of files in archive_status need to archive | Count of files to archive. |
Dependent item | pgsql.archive.count_files_to_archive Preprocessing
|
| Archive: Size of files need to archive | Size of files to archive. |
Dependent item | pgsql.archive.size_files_to_archive Preprocessing
|
| Dbstat: Blocks read time | Time spent reading data file blocks by backends. |
Dependent item | pgsql.dbstat.sum.blk_read_time Preprocessing
|
| Dbstat: Blocks write time | Time spent writing data file blocks by backends. |
Dependent item | pgsql.dbstat.sum.blk_write_time Preprocessing
|
| Dbstat: Committed transactions per second | Number of transactions that have been committed per second. |
Dependent item | pgsql.dbstat.sum.xact_commit.rate Preprocessing
|
| Dbstat: Conflicts per second | Number of queries canceled per second due to conflicts with recovery (conflicts occur only on standby servers; see pg_stat_database_conflicts for details). |
Dependent item | pgsql.dbstat.sum.conflicts.rate Preprocessing
|
| Dbstat: Deadlocks per second | Number of deadlocks detected per second. |
Dependent item | pgsql.dbstat.sum.deadlocks.rate Preprocessing
|
| Dbstat: Disk blocks read per second | Number of disk blocks read per second. |
Dependent item | pgsql.dbstat.sum.blks_read.rate Preprocessing
|
| Dbstat: Hit blocks read per second | Number of times per second disk blocks were found already in the buffer cache. |
Dependent item | pgsql.dbstat.sum.blks_hit.rate Preprocessing
|
| Dbstat: Number temp bytes per second | Total amount of data written per second to temporary files by queries. |
Dependent item | pgsql.dbstat.sum.temp_bytes.rate Preprocessing
|
| Dbstat: Number temp files per second | Number of temporary files created by queries per second. |
Dependent item | pgsql.dbstat.sum.temp_files.rate Preprocessing
|
| Dbstat: Roll backed transactions per second | Number of transactions that have been rolled back per second. |
Dependent item | pgsql.dbstat.sum.xact_rollback.rate Preprocessing
|
| Dbstat: Rows deleted per second | Number of rows deleted by queries per second. |
Dependent item | pgsql.dbstat.sum.tup_deleted.rate Preprocessing
|
| Dbstat: Rows fetched per second | Number of rows fetched by queries per second. |
Dependent item | pgsql.dbstat.sum.tup_fetched.rate Preprocessing
|
| Dbstat: Rows inserted per second | Number of rows inserted by queries per second. |
Dependent item | pgsql.dbstat.sum.tup_inserted.rate Preprocessing
|
| Dbstat: Rows returned per second | Number of rows returned by queries per second. |
Dependent item | pgsql.dbstat.sum.tup_returned.rate Preprocessing
|
| Dbstat: Rows updated per second | Number of rows updated by queries per second. |
Dependent item | pgsql.dbstat.sum.tup_updated.rate Preprocessing
|
| Dbstat: Backends connected | Number of connected backends. |
Dependent item | pgsql.dbstat.sum.numbackends Preprocessing
|
| Connections sum: Active | Total number of connections executing a query. |
Dependent item | pgsql.connections.sum.active Preprocessing
|
| Connections sum: Fastpath function call | Total number of connections executing a fast-path function. |
Dependent item | pgsql.connections.sum.fastpath_function_call Preprocessing
|
| Connections sum: Idle | Total number of connections waiting for a new client command. |
Dependent item | pgsql.connections.sum.idle Preprocessing
|
| Connections sum: Idle in transaction | Total number of connections in a transaction state but not executing a query. |
Dependent item | pgsql.connections.sum.idle_in_transaction Preprocessing
|
| Connections sum: Prepared | Total number of prepared transactions: https://www.postgresql.org/docs/current/sql-prepare-transaction.html |
Dependent item | pgsql.connections.sum.prepared Preprocessing
|
| Connections sum: Total | Total number of connections. |
Dependent item | pgsql.connections.sum.total Preprocessing
|
| Connections sum: Total, % | Total number of connections, in percentage. |
Dependent item | pgsql.connections.sum.total_pct Preprocessing
|
| Connections sum: Waiting | Total number of waiting connections: https://www.postgresql.org/docs/current/monitoring-stats.html#WAIT-EVENT-TABLE |
Dependent item | pgsql.connections.sum.waiting Preprocessing
|
| Connections sum: Idle in transaction (aborted) | 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. |
Dependent item | pgsql.connections.sum.idle_in_transaction_aborted Preprocessing
|
| Connections sum: Disabled | Total number of disabled connections. |
Dependent item | pgsql.connections.sum.disabled Preprocessing
|
| Age of oldest xid | Age of oldest xid. |
Database monitor | db.odbc.select[pgsql.oldest.xid,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] |
| Count of autovacuum workers | Number of autovacuum workers. |
Database monitor | db.odbc.select[pgsql.autovacuum.count,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] |
| Cache hit ratio, % | Cache hit ratio. |
Calculated | pgsql.cache.hit |
| Uptime | Time since the server started. |
Database monitor | db.odbc.select[pgsql.uptime,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] |
| Replication: Lag in bytes | Replication lag with master, in bytes. |
Database monitor | db.odbc.select[pgsql.replication.lag.b,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] |
| Replication: Lag in seconds | Replication lag with master, in seconds. |
Database monitor | db.odbc.select[pgsql.replication.lag.sec,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] |
| Replication: Recovery role | Replication role: 1 — recovery is still in progress (standby mode), 0 — master mode. |
Database monitor | db.odbc.select[pgsql.replication.recovery_role,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] |
| Replication: Standby count | Number of standby servers. |
Database monitor | db.odbc.select[pgsql.replication.count,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] |
| Replication: Status | Replication status: 0 — streaming is down, 1 — streaming is up, 2 — master mode. |
Database monitor | db.odbc.select[pgsql.replication.status,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] |
| Ping | Used to test a connection to see if it is alive. It is set to 0 if the query is unsuccessful. |
Database monitor | db.odbc.select[pgsql.ping,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] Preprocessing
|
| Name | Description | Expression | Severity | Dependencies and additional info |
|---|---|---|---|---|
| PostgreSQL: Version has changed | last(/PostgreSQL by ODBC/db.odbc.select[pgsql.version,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"],#1)<>last(/PostgreSQL by ODBC/db.odbc.select[pgsql.version,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"],#2) and length(last(/PostgreSQL by ODBC/db.odbc.select[pgsql.version,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"]))>0 |
Info | ||
| PostgreSQL: Total number of connections is too high | 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). |
min(/PostgreSQL by ODBC/pgsql.connections.sum.total_pct,5m) > {$PG.CONN_TOTAL_PCT.MAX.WARN} |
Average | |
| PostgreSQL: Oldest xid is too big | last(/PostgreSQL by ODBC/db.odbc.select[pgsql.oldest.xid,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"]) > 18000000 |
Average | ||
| PostgreSQL: Service has been restarted | PostgreSQL uptime is less than 10 minutes. |
last(/PostgreSQL by ODBC/db.odbc.select[pgsql.uptime,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"]) < 10m |
Average | |
| PostgreSQL: Service is down | Last test of a connection was unsuccessful. |
last(/PostgreSQL by ODBC/db.odbc.select[pgsql.ping,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"])=0 |
High |
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Replication discovery | Discovers replication lag metrics. |
Database monitor | db.odbc.select[pgsql.replication.process.discovery,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] Preprocessing
|
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Application [{#APPLICATION_NAME}]: Get replication | 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. |
Dependent item | pgsql.replication.get_metrics["{#APPLICATION_NAME}"] Preprocessing
|
| Application [{#APPLICATION_NAME}]: Replication flush lag | 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. |
Dependent item | pgsql.replication.process.flush_lag["{#APPLICATION_NAME}"] Preprocessing
|
| Application [{#APPLICATION_NAME}]: Replication replay lag | 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. |
Dependent item | pgsql.replication.process.replay_lag["{#APPLICATION_NAME}"] Preprocessing
|
| Application [{#APPLICATION_NAME}]: Replication write lag | 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. |
Dependent item | pgsql.replication.process.write_lag["{#APPLICATION_NAME}"] Preprocessing
|
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Database discovery | Discovers databases (DB) in the database management system (DBMS), except: - templates; - default "postgres" DB; - DBs that do not allow connections. |
Database monitor | db.odbc.select[pgsql.db.discovery,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] |
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| DB [{#DBNAME}]: Get dbstat | Get dbstat metrics for database "{#DBNAME}". |
Dependent item | pgsql.dbstat.get_metrics["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Get locks | Get locks metrics for database "{#DBNAME}". |
Dependent item | pgsql.locks.get_metrics["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Get queries | Get queries metrics for database "{#DBNAME}". |
Dependent item | pgsql.queries.get_metrics["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Database age | Database age. |
Database monitor | db.odbc.select[pgsql.db.age,,"Database={#DBNAME};{$PG.CONNSTRING.ODBC}"] |
| DB [{#DBNAME}]: Bloating tables | Number of bloating tables. |
Database monitor | db.odbc.select[pgsql.db.bloating_tables,,"Database={#DBNAME};{$PG.CONNSTRING.ODBC}"] |
| DB [{#DBNAME}]: Database size | Database size. |
Database monitor | db.odbc.select[pgsql.db.size,,"Database={#DBNAME};{$PG.CONNSTRING.ODBC}"] |
| DB [{#DBNAME}]: Blocks hit per second | Total number of times per second disk blocks were found already in the buffer cache, so that a read was not necessary. |
Dependent item | pgsql.dbstat.blks_hit.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Disk blocks read per second | Total number of disk blocks read per second in this database. |
Dependent item | pgsql.dbstat.blks_read.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Detected conflicts per second | Total number of queries canceled due to conflicts with recovery in this database per second. |
Dependent item | pgsql.dbstat.conflicts.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Detected deadlocks per second | Total number of detected deadlocks in this database per second. |
Dependent item | pgsql.dbstat.deadlocks.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Temp_bytes written per second | Total amount of data written to temporary files by queries in this database. |
Dependent item | pgsql.dbstat.temp_bytes.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Temp_files created per second | Total number of temporary files created by queries in this database. |
Dependent item | pgsql.dbstat.temp_files.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Tuples deleted per second | Total number of rows deleted by queries in this database per second. |
Dependent item | pgsql.dbstat.tup_deleted.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Tuples fetched per second | Total number of rows fetched by queries in this database per second. |
Dependent item | pgsql.dbstat.tup_fetched.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Tuples inserted per second | Total number of rows inserted by queries in this database per second. |
Dependent item | pgsql.dbstat.tup_inserted.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Tuples returned per second | Number of rows returned by queries in this database per second. |
Dependent item | pgsql.dbstat.tup_returned.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Tuples updated per second | Total number of rows updated by queries in this database per second. |
Dependent item | pgsql.dbstat.tup_updated.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Commits per second | Number of transactions in this database that have been committed per second. |
Dependent item | pgsql.dbstat.xact_commit.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Rollbacks per second | Total number of transactions in this database that have been rolled back. |
Dependent item | pgsql.dbstat.xact_rollback.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Backends connected | Number of backends currently connected to this database. |
Dependent item | pgsql.dbstat.numbackends["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Disk blocks read time per second | Time spent reading data file blocks by backends per second. |
Dependent item | pgsql.dbstat.blk_read_time.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Disk blocks write time per second | Time spent writing data file blocks by backends per second. |
Dependent item | pgsql.dbstat.blk_write_time.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Num of accessexclusive locks | Number of accessexclusive locks for this database. |
Dependent item | pgsql.locks.accessexclusive["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Num of accessshare locks | Number of accessshare locks for this database. |
Dependent item | pgsql.locks.accessshare["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Num of exclusive locks | Number of exclusive locks for this database. |
Dependent item | pgsql.locks.exclusive["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Num of rowexclusive locks | Number of rowexclusive locks for this database. |
Dependent item | pgsql.locks.rowexclusive["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Num of rowshare locks | Number of rowshare locks for this database. |
Dependent item | pgsql.locks.rowshare["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Num of sharerowexclusive locks | Number of total sharerowexclusive for this database. |
Dependent item | pgsql.locks.sharerowexclusive["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Num of shareupdateexclusive locks | Number of shareupdateexclusive locks for this database. |
Dependent item | pgsql.locks.shareupdateexclusive["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Num of share locks | Number of share locks for this database. |
Dependent item | pgsql.locks.share["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Num of locks total | Total number of locks in this database. |
Dependent item | pgsql.locks.total["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries max maintenance time | Max maintenance query time for this database. |
Dependent item | pgsql.queries.mro.time_max["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries max query time | Max query time for this database. |
Dependent item | pgsql.queries.query.time_max["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries max transaction time | Max transaction query time for this database. |
Dependent item | pgsql.queries.tx.time_max["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries slow maintenance count | Slow maintenance query count for this database. |
Dependent item | pgsql.queries.mro.slow_count["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries slow query count | Slow query count for this database. |
Dependent item | pgsql.queries.query.slow_count["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries slow transaction count | Slow transaction query count for this database. |
Dependent item | pgsql.queries.tx.slow_count["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries sum maintenance time | Sum maintenance query time for this database. |
Dependent item | pgsql.queries.mro.time_sum["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries sum query time | Sum query time for this database. |
Dependent item | pgsql.queries.query.time_sum["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries sum transaction time | Sum transaction query time for this database. |
Dependent item | pgsql.queries.tx.time_sum["{#DBNAME}"] Preprocessing
|
| Name | Description | Expression | Severity | Dependencies and additional info |
|---|---|---|---|---|
| PostgreSQL: DB [{#DBNAME}]: Too many recovery conflicts | 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. |
min(/PostgreSQL by ODBC/pgsql.dbstat.conflicts.rate["{#DBNAME}"],5m) > {$PG.CONFLICTS.MAX.WARN:"{#DBNAME}"} |
Average | |
| PostgreSQL: DB [{#DBNAME}]: Deadlock occurred | Number of deadlocks detected per second exceeds {$PG.DEADLOCKS.MAX.WARN:"{#DBNAME}"} for 5m. |
min(/PostgreSQL by ODBC/pgsql.dbstat.deadlocks.rate["{#DBNAME}"],5m) > {$PG.DEADLOCKS.MAX.WARN:"{#DBNAME}"} |
High | |
| PostgreSQL: DB [{#DBNAME}]: Too many slow queries | The number of detected slow queries exceeds the limit of {$PG.SLOW_QUERIES.MAX.WARN:"{#DBNAME}"}. |
min(/PostgreSQL by ODBC/pgsql.queries.query.slow_count["{#DBNAME}"],5m)>{$PG.SLOW_QUERIES.MAX.WARN:"{#DBNAME}"} |
Warning |
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Bgwriter metrics discovery (versions below 17) | Discovers "bgwriter" metrics for PostgreSQL below version 17. |
Dependent item | pgsql.bgwriter.below_17.discovery |
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Get bgwriter{#SINGLETON} | Collect all metrics from pg_stat_bgwriter: https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-BGWRITER-VIEW |
Database monitor | db.odbc.select[pgsql.bgwriter.below_17{#SINGLETON},,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] |
| Bgwriter: Buffers allocated per second{#SINGLETON} | Number of buffers allocated per second. |
Dependent item | pgsql.bgwriter.buffers_alloc.rate.below_17[{#SINGLETON}] Preprocessing
|
| Bgwriter: Number of bgwriter cleaning scan stopped per second{#SINGLETON} | Number of times the background writer stopped a cleaning scan because it had written too many buffers per second. |
Dependent item | pgsql.bgwriter.maxwritten_clean.rate.below_17[{#SINGLETON}] Preprocessing
|
| Checkpoint: Buffers written by the background writer per second{#SINGLETON} | Number of buffers written by the background writer per second. |
Dependent item | pgsql.bgwriter.buffers_clean.rate.below_17[{#SINGLETON}] Preprocessing
|
| Checkpoint: Buffers written during checkpoints per second{#SINGLETON} | Number of buffers written during checkpoints per second. |
Dependent item | pgsql.bgwriter.buffers_checkpoint.rate.below_17[{#SINGLETON}] Preprocessing
|
| Checkpoint: Scheduled per second{#SINGLETON} | Number of scheduled checkpoints that have been performed per second. |
Dependent item | pgsql.bgwriter.checkpoints_timed.rate.below_17[{#SINGLETON}] Preprocessing
|
| Checkpoint: Requested per second{#SINGLETON} | Number of requested checkpoints that have been performed per second. |
Dependent item | pgsql.bgwriter.checkpoints_req.rate.below_17[{#SINGLETON}] Preprocessing
|
| Checkpoint: Checkpoint write time per second{#SINGLETON} | Total amount of time per second that has been spent in the portion of checkpoint processing where files are written to disk. |
Dependent item | pgsql.bgwriter.checkpoint_write_time.rate.below_17[{#SINGLETON}] Preprocessing
|
| Bgwriter: Checkpoint sync time per second{#SINGLETON} | Total amount of time per second that has been spent in the portion of checkpoint processing where files are synchronized to disk. |
Dependent item | pgsql.bgwriter.checkpoint_sync_time.rate.below_17[{#SINGLETON}] Preprocessing
|
| Bgwriter: Buffers written directly by a backend per second{#SINGLETON} | Number of buffers written directly by a backend per second. |
Dependent item | pgsql.bgwriter.buffers_backend.rate.below_17[{#SINGLETON}] Preprocessing
|
| Bgwriter: Times a backend executed its own fsync per second{#SINGLETON} | 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). |
Dependent item | pgsql.bgwriter.buffers_backend_fsync.rate.below_17[{#SINGLETON}] Preprocessing
|
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Bgwriter metrics discovery (versions above 17) | Discovers "bgwriter" metrics for PostgreSQL version 17 and above. |
Dependent item | pgsql.bgwriter.above_17.discovery |
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Get bgwriter{#SINGLETON} | Collect all metrics from pg_stat_bgwriter: https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-BGWRITER-VIEW |
Database monitor | db.odbc.select[pgsql.bgwriter.above_17{#SINGLETON},,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] |
| Bgwriter: Buffers allocated per second{#SINGLETON} | Number of buffers allocated per second. |
Dependent item | pgsql.bgwriter.buffers_alloc.rate.above_17[{#SINGLETON}] Preprocessing
|
| Bgwriter: Number of bgwriter cleaning scan stopped per second{#SINGLETON} | Number of times the background writer stopped a cleaning scan because it had written too many buffers per second. |
Dependent item | pgsql.bgwriter.maxwritten_clean.rate.above_17[{#SINGLETON}] Preprocessing
|
| Checkpoint: Buffers written by the background writer per second{#SINGLETON} | Number of buffers written by the background writer per second. |
Dependent item | pgsql.bgwriter.buffers_clean.rate.above_17[{#SINGLETON}] Preprocessing
|
| Checkpoint: Buffers written during checkpoints per second{#SINGLETON} | Number of buffers written during checkpoints per second. |
Dependent item | pgsql.bgwriter.buffers_checkpoint.rate.above_17[{#SINGLETON}] Preprocessing
|
| Checkpoint: Scheduled per second{#SINGLETON} | Number of scheduled checkpoints that have been performed per second. |
Dependent item | pgsql.bgwriter.checkpoints_timed.rate.above_17[{#SINGLETON}] Preprocessing
|
| Checkpoint: Requested per second{#SINGLETON} | Number of requested checkpoints that have been performed per second. |
Dependent item | pgsql.bgwriter.checkpoints_req.rate.above_17[{#SINGLETON}] Preprocessing
|
| Checkpoint: Checkpoint write time per second{#SINGLETON} | Total amount of time per second that has been spent in the portion of checkpoint processing where files are written to disk. |
Dependent item | pgsql.bgwriter.checkpoint_write_time.rate.above_17[{#SINGLETON}] Preprocessing
|
| Bgwriter: Checkpoint sync time per second{#SINGLETON} | Total amount of time per second that has been spent in the portion of checkpoint processing where files are synchronized to disk. |
Dependent item | pgsql.bgwriter.checkpoint_sync_time.rate.above_17[{#SINGLETON}] Preprocessing
|
Please report any issues with the template at https://support.zabbix.com
You can also provide feedback, discuss the template, or ask for help at ZABBIX forums
Source: https://git.zabbix.com/projects/ZBX/repos/zabbix/browse/templates/db/postgresql_odbc?at=release/7.2
This template is designed for the effortless deployment of PostgreSQL monitoring by Zabbix via ODBC and doesn't require any external scripts.
Zabbix version: 7.2 and higher.
This template has been tested on:
Zabbix should be configured according to the instructions in the Templates out of the box section.
<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;
pg_hba.conf configuration file to allow TCP connections for the user zbx_monitor. For example, you could add one of the following rows to allow local connections from the same host:# TYPE DATABASE USER ADDRESS METHOD
host all zbx_monitor localhost trust
host all zbx_monitor 127.0.0.1/32 md5
host all zbx_monitor ::1/128 scram-sha-256
For more information please read the PostgreSQL documentation https://www.postgresql.org/docs/current/auth-pg-hba-conf.html.
Install the PostgreSQL ODBC driver. Check the Zabbix documentation for details about ODBC checks and recommended parameters page.
Set up the connection string with the {$PG.CONNSTRING.ODBC} 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.Note: 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 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
{$PG.PASSWORD}.| Name | Description | Default |
|---|---|---|
| {$PG.PASSWORD} | PostgreSQL user password. |
<Put the password here> |
| {$PG.USER} | PostgreSQL username. |
zbx_monitor |
| {$PG.CONNSTRING.ODBC} | Connection string for the PostgreSQL instance. |
Macro too long. Please see the template. |
| {$PG.LLD.FILTER.DBNAME} | Filter of discoverable databases. |
.+ |
| {$PG.CONN_TOTAL_PCT.MAX.WARN} | Maximum percentage of current connections for trigger expression. |
90 |
| {$PG.DATABASE} | Default PostgreSQL database for the connection. |
postgres |
| {$PG.DEADLOCKS.MAX.WARN} | Maximum number of detected deadlocks for trigger expression. |
0 |
| {$PG.LLD.FILTER.APPLICATION} | Filter of discoverable applications. |
.+ |
| {$PG.CONFLICTS.MAX.WARN} | Maximum number of recovery conflicts for trigger expression. |
0 |
| {$PG.QUERY_ETIME.MAX.WARN} | Execution time limit for count of slow queries. |
30 |
| {$PG.SLOW_QUERIES.MAX.WARN} | Slow queries count threshold for a trigger. |
5 |
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Get archive | Collect archive status metrics. |
Database monitor | db.odbc.select[pgsql.archive,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] |
| Get dbstat | Collect all metrics from pg_stat_database per database: https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-DATABASE-VIEW |
Database monitor | db.odbc.select[pgsql.dbstat,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] |
| Get dbstat sum | 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 |
Database monitor | db.odbc.select[pgsql.dbstat.sum,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] |
| Get connections sum | Collect all metrics from pg_stat_activity: https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-ACTIVITY-VIEW |
Database monitor | db.odbc.select[pgsql.connections.sum,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] |
| Get WAL | Collect write-ahead log (WAL) metrics. |
Database monitor | db.odbc.select[pgsql.wal.stat,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] |
| Get locks | Collect all metrics from pg_locks per database: https://www.postgresql.org/docs/current/explicit-locking.html#LOCKING-TABLES |
Database monitor | db.odbc.select[pgsql.locks,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] |
| Get replication | 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. |
Database monitor | db.odbc.select[pgsql.replication.process,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] Preprocessing
|
| Get queries | Collect all metrics by query execution time. |
Database monitor | db.odbc.select[pgsql.queries,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] |
| Version | PostgreSQL version. |
Database monitor | db.odbc.select[pgsql.version,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] Preprocessing
|
| Version (numeric) | Reports the version number of the server as an integer. |
Database monitor | db.odbc.select[pgsql.version.num,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] Preprocessing
|
| Bgwriter LLD | LLD data for "bgwriter" metrics discovery. |
Dependent item | pgsql.bgwriter.lld Preprocessing
|
| WAL: Bytes written | WAL write, in bytes. |
Dependent item | pgsql.wal.write Preprocessing
|
| WAL: Bytes received | WAL receive, in bytes. |
Dependent item | pgsql.wal.receive Preprocessing
|
| WAL: Segments count | Number of WAL segments. |
Dependent item | pgsql.wal.count Preprocessing
|
| Archive: Count of archived files | Count of archived files. |
Dependent item | pgsql.archive.count_archived_files Preprocessing
|
| Archive: Count of failed attempts to archive files | Count of failed attempts to archive files. |
Dependent item | pgsql.archive.failed_trying_to_archive Preprocessing
|
| Archive: Count of files in archive_status need to archive | Count of files to archive. |
Dependent item | pgsql.archive.count_files_to_archive Preprocessing
|
| Archive: Size of files need to archive | Size of files to archive. |
Dependent item | pgsql.archive.size_files_to_archive Preprocessing
|
| Dbstat: Blocks read time | Time spent reading data file blocks by backends. |
Dependent item | pgsql.dbstat.sum.blk_read_time Preprocessing
|
| Dbstat: Blocks write time | Time spent writing data file blocks by backends. |
Dependent item | pgsql.dbstat.sum.blk_write_time Preprocessing
|
| Dbstat: Committed transactions per second | Number of transactions that have been committed per second. |
Dependent item | pgsql.dbstat.sum.xact_commit.rate Preprocessing
|
| Dbstat: Conflicts per second | Number of queries canceled per second due to conflicts with recovery (conflicts occur only on standby servers; see pg_stat_database_conflicts for details). |
Dependent item | pgsql.dbstat.sum.conflicts.rate Preprocessing
|
| Dbstat: Deadlocks per second | Number of deadlocks detected per second. |
Dependent item | pgsql.dbstat.sum.deadlocks.rate Preprocessing
|
| Dbstat: Disk blocks read per second | Number of disk blocks read per second. |
Dependent item | pgsql.dbstat.sum.blks_read.rate Preprocessing
|
| Dbstat: Hit blocks read per second | Number of times per second disk blocks were found already in the buffer cache. |
Dependent item | pgsql.dbstat.sum.blks_hit.rate Preprocessing
|
| Dbstat: Number temp bytes per second | Total amount of data written per second to temporary files by queries. |
Dependent item | pgsql.dbstat.sum.temp_bytes.rate Preprocessing
|
| Dbstat: Number temp files per second | Number of temporary files created by queries per second. |
Dependent item | pgsql.dbstat.sum.temp_files.rate Preprocessing
|
| Dbstat: Roll backed transactions per second | Number of transactions that have been rolled back per second. |
Dependent item | pgsql.dbstat.sum.xact_rollback.rate Preprocessing
|
| Dbstat: Rows deleted per second | Number of rows deleted by queries per second. |
Dependent item | pgsql.dbstat.sum.tup_deleted.rate Preprocessing
|
| Dbstat: Rows fetched per second | Number of rows fetched by queries per second. |
Dependent item | pgsql.dbstat.sum.tup_fetched.rate Preprocessing
|
| Dbstat: Rows inserted per second | Number of rows inserted by queries per second. |
Dependent item | pgsql.dbstat.sum.tup_inserted.rate Preprocessing
|
| Dbstat: Rows returned per second | Number of rows returned by queries per second. |
Dependent item | pgsql.dbstat.sum.tup_returned.rate Preprocessing
|
| Dbstat: Rows updated per second | Number of rows updated by queries per second. |
Dependent item | pgsql.dbstat.sum.tup_updated.rate Preprocessing
|
| Dbstat: Backends connected | Number of connected backends. |
Dependent item | pgsql.dbstat.sum.numbackends Preprocessing
|
| Connections sum: Active | Total number of connections executing a query. |
Dependent item | pgsql.connections.sum.active Preprocessing
|
| Connections sum: Fastpath function call | Total number of connections executing a fast-path function. |
Dependent item | pgsql.connections.sum.fastpath_function_call Preprocessing
|
| Connections sum: Idle | Total number of connections waiting for a new client command. |
Dependent item | pgsql.connections.sum.idle Preprocessing
|
| Connections sum: Idle in transaction | Total number of connections in a transaction state but not executing a query. |
Dependent item | pgsql.connections.sum.idle_in_transaction Preprocessing
|
| Connections sum: Prepared | Total number of prepared transactions: https://www.postgresql.org/docs/current/sql-prepare-transaction.html |
Dependent item | pgsql.connections.sum.prepared Preprocessing
|
| Connections sum: Total | Total number of connections. |
Dependent item | pgsql.connections.sum.total Preprocessing
|
| Connections sum: Total, % | Total number of connections, in percentage. |
Dependent item | pgsql.connections.sum.total_pct Preprocessing
|
| Connections sum: Waiting | Total number of waiting connections: https://www.postgresql.org/docs/current/monitoring-stats.html#WAIT-EVENT-TABLE |
Dependent item | pgsql.connections.sum.waiting Preprocessing
|
| Connections sum: Idle in transaction (aborted) | 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. |
Dependent item | pgsql.connections.sum.idle_in_transaction_aborted Preprocessing
|
| Connections sum: Disabled | Total number of disabled connections. |
Dependent item | pgsql.connections.sum.disabled Preprocessing
|
| Age of oldest xid | Age of oldest xid. |
Database monitor | db.odbc.select[pgsql.oldest.xid,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] |
| Count of autovacuum workers | Number of autovacuum workers. |
Database monitor | db.odbc.select[pgsql.autovacuum.count,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] |
| Cache hit ratio, % | Cache hit ratio. |
Calculated | pgsql.cache.hit |
| Uptime | Time since the server started. |
Database monitor | db.odbc.select[pgsql.uptime,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] |
| Replication: Lag in bytes | Replication lag with master, in bytes. |
Database monitor | db.odbc.select[pgsql.replication.lag.b,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] |
| Replication: Lag in seconds | Replication lag with master, in seconds. |
Database monitor | db.odbc.select[pgsql.replication.lag.sec,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] |
| Replication: Recovery role | Replication role: 1 — recovery is still in progress (standby mode), 0 — master mode. |
Database monitor | db.odbc.select[pgsql.replication.recovery_role,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] |
| Replication: Standby count | Number of standby servers. |
Database monitor | db.odbc.select[pgsql.replication.count,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] |
| Replication: Status | Replication status: 0 — streaming is down, 1 — streaming is up, 2 — master mode. |
Database monitor | db.odbc.select[pgsql.replication.status,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] |
| Ping | Used to test a connection to see if it is alive. It is set to 0 if the query is unsuccessful. |
Database monitor | db.odbc.select[pgsql.ping,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] Preprocessing
|
| Name | Description | Expression | Severity | Dependencies and additional info |
|---|---|---|---|---|
| PostgreSQL: Version has changed | last(/PostgreSQL by ODBC/db.odbc.select[pgsql.version,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"],#1)<>last(/PostgreSQL by ODBC/db.odbc.select[pgsql.version,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"],#2) and length(last(/PostgreSQL by ODBC/db.odbc.select[pgsql.version,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"]))>0 |
Info | ||
| PostgreSQL: Total number of connections is too high | 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). |
min(/PostgreSQL by ODBC/pgsql.connections.sum.total_pct,5m) > {$PG.CONN_TOTAL_PCT.MAX.WARN} |
Average | |
| PostgreSQL: Oldest xid is too big | last(/PostgreSQL by ODBC/db.odbc.select[pgsql.oldest.xid,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"]) > 18000000 |
Average | ||
| PostgreSQL: Service has been restarted | PostgreSQL uptime is less than 10 minutes. |
last(/PostgreSQL by ODBC/db.odbc.select[pgsql.uptime,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"]) < 10m |
Average | |
| PostgreSQL: Service is down | Last test of a connection was unsuccessful. |
last(/PostgreSQL by ODBC/db.odbc.select[pgsql.ping,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"])=0 |
High |
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Replication discovery | Discovers replication lag metrics. |
Database monitor | db.odbc.select[pgsql.replication.process.discovery,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] Preprocessing
|
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Application [{#APPLICATION_NAME}]: Get replication | 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. |
Dependent item | pgsql.replication.get_metrics["{#APPLICATION_NAME}"] Preprocessing
|
| Application [{#APPLICATION_NAME}]: Replication flush lag | 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. |
Dependent item | pgsql.replication.process.flush_lag["{#APPLICATION_NAME}"] Preprocessing
|
| Application [{#APPLICATION_NAME}]: Replication replay lag | 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. |
Dependent item | pgsql.replication.process.replay_lag["{#APPLICATION_NAME}"] Preprocessing
|
| Application [{#APPLICATION_NAME}]: Replication write lag | 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. |
Dependent item | pgsql.replication.process.write_lag["{#APPLICATION_NAME}"] Preprocessing
|
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Database discovery | Discovers databases (DB) in the database management system (DBMS), except: - templates; - default "postgres" DB; - DBs that do not allow connections. |
Database monitor | db.odbc.select[pgsql.db.discovery,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] |
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| DB [{#DBNAME}]: Get dbstat | Get dbstat metrics for database "{#DBNAME}". |
Dependent item | pgsql.dbstat.get_metrics["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Get locks | Get locks metrics for database "{#DBNAME}". |
Dependent item | pgsql.locks.get_metrics["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Get queries | Get queries metrics for database "{#DBNAME}". |
Dependent item | pgsql.queries.get_metrics["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Database age | Database age. |
Database monitor | db.odbc.select[pgsql.db.age,,"Database={#DBNAME};{$PG.CONNSTRING.ODBC}"] |
| DB [{#DBNAME}]: Bloating tables | Number of bloating tables. |
Database monitor | db.odbc.select[pgsql.db.bloating_tables,,"Database={#DBNAME};{$PG.CONNSTRING.ODBC}"] |
| DB [{#DBNAME}]: Database size | Database size. |
Database monitor | db.odbc.select[pgsql.db.size,,"Database={#DBNAME};{$PG.CONNSTRING.ODBC}"] |
| DB [{#DBNAME}]: Blocks hit per second | Total number of times per second disk blocks were found already in the buffer cache, so that a read was not necessary. |
Dependent item | pgsql.dbstat.blks_hit.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Disk blocks read per second | Total number of disk blocks read per second in this database. |
Dependent item | pgsql.dbstat.blks_read.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Detected conflicts per second | Total number of queries canceled due to conflicts with recovery in this database per second. |
Dependent item | pgsql.dbstat.conflicts.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Detected deadlocks per second | Total number of detected deadlocks in this database per second. |
Dependent item | pgsql.dbstat.deadlocks.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Temp_bytes written per second | Total amount of data written to temporary files by queries in this database. |
Dependent item | pgsql.dbstat.temp_bytes.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Temp_files created per second | Total number of temporary files created by queries in this database. |
Dependent item | pgsql.dbstat.temp_files.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Tuples deleted per second | Total number of rows deleted by queries in this database per second. |
Dependent item | pgsql.dbstat.tup_deleted.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Tuples fetched per second | Total number of rows fetched by queries in this database per second. |
Dependent item | pgsql.dbstat.tup_fetched.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Tuples inserted per second | Total number of rows inserted by queries in this database per second. |
Dependent item | pgsql.dbstat.tup_inserted.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Tuples returned per second | Number of rows returned by queries in this database per second. |
Dependent item | pgsql.dbstat.tup_returned.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Tuples updated per second | Total number of rows updated by queries in this database per second. |
Dependent item | pgsql.dbstat.tup_updated.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Commits per second | Number of transactions in this database that have been committed per second. |
Dependent item | pgsql.dbstat.xact_commit.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Rollbacks per second | Total number of transactions in this database that have been rolled back. |
Dependent item | pgsql.dbstat.xact_rollback.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Backends connected | Number of backends currently connected to this database. |
Dependent item | pgsql.dbstat.numbackends["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Disk blocks read time per second | Time spent reading data file blocks by backends per second. |
Dependent item | pgsql.dbstat.blk_read_time.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Disk blocks write time per second | Time spent writing data file blocks by backends per second. |
Dependent item | pgsql.dbstat.blk_write_time.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Num of accessexclusive locks | Number of accessexclusive locks for this database. |
Dependent item | pgsql.locks.accessexclusive["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Num of accessshare locks | Number of accessshare locks for this database. |
Dependent item | pgsql.locks.accessshare["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Num of exclusive locks | Number of exclusive locks for this database. |
Dependent item | pgsql.locks.exclusive["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Num of rowexclusive locks | Number of rowexclusive locks for this database. |
Dependent item | pgsql.locks.rowexclusive["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Num of rowshare locks | Number of rowshare locks for this database. |
Dependent item | pgsql.locks.rowshare["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Num of sharerowexclusive locks | Number of total sharerowexclusive for this database. |
Dependent item | pgsql.locks.sharerowexclusive["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Num of shareupdateexclusive locks | Number of shareupdateexclusive locks for this database. |
Dependent item | pgsql.locks.shareupdateexclusive["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Num of share locks | Number of share locks for this database. |
Dependent item | pgsql.locks.share["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Num of locks total | Total number of locks in this database. |
Dependent item | pgsql.locks.total["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries max maintenance time | Max maintenance query time for this database. |
Dependent item | pgsql.queries.mro.time_max["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries max query time | Max query time for this database. |
Dependent item | pgsql.queries.query.time_max["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries max transaction time | Max transaction query time for this database. |
Dependent item | pgsql.queries.tx.time_max["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries slow maintenance count | Slow maintenance query count for this database. |
Dependent item | pgsql.queries.mro.slow_count["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries slow query count | Slow query count for this database. |
Dependent item | pgsql.queries.query.slow_count["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries slow transaction count | Slow transaction query count for this database. |
Dependent item | pgsql.queries.tx.slow_count["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries sum maintenance time | Sum maintenance query time for this database. |
Dependent item | pgsql.queries.mro.time_sum["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries sum query time | Sum query time for this database. |
Dependent item | pgsql.queries.query.time_sum["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries sum transaction time | Sum transaction query time for this database. |
Dependent item | pgsql.queries.tx.time_sum["{#DBNAME}"] Preprocessing
|
| Name | Description | Expression | Severity | Dependencies and additional info |
|---|---|---|---|---|
| PostgreSQL: DB [{#DBNAME}]: Too many recovery conflicts | 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. |
min(/PostgreSQL by ODBC/pgsql.dbstat.conflicts.rate["{#DBNAME}"],5m) > {$PG.CONFLICTS.MAX.WARN:"{#DBNAME}"} |
Average | |
| PostgreSQL: DB [{#DBNAME}]: Deadlock occurred | Number of deadlocks detected per second exceeds {$PG.DEADLOCKS.MAX.WARN:"{#DBNAME}"} for 5m. |
min(/PostgreSQL by ODBC/pgsql.dbstat.deadlocks.rate["{#DBNAME}"],5m) > {$PG.DEADLOCKS.MAX.WARN:"{#DBNAME}"} |
High | |
| PostgreSQL: DB [{#DBNAME}]: Too many slow queries | The number of detected slow queries exceeds the limit of {$PG.SLOW_QUERIES.MAX.WARN:"{#DBNAME}"}. |
min(/PostgreSQL by ODBC/pgsql.queries.query.slow_count["{#DBNAME}"],5m)>{$PG.SLOW_QUERIES.MAX.WARN:"{#DBNAME}"} |
Warning |
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Bgwriter metrics discovery (versions below 17) | Discovers "bgwriter" metrics for PostgreSQL below version 17. |
Dependent item | pgsql.bgwriter.below_17.discovery |
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Get bgwriter{#SINGLETON} | Collect all metrics from pg_stat_bgwriter: https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-BGWRITER-VIEW |
Database monitor | db.odbc.select[pgsql.bgwriter.below_17{#SINGLETON},,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] |
| Bgwriter: Buffers allocated per second{#SINGLETON} | Number of buffers allocated per second. |
Dependent item | pgsql.bgwriter.buffers_alloc.rate.below_17[{#SINGLETON}] Preprocessing
|
| Bgwriter: Number of bgwriter cleaning scan stopped per second{#SINGLETON} | Number of times the background writer stopped a cleaning scan because it had written too many buffers per second. |
Dependent item | pgsql.bgwriter.maxwritten_clean.rate.below_17[{#SINGLETON}] Preprocessing
|
| Checkpoint: Buffers written by the background writer per second{#SINGLETON} | Number of buffers written by the background writer per second. |
Dependent item | pgsql.bgwriter.buffers_clean.rate.below_17[{#SINGLETON}] Preprocessing
|
| Checkpoint: Buffers written during checkpoints per second{#SINGLETON} | Number of buffers written during checkpoints per second. |
Dependent item | pgsql.bgwriter.buffers_checkpoint.rate.below_17[{#SINGLETON}] Preprocessing
|
| Checkpoint: Scheduled per second{#SINGLETON} | Number of scheduled checkpoints that have been performed per second. |
Dependent item | pgsql.bgwriter.checkpoints_timed.rate.below_17[{#SINGLETON}] Preprocessing
|
| Checkpoint: Requested per second{#SINGLETON} | Number of requested checkpoints that have been performed per second. |
Dependent item | pgsql.bgwriter.checkpoints_req.rate.below_17[{#SINGLETON}] Preprocessing
|
| Checkpoint: Checkpoint write time per second{#SINGLETON} | Total amount of time per second that has been spent in the portion of checkpoint processing where files are written to disk. |
Dependent item | pgsql.bgwriter.checkpoint_write_time.rate.below_17[{#SINGLETON}] Preprocessing
|
| Bgwriter: Checkpoint sync time per second{#SINGLETON} | Total amount of time per second that has been spent in the portion of checkpoint processing where files are synchronized to disk. |
Dependent item | pgsql.bgwriter.checkpoint_sync_time.rate.below_17[{#SINGLETON}] Preprocessing
|
| Bgwriter: Buffers written directly by a backend per second{#SINGLETON} | Number of buffers written directly by a backend per second. |
Dependent item | pgsql.bgwriter.buffers_backend.rate.below_17[{#SINGLETON}] Preprocessing
|
| Bgwriter: Times a backend executed its own fsync per second{#SINGLETON} | 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). |
Dependent item | pgsql.bgwriter.buffers_backend_fsync.rate.below_17[{#SINGLETON}] Preprocessing
|
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Bgwriter metrics discovery (versions above 17) | Discovers "bgwriter" metrics for PostgreSQL version 17 and above. |
Dependent item | pgsql.bgwriter.above_17.discovery |
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Get bgwriter{#SINGLETON} | Collect all metrics from pg_stat_bgwriter: https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-BGWRITER-VIEW |
Database monitor | db.odbc.select[pgsql.bgwriter.above_17{#SINGLETON},,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] |
| Bgwriter: Buffers allocated per second{#SINGLETON} | Number of buffers allocated per second. |
Dependent item | pgsql.bgwriter.buffers_alloc.rate.above_17[{#SINGLETON}] Preprocessing
|
| Bgwriter: Number of bgwriter cleaning scan stopped per second{#SINGLETON} | Number of times the background writer stopped a cleaning scan because it had written too many buffers per second. |
Dependent item | pgsql.bgwriter.maxwritten_clean.rate.above_17[{#SINGLETON}] Preprocessing
|
| Checkpoint: Buffers written by the background writer per second{#SINGLETON} | Number of buffers written by the background writer per second. |
Dependent item | pgsql.bgwriter.buffers_clean.rate.above_17[{#SINGLETON}] Preprocessing
|
| Checkpoint: Buffers written during checkpoints per second{#SINGLETON} | Number of buffers written during checkpoints per second. |
Dependent item | pgsql.bgwriter.buffers_checkpoint.rate.above_17[{#SINGLETON}] Preprocessing
|
| Checkpoint: Scheduled per second{#SINGLETON} | Number of scheduled checkpoints that have been performed per second. |
Dependent item | pgsql.bgwriter.checkpoints_timed.rate.above_17[{#SINGLETON}] Preprocessing
|
| Checkpoint: Requested per second{#SINGLETON} | Number of requested checkpoints that have been performed per second. |
Dependent item | pgsql.bgwriter.checkpoints_req.rate.above_17[{#SINGLETON}] Preprocessing
|
| Checkpoint: Checkpoint write time per second{#SINGLETON} | Total amount of time per second that has been spent in the portion of checkpoint processing where files are written to disk. |
Dependent item | pgsql.bgwriter.checkpoint_write_time.rate.above_17[{#SINGLETON}] Preprocessing
|
| Bgwriter: Checkpoint sync time per second{#SINGLETON} | Total amount of time per second that has been spent in the portion of checkpoint processing where files are synchronized to disk. |
Dependent item | pgsql.bgwriter.checkpoint_sync_time.rate.above_17[{#SINGLETON}] Preprocessing
|
Please report any issues with the template at https://support.zabbix.com
You can also provide feedback, discuss the template, or ask for help at ZABBIX forums
Source: https://git.zabbix.com/projects/ZBX/repos/zabbix/browse/templates/db/postgresql_odbc?at=release/7.0
This template is designed for the effortless deployment of PostgreSQL monitoring by Zabbix via ODBC and doesn't require any external scripts.
Zabbix version: 7.0 and higher.
This template has been tested on:
Zabbix should be configured according to the instructions in the Templates out of the box section.
<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;
pg_hba.conf configuration file to allow TCP connections for the user zbx_monitor. For example, you could add one of the following rows to allow local connections from the same host:# TYPE DATABASE USER ADDRESS METHOD
host all zbx_monitor localhost trust
host all zbx_monitor 127.0.0.1/32 md5
host all zbx_monitor ::1/128 scram-sha-256
For more information please read the PostgreSQL documentation https://www.postgresql.org/docs/current/auth-pg-hba-conf.html.
Install the PostgreSQL ODBC driver. Check the Zabbix documentation for details about ODBC checks and recommended parameters page.
Set up the connection string with the {$PG.CONNSTRING.ODBC} 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.Note: 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 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
{$PG.PASSWORD}.| Name | Description | Default |
|---|---|---|
| {$PG.PASSWORD} | PostgreSQL user password. |
<Put the password here> |
| {$PG.USER} | PostgreSQL username. |
zbx_monitor |
| {$PG.CONNSTRING.ODBC} | Connection string for the PostgreSQL instance. |
Macro too long. Please see the template. |
| {$PG.LLD.FILTER.DBNAME} | Filter of discoverable databases. |
.+ |
| {$PG.CONN_TOTAL_PCT.MAX.WARN} | Maximum percentage of current connections for trigger expression. |
90 |
| {$PG.DATABASE} | Default PostgreSQL database for the connection. |
postgres |
| {$PG.DEADLOCKS.MAX.WARN} | Maximum number of detected deadlocks for trigger expression. |
0 |
| {$PG.LLD.FILTER.APPLICATION} | Filter of discoverable applications. |
.+ |
| {$PG.CONFLICTS.MAX.WARN} | Maximum number of recovery conflicts for trigger expression. |
0 |
| {$PG.QUERY_ETIME.MAX.WARN} | Execution time limit for count of slow queries. |
30 |
| {$PG.SLOW_QUERIES.MAX.WARN} | Slow queries count threshold for a trigger. |
5 |
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Get archive | Collect archive status metrics. |
Database monitor | db.odbc.select[pgsql.archive,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] |
| Get dbstat | Collect all metrics from pg_stat_database per database: https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-DATABASE-VIEW |
Database monitor | db.odbc.select[pgsql.dbstat,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] |
| Get dbstat sum | 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 |
Database monitor | db.odbc.select[pgsql.dbstat.sum,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] |
| Get connections sum | Collect all metrics from pg_stat_activity: https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-ACTIVITY-VIEW |
Database monitor | db.odbc.select[pgsql.connections.sum,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] |
| Get WAL | Collect write-ahead log (WAL) metrics. |
Database monitor | db.odbc.select[pgsql.wal.stat,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] |
| Get locks | Collect all metrics from pg_locks per database: https://www.postgresql.org/docs/current/explicit-locking.html#LOCKING-TABLES |
Database monitor | db.odbc.select[pgsql.locks,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] |
| Get replication | 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. |
Database monitor | db.odbc.select[pgsql.replication.process,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] Preprocessing
|
| Get queries | Collect all metrics by query execution time. |
Database monitor | db.odbc.select[pgsql.queries,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] |
| Version | PostgreSQL version. |
Database monitor | db.odbc.select[pgsql.version,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] Preprocessing
|
| Version (numeric) | Reports the version number of the server as an integer. |
Database monitor | db.odbc.select[pgsql.version.num,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] Preprocessing
|
| Bgwriter LLD | LLD data for "bgwriter" metrics discovery. |
Dependent item | pgsql.bgwriter.lld Preprocessing
|
| WAL: Bytes written | WAL write, in bytes. |
Dependent item | pgsql.wal.write Preprocessing
|
| WAL: Bytes received | WAL receive, in bytes. |
Dependent item | pgsql.wal.receive Preprocessing
|
| WAL: Segments count | Number of WAL segments. |
Dependent item | pgsql.wal.count Preprocessing
|
| Archive: Count of archived files | Count of archived files. |
Dependent item | pgsql.archive.count_archived_files Preprocessing
|
| Archive: Count of failed attempts to archive files | Count of failed attempts to archive files. |
Dependent item | pgsql.archive.failed_trying_to_archive Preprocessing
|
| Archive: Count of files in archive_status need to archive | Count of files to archive. |
Dependent item | pgsql.archive.count_files_to_archive Preprocessing
|
| Archive: Size of files need to archive | Size of files to archive. |
Dependent item | pgsql.archive.size_files_to_archive Preprocessing
|
| Dbstat: Blocks read time | Time spent reading data file blocks by backends. |
Dependent item | pgsql.dbstat.sum.blk_read_time Preprocessing
|
| Dbstat: Blocks write time | Time spent writing data file blocks by backends. |
Dependent item | pgsql.dbstat.sum.blk_write_time Preprocessing
|
| Dbstat: Committed transactions per second | Number of transactions that have been committed per second. |
Dependent item | pgsql.dbstat.sum.xact_commit.rate Preprocessing
|
| Dbstat: Conflicts per second | Number of queries canceled per second due to conflicts with recovery (conflicts occur only on standby servers; see pg_stat_database_conflicts for details). |
Dependent item | pgsql.dbstat.sum.conflicts.rate Preprocessing
|
| Dbstat: Deadlocks per second | Number of deadlocks detected per second. |
Dependent item | pgsql.dbstat.sum.deadlocks.rate Preprocessing
|
| Dbstat: Disk blocks read per second | Number of disk blocks read per second. |
Dependent item | pgsql.dbstat.sum.blks_read.rate Preprocessing
|
| Dbstat: Hit blocks read per second | Number of times per second disk blocks were found already in the buffer cache. |
Dependent item | pgsql.dbstat.sum.blks_hit.rate Preprocessing
|
| Dbstat: Number temp bytes per second | Total amount of data written per second to temporary files by queries. |
Dependent item | pgsql.dbstat.sum.temp_bytes.rate Preprocessing
|
| Dbstat: Number temp files per second | Number of temporary files created by queries per second. |
Dependent item | pgsql.dbstat.sum.temp_files.rate Preprocessing
|
| Dbstat: Roll backed transactions per second | Number of transactions that have been rolled back per second. |
Dependent item | pgsql.dbstat.sum.xact_rollback.rate Preprocessing
|
| Dbstat: Rows deleted per second | Number of rows deleted by queries per second. |
Dependent item | pgsql.dbstat.sum.tup_deleted.rate Preprocessing
|
| Dbstat: Rows fetched per second | Number of rows fetched by queries per second. |
Dependent item | pgsql.dbstat.sum.tup_fetched.rate Preprocessing
|
| Dbstat: Rows inserted per second | Number of rows inserted by queries per second. |
Dependent item | pgsql.dbstat.sum.tup_inserted.rate Preprocessing
|
| Dbstat: Rows returned per second | Number of rows returned by queries per second. |
Dependent item | pgsql.dbstat.sum.tup_returned.rate Preprocessing
|
| Dbstat: Rows updated per second | Number of rows updated by queries per second. |
Dependent item | pgsql.dbstat.sum.tup_updated.rate Preprocessing
|
| Dbstat: Backends connected | Number of connected backends. |
Dependent item | pgsql.dbstat.sum.numbackends Preprocessing
|
| Connections sum: Active | Total number of connections executing a query. |
Dependent item | pgsql.connections.sum.active Preprocessing
|
| Connections sum: Fastpath function call | Total number of connections executing a fast-path function. |
Dependent item | pgsql.connections.sum.fastpath_function_call Preprocessing
|
| Connections sum: Idle | Total number of connections waiting for a new client command. |
Dependent item | pgsql.connections.sum.idle Preprocessing
|
| Connections sum: Idle in transaction | Total number of connections in a transaction state but not executing a query. |
Dependent item | pgsql.connections.sum.idle_in_transaction Preprocessing
|
| Connections sum: Prepared | Total number of prepared transactions: https://www.postgresql.org/docs/current/sql-prepare-transaction.html |
Dependent item | pgsql.connections.sum.prepared Preprocessing
|
| Connections sum: Total | Total number of connections. |
Dependent item | pgsql.connections.sum.total Preprocessing
|
| Connections sum: Total, % | Total number of connections, in percentage. |
Dependent item | pgsql.connections.sum.total_pct Preprocessing
|
| Connections sum: Waiting | Total number of waiting connections: https://www.postgresql.org/docs/current/monitoring-stats.html#WAIT-EVENT-TABLE |
Dependent item | pgsql.connections.sum.waiting Preprocessing
|
| Connections sum: Idle in transaction (aborted) | 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. |
Dependent item | pgsql.connections.sum.idle_in_transaction_aborted Preprocessing
|
| Connections sum: Disabled | Total number of disabled connections. |
Dependent item | pgsql.connections.sum.disabled Preprocessing
|
| Age of oldest xid | Age of oldest xid. |
Database monitor | db.odbc.select[pgsql.oldest.xid,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] |
| Count of autovacuum workers | Number of autovacuum workers. |
Database monitor | db.odbc.select[pgsql.autovacuum.count,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] |
| Cache hit ratio, % | Cache hit ratio. |
Calculated | pgsql.cache.hit |
| Uptime | Time since the server started. |
Database monitor | db.odbc.select[pgsql.uptime,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] |
| Replication: Lag in bytes | Replication lag with master, in bytes. |
Database monitor | db.odbc.select[pgsql.replication.lag.b,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] |
| Replication: Lag in seconds | Replication lag with master, in seconds. |
Database monitor | db.odbc.select[pgsql.replication.lag.sec,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] |
| Replication: Recovery role | Replication role: 1 — recovery is still in progress (standby mode), 0 — master mode. |
Database monitor | db.odbc.select[pgsql.replication.recovery_role,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] |
| Replication: Standby count | Number of standby servers. |
Database monitor | db.odbc.select[pgsql.replication.count,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] |
| Replication: Status | Replication status: 0 — streaming is down, 1 — streaming is up, 2 — master mode. |
Database monitor | db.odbc.select[pgsql.replication.status,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] |
| Ping | Used to test a connection to see if it is alive. It is set to 0 if the query is unsuccessful. |
Database monitor | db.odbc.select[pgsql.ping,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] Preprocessing
|
| Name | Description | Expression | Severity | Dependencies and additional info |
|---|---|---|---|---|
| PostgreSQL: Version has changed | last(/PostgreSQL by ODBC/db.odbc.select[pgsql.version,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"],#1)<>last(/PostgreSQL by ODBC/db.odbc.select[pgsql.version,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"],#2) and length(last(/PostgreSQL by ODBC/db.odbc.select[pgsql.version,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"]))>0 |
Info | ||
| PostgreSQL: Total number of connections is too high | 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). |
min(/PostgreSQL by ODBC/pgsql.connections.sum.total_pct,5m) > {$PG.CONN_TOTAL_PCT.MAX.WARN} |
Average | |
| PostgreSQL: Oldest xid is too big | last(/PostgreSQL by ODBC/db.odbc.select[pgsql.oldest.xid,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"]) > 18000000 |
Average | ||
| PostgreSQL: Service has been restarted | PostgreSQL uptime is less than 10 minutes. |
last(/PostgreSQL by ODBC/db.odbc.select[pgsql.uptime,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"]) < 10m |
Average | |
| PostgreSQL: Service is down | Last test of a connection was unsuccessful. |
last(/PostgreSQL by ODBC/db.odbc.select[pgsql.ping,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"])=0 |
High |
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Replication discovery | Discovers replication lag metrics. |
Database monitor | db.odbc.select[pgsql.replication.process.discovery,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] Preprocessing
|
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Application [{#APPLICATION_NAME}]: Get replication | 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. |
Dependent item | pgsql.replication.get_metrics["{#APPLICATION_NAME}"] Preprocessing
|
| Application [{#APPLICATION_NAME}]: Replication flush lag | 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. |
Dependent item | pgsql.replication.process.flush_lag["{#APPLICATION_NAME}"] Preprocessing
|
| Application [{#APPLICATION_NAME}]: Replication replay lag | 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. |
Dependent item | pgsql.replication.process.replay_lag["{#APPLICATION_NAME}"] Preprocessing
|
| Application [{#APPLICATION_NAME}]: Replication write lag | 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. |
Dependent item | pgsql.replication.process.write_lag["{#APPLICATION_NAME}"] Preprocessing
|
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Database discovery | Discovers databases (DB) in the database management system (DBMS), except: - templates; - default "postgres" DB; - DBs that do not allow connections. |
Database monitor | db.odbc.select[pgsql.db.discovery,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] |
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| DB [{#DBNAME}]: Get dbstat | Get dbstat metrics for database "{#DBNAME}". |
Dependent item | pgsql.dbstat.get_metrics["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Get locks | Get locks metrics for database "{#DBNAME}". |
Dependent item | pgsql.locks.get_metrics["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Get queries | Get queries metrics for database "{#DBNAME}". |
Dependent item | pgsql.queries.get_metrics["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Database age | Database age. |
Database monitor | db.odbc.select[pgsql.db.age,,"Database={#DBNAME};{$PG.CONNSTRING.ODBC}"] |
| DB [{#DBNAME}]: Bloating tables | Number of bloating tables. |
Database monitor | db.odbc.select[pgsql.db.bloating_tables,,"Database={#DBNAME};{$PG.CONNSTRING.ODBC}"] |
| DB [{#DBNAME}]: Database size | Database size. |
Database monitor | db.odbc.select[pgsql.db.size,,"Database={#DBNAME};{$PG.CONNSTRING.ODBC}"] |
| DB [{#DBNAME}]: Blocks hit per second | Total number of times per second disk blocks were found already in the buffer cache, so that a read was not necessary. |
Dependent item | pgsql.dbstat.blks_hit.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Disk blocks read per second | Total number of disk blocks read per second in this database. |
Dependent item | pgsql.dbstat.blks_read.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Detected conflicts per second | Total number of queries canceled due to conflicts with recovery in this database per second. |
Dependent item | pgsql.dbstat.conflicts.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Detected deadlocks per second | Total number of detected deadlocks in this database per second. |
Dependent item | pgsql.dbstat.deadlocks.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Temp_bytes written per second | Total amount of data written to temporary files by queries in this database. |
Dependent item | pgsql.dbstat.temp_bytes.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Temp_files created per second | Total number of temporary files created by queries in this database. |
Dependent item | pgsql.dbstat.temp_files.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Tuples deleted per second | Total number of rows deleted by queries in this database per second. |
Dependent item | pgsql.dbstat.tup_deleted.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Tuples fetched per second | Total number of rows fetched by queries in this database per second. |
Dependent item | pgsql.dbstat.tup_fetched.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Tuples inserted per second | Total number of rows inserted by queries in this database per second. |
Dependent item | pgsql.dbstat.tup_inserted.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Tuples returned per second | Number of rows returned by queries in this database per second. |
Dependent item | pgsql.dbstat.tup_returned.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Tuples updated per second | Total number of rows updated by queries in this database per second. |
Dependent item | pgsql.dbstat.tup_updated.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Commits per second | Number of transactions in this database that have been committed per second. |
Dependent item | pgsql.dbstat.xact_commit.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Rollbacks per second | Total number of transactions in this database that have been rolled back. |
Dependent item | pgsql.dbstat.xact_rollback.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Backends connected | Number of backends currently connected to this database. |
Dependent item | pgsql.dbstat.numbackends["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Disk blocks read time per second | Time spent reading data file blocks by backends per second. |
Dependent item | pgsql.dbstat.blk_read_time.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Disk blocks write time per second | Time spent writing data file blocks by backends per second. |
Dependent item | pgsql.dbstat.blk_write_time.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Num of accessexclusive locks | Number of accessexclusive locks for this database. |
Dependent item | pgsql.locks.accessexclusive["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Num of accessshare locks | Number of accessshare locks for this database. |
Dependent item | pgsql.locks.accessshare["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Num of exclusive locks | Number of exclusive locks for this database. |
Dependent item | pgsql.locks.exclusive["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Num of rowexclusive locks | Number of rowexclusive locks for this database. |
Dependent item | pgsql.locks.rowexclusive["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Num of rowshare locks | Number of rowshare locks for this database. |
Dependent item | pgsql.locks.rowshare["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Num of sharerowexclusive locks | Number of total sharerowexclusive for this database. |
Dependent item | pgsql.locks.sharerowexclusive["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Num of shareupdateexclusive locks | Number of shareupdateexclusive locks for this database. |
Dependent item | pgsql.locks.shareupdateexclusive["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Num of share locks | Number of share locks for this database. |
Dependent item | pgsql.locks.share["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Num of locks total | Total number of locks in this database. |
Dependent item | pgsql.locks.total["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries max maintenance time | Max maintenance query time for this database. |
Dependent item | pgsql.queries.mro.time_max["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries max query time | Max query time for this database. |
Dependent item | pgsql.queries.query.time_max["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries max transaction time | Max transaction query time for this database. |
Dependent item | pgsql.queries.tx.time_max["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries slow maintenance count | Slow maintenance query count for this database. |
Dependent item | pgsql.queries.mro.slow_count["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries slow query count | Slow query count for this database. |
Dependent item | pgsql.queries.query.slow_count["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries slow transaction count | Slow transaction query count for this database. |
Dependent item | pgsql.queries.tx.slow_count["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries sum maintenance time | Sum maintenance query time for this database. |
Dependent item | pgsql.queries.mro.time_sum["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries sum query time | Sum query time for this database. |
Dependent item | pgsql.queries.query.time_sum["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries sum transaction time | Sum transaction query time for this database. |
Dependent item | pgsql.queries.tx.time_sum["{#DBNAME}"] Preprocessing
|
| Name | Description | Expression | Severity | Dependencies and additional info |
|---|---|---|---|---|
| PostgreSQL: DB [{#DBNAME}]: Too many recovery conflicts | 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. |
min(/PostgreSQL by ODBC/pgsql.dbstat.conflicts.rate["{#DBNAME}"],5m) > {$PG.CONFLICTS.MAX.WARN:"{#DBNAME}"} |
Average | |
| PostgreSQL: DB [{#DBNAME}]: Deadlock occurred | Number of deadlocks detected per second exceeds {$PG.DEADLOCKS.MAX.WARN:"{#DBNAME}"} for 5m. |
min(/PostgreSQL by ODBC/pgsql.dbstat.deadlocks.rate["{#DBNAME}"],5m) > {$PG.DEADLOCKS.MAX.WARN:"{#DBNAME}"} |
High | |
| PostgreSQL: DB [{#DBNAME}]: Too many slow queries | The number of detected slow queries exceeds the limit of {$PG.SLOW_QUERIES.MAX.WARN:"{#DBNAME}"}. |
min(/PostgreSQL by ODBC/pgsql.queries.query.slow_count["{#DBNAME}"],5m)>{$PG.SLOW_QUERIES.MAX.WARN:"{#DBNAME}"} |
Warning |
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Bgwriter metrics discovery (versions below 17) | Discovers "bgwriter" metrics for PostgreSQL below version 17. |
Dependent item | pgsql.bgwriter.below_17.discovery |
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Get bgwriter{#SINGLETON} | Collect all metrics from pg_stat_bgwriter: https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-BGWRITER-VIEW |
Database monitor | db.odbc.select[pgsql.bgwriter.below_17{#SINGLETON},,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] |
| Bgwriter: Buffers allocated per second{#SINGLETON} | Number of buffers allocated per second. |
Dependent item | pgsql.bgwriter.buffers_alloc.rate.below_17[{#SINGLETON}] Preprocessing
|
| Bgwriter: Number of bgwriter cleaning scan stopped per second{#SINGLETON} | Number of times the background writer stopped a cleaning scan because it had written too many buffers per second. |
Dependent item | pgsql.bgwriter.maxwritten_clean.rate.below_17[{#SINGLETON}] Preprocessing
|
| Checkpoint: Buffers written by the background writer per second{#SINGLETON} | Number of buffers written by the background writer per second. |
Dependent item | pgsql.bgwriter.buffers_clean.rate.below_17[{#SINGLETON}] Preprocessing
|
| Checkpoint: Buffers written during checkpoints per second{#SINGLETON} | Number of buffers written during checkpoints per second. |
Dependent item | pgsql.bgwriter.buffers_checkpoint.rate.below_17[{#SINGLETON}] Preprocessing
|
| Checkpoint: Scheduled per second{#SINGLETON} | Number of scheduled checkpoints that have been performed per second. |
Dependent item | pgsql.bgwriter.checkpoints_timed.rate.below_17[{#SINGLETON}] Preprocessing
|
| Checkpoint: Requested per second{#SINGLETON} | Number of requested checkpoints that have been performed per second. |
Dependent item | pgsql.bgwriter.checkpoints_req.rate.below_17[{#SINGLETON}] Preprocessing
|
| Checkpoint: Checkpoint write time per second{#SINGLETON} | Total amount of time per second that has been spent in the portion of checkpoint processing where files are written to disk. |
Dependent item | pgsql.bgwriter.checkpoint_write_time.rate.below_17[{#SINGLETON}] Preprocessing
|
| Bgwriter: Checkpoint sync time per second{#SINGLETON} | Total amount of time per second that has been spent in the portion of checkpoint processing where files are synchronized to disk. |
Dependent item | pgsql.bgwriter.checkpoint_sync_time.rate.below_17[{#SINGLETON}] Preprocessing
|
| Bgwriter: Buffers written directly by a backend per second{#SINGLETON} | Number of buffers written directly by a backend per second. |
Dependent item | pgsql.bgwriter.buffers_backend.rate.below_17[{#SINGLETON}] Preprocessing
|
| Bgwriter: Times a backend executed its own fsync per second{#SINGLETON} | 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). |
Dependent item | pgsql.bgwriter.buffers_backend_fsync.rate.below_17[{#SINGLETON}] Preprocessing
|
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Bgwriter metrics discovery (versions above 17) | Discovers "bgwriter" metrics for PostgreSQL version 17 and above. |
Dependent item | pgsql.bgwriter.above_17.discovery |
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Get bgwriter{#SINGLETON} | Collect all metrics from pg_stat_bgwriter: https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-BGWRITER-VIEW |
Database monitor | db.odbc.select[pgsql.bgwriter.above_17{#SINGLETON},,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] |
| Bgwriter: Buffers allocated per second{#SINGLETON} | Number of buffers allocated per second. |
Dependent item | pgsql.bgwriter.buffers_alloc.rate.above_17[{#SINGLETON}] Preprocessing
|
| Bgwriter: Number of bgwriter cleaning scan stopped per second{#SINGLETON} | Number of times the background writer stopped a cleaning scan because it had written too many buffers per second. |
Dependent item | pgsql.bgwriter.maxwritten_clean.rate.above_17[{#SINGLETON}] Preprocessing
|
| Checkpoint: Buffers written by the background writer per second{#SINGLETON} | Number of buffers written by the background writer per second. |
Dependent item | pgsql.bgwriter.buffers_clean.rate.above_17[{#SINGLETON}] Preprocessing
|
| Checkpoint: Buffers written during checkpoints per second{#SINGLETON} | Number of buffers written during checkpoints per second. |
Dependent item | pgsql.bgwriter.buffers_checkpoint.rate.above_17[{#SINGLETON}] Preprocessing
|
| Checkpoint: Scheduled per second{#SINGLETON} | Number of scheduled checkpoints that have been performed per second. |
Dependent item | pgsql.bgwriter.checkpoints_timed.rate.above_17[{#SINGLETON}] Preprocessing
|
| Checkpoint: Requested per second{#SINGLETON} | Number of requested checkpoints that have been performed per second. |
Dependent item | pgsql.bgwriter.checkpoints_req.rate.above_17[{#SINGLETON}] Preprocessing
|
| Checkpoint: Checkpoint write time per second{#SINGLETON} | Total amount of time per second that has been spent in the portion of checkpoint processing where files are written to disk. |
Dependent item | pgsql.bgwriter.checkpoint_write_time.rate.above_17[{#SINGLETON}] Preprocessing
|
| Bgwriter: Checkpoint sync time per second{#SINGLETON} | Total amount of time per second that has been spent in the portion of checkpoint processing where files are synchronized to disk. |
Dependent item | pgsql.bgwriter.checkpoint_sync_time.rate.above_17[{#SINGLETON}] Preprocessing
|
Please report any issues with the template at https://support.zabbix.com
You can also provide feedback, discuss the template, or ask for help at ZABBIX forums
Source: https://git.zabbix.com/projects/ZBX/repos/zabbix/browse/templates/db/postgresql_odbc?at=release/6.4
This template is designed for the effortless deployment of PostgreSQL monitoring by Zabbix via ODBC and doesn't require any external scripts.
Zabbix version: 6.4 and higher.
This template has been tested on:
Zabbix should be configured according to the instructions in the Templates out of the box section.
<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;
pg_hba.conf configuration file to allow TCP connections for the user zbx_monitor. For example, you could add one of the following rows to allow local connections from the same host:# TYPE DATABASE USER ADDRESS METHOD
host all zbx_monitor localhost trust
host all zbx_monitor 127.0.0.1/32 md5
host all zbx_monitor ::1/128 scram-sha-256
For more information please read the PostgreSQL documentation https://www.postgresql.org/docs/current/auth-pg-hba-conf.html.
Install the PostgreSQL ODBC driver. Check the Zabbix documentation for details about ODBC checks and recommended parameters page.
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.Note: 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 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
{$PG.PASSWORD}.| Name | Description | Default |
|---|---|---|
| {$PG.PASSWORD} | PostgreSQL user password. |
<Put the password here> |
| {$PG.USER} | PostgreSQL username. |
zbx_monitor |
| {$PG.CONNSTRING} | Connection string for the PostgreSQL instance. |
Macro too long. Please see the template. |
| {$PG.LLD.FILTER.DBNAME} | Filter of discoverable databases. |
.+ |
| {$PG.CONN_TOTAL_PCT.MAX.WARN} | Maximum percentage of current connections for trigger expression. |
90 |
| {$PG.DATABASE} | Default PostgreSQL database for the connection. |
postgres |
| {$PG.DEADLOCKS.MAX.WARN} | Maximum number of detected deadlocks for trigger expression. |
0 |
| {$PG.LLD.FILTER.APPLICATION} | Filter of discoverable applications. |
.+ |
| {$PG.CONFLICTS.MAX.WARN} | Maximum number of recovery conflicts for trigger expression. |
0 |
| {$PG.QUERY_ETIME.MAX.WARN} | Execution time limit for count of slow queries. |
30 |
| {$PG.SLOW_QUERIES.MAX.WARN} | Slow queries count threshold for a trigger. |
5 |
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| PostgreSQL: Get bgwriter | Collect all metrics from pg_stat_bgwriter: https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-BGWRITER-VIEW |
Database monitor | db.odbc.select[pgsql.bgwriter,,"Database={$PG.DATABASE};{$PG.CONNSTRING}"] |
| PostgreSQL: Get archive | Collect archive status metrics. |
Database monitor | db.odbc.select[pgsql.archive,,"Database={$PG.DATABASE};{$PG.CONNSTRING}"] |
| PostgreSQL: Get dbstat | Collect all metrics from pg_stat_database per database: https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-DATABASE-VIEW |
Database monitor | db.odbc.select[pgsql.dbstat,,"Database={$PG.DATABASE};{$PG.CONNSTRING}"] |
| PostgreSQL: Get dbstat sum | 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 |
Database monitor | db.odbc.select[pgsql.dbstat.sum,,"Database={$PG.DATABASE};{$PG.CONNSTRING}"] |
| PostgreSQL: Get connections sum | Collect all metrics from pg_stat_activity: https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-ACTIVITY-VIEW |
Database monitor | db.odbc.select[pgsql.connections.sum,,"Database={$PG.DATABASE};{$PG.CONNSTRING}"] |
| PostgreSQL: Get WAL | Collect write-ahead log (WAL) metrics. |
Database monitor | db.odbc.select[pgsql.wal.stat,,"Database={$PG.DATABASE};{$PG.CONNSTRING}"] |
| PostgreSQL: Get locks | Collect all metrics from pg_locks per database: https://www.postgresql.org/docs/current/explicit-locking.html#LOCKING-TABLES |
Database monitor | db.odbc.select[pgsql.locks,,"Database={$PG.DATABASE};{$PG.CONNSTRING}"] |
| PostgreSQL: Get replication | 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. |
Database monitor | db.odbc.select[pgsql.replication.process,,"Database={$PG.DATABASE};{$PG.CONNSTRING}"] Preprocessing
|
| PostgreSQL: Get queries | Collect all metrics by query execution time. |
Database monitor | db.odbc.select[pgsql.queries,,"Database={$PG.DATABASE};{$PG.CONNSTRING}"] |
| PostgreSQL: Version | PostgreSQL version. |
Database monitor | db.odbc.select[pgsql.version,,"Database={$PG.DATABASE};{$PG.CONNSTRING}"] Preprocessing
|
| WAL: Bytes written | WAL write, in bytes. |
Dependent item | pgsql.wal.write Preprocessing
|
| WAL: Bytes received | WAL receive, in bytes. |
Dependent item | pgsql.wal.receive Preprocessing
|
| WAL: Segments count | Number of WAL segments. |
Dependent item | pgsql.wal.count Preprocessing
|
| Bgwriter: Buffers allocated per second | Number of buffers allocated per second. |
Dependent item | pgsql.bgwriter.buffers_alloc.rate Preprocessing
|
| Bgwriter: Buffers written directly by a backend per second | Number of buffers written directly by a backend per second. |
Dependent item | pgsql.bgwriter.buffers_backend.rate Preprocessing
|
| Bgwriter: Number of bgwriter cleaning scan stopped per second | Number of times the background writer stopped a cleaning scan because it had written too many buffers per second. |
Dependent item | pgsql.bgwriter.maxwritten_clean.rate Preprocessing
|
| Bgwriter: Times a backend executed its own fsync per second | 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). |
Dependent item | pgsql.bgwriter.buffers_backend_fsync.rate Preprocessing
|
| Checkpoint: Buffers written by the background writer per second | Number of buffers written by the background writer per second. |
Dependent item | pgsql.bgwriter.buffers_clean.rate Preprocessing
|
| Checkpoint: Buffers written during checkpoints per second | Number of buffers written during checkpoints per second. |
Dependent item | pgsql.bgwriter.buffers_checkpoint.rate Preprocessing
|
| Checkpoint: Scheduled per second | Number of scheduled checkpoints that have been performed per second. |
Dependent item | pgsql.bgwriter.checkpoints_timed.rate Preprocessing
|
| Checkpoint: Requested per second | Number of requested checkpoints that have been performed per second. |
Dependent item | pgsql.bgwriter.checkpoints_req.rate Preprocessing
|
| Checkpoint: Checkpoint write time per second | Total amount of time per second that has been spent in the portion of checkpoint processing where files are written to disk. |
Dependent item | pgsql.bgwriter.checkpoint_write_time.rate Preprocessing
|
| Checkpoint: Checkpoint sync time per second | Total amount of time per second that has been spent in the portion of checkpoint processing where files are synchronized to disk. |
Dependent item | pgsql.bgwriter.checkpoint_sync_time.rate Preprocessing
|
| Archive: Count of archived files | Count of archived files. |
Dependent item | pgsql.archive.count_archived_files Preprocessing
|
| Archive: Count of failed attempts to archive files | Count of failed attempts to archive files. |
Dependent item | pgsql.archive.failed_trying_to_archive Preprocessing
|
| Archive: Count of files in archive_status need to archive | Count of files to archive. |
Dependent item | pgsql.archive.count_files_to_archive Preprocessing
|
| Archive: Size of files need to archive | Size of files to archive. |
Dependent item | pgsql.archive.size_files_to_archive Preprocessing
|
| Dbstat: Blocks read time | Time spent reading data file blocks by backends. |
Dependent item | pgsql.dbstat.sum.blk_read_time Preprocessing
|
| Dbstat: Blocks write time | Time spent writing data file blocks by backends. |
Dependent item | pgsql.dbstat.sum.blk_write_time Preprocessing
|
| Dbstat: Committed transactions per second | Number of transactions that have been committed per second. |
Dependent item | pgsql.dbstat.sum.xact_commit.rate Preprocessing
|
| Dbstat: Conflicts per second | Number of queries canceled per second due to conflicts with recovery (conflicts occur only on standby servers; see pg_stat_database_conflicts for details). |
Dependent item | pgsql.dbstat.sum.conflicts.rate Preprocessing
|
| Dbstat: Deadlocks per second | Number of deadlocks detected per second. |
Dependent item | pgsql.dbstat.sum.deadlocks.rate Preprocessing
|
| Dbstat: Disk blocks read per second | Number of disk blocks read per second. |
Dependent item | pgsql.dbstat.sum.blks_read.rate Preprocessing
|
| Dbstat: Hit blocks read per second | Number of times per second disk blocks were found already in the buffer cache. |
Dependent item | pgsql.dbstat.sum.blks_hit.rate Preprocessing
|
| Dbstat: Number temp bytes per second | Total amount of data written per second to temporary files by queries. |
Dependent item | pgsql.dbstat.sum.temp_bytes.rate Preprocessing
|
| Dbstat: Number temp files per second | Number of temporary files created by queries per second. |
Dependent item | pgsql.dbstat.sum.temp_files.rate Preprocessing
|
| Dbstat: Roll backed transactions per second | Number of transactions that have been rolled back per second. |
Dependent item | pgsql.dbstat.sum.xact_rollback.rate Preprocessing
|
| Dbstat: Rows deleted per second | Number of rows deleted by queries per second. |
Dependent item | pgsql.dbstat.sum.tup_deleted.rate Preprocessing
|
| Dbstat: Rows fetched per second | Number of rows fetched by queries per second. |
Dependent item | pgsql.dbstat.sum.tup_fetched.rate Preprocessing
|
| Dbstat: Rows inserted per second | Number of rows inserted by queries per second. |
Dependent item | pgsql.dbstat.sum.tup_inserted.rate Preprocessing
|
| Dbstat: Rows returned per second | Number of rows returned by queries per second. |
Dependent item | pgsql.dbstat.sum.tup_returned.rate Preprocessing
|
| Dbstat: Rows updated per second | Number of rows updated by queries per second. |
Dependent item | pgsql.dbstat.sum.tup_updated.rate Preprocessing
|
| Dbstat: Backends connected | Number of connected backends. |
Dependent item | pgsql.dbstat.sum.numbackends Preprocessing
|
| Connections sum: Active | Total number of connections executing a query. |
Dependent item | pgsql.connections.sum.active Preprocessing
|
| Connections sum: Fastpath function call | Total number of connections executing a fast-path function. |
Dependent item | pgsql.connections.sum.fastpath_function_call Preprocessing
|
| Connections sum: Idle | Total number of connections waiting for a new client command. |
Dependent item | pgsql.connections.sum.idle Preprocessing
|
| Connections sum: Idle in transaction | Total number of connections in a transaction state but not executing a query. |
Dependent item | pgsql.connections.sum.idle_in_transaction Preprocessing
|
| Connections sum: Prepared | Total number of prepared transactions: https://www.postgresql.org/docs/current/sql-prepare-transaction.html |
Dependent item | pgsql.connections.sum.prepared Preprocessing
|
| Connections sum: Total | Total number of connections. |
Dependent item | pgsql.connections.sum.total Preprocessing
|
| Connections sum: Total, % | Total number of connections, in percentage. |
Dependent item | pgsql.connections.sum.total_pct Preprocessing
|
| Connections sum: Waiting | Total number of waiting connections: https://www.postgresql.org/docs/current/monitoring-stats.html#WAIT-EVENT-TABLE |
Dependent item | pgsql.connections.sum.waiting Preprocessing
|
| Connections sum: Idle in transaction (aborted) | 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. |
Dependent item | pgsql.connections.sum.idle_in_transaction_aborted Preprocessing
|
| Connections sum: Disabled | Total number of disabled connections. |
Dependent item | pgsql.connections.sum.disabled Preprocessing
|
| PostgreSQL: Age of oldest xid | Age of oldest xid. |
Database monitor | db.odbc.select[pgsql.oldest.xid,,"Database={$PG.DATABASE};{$PG.CONNSTRING}"] |
| PostgreSQL: Count of autovacuum workers | Number of autovacuum workers. |
Database monitor | db.odbc.select[pgsql.autovacuum.count,,"Database={$PG.DATABASE};{$PG.CONNSTRING}"] |
| PostgreSQL: Cache hit ratio, % | Cache hit ratio. |
Calculated | pgsql.cache.hit |
| PostgreSQL: Uptime | Time since the server started. |
Database monitor | db.odbc.select[pgsql.uptime,,"Database={$PG.DATABASE};{$PG.CONNSTRING}"] |
| PostgreSQL: Replication: Lag in bytes | Replication lag with master, in bytes. |
Database monitor | db.odbc.select[pgsql.replication.lag.b,,"Database={$PG.DATABASE};{$PG.CONNSTRING}"] |
| PostgreSQL: Replication: Lag in seconds | Replication lag with master, in seconds. |
Database monitor | db.odbc.select[pgsql.replication.lag.sec,,"Database={$PG.DATABASE};{$PG.CONNSTRING}"] |
| PostgreSQL: Replication: Recovery role | Replication role: 1 — recovery is still in progress (standby mode), 0 — master mode. |
Database monitor | db.odbc.select[pgsql.replication.recovery_role,,"Database={$PG.DATABASE};{$PG.CONNSTRING}"] |
| PostgreSQL: Replication: Standby count | Number of standby servers. |
Database monitor | db.odbc.select[pgsql.replication.count,,"Database={$PG.DATABASE};{$PG.CONNSTRING}"] |
| PostgreSQL: Replication: Status | Replication status: 0 — streaming is down, 1 — streaming is up, 2 — master mode. |
Database monitor | db.odbc.select[pgsql.replication.status,,"Database={$PG.DATABASE};{$PG.CONNSTRING}"] |
| PostgreSQL: Ping | Used to test a connection to see if it is alive. It is set to 0 if the query is unsuccessful. |
Database monitor | db.odbc.select[pgsql.ping,,"Database={$PG.DATABASE};{$PG.CONNSTRING}"] Preprocessing
|
| Name | Description | Expression | Severity | Dependencies and additional info |
|---|---|---|---|---|
| PostgreSQL: Version has changed | last(/PostgreSQL by ODBC/db.odbc.select[pgsql.version,,"Database={$PG.DATABASE};{$PG.CONNSTRING}"],#1)<>last(/PostgreSQL by ODBC/db.odbc.select[pgsql.version,,"Database={$PG.DATABASE};{$PG.CONNSTRING}"],#2) and length(last(/PostgreSQL by ODBC/db.odbc.select[pgsql.version,,"Database={$PG.DATABASE};{$PG.CONNSTRING}"]))>0 |
Info | ||
| PostgreSQL: Total number of connections is too high | 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). |
min(/PostgreSQL by ODBC/pgsql.connections.sum.total_pct,5m) > {$PG.CONN_TOTAL_PCT.MAX.WARN} |
Average | |
| PostgreSQL: Oldest xid is too big | last(/PostgreSQL by ODBC/db.odbc.select[pgsql.oldest.xid,,"Database={$PG.DATABASE};{$PG.CONNSTRING}"]) > 18000000 |
Average | ||
| PostgreSQL: Service has been restarted | PostgreSQL uptime is less than 10 minutes. |
last(/PostgreSQL by ODBC/db.odbc.select[pgsql.uptime,,"Database={$PG.DATABASE};{$PG.CONNSTRING}"]) < 10m |
Average | |
| PostgreSQL: Service is down | Last test of a connection was unsuccessful. |
last(/PostgreSQL by ODBC/db.odbc.select[pgsql.ping,,"Database={$PG.DATABASE};{$PG.CONNSTRING}"])=0 |
High |
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Replication discovery | Discovers replication lag metrics. |
Database monitor | db.odbc.select[pgsql.replication.process.discovery,,"Database={$PG.DATABASE};{$PG.CONNSTRING}"] Preprocessing
|
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Application [{#APPLICATION_NAME}]: Get replication | 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. |
Dependent item | pgsql.replication.get_metrics["{#APPLICATION_NAME}"] Preprocessing
|
| Application [{#APPLICATION_NAME}]: Replication flush lag | 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. |
Dependent item | pgsql.replication.process.flush_lag["{#APPLICATION_NAME}"] Preprocessing
|
| Application [{#APPLICATION_NAME}]: Replication replay lag | 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. |
Dependent item | pgsql.replication.process.replay_lag["{#APPLICATION_NAME}"] Preprocessing
|
| Application [{#APPLICATION_NAME}]: Replication write lag | 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. |
Dependent item | pgsql.replication.process.write_lag["{#APPLICATION_NAME}"] Preprocessing
|
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Database discovery | Discovers databases (DB) in the database management system (DBMS), except: - templates; - default "postgres" DB; - DBs that do not allow connections. |
Database monitor | db.odbc.select[pgsql.db.discovery,,"Database={$PG.DATABASE};{$PG.CONNSTRING}"] |
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| DB [{#DBNAME}]: Get dbstat | Get dbstat metrics for database "{#DBNAME}". |
Dependent item | pgsql.dbstat.get_metrics["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Get locks | Get locks metrics for database "{#DBNAME}". |
Dependent item | pgsql.locks.get_metrics["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Get queries | Get queries metrics for database "{#DBNAME}". |
Dependent item | pgsql.queries.get_metrics["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Database age | Database age. |
Database monitor | db.odbc.select[pgsql.db.age,,"Database={#DBNAME};{$PG.CONNSTRING}"] |
| DB [{#DBNAME}]: Bloating tables | Number of bloating tables. |
Database monitor | db.odbc.select[pgsql.db.bloating_tables,,"Database={#DBNAME};{$PG.CONNSTRING}"] |
| DB [{#DBNAME}]: Database size | Database size. |
Database monitor | db.odbc.select[pgsql.db.size,,"Database={#DBNAME};{$PG.CONNSTRING}"] |
| DB [{#DBNAME}]: Blocks hit per second | Total number of times per second disk blocks were found already in the buffer cache, so that a read was not necessary. |
Dependent item | pgsql.dbstat.blks_hit.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Disk blocks read per second | Total number of disk blocks read per second in this database. |
Dependent item | pgsql.dbstat.blks_read.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Detected conflicts per second | Total number of queries canceled due to conflicts with recovery in this database per second. |
Dependent item | pgsql.dbstat.conflicts.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Detected deadlocks per second | Total number of detected deadlocks in this database per second. |
Dependent item | pgsql.dbstat.deadlocks.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Temp_bytes written per second | Total amount of data written to temporary files by queries in this database. |
Dependent item | pgsql.dbstat.temp_bytes.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Temp_files created per second | Total number of temporary files created by queries in this database. |
Dependent item | pgsql.dbstat.temp_files.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Tuples deleted per second | Total number of rows deleted by queries in this database per second. |
Dependent item | pgsql.dbstat.tup_deleted.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Tuples fetched per second | Total number of rows fetched by queries in this database per second. |
Dependent item | pgsql.dbstat.tup_fetched.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Tuples inserted per second | Total number of rows inserted by queries in this database per second. |
Dependent item | pgsql.dbstat.tup_inserted.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Tuples returned per second | Number of rows returned by queries in this database per second. |
Dependent item | pgsql.dbstat.tup_returned.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Tuples updated per second | Total number of rows updated by queries in this database per second. |
Dependent item | pgsql.dbstat.tup_updated.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Commits per second | Number of transactions in this database that have been committed per second. |
Dependent item | pgsql.dbstat.xact_commit.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Rollbacks per second | Total number of transactions in this database that have been rolled back. |
Dependent item | pgsql.dbstat.xact_rollback.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Backends connected | Number of backends currently connected to this database. |
Dependent item | pgsql.dbstat.numbackends["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Disk blocks read time per second | Time spent reading data file blocks by backends per second. |
Dependent item | pgsql.dbstat.blk_read_time.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Disk blocks write time per second | Time spent writing data file blocks by backends per second. |
Dependent item | pgsql.dbstat.blk_write_time.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Num of accessexclusive locks | Number of accessexclusive locks for this database. |
Dependent item | pgsql.locks.accessexclusive["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Num of accessshare locks | Number of accessshare locks for this database. |
Dependent item | pgsql.locks.accessshare["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Num of exclusive locks | Number of exclusive locks for this database. |
Dependent item | pgsql.locks.exclusive["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Num of rowexclusive locks | Number of rowexclusive locks for this database. |
Dependent item | pgsql.locks.rowexclusive["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Num of rowshare locks | Number of rowshare locks for this database. |
Dependent item | pgsql.locks.rowshare["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Num of sharerowexclusive locks | Number of total sharerowexclusive for this database. |
Dependent item | pgsql.locks.sharerowexclusive["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Num of shareupdateexclusive locks | Number of shareupdateexclusive locks for this database. |
Dependent item | pgsql.locks.shareupdateexclusive["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Num of share locks | Number of share locks for this database. |
Dependent item | pgsql.locks.share["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Num of locks total | Total number of locks in this database. |
Dependent item | pgsql.locks.total["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries max maintenance time | Max maintenance query time for this database. |
Dependent item | pgsql.queries.mro.time_max["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries max query time | Max query time for this database. |
Dependent item | pgsql.queries.query.time_max["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries max transaction time | Max transaction query time for this database. |
Dependent item | pgsql.queries.tx.time_max["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries slow maintenance count | Slow maintenance query count for this database. |
Dependent item | pgsql.queries.mro.slow_count["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries slow query count | Slow query count for this database. |
Dependent item | pgsql.queries.query.slow_count["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries slow transaction count | Slow transaction query count for this database. |
Dependent item | pgsql.queries.tx.slow_count["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries sum maintenance time | Sum maintenance query time for this database. |
Dependent item | pgsql.queries.mro.time_sum["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries sum query time | Sum query time for this database. |
Dependent item | pgsql.queries.query.time_sum["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries sum transaction time | Sum transaction query time for this database. |
Dependent item | pgsql.queries.tx.time_sum["{#DBNAME}"] Preprocessing
|
| Name | Description | Expression | Severity | Dependencies and additional info |
|---|---|---|---|---|
| DB [{#DBNAME}]: Too many recovery conflicts | 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. |
min(/PostgreSQL by ODBC/pgsql.dbstat.conflicts.rate["{#DBNAME}"],5m) > {$PG.CONFLICTS.MAX.WARN:"{#DBNAME}"} |
Average | |
| DB [{#DBNAME}]: Deadlock occurred | Number of deadlocks detected per second exceeds {$PG.DEADLOCKS.MAX.WARN:"{#DBNAME}"} for 5m. |
min(/PostgreSQL by ODBC/pgsql.dbstat.deadlocks.rate["{#DBNAME}"],5m) > {$PG.DEADLOCKS.MAX.WARN:"{#DBNAME}"} |
High | |
| DB [{#DBNAME}]: Too many slow queries | The number of detected slow queries exceeds the limit of {$PG.SLOW_QUERIES.MAX.WARN:"{#DBNAME}"}. |
min(/PostgreSQL by ODBC/pgsql.queries.query.slow_count["{#DBNAME}"],5m)>{$PG.SLOW_QUERIES.MAX.WARN:"{#DBNAME}"} |
Warning |
Please report any issues with the template at https://support.zabbix.com
You can also provide feedback, discuss the template, or ask for help at ZABBIX forums
Source: https://git.zabbix.com/projects/ZBX/repos/zabbix/browse/templates/db/postgresql_odbc?at=release/6.0
This template is designed for the effortless deployment of PostgreSQL monitoring by Zabbix via ODBC and doesn't require any external scripts.
Zabbix version: 6.0 and higher.
This template has been tested on:
Zabbix should be configured according to the instructions in the Templates out of the box section.
<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;
pg_hba.conf configuration file to allow TCP connections for the user zbx_monitor. For example, you could add one of the following rows to allow local connections from the same host:# TYPE DATABASE USER ADDRESS METHOD
host all zbx_monitor localhost trust
host all zbx_monitor 127.0.0.1/32 md5
host all zbx_monitor ::1/128 scram-sha-256
For more information please read the PostgreSQL documentation https://www.postgresql.org/docs/current/auth-pg-hba-conf.html.
Install the PostgreSQL ODBC driver. Check the Zabbix documentation for details about ODBC checks and recommended parameters page.
Set up the connection string with the {$PG.CONNSTRING.ODBC} 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.Note: 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 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
{$PG.PASSWORD}.| Name | Description | Default |
|---|---|---|
| {$PG.PASSWORD} | PostgreSQL user password. |
<Put the password here> |
| {$PG.USER} | PostgreSQL username. |
zbx_monitor |
| {$PG.CONNSTRING.ODBC} | Connection string for the PostgreSQL instance. |
Macro too long. Please see the template. |
| {$PG.LLD.FILTER.DBNAME} | Filter of discoverable databases. |
.+ |
| {$PG.CONN_TOTAL_PCT.MAX.WARN} | Maximum percentage of current connections for trigger expression. |
90 |
| {$PG.DATABASE} | Default PostgreSQL database for the connection. |
postgres |
| {$PG.DEADLOCKS.MAX.WARN} | Maximum number of detected deadlocks for trigger expression. |
0 |
| {$PG.LLD.FILTER.APPLICATION} | Filter of discoverable applications. |
.+ |
| {$PG.CONFLICTS.MAX.WARN} | Maximum number of recovery conflicts for trigger expression. |
0 |
| {$PG.QUERY_ETIME.MAX.WARN} | Execution time limit for count of slow queries. |
30 |
| {$PG.SLOW_QUERIES.MAX.WARN} | Slow queries count threshold for a trigger. |
5 |
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| PostgreSQL: Get bgwriter | Collect all metrics from pg_stat_bgwriter: https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-BGWRITER-VIEW |
Database monitor | db.odbc.select[pgsql.bgwriter,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] |
| PostgreSQL: Get archive | Collect archive status metrics. |
Database monitor | db.odbc.select[pgsql.archive,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] |
| PostgreSQL: Get dbstat | Collect all metrics from pg_stat_database per database: https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-DATABASE-VIEW |
Database monitor | db.odbc.select[pgsql.dbstat,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] |
| PostgreSQL: Get dbstat sum | 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 |
Database monitor | db.odbc.select[pgsql.dbstat.sum,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] |
| PostgreSQL: Get connections sum | Collect all metrics from pg_stat_activity: https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-ACTIVITY-VIEW |
Database monitor | db.odbc.select[pgsql.connections.sum,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] |
| PostgreSQL: Get WAL | Collect write-ahead log (WAL) metrics. |
Database monitor | db.odbc.select[pgsql.wal.stat,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] |
| PostgreSQL: Get locks | Collect all metrics from pg_locks per database: https://www.postgresql.org/docs/current/explicit-locking.html#LOCKING-TABLES |
Database monitor | db.odbc.select[pgsql.locks,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] |
| PostgreSQL: Get replication | 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. |
Database monitor | db.odbc.select[pgsql.replication.process,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] Preprocessing
|
| PostgreSQL: Get queries | Collect all metrics by query execution time. |
Database monitor | db.odbc.select[pgsql.queries,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] |
| PostgreSQL: Version | PostgreSQL version. |
Database monitor | db.odbc.select[pgsql.version,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] Preprocessing
|
| WAL: Bytes written | WAL write, in bytes. |
Dependent item | pgsql.wal.write Preprocessing
|
| WAL: Bytes received | WAL receive, in bytes. |
Dependent item | pgsql.wal.receive Preprocessing
|
| WAL: Segments count | Number of WAL segments. |
Dependent item | pgsql.wal.count Preprocessing
|
| Bgwriter: Buffers allocated per second | Number of buffers allocated per second. |
Dependent item | pgsql.bgwriter.buffers_alloc.rate Preprocessing
|
| Bgwriter: Buffers written directly by a backend per second | Number of buffers written directly by a backend per second. |
Dependent item | pgsql.bgwriter.buffers_backend.rate Preprocessing
|
| Bgwriter: Number of bgwriter cleaning scan stopped per second | Number of times the background writer stopped a cleaning scan because it had written too many buffers per second. |
Dependent item | pgsql.bgwriter.maxwritten_clean.rate Preprocessing
|
| Bgwriter: Times a backend executed its own fsync per second | 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). |
Dependent item | pgsql.bgwriter.buffers_backend_fsync.rate Preprocessing
|
| Checkpoint: Buffers written by the background writer per second | Number of buffers written by the background writer per second. |
Dependent item | pgsql.bgwriter.buffers_clean.rate Preprocessing
|
| Checkpoint: Buffers written during checkpoints per second | Number of buffers written during checkpoints per second. |
Dependent item | pgsql.bgwriter.buffers_checkpoint.rate Preprocessing
|
| Checkpoint: Scheduled per second | Number of scheduled checkpoints that have been performed per second. |
Dependent item | pgsql.bgwriter.checkpoints_timed.rate Preprocessing
|
| Checkpoint: Requested per second | Number of requested checkpoints that have been performed per second. |
Dependent item | pgsql.bgwriter.checkpoints_req.rate Preprocessing
|
| Checkpoint: Checkpoint write time per second | Total amount of time per second that has been spent in the portion of checkpoint processing where files are written to disk. |
Dependent item | pgsql.bgwriter.checkpoint_write_time.rate Preprocessing
|
| Checkpoint: Checkpoint sync time per second | Total amount of time per second that has been spent in the portion of checkpoint processing where files are synchronized to disk. |
Dependent item | pgsql.bgwriter.checkpoint_sync_time.rate Preprocessing
|
| Archive: Count of archived files | Count of archived files. |
Dependent item | pgsql.archive.count_archived_files Preprocessing
|
| Archive: Count of failed attempts to archive files | Count of failed attempts to archive files. |
Dependent item | pgsql.archive.failed_trying_to_archive Preprocessing
|
| Archive: Count of files in archive_status need to archive | Count of files to archive. |
Dependent item | pgsql.archive.count_files_to_archive Preprocessing
|
| Archive: Size of files need to archive | Size of files to archive. |
Dependent item | pgsql.archive.size_files_to_archive Preprocessing
|
| Dbstat: Blocks read time | Time spent reading data file blocks by backends. |
Dependent item | pgsql.dbstat.sum.blk_read_time Preprocessing
|
| Dbstat: Blocks write time | Time spent writing data file blocks by backends. |
Dependent item | pgsql.dbstat.sum.blk_write_time Preprocessing
|
| Dbstat: Committed transactions per second | Number of transactions that have been committed per second. |
Dependent item | pgsql.dbstat.sum.xact_commit.rate Preprocessing
|
| Dbstat: Conflicts per second | Number of queries canceled per second due to conflicts with recovery (conflicts occur only on standby servers; see pg_stat_database_conflicts for details). |
Dependent item | pgsql.dbstat.sum.conflicts.rate Preprocessing
|
| Dbstat: Deadlocks per second | Number of deadlocks detected per second. |
Dependent item | pgsql.dbstat.sum.deadlocks.rate Preprocessing
|
| Dbstat: Disk blocks read per second | Number of disk blocks read per second. |
Dependent item | pgsql.dbstat.sum.blks_read.rate Preprocessing
|
| Dbstat: Hit blocks read per second | Number of times per second disk blocks were found already in the buffer cache. |
Dependent item | pgsql.dbstat.sum.blks_hit.rate Preprocessing
|
| Dbstat: Number temp bytes per second | Total amount of data written per second to temporary files by queries. |
Dependent item | pgsql.dbstat.sum.temp_bytes.rate Preprocessing
|
| Dbstat: Number temp files per second | Number of temporary files created by queries per second. |
Dependent item | pgsql.dbstat.sum.temp_files.rate Preprocessing
|
| Dbstat: Roll backed transactions per second | Number of transactions that have been rolled back per second. |
Dependent item | pgsql.dbstat.sum.xact_rollback.rate Preprocessing
|
| Dbstat: Rows deleted per second | Number of rows deleted by queries per second. |
Dependent item | pgsql.dbstat.sum.tup_deleted.rate Preprocessing
|
| Dbstat: Rows fetched per second | Number of rows fetched by queries per second. |
Dependent item | pgsql.dbstat.sum.tup_fetched.rate Preprocessing
|
| Dbstat: Rows inserted per second | Number of rows inserted by queries per second. |
Dependent item | pgsql.dbstat.sum.tup_inserted.rate Preprocessing
|
| Dbstat: Rows returned per second | Number of rows returned by queries per second. |
Dependent item | pgsql.dbstat.sum.tup_returned.rate Preprocessing
|
| Dbstat: Rows updated per second | Number of rows updated by queries per second. |
Dependent item | pgsql.dbstat.sum.tup_updated.rate Preprocessing
|
| Dbstat: Backends connected | Number of connected backends. |
Dependent item | pgsql.dbstat.sum.numbackends Preprocessing
|
| Connections sum: Active | Total number of connections executing a query. |
Dependent item | pgsql.connections.sum.active Preprocessing
|
| Connections sum: Fastpath function call | Total number of connections executing a fast-path function. |
Dependent item | pgsql.connections.sum.fastpath_function_call Preprocessing
|
| Connections sum: Idle | Total number of connections waiting for a new client command. |
Dependent item | pgsql.connections.sum.idle Preprocessing
|
| Connections sum: Idle in transaction | Total number of connections in a transaction state but not executing a query. |
Dependent item | pgsql.connections.sum.idle_in_transaction Preprocessing
|
| Connections sum: Prepared | Total number of prepared transactions: https://www.postgresql.org/docs/current/sql-prepare-transaction.html |
Dependent item | pgsql.connections.sum.prepared Preprocessing
|
| Connections sum: Total | Total number of connections. |
Dependent item | pgsql.connections.sum.total Preprocessing
|
| Connections sum: Total, % | Total number of connections, in percentage. |
Dependent item | pgsql.connections.sum.total_pct Preprocessing
|
| Connections sum: Waiting | Total number of waiting connections: https://www.postgresql.org/docs/current/monitoring-stats.html#WAIT-EVENT-TABLE |
Dependent item | pgsql.connections.sum.waiting Preprocessing
|
| Connections sum: Idle in transaction (aborted) | 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. |
Dependent item | pgsql.connections.sum.idle_in_transaction_aborted Preprocessing
|
| Connections sum: Disabled | Total number of disabled connections. |
Dependent item | pgsql.connections.sum.disabled Preprocessing
|
| PostgreSQL: Age of oldest xid | Age of oldest xid. |
Database monitor | db.odbc.select[pgsql.oldest.xid,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] |
| PostgreSQL: Count of autovacuum workers | Number of autovacuum workers. |
Database monitor | db.odbc.select[pgsql.autovacuum.count,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] |
| PostgreSQL: Cache hit ratio, % | Cache hit ratio. |
Calculated | pgsql.cache.hit |
| PostgreSQL: Uptime | Time since the server started. |
Database monitor | db.odbc.select[pgsql.uptime,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] |
| PostgreSQL: Replication: Lag in bytes | Replication lag with master, in bytes. |
Database monitor | db.odbc.select[pgsql.replication.lag.b,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] |
| PostgreSQL: Replication: Lag in seconds | Replication lag with master, in seconds. |
Database monitor | db.odbc.select[pgsql.replication.lag.sec,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] |
| PostgreSQL: Replication: Recovery role | Replication role: 1 — recovery is still in progress (standby mode), 0 — master mode. |
Database monitor | db.odbc.select[pgsql.replication.recovery_role,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] |
| PostgreSQL: Replication: Standby count | Number of standby servers. |
Database monitor | db.odbc.select[pgsql.replication.count,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] |
| PostgreSQL: Replication: Status | Replication status: 0 — streaming is down, 1 — streaming is up, 2 — master mode. |
Database monitor | db.odbc.select[pgsql.replication.status,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] |
| PostgreSQL: Ping | Used to test a connection to see if it is alive. It is set to 0 if the query is unsuccessful. |
Database monitor | db.odbc.select[pgsql.ping,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] Preprocessing
|
| Name | Description | Expression | Severity | Dependencies and additional info |
|---|---|---|---|---|
| PostgreSQL: Version has changed | last(/PostgreSQL by ODBC/db.odbc.select[pgsql.version,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"],#1)<>last(/PostgreSQL by ODBC/db.odbc.select[pgsql.version,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"],#2) and length(last(/PostgreSQL by ODBC/db.odbc.select[pgsql.version,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"]))>0 |
Info | ||
| PostgreSQL: Total number of connections is too high | 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). |
min(/PostgreSQL by ODBC/pgsql.connections.sum.total_pct,5m) > {$PG.CONN_TOTAL_PCT.MAX.WARN} |
Average | |
| PostgreSQL: Oldest xid is too big | last(/PostgreSQL by ODBC/db.odbc.select[pgsql.oldest.xid,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"]) > 18000000 |
Average | ||
| PostgreSQL: Service has been restarted | PostgreSQL uptime is less than 10 minutes. |
last(/PostgreSQL by ODBC/db.odbc.select[pgsql.uptime,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"]) < 10m |
Average | |
| PostgreSQL: Service is down | Last test of a connection was unsuccessful. |
last(/PostgreSQL by ODBC/db.odbc.select[pgsql.ping,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"])=0 |
High |
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Replication discovery | Discovers replication lag metrics. |
Database monitor | db.odbc.select[pgsql.replication.process.discovery,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] Preprocessing
|
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Application [{#APPLICATION_NAME}]: Get replication | 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. |
Dependent item | pgsql.replication.get_metrics["{#APPLICATION_NAME}"] Preprocessing
|
| Application [{#APPLICATION_NAME}]: Replication flush lag | 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. |
Dependent item | pgsql.replication.process.flush_lag["{#APPLICATION_NAME}"] Preprocessing
|
| Application [{#APPLICATION_NAME}]: Replication replay lag | 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. |
Dependent item | pgsql.replication.process.replay_lag["{#APPLICATION_NAME}"] Preprocessing
|
| Application [{#APPLICATION_NAME}]: Replication write lag | 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. |
Dependent item | pgsql.replication.process.write_lag["{#APPLICATION_NAME}"] Preprocessing
|
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Database discovery | Discovers databases (DB) in the database management system (DBMS), except: - templates; - default "postgres" DB; - DBs that do not allow connections. |
Database monitor | db.odbc.select[pgsql.db.discovery,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] |
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| DB [{#DBNAME}]: Get dbstat | Get dbstat metrics for database "{#DBNAME}". |
Dependent item | pgsql.dbstat.get_metrics["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Get locks | Get locks metrics for database "{#DBNAME}". |
Dependent item | pgsql.locks.get_metrics["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Get queries | Get queries metrics for database "{#DBNAME}". |
Dependent item | pgsql.queries.get_metrics["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Database age | Database age. |
Database monitor | db.odbc.select[pgsql.db.age,,"Database={#DBNAME};{$PG.CONNSTRING.ODBC}"] |
| DB [{#DBNAME}]: Bloating tables | Number of bloating tables. |
Database monitor | db.odbc.select[pgsql.db.bloating_tables,,"Database={#DBNAME};{$PG.CONNSTRING.ODBC}"] |
| DB [{#DBNAME}]: Database size | Database size. |
Database monitor | db.odbc.select[pgsql.db.size,,"Database={#DBNAME};{$PG.CONNSTRING.ODBC}"] |
| DB [{#DBNAME}]: Blocks hit per second | Total number of times per second disk blocks were found already in the buffer cache, so that a read was not necessary. |
Dependent item | pgsql.dbstat.blks_hit.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Disk blocks read per second | Total number of disk blocks read per second in this database. |
Dependent item | pgsql.dbstat.blks_read.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Detected conflicts per second | Total number of queries canceled due to conflicts with recovery in this database per second. |
Dependent item | pgsql.dbstat.conflicts.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Detected deadlocks per second | Total number of detected deadlocks in this database per second. |
Dependent item | pgsql.dbstat.deadlocks.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Temp_bytes written per second | Total amount of data written to temporary files by queries in this database. |
Dependent item | pgsql.dbstat.temp_bytes.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Temp_files created per second | Total number of temporary files created by queries in this database. |
Dependent item | pgsql.dbstat.temp_files.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Tuples deleted per second | Total number of rows deleted by queries in this database per second. |
Dependent item | pgsql.dbstat.tup_deleted.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Tuples fetched per second | Total number of rows fetched by queries in this database per second. |
Dependent item | pgsql.dbstat.tup_fetched.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Tuples inserted per second | Total number of rows inserted by queries in this database per second. |
Dependent item | pgsql.dbstat.tup_inserted.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Tuples returned per second | Number of rows returned by queries in this database per second. |
Dependent item | pgsql.dbstat.tup_returned.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Tuples updated per second | Total number of rows updated by queries in this database per second. |
Dependent item | pgsql.dbstat.tup_updated.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Commits per second | Number of transactions in this database that have been committed per second. |
Dependent item | pgsql.dbstat.xact_commit.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Rollbacks per second | Total number of transactions in this database that have been rolled back. |
Dependent item | pgsql.dbstat.xact_rollback.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Backends connected | Number of backends currently connected to this database. |
Dependent item | pgsql.dbstat.numbackends["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Disk blocks read time per second | Time spent reading data file blocks by backends per second. |
Dependent item | pgsql.dbstat.blk_read_time.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Disk blocks write time per second | Time spent writing data file blocks by backends per second. |
Dependent item | pgsql.dbstat.blk_write_time.rate["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Num of accessexclusive locks | Number of accessexclusive locks for this database. |
Dependent item | pgsql.locks.accessexclusive["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Num of accessshare locks | Number of accessshare locks for this database. |
Dependent item | pgsql.locks.accessshare["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Num of exclusive locks | Number of exclusive locks for this database. |
Dependent item | pgsql.locks.exclusive["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Num of rowexclusive locks | Number of rowexclusive locks for this database. |
Dependent item | pgsql.locks.rowexclusive["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Num of rowshare locks | Number of rowshare locks for this database. |
Dependent item | pgsql.locks.rowshare["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Num of sharerowexclusive locks | Number of total sharerowexclusive for this database. |
Dependent item | pgsql.locks.sharerowexclusive["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Num of shareupdateexclusive locks | Number of shareupdateexclusive locks for this database. |
Dependent item | pgsql.locks.shareupdateexclusive["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Num of share locks | Number of share locks for this database. |
Dependent item | pgsql.locks.share["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Num of locks total | Total number of locks in this database. |
Dependent item | pgsql.locks.total["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries max maintenance time | Max maintenance query time for this database. |
Dependent item | pgsql.queries.mro.time_max["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries max query time | Max query time for this database. |
Dependent item | pgsql.queries.query.time_max["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries max transaction time | Max transaction query time for this database. |
Dependent item | pgsql.queries.tx.time_max["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries slow maintenance count | Slow maintenance query count for this database. |
Dependent item | pgsql.queries.mro.slow_count["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries slow query count | Slow query count for this database. |
Dependent item | pgsql.queries.query.slow_count["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries slow transaction count | Slow transaction query count for this database. |
Dependent item | pgsql.queries.tx.slow_count["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries sum maintenance time | Sum maintenance query time for this database. |
Dependent item | pgsql.queries.mro.time_sum["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries sum query time | Sum query time for this database. |
Dependent item | pgsql.queries.query.time_sum["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries sum transaction time | Sum transaction query time for this database. |
Dependent item | pgsql.queries.tx.time_sum["{#DBNAME}"] Preprocessing
|
| Name | Description | Expression | Severity | Dependencies and additional info |
|---|---|---|---|---|
| DB [{#DBNAME}]: Too many recovery conflicts | 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. |
min(/PostgreSQL by ODBC/pgsql.dbstat.conflicts.rate["{#DBNAME}"],5m) > {$PG.CONFLICTS.MAX.WARN:"{#DBNAME}"} |
Average | |
| DB [{#DBNAME}]: Deadlock occurred | Number of deadlocks detected per second exceeds {$PG.DEADLOCKS.MAX.WARN:"{#DBNAME}"} for 5m. |
min(/PostgreSQL by ODBC/pgsql.dbstat.deadlocks.rate["{#DBNAME}"],5m) > {$PG.DEADLOCKS.MAX.WARN:"{#DBNAME}"} |
High | |
| DB [{#DBNAME}]: Too many slow queries | The number of detected slow queries exceeds the limit of {$PG.SLOW_QUERIES.MAX.WARN:"{#DBNAME}"}. |
min(/PostgreSQL by ODBC/pgsql.queries.query.slow_count["{#DBNAME}"],5m)>{$PG.SLOW_QUERIES.MAX.WARN:"{#DBNAME}"} |
Warning |
Please report any issues with the template at https://support.zabbix.com
You can also provide feedback, discuss the template, or ask for help at ZABBIX forums
| Link | Source | Compatibility | Type, Technology | Created Updated | Rating |
|---|---|---|---|---|---|
| PostgreSQL monitoring with Zabbix The Template DB PostgreSQL was formerly known as pgCayenne. It is a set of UserParameter for PostgreSQL monitoring, which consists of Zabbix agent configuration and XML Template for web monitoring. It is using built-in PostgreSQL system views and functions. The agent requires the standard psql client ... github.com/lesovsky/zabbix-extensions/tree/master/files/postgresql |
GitHub |
3.4 |
Template |
Recommended
|
|
| Postgres ODBC I have been looking for templates to use with the new ODBC database monitoring item type with out success.I have created a rudimentary one for postgres. To use it follow these instructions for setting up ODBC on the server side.https://www.zabbix.com/documentation/4.0/manual/config/items/itemtypes/odbc\_checksWe ... template_postgres_odbc_database_monitoring |
GitHub Community Templates |
5.0+ |
| ||
| Zabbix plugin to monitor RDBMS ZabbixDBA is fast, flexible, and continuously developing plugin to monitor your RDBMS. ZabbixDBA uses threading of DBI connections which is good for monitoring of multiple database instances simultaneously. Just configure it, run daemon and it will do all the job github.com/netrusov/ZabbixDBA |
GitHub |
Module, Template Perl |
2015-06-29 2 y |
Popular
|
|
| PostgreSQL partitioning Scripts to install, manage, and remove PostgreSQL partitioning for Zabbix DB github.com/robbrucks/zabbix-postgresql-auto-partitioning |
GitHub |
Shell |
2017-05-15 2 y |
||
| Docker for postgreSQL Docker container for Zabbix DB on postrges, automatic partitioning. github.com/blackcobra1973/zabbix-db-postgresql |
GitHub |
docker Shell |
2015-12-18 10 y |
||
| Monitoring PostgreSQL in Zabbix Monitoring will be based on SQL queries to the statistics tables. github.com/CBEPX/PostgreSQL_Zabbix |
GitHub |
Template, Userparameter |
2017-07-06 3 y |
||
| pgmon_2ndq is a set of postgresql monitoring functions implemented in the server. The functions are installed in their own database and connect back to all databases in the server to get database specific infoA cronjob gets the monitoring info from these functions in a single database call and saves it to a file github.com/postsql/pgmon_zabbix |
GitHub |
PLpgSQL |
2011-12-30 8 y |
||
| Backup script for Zabbix on postgreSQL github.com/YxRyaB/zabbix-postgres-backup |
GitHub |
Shell |
2015-07-22 8 y |