Available solutions
PostgreSQL by Zabbix agent
Overview
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.
Requirements
Zabbix version: 8.0 and higher.
Tested versions
This template has been tested on:
- PostgreSQL 10-18
Configuration
Zabbix should be configured according to the instructions in the Templates out of the box section.
Setup
Note:
- The template requires
pg_isreadyandpsqlutilities to be installed on the same host with Zabbix agent.
- Deploy Zabbix agent and create the PostgreSQL user for monitoring (
<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;
- Copy the
postgresql/directory to thezabbixuser home directory -/var/lib/zabbix/. Thepostgresql/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
- Copy the
template_db_postgresql.conffile, containing user parameters, to the Zabbix agent configuration directory/etc/zabbix/zabbix_agentd.d/and restart Zabbix agent service.
Note: the template and these files are shipped together and have to be updated together. The postgresql/ directory and template_db_postgresql.conf carry a revision number, reported by the User parameters revision item. If the deployed files are older than the template requires, the trigger User parameters are outdated is raised - copy both the directory and the configuration file of the current template version to the host and restart Zabbix agent. Newer files always work with an older template, so the agent side can be updated first.
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.
- Edit the
pg_hba.confconfiguration file to allow connections for the userzbx_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}.
Macros used
| Name | Description | Default |
|---|---|---|
| {$PG.HOST} | Hostname or IP of PostgreSQL host. |
localhost |
| {$PG.PORT} | PostgreSQL service port. |
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.SCHEMA} | Filter of discoverable schemas. |
.+ |
| {$PG.LLD.FILTER.SUBSCRIPTION} | Filter of discoverable logical replication subscriptions. |
.+ |
| {$PG.LLD.FILTER.TABLESPACE} | Filter of discoverable tablespaces. |
.+ |
| {$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.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.IO.CACHE.MIN.WARN} | Minimum shared buffers hit ratio percentage for trigger expression. |
90 |
| {$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.QUERY_EXECUTION_TIME.MAX.WARN} | Execution time limit for count of slow queries. |
30 |
| {$PG.REPLICATION.SLOTS.RETAINING.MAX.HIGH} | Critical number of inactive replication slots retaining WAL for trigger expression. |
2 |
| {$PG.REPLICATION.SLOTS.RETAINING.MAX.WARN} | Maximum number of inactive replication slots retaining WAL for trigger expression. |
1 |
| {$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.SLRU.CACHE.MIN.HIGH} | Critical SLRU cache hit ratio percentage for trigger expression. |
95 |
| {$PG.SLRU.CACHE.MIN.WARN} | Minimum SLRU cache hit ratio percentage for trigger expression. |
98 |
| {$PG.SUBSCRIPTION.ERRORS.MAX.WARN} | Maximum number of logical replication subscription errors for trigger expression. |
2 |
| {$PG.TABLESPACE.SIZE.MAX.HIGH} | Critical tablespace size for trigger expression. |
15G |
| {$PG.TABLESPACE.SIZE.MAX.WARN} | Maximum tablespace size for trigger expression. |
5G |
| {$PG.WAL.BUFFERS_FULL.MAX.WARN} | Maximum number of WAL buffer exhaustions per second for trigger expression. |
10 |
Items
| 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. Available in PostgreSQL versions prior to 17. |
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). Available in PostgreSQL versions prior to 17. |
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
|
| 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}"] |
| Cache hit ratio, % | Cache hit ratio. |
Zabbix agent | pgsql.cache.hit["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| 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
|
| 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}"] |
| 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}"] |
| 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}"] |
| Ping time | Used to get the |
Zabbix agent | pgsql.ping.time["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] Preprocessing
|
| 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
|
| 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_EXECUTION_TIME.MAX.WARN}"] |
| Get relation sizes | Collects the on-disk size of the tables, their indexes and TOAST data, summed per schema of the "{$PG.DATABASE}" database. Reads the size metadata of every relation, therefore it is polled less frequently than the other metrics. |
Zabbix agent | pgsql.relation.size["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Replication: Standby count | Number of standby servers. |
Zabbix agent | pgsql.replication.count["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| 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}"] |
| 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}"] |
| 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}"] |
| Get subscription stats | Collects the error counters of the logical replication subscriptions from https://www.postgresql.org/docs/current/monitoring-stats.html#MONITORING-PG-STAT-SUBSCRIPTION-STATS |
Zabbix agent | pgsql.subscription.stats["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Get tablespace sizes | Collects the size, location and owner of every tablespace of the instance. Scans the tablespace directories, therefore it is polled less frequently than the other metrics. |
Zabbix agent | pgsql.tablespace.size["{$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
|
| Get transactions | Collect metrics by transaction execution time. |
Zabbix agent | pgsql.transactions["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Uptime | Time since the server started. |
Zabbix agent | pgsql.uptime["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| User parameters revision | Revision of the user parameter files deployed on the host with Zabbix agent. Reported by the |
Zabbix agent | pgsql.userparam.revision Preprocessing
|
| Version | PostgreSQL version. |
Zabbix agent | pgsql.version["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] Preprocessing
|
| Version (numeric) | The PostgreSQL version as an integer, the same way |
Dependent item | pgsql.version.num Preprocessing
|
| Version validator | Converts the PostgreSQL version into low-level discovery data: one entry with a Discovery rules filter on those macros, which is how version-specific metrics are created only where PostgreSQL provides them. |
Dependent item | pgsql.version.validator Preprocessing
|
| WAL: Segments count | Number of WAL segments. |
Dependent item | pgsql.wal.count Preprocessing
|
| 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
|
Triggers
| 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: User parameters are outdated | The user parameter files deployed on the host with Zabbix agent are older than this template version, so some items cannot collect data. |
last(/PostgreSQL by Zabbix agent/pgsql.userparam.revision) < 2 |
Warning | |
| PostgreSQL: Version has changed | The PostgreSQL version has changed. Check whether the update was planned, since a major version change can affect the availability of the collected metrics. |
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 |
LLD rule Database discovery
| 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}"] |
Item prototypes for Database discovery
| 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}"] |
Trigger prototypes for Database discovery
| 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/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/pgsql.dbstat.deadlocks.rate["{#DBNAME}"],5m) > {$PG.DEADLOCKS.MAX.WARN:"{#DBNAME}"} |
High | |
| PostgreSQL: 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 | |
| PostgreSQL: DB [{#DBNAME}]: Number of locks is too high | The number of locks in the database "{#DBNAME}" has exceeded {$PG.LOCKS.MAX.WARN:"{#DBNAME}"} for 5m. A growing number of locks indicates contention between transactions and can lead to queries waiting instead of being executed. |
min(/PostgreSQL by Zabbix agent/pgsql.locks.total["{#DBNAME}"],5m)>{$PG.LOCKS.MAX.WARN:"{#DBNAME}"} |
Warning | |
| 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/pgsql.queries.query.slow_count["{#DBNAME}"],5m)>{$PG.SLOW_QUERIES.MAX.WARN:"{#DBNAME}"} |
Warning |
LLD rule WAL statistics metrics discovery
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| WAL statistics metrics discovery | Discovers the |
Dependent item | pgsql.stat.wal.discovery Preprocessing
|
Item prototypes for WAL statistics metrics discovery
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| WAL statistics: Get data | Collects write-ahead log activity from https://www.postgresql.org/docs/current/monitoring-stats.html#MONITORING-PG-STAT-WAL-VIEW |
Zabbix agent | pgsql.stat.wal["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}","{#SINGLETON}"] |
| WAL statistics: Bytes generated total | Total amount of WAL generated since the last statistics reset. |
Dependent item | pgsql.stat.wal.bytes[{#SINGLETON}] Preprocessing
|
| WAL statistics: Records total | Total number of WAL records generated since the last statistics reset. |
Dependent item | pgsql.stat.wal.records[{#SINGLETON}] Preprocessing
|
| WAL statistics: Full page images total | Total number of full page images written to WAL since the last statistics reset. Full page images increase the WAL volume and are usually caused by frequent checkpoints. |
Dependent item | pgsql.stat.wal.fpi[{#SINGLETON}] Preprocessing
|
| WAL statistics: Buffers full total | Total number of times the WAL buffers were full and WAL had to be written out before the transaction could continue, since the last statistics reset. A growing value indicates WAL buffer pressure - consider increasing |
Dependent item | pgsql.stat.wal.buffers_full[{#SINGLETON}] Preprocessing
|
| WAL statistics: Buffers full per second | Number of times per second the WAL buffers were full and had to be written out. |
Dependent item | pgsql.stat.wal.buffers_full.rate[{#SINGLETON}] Preprocessing
|
| WAL statistics: Statistics reset time | Time of the last reset of the WAL statistics. The totals above are counted from this moment. |
Dependent item | pgsql.stat.wal.reset_time[{#SINGLETON}] Preprocessing
|
Trigger prototypes for WAL statistics metrics discovery
| Name | Description | Expression | Severity | Dependencies and additional info |
|---|---|---|---|---|
| PostgreSQL: WAL statistics: WAL buffers are full too often | The WAL buffers are exhausted more than {$PG.WAL.BUFFERS_FULL.MAX.WARN} times per second, so backends have to flush WAL themselves instead of doing useful work. |
min(/PostgreSQL by Zabbix agent/pgsql.stat.wal.buffers_full.rate[{#SINGLETON}],15m) > {$PG.WAL.BUFFERS_FULL.MAX.WARN} |
Warning |
LLD rule SLRU metrics discovery
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| SLRU metrics discovery | Discovers the |
Dependent item | pgsql.stat.slru.discovery Preprocessing
|
Item prototypes for SLRU metrics discovery
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| SLRU: Get data | Collects the SLRU cache statistics from https://www.postgresql.org/docs/current/monitoring-stats.html#MONITORING-PG-STAT-SLRU-VIEW |
Zabbix agent | pgsql.stat.slru["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}","{#SINGLETON}"] |
| SLRU: Blocks read total | Total number of blocks read from disk into the SLRU caches since the last statistics reset. |
Dependent item | pgsql.stat.slru.blks_read[{#SINGLETON}] Preprocessing
|
| SLRU: Blocks read per second | Number of blocks per second read from disk into the SLRU caches. |
Dependent item | pgsql.stat.slru.blks_read.rate[{#SINGLETON}] Preprocessing
|
| SLRU: Blocks hit total | Total number of blocks found in the SLRU caches since the last statistics reset. |
Dependent item | pgsql.stat.slru.blks_hit[{#SINGLETON}] Preprocessing
|
| SLRU: Blocks written total | Total number of dirty SLRU blocks written to disk since the last statistics reset. |
Dependent item | pgsql.stat.slru.blks_written[{#SINGLETON}] Preprocessing
|
| SLRU: Cache hit ratio | Percentage of the SLRU cache lookups served from memory, over all caches. A dropping ratio means the transaction status and multixact caches no longer fit, which shows up as extra disk reads under high concurrency. |
Dependent item | pgsql.stat.slru.hit_ratio[{#SINGLETON}] Preprocessing
|
Trigger prototypes for SLRU metrics discovery
| Name | Description | Expression | Severity | Dependencies and additional info |
|---|---|---|---|---|
| PostgreSQL: SLRU: Cache hit ratio too low | The SLRU caches serve less than {$PG.SLRU.CACHE.MIN.WARN}% of their lookups from memory. Check the disk load and the concurrency of transactions using multixacts ( |
max(/PostgreSQL by Zabbix agent/pgsql.stat.slru.hit_ratio[{#SINGLETON}],5m) < {$PG.SLRU.CACHE.MIN.WARN} |
Warning | Depends on:
|
| PostgreSQL: SLRU: Cache hit ratio is critically low | The SLRU caches serve less than {$PG.SLRU.CACHE.MIN.HIGH}% of their lookups from memory, so the instance is doing significant extra I/O for transaction status lookups. |
max(/PostgreSQL by Zabbix agent/pgsql.stat.slru.hit_ratio[{#SINGLETON}],5m) < {$PG.SLRU.CACHE.MIN.HIGH} |
High |
LLD rule Replication slots metrics discovery
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Replication slots metrics discovery | Discovers the |
Dependent item | pgsql.replication.slots.discovery Preprocessing
|
Item prototypes for Replication slots metrics discovery
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Replication slots: Get data | Collects the state of the replication slots from https://www.postgresql.org/docs/current/view-pg-replication-slots.html |
Zabbix agent | pgsql.replication.slots["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}","{#SINGLETON}"] |
| Replication slots: Total | Total number of replication slots. |
Dependent item | pgsql.replication.slots.total[{#SINGLETON}] Preprocessing
|
| Replication slots: Active | Number of replication slots currently in use by a connected consumer. |
Dependent item | pgsql.replication.slots.active[{#SINGLETON}] Preprocessing
|
| Replication slots: Inactive | Number of replication slots without a connected consumer. |
Dependent item | pgsql.replication.slots.inactive[{#SINGLETON}] Preprocessing
|
| Replication slots: Worst slot lag | Amount of WAL the most lagging slot has not confirmed yet. Reported as 0 on a standby, where the current WAL position is not defined. |
Dependent item | pgsql.replication.slots.worst_lag[{#SINGLETON}] Preprocessing
|
| Replication slots: Min safe WAL size | Amount of WAL that can still be written before the slot closest to the limit starts losing the data it needs. Turns negative once that slot is past its safety margin: the WAL it needs is only kept until the next checkpoint. Always 0 when |
Dependent item | pgsql.replication.slots.min_safe_wal_size[{#SINGLETON}] Preprocessing
|
| Replication slots: Inactive retaining WAL | Number of inactive replication slots that still hold WAL segments. Such slots prevent WAL cleanup and are the usual cause of a slowly filling disk on the primary. |
Dependent item | pgsql.replication.slots.inactive_retaining[{#SINGLETON}] Preprocessing
|
Trigger prototypes for Replication slots metrics discovery
| Name | Description | Expression | Severity | Dependencies and additional info |
|---|---|---|---|---|
| PostgreSQL: Replication slots: Inactive slots are retaining WAL | Inactive replication slots are holding WAL segments. Check whether the consumers are gone for good and drop the slots that are no longer needed. |
min(/PostgreSQL by Zabbix agent/pgsql.replication.slots.inactive_retaining[{#SINGLETON}],5m) > {$PG.REPLICATION.SLOTS.RETAINING.MAX.WARN} |
Warning | Depends on:
|
| PostgreSQL: Replication slots: Too many inactive slots are retaining WAL | Several inactive replication slots are holding WAL segments, which can fill the disk and stop the instance from accepting writes. Drop the slots that are no longer needed. |
min(/PostgreSQL by Zabbix agent/pgsql.replication.slots.inactive_retaining[{#SINGLETON}],5m) > {$PG.REPLICATION.SLOTS.RETAINING.MAX.HIGH} |
High |
LLD rule Subscription discovery
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Subscription discovery | Discovers the logical replication subscriptions of the instance. |
Dependent item | pgsql.subscription.discovery Preprocessing
|
Item prototypes for Subscription discovery
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Subscription [{#SUBNAME}]: Get subscription stats | Subscription stats of the "{#SUBNAME}" subscription. |
Dependent item | pgsql.subscription.get_metrics["{#SUBNAME}"] Preprocessing
|
| Subscription [{#SUBNAME}]: Apply errors | Number of errors that occurred while applying the changes received from the publisher, since the last statistics reset. |
Dependent item | pgsql.subscription.apply_errors["{#SUBNAME}"] Preprocessing
|
| Subscription [{#SUBNAME}]: Sync errors | Number of errors that occurred during the initial data copy of the subscribed tables, since the last statistics reset. |
Dependent item | pgsql.subscription.sync_errors["{#SUBNAME}"] Preprocessing
|
| Subscription [{#SUBNAME}]: Statistics reset time | Time of the last reset of the subscription statistics. The error counters above are counted from this moment. |
Dependent item | pgsql.subscription.reset_time["{#SUBNAME}"] Preprocessing
|
Trigger prototypes for Subscription discovery
| Name | Description | Expression | Severity | Dependencies and additional info |
|---|---|---|---|---|
| PostgreSQL: Subscription [{#SUBNAME}]: Errors while applying changes | The subscription "{#SUBNAME}" fails to apply the changes it receives, so the subscriber data is drifting away from the publisher. Check the subscription worker errors in the PostgreSQL log. |
min(/PostgreSQL by Zabbix agent/pgsql.subscription.apply_errors["{#SUBNAME}"],5m) > {$PG.SUBSCRIPTION.ERRORS.MAX.WARN:"{#SUBNAME}"} |
Warning | |
| PostgreSQL: Subscription [{#SUBNAME}]: Errors while synchronizing tables | The initial table synchronization of the subscription "{#SUBNAME}" keeps failing, so the subscribed tables never reach a consistent state. Check the table sync worker errors in the PostgreSQL log. |
min(/PostgreSQL by Zabbix agent/pgsql.subscription.sync_errors["{#SUBNAME}"],5m) > {$PG.SUBSCRIPTION.ERRORS.MAX.WARN:"{#SUBNAME}"} |
Warning |
LLD rule I/O metrics discovery
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| I/O metrics discovery | Discovers the |
Dependent item | pgsql.stat.io.discovery Preprocessing
|
Item prototypes for I/O metrics discovery
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| I/O: Get data | Collects the I/O activity of the instance from https://www.postgresql.org/docs/current/monitoring-stats.html#MONITORING-PG-STAT-IO-VIEW |
Zabbix agent | pgsql.stat.io["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}","{#SINGLETON}"] |
| I/O: Reads per second | Number of read operations per second the instance issues to the storage. Reads mean the data was not found in the shared buffers. |
Dependent item | pgsql.stat.io.reads.rate[{#SINGLETON}] Preprocessing
|
| I/O: Writes per second | Number of write operations per second the instance issues to the storage. |
Dependent item | pgsql.stat.io.writes.rate[{#SINGLETON}] Preprocessing
|
| I/O: Read per second | Amount of data per second the instance reads from the storage. |
Dependent item | pgsql.stat.io.read_bytes.rate[{#SINGLETON}] Preprocessing
|
| I/O: Written per second | Amount of data per second the instance writes to the storage. |
Dependent item | pgsql.stat.io.write_bytes.rate[{#SINGLETON}] Preprocessing
|
| I/O: Fsyncs per second | Number of Most of them are normally done by the checkpointer, so a high rate from other backends points at a checkpoint or WAL configuration problem. |
Dependent item | pgsql.stat.io.fsyncs.rate[{#SINGLETON}] Preprocessing
|
| I/O: Time spent per second | Time per second the instance spends waiting for reads and writes to complete. Requires |
Dependent item | pgsql.stat.io.time.rate[{#SINGLETON}] Preprocessing
|
| I/O: Buffer hit ratio | Percentage of the block requests served from the shared buffers instead of the storage, since the last statistics reset. A low value means the working set does not fit into |
Dependent item | pgsql.stat.io.hit_ratio[{#SINGLETON}] Preprocessing
|
Trigger prototypes for I/O metrics discovery
| Name | Description | Expression | Severity | Dependencies and additional info |
|---|---|---|---|---|
| PostgreSQL: I/O: Buffer hit ratio too low | Less than {$PG.IO.CACHE.MIN.WARN}% of the block requests are served from the shared buffers, so the instance keeps going to the storage for data. Consider increasing |
max(/PostgreSQL by Zabbix agent/pgsql.stat.io.hit_ratio[{#SINGLETON}],15m) < {$PG.IO.CACHE.MIN.WARN} |
Warning |
LLD rule Schema discovery
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Schema discovery | Discovers the schemas of the "{$PG.DATABASE}" database, except the system ones. |
Dependent item | pgsql.relation.discovery Preprocessing
|
Item prototypes for Schema discovery
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Schema [{#SCHEMA.NAME}]: Size | Total on-disk size of the tables of the schema "{#SCHEMA.NAME}", including their indexes and TOAST data. |
Dependent item | pgsql.relation.size["{#SCHEMA.NAME}"] Preprocessing
|
| Schema [{#SCHEMA.NAME}]: Number of tables | Number of tables in the schema "{#SCHEMA.NAME}", partitioned tables included. |
Dependent item | pgsql.relation.tables["{#SCHEMA.NAME}"] Preprocessing
|
LLD rule Tablespace discovery
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Tablespace discovery | Discovers the tablespaces of the instance, including the built-in |
Dependent item | pgsql.tablespace.discovery Preprocessing
|
Item prototypes for Tablespace discovery
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Tablespace [{#TABLESPACE.NAME}]: Get tablespace data | Data of the tablespace "{#TABLESPACE.NAME}". |
Dependent item | pgsql.tablespace.get_metrics["{#TABLESPACE.NAME}"] Preprocessing
|
| Tablespace [{#TABLESPACE.NAME}]: Size | Total size of the files stored in the tablespace "{#TABLESPACE.NAME}". |
Dependent item | pgsql.tablespace.size["{#TABLESPACE.NAME}"] Preprocessing
|
| Tablespace [{#TABLESPACE.NAME}]: Location | Directory the tablespace "{#TABLESPACE.NAME}" is stored in. Empty for the built-in |
Dependent item | pgsql.tablespace.location["{#TABLESPACE.NAME}"] Preprocessing
|
| Tablespace [{#TABLESPACE.NAME}]: Owner | Owner of the tablespace "{#TABLESPACE.NAME}". |
Dependent item | pgsql.tablespace.owner["{#TABLESPACE.NAME}"] Preprocessing
|
Trigger prototypes for Tablespace discovery
| Name | Description | Expression | Severity | Dependencies and additional info |
|---|---|---|---|---|
| PostgreSQL: Tablespace [{#TABLESPACE.NAME}]: Size is too big | The tablespace "{#TABLESPACE.NAME}" has grown beyond the expected size. Check the storage capacity and the growth rate before it becomes a problem. |
min(/PostgreSQL by Zabbix agent/pgsql.tablespace.size["{#TABLESPACE.NAME}"],5m) > {$PG.TABLESPACE.SIZE.MAX.WARN:"{#TABLESPACE.NAME}"} |
Warning | Depends on:
|
| PostgreSQL: Tablespace [{#TABLESPACE.NAME}]: Size is critically big | The tablespace "{#TABLESPACE.NAME}" is close to exhausting its storage. Free up space or move relations to another tablespace - a full disk stops the instance from accepting writes. |
min(/PostgreSQL by Zabbix agent/pgsql.tablespace.size["{#TABLESPACE.NAME}"],5m) > {$PG.TABLESPACE.SIZE.MAX.HIGH:"{#TABLESPACE.NAME}"} |
High |
Feedback
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
PostgreSQL by Zabbix agent 2
Overview
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.
Requirements
Zabbix version: 8.0 and higher.
Tested versions
This template has been tested on:
- PostgreSQL 10-17
Configuration
Zabbix should be configured according to the instructions in the Templates out of the box section.
Setup
-
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 rolepg_monitor:
CREATE USER zbx_monitor WITH PASSWORD '<PASSWORD>' INHERIT;
GRANT pg_monitor TO zbx_monitor;
- Edit the
pg_hba.confconfiguration file to allow connections for the userzbx_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.
- Set the connection string for the PostgreSQL instance in the
{$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.
- Set the password that you specified in step 2 in the macro
{$PG.PASSWORD}.
Macros used
| 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 |
Items
| 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
|
Triggers
| 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 |
LLD rule Replication discovery
| 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}"] |
Item prototypes for Replication discovery
| 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
|
LLD rule Database discovery
| 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}"] |
Item prototypes for Database discovery
| 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
|
Trigger prototypes for Database discovery
| 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 |
Feedback
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
PostgreSQL by ODBC
Overview
This template is designed for the effortless deployment of PostgreSQL monitoring by Zabbix via ODBC and doesn't require any external scripts.
Requirements
Zabbix version: 8.0 and higher.
Tested versions
This template has been tested on:
- PostgreSQL 11–18
Configuration
Zabbix should be configured according to the instructions in the Templates out of the box section.
Setup
- Create the PostgreSQL user for monitoring (
<password>at your discretion) and inherit permissions from the default rolepg_monitor:
CREATE USER zbx_monitor WITH PASSWORD '<PASSWORD>' INHERIT;
GRANT pg_monitor TO zbx_monitor;
- Edit the
pg_hba.confconfiguration file to allow TCP connections for the userzbx_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 consult PostgreSQL documentation.
-
Install the PostgreSQL ODBC driver. Consult Zabbix documentation for details on ODBC checks and recommended parameters.
-
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 theodbcinst.inifile) 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. Consult 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
- Set the password that you specified in step 1 in the macro
{$PG.PASSWORD}.
IMPORTANT!
- Ensure
pg_stat_statementsis installed. Add it toshared_preload_libraries, turn oncompute_query_id, and setpg_stat_statements.tracktoall, so all queries are tracked. - Ensure logical replication is enabled. Set
wal_level=logical,max_replication_slots>= 1,max_wal_senders>= 1 inpostgresql.conf. - PostgreSQL 18 requires
track_io_timing = oninpostgresql.confor viaALTER SYSTEM. Otherwise, this metric will always be0. - Logical replication subscription metrics are supported for PostgreSQL 15–18 and are designed for subscriber databases with existing subscriptions. Unsupported or missing values will be discarded.
- The
PostgreSQL: Subscriptiondashboard page is intended for PG subscriber servers. - The
PostgreSQL: Replicationdashboard page is intended for PG publisher servers.
Macros used
| Name | Description | Default |
|---|---|---|
| {$PG.AUTOVAC.ACTIVE.WORKERS.WARN} | Warning threshold of active autovacuum workers for trigger expression. |
5 |
| {$PG.AUTOVAC.IDLE.WORKERS.WARN} | Warning threshold of idle autovacuum workers for trigger expression. |
10 |
| {$PG.IO.CACHE.WARN} | Warning threshold of I/O buffer hit ratio, in percent, for trigger expression. |
98 |
| {$PG.IO.CACHE.AVG} | Average threshold of I/O buffer hit ratio, in percent, for trigger expression. |
97 |
| {$PG.IO.CACHE.HIGH} | High threshold of I/O buffer hit ratio, in percent, for trigger expression. |
96 |
| {$PG.SLRU.CACHE.WARN} | Warning threshold of SLRU buffer hit ratio, in percent, for trigger expression. |
98 |
| {$PG.SLRU.CACHE.AVG} | Average threshold of SLRU buffer hit ratio, in percent, for trigger expression. |
97 |
| {$PG.SLRU.CACHE.HIGH} | High threshold of SLRU buffer hit ratio, in percent, for trigger expression. |
95 |
| {$PG.HEALTH.CACHE.WARN} | Warning threshold of [HEALTH] buffer hit ratio, in percent, for trigger expression. |
96 |
| {$PG.HEALTH.CACHE.AVG} | Average threshold of [HEALTH] buffer hit ratio, in percent, for trigger expression. |
94 |
| {$PG.HEALTH.CACHE.HIGH} | High threshold of [HEALTH] buffer hit ratio, in percent, for trigger expression. |
92 |
| {$PG.CONNECTION.COUNT.WARN} | Warning threshold of current connections, in percent, for trigger expression. |
70 |
| {$PG.CONNECTION.COUNT.AVG} | Average state of current connections, in percent, for trigger expression. |
85 |
| {$PG.CONNECTION.COUNT.HIGH} | High state of current connections, in percent, for trigger expression. |
90 |
| {$PG.IDLE.WARN} | Warning threshold of idle connections for trigger expression. |
1 |
| {$PG.IDLE.AVG} | Average state of idle connections for trigger expression. |
2 |
| {$PG.IDLE.HIGH} | High state of idle connections for trigger expression. |
3 |
| {$PG.WAITING.WARN} | Warning threshold of waiting connections for trigger expression. |
1 |
| {$PG.WAITING.AVG} | Average state of waiting connections for trigger expression. |
2 |
| {$PG.WAITING.HIGH} | High state of waiting connections for trigger expression. |
3 |
| {$PG.IDLE.TRANSACTION.WARN} | Warning threshold of idle in transaction connections for trigger expression. |
1 |
| {$PG.IDLE.TRANSACTION.AVG} | Average state of idle in transaction connections for trigger expression. |
2 |
| {$PG.IDLE.TRANSACTION.HIGH} | High state of idle in transaction connections for trigger expression. |
3 |
| {$PG.IDLE.TRANSACTION.ABORTED.WARN} | Warning threshold of idle in transaction (aborted) connections for trigger expression. |
1 |
| {$PG.IDLE.TRANSACTION.ABORTED.AVG} | Average state of idle in transaction (aborted) connections for trigger expression. |
2 |
| {$PG.IDLE.TRANSACTION.ABORTED.HIGH} | High state of idle in transaction (aborted) connections for trigger expression. |
3 |
| {$PG.REPLICATION.SLOTS.RETAINING.AVG} | Average threshold for slots retaining WAL affecting replication load. |
1 |
| {$PG.REPLICATION.SLOTS.RETAINING.HIGH} | High threshold for slots retaining WAL affecting replication load. |
2 |
| {$PG.SUBSCRIPTION.TOTAL.ERROR.AVG} | Average threshold of total subscription errors (sync + apply) per interval. |
4 |
| {$PG.SUBSCRIPTION.TOTAL.ERROR.HIGH} | High threshold of total subscription errors (sync + apply) per interval. |
6 |
| {$PG.SUBSCRIPTION.APPLY.ERROR.AVG} | Average threshold of apply errors in subscription per interval. |
2 |
| {$PG.SUBSCRIPTION.APPLY.ERROR.HIGH} | High threshold of apply errors in subscription per interval. |
3 |
| {$PG.SUBSCRIPTION.SYNC.ERROR.AVG} | Average threshold of sync errors in subscription per interval. |
2 |
| {$PG.SUBSCRIPTION.SYNC.ERROR.HIGH} | High threshold of sync errors in subscription per interval. |
3 |
| {$PG.LRQ.TIME.AVG} | Average threshold for longest running query time, in seconds, for trigger expression. |
30 |
| {$PG.LRQ.TIME.HIGH} | High threshold for longest running query time, in seconds, for trigger expression. |
120 |
| {$PG.DEADLOCKS.MAX.WARN} | Maximum number of detected deadlocks for trigger expression. |
0 |
| {$PG.CONFLICTS.MAX.WARN} | Maximum number of recovery conflicts for trigger expression. |
0 |
| {$PG.QUERY_EXECUTION_TIME.MAX.WARN} | Execution time limit for slow query count. |
30 |
| {$PG.SLOW_QUERIES.MAX.WARN} | Slow query count threshold for trigger expression. |
5 |
| {$PG.DATABASE.SIZE.WARN} | Warning threshold of database size, in bytes, for trigger expression. |
5000000000 |
| {$PG.DATABASE.SIZE.AVG} | Average threshold of database size, in bytes, for trigger expression. |
10000000000 |
| {$PG.DATABASE.SIZE.HIGH} | High threshold of database size, in bytes, for trigger expression. |
15000000000 |
| {$PG.TABLESPACE.SIZE.WARN} | Warning threshold of tablespace size, in bytes, for trigger expression. |
5000000000 |
| {$PG.TABLESPACE.SIZE.AVG} | Average state of tablespace size, in bytes, for trigger expression. |
10000000000 |
| {$PG.TABLESPACE.SIZE.HIGH} | High state of tablespace size, in bytes, for trigger expression. |
15000000000 |
| {$PG.XID_ACTIVE.WARN} | Warning threshold for oldest active XID age to trigger alert (prevents long-running transactions from delaying cleanup). |
5000 |
| {$PG.XID_ACTIVE.AVG} | Average threshold for oldest active XID age to trigger alert (prevents long-running transactions from delaying cleanup). |
15000 |
| {$PG.XID_ACTIVE.HIGH} | High threshold for oldest active XID age to trigger alert (prevents long-running transactions from delaying cleanup). |
30000 |
| {$PG.XID_MAX.WARN} | Warning threshold for maximum XID age to trigger alert (prevents wraparound). |
2000000 |
| {$PG.XID_MAX.AVG} | Average threshold for maximum XID age to trigger alert (prevents wraparound). |
3500000 |
| {$PG.XID_MAX.HIGH} | High threshold for maximum XID age to trigger alert (prevents wraparound). |
18000000 |
| {$PG.CONNSTRING.ODBC} | Connection string for 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 connection. |
postgres |
| {$PG.LLD.FILTER.DBNAME.MATCHES} | Filter for PostgreSQL database discovery by name to include. |
.* |
| {$PG.LLD.FILTER.DBNAME.NOT_MATCHES} | Filter for PostgreSQL database discovery by name to exclude. |
^$ |
| {$PG.LLD.FILTER.APPLICATION.MATCHES} | Filter for PostgreSQL application discovery by name to include. |
.* |
| {$PG.LLD.FILTER.APPLICATION.NOT_MATCHES} | Filter for PostgreSQL application discovery by name to exclude. |
^$ |
| {$PG.LLD.FILTER.TABLESPACE.DEFAULT.MATCHES} | Regex filter applied to tablespace |
.* |
| {$PG.LLD.FILTER.TABLESPACE.DEFAULT.NOT_MATCHES} | Exclude regex filter applied to tablespace |
^$ |
| {$PG.LLD.FILTER.TABLESPACE.NAME.MATCHES} | Filter for PostgreSQL tablespace discovery by name. |
.* |
| {$PG.LLD.FILTER.TABLESPACE.NAME.NOT_MATCHES} | Exclude filter for PostgreSQL tablespace discovery by name. |
^$ |
| {$PG.LLD.FILTER.SCHEMA.MATCHES} | Filter for PostgreSQL schema discovery by name. |
.* |
| {$PG.LLD.FILTER.SCHEMA.NOT_MATCHES} | Exclude filter for PostgreSQL schema discovery by name. |
^$ |
| {$PG.LLD.FILTER.SUBSCRIPTION.MATCHES} | Filter for PostgreSQL subscription discovery by name. |
.* |
| {$PG.LLD.FILTER.SUBSCRIPTION.NOT_MATCHES} | Exclude filter for PostgreSQL subscription discovery by name. |
^$ |
Items
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Get archive | Collects archive status metrics. |
Database monitor | db.odbc.select[pgsql.archive.get,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] |
| Get dbstat inventory | Collects all metrics from https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-DATABASE-VIEW |
Database monitor | db.odbc.select[pgsql.dbstat.inventory.get,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] |
| Get dbstat sum | Collects all metrics from https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-DATABASE-VIEW |
Database monitor | db.odbc.select[pgsql.dbstat.sum.get,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] |
| Get connections sum | Collects all metrics from https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-ACTIVITY-VIEW |
Database monitor | db.odbc.select[pgsql.connections.sum.get,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] |
| Get WAL | Collects write-ahead log (WAL) metrics. |
Database monitor | db.odbc.select[pgsql.wal.stat.get,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] |
| Get locks inventory | Collects all metrics from https://www.postgresql.org/docs/current/explicit-locking.html#LOCKING-TABLES |
Database monitor | db.odbc.select[pgsql.locks.inventory.get,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] |
| Get replication inventory | Collects metrics from |
Database monitor | db.odbc.select[pgsql.replication.inventory.get,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] Preprocessing
|
| Get relation inventory | Collects raw relation size information from the primary core database. |
Database monitor | db.odbc.select[pgsql.relation.inventory.get,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] Preprocessing
|
| Get queries inventory | Collects all metrics by query execution time. |
Database monitor | db.odbc.select[pgsql.queries.inventory.get,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] |
| Build: Get data | Retrieves PostgreSQL version and build details, including platform, compiler, and package information. |
Database monitor | db.odbc.select[pgsql.version.get,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] Preprocessing
|
| Build: Version | PostgreSQL version (major.minor). |
Dependent item | pgsql.version.major.minor Preprocessing
|
| Build: Package info | Distribution / package build information. |
Dependent item | pgsql.version.package Preprocessing
|
| Build: Platform | Build platform / architecture. |
Dependent item | pgsql.version.platform Preprocessing
|
| Build: Compiler | Compiler used to build PostgreSQL. |
Dependent item | pgsql.version.compiler Preprocessing
|
| Build: Compiler package info | Compiler package / distribution info. |
Dependent item | pgsql.version.compiler.pkg Preprocessing
|
| Build: Compiler version | Compiler version number. |
Dependent item | pgsql.version.compiler.version Preprocessing
|
| Build: Word size | PostgreSQL word size (32-bit / 64-bit). |
Dependent item | pgsql.version.wordsize Preprocessing
|
| Build: 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
|
| Health: Get data | Collects raw PostgreSQL health metrics. |
Database monitor | db.odbc.select[pgsql.health.snapshot.get,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] |
| Health: Max XID age | Current age of the oldest transaction ID (XID) in the database as a numeric count, used to detect wraparound risk. |
Dependent item | pgsql.health.max.xid.age Preprocessing
|
| Health: Max XID, in % | Max XID age as % of wraparound. |
Dependent item | pgsql.health.max.xid.percent Preprocessing
|
| Health: Waiting locks | Number of sessions currently waiting on locks, indicating blocking or contention. |
Dependent item | pgsql.health.waiting.locks Preprocessing
|
| Health: Active connections | Number of connections currently executing queries. |
Dependent item | pgsql.health.active.connections Preprocessing
|
| Health: Total connections (active/inactive) | Total number of current client connections to the database. |
Dependent item | pgsql.health.total.connections Preprocessing
|
| Health: Deadlocks | Total number of deadlocks detected across all databases. |
Dependent item | pgsql.health.deadlocks Preprocessing
|
| Health: Buffer hit ratio | Percentage of data served from memory cache. Low values indicate more disk I/O and potential performance pressure. |
Dependent item | pgsql.health.cache.hit.ratio Preprocessing
|
| Health: Autovacuum active | Number of autovacuum processes currently running in the database. |
Dependent item | pgsql.health.autovacuum.active Preprocessing
|
| Health: Autovacuum idle | Number of autovacuum workers currently idle in the database. |
Dependent item | pgsql.health.autovacuum.idle Preprocessing
|
| Get subscription inventory | Shows IMPORTANT! Logical replication subscription metrics are supported for PostgreSQL 15–18 and are designed for subscriber databases with existing subscriptions. Unsupported or missing values will be discarded. |
Database monitor | db.odbc.select[pgsql.subscription.inventory.get{,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] Preprocessing
|
| Get tablespace inventory | Collects raw tablespace inventory JSON. |
Database monitor | db.odbc.select[pgsql.tablespace.inventory.get{,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] Preprocessing
|
| Build: Version validator | Validates the PostgreSQL version and sets version macros for LLDs. |
Dependent item | pgsql.version.validator 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 |
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 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: Temp files created per second | Number of temporary files created by queries per second. |
Dependent item | pgsql.dbstat.sum.temp_files.rate Preprocessing
|
| Dbstat: Rollbacks 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, in % | Total number of connections, in percent. |
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
|
| Oldest active XID | Age of the oldest active transaction (XID) among live backends. |
Database monitor | db.odbc.select[pgsql.oldest.xid,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] |
| Cache hit ratio, in % | 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: Role | Replication role: 1 - Standby mode 0 - Master mode |
Database monitor | db.odbc.select[pgsql.replication.recovery_role,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] |
| Replication: Standby | Number of standby servers. |
Database monitor | db.odbc.select[pgsql.replication.count,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] |
| Replication: Status | Shows replication streaming state: 0 - Standby offline 1 - Standby streaming 2 - Master node |
Database monitor | db.odbc.select[pgsql.replication.status,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] |
| LRQ: Get data | Returns data about the currently active LRQ (Longest Running Query) and its execution duration from |
Database monitor | db.odbc.select[pgsql.longest.running.query.data.get,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] Preprocessing
|
| LRQ: PID | PID of the current LRQ (Longest Running Query). |
Dependent item | pgsql.longest.running.query.pid Preprocessing
|
| LRQ: Duration | Duration of the current LRQ (Longest Running Query). |
Dependent item | pgsql.longest.running.query.duration Preprocessing
|
| Ping | Used to test a connection to see if it is alive. Set to |
Database monitor | db.odbc.select[pgsql.ping,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] Preprocessing
|
Triggers
| Name | Description | Expression | Severity | Dependencies and additional info |
|---|---|---|---|---|
| PostgreSQL: Version info | PostgreSQL version changed. Verify that the upgrade was intentional and applications remain compatible. |
last(/PostgreSQL by ODBC/pgsql.version.major.minor,#1)<>last(/PostgreSQL by ODBC/pgsql.version.major.minor,#2) and length(last(/PostgreSQL by ODBC/pgsql.version.major.minor))>0 |
Info | |
| PostgreSQL: Word size info | PostgreSQL word size has changed. Verify that the upgrade or server rebuild was intentional and applications remain compatible. |
last(/PostgreSQL by ODBC/pgsql.version.wordsize,#1)<>last(/PostgreSQL by ODBC/pgsql.version.wordsize,#2) and length(last(/PostgreSQL by ODBC/pgsql.version.wordsize))>0 |
Info | |
| PostgreSQL: XID age warning | Oldest XID age >= |
min(/PostgreSQL by ODBC/pgsql.health.max.xid.age,5m) >= {$PG.XID_MAX.WARN} |
Warning | Depends on:
|
| PostgreSQL: XID age average | Oldest XID age >= |
min(/PostgreSQL by ODBC/pgsql.health.max.xid.age,5m) >= {$PG.XID_MAX.AVG} |
Average | Depends on:
|
| PostgreSQL: XID age high | Oldest XID age >= |
min(/PostgreSQL by ODBC/pgsql.health.max.xid.age,5m) >= {$PG.XID_MAX.HIGH} |
High | |
| PostgreSQL: Buffer hit warning | Buffer hit ratio <= |
max(/PostgreSQL by ODBC/pgsql.health.cache.hit.ratio,5m) <= {$PG.HEALTH.CACHE.WARN} |
Warning | Depends on:
|
| PostgreSQL: Health: Buffer hit average | Buffer hit ratio <= |
max(/PostgreSQL by ODBC/pgsql.health.cache.hit.ratio,5m) <= {$PG.HEALTH.CACHE.AVG} |
Average | Depends on:
|
| PostgreSQL: Health: Buffer hit high | Buffer hit ratio <= |
max(/PostgreSQL by ODBC/pgsql.health.cache.hit.ratio,5m) <= {$PG.HEALTH.CACHE.HIGH} |
High | |
| PostgreSQL: Autovacuum active workers warning | Number of active autovacuum workers has exceeded the |
min(/PostgreSQL by ODBC/pgsql.health.autovacuum.active,5m) >= {$PG.AUTOVAC.ACTIVE.WORKERS.WARN} |
Warning | |
| PostgreSQL: Autovacuum idle workers warning | Number of idle autovacuum workers has exceeded the |
min(/PostgreSQL by ODBC/pgsql.health.autovacuum.idle,5m) >= {$PG.AUTOVAC.IDLE.WORKERS.WARN} |
Warning | |
| PostgreSQL: Idle warning | Number of idle connections >= |
min(/PostgreSQL by ODBC/pgsql.connections.sum.idle,5m) >= {$PG.IDLE.WARN} |
Warning | Depends on:
|
| PostgreSQL: Idle average | Number of idle connections >= |
min(/PostgreSQL by ODBC/pgsql.connections.sum.idle,5m) >= {$PG.IDLE.AVG} |
Average | Depends on:
|
| PostgreSQL: Idle high | Number of idle connections >= |
min(/PostgreSQL by ODBC/pgsql.connections.sum.idle,5m) >= {$PG.IDLE.HIGH} |
High | |
| PostgreSQL: Idle in transaction warning | Number of idle in transaction connections >= |
min(/PostgreSQL by ODBC/pgsql.connections.sum.idle_in_transaction,5m) >= {$PG.IDLE.TRANSACTION.WARN} |
Warning | Depends on:
|
| PostgreSQL: Idle in transaction average | Number of idle in transaction connections >= |
min(/PostgreSQL by ODBC/pgsql.connections.sum.idle_in_transaction,5m) >= {$PG.IDLE.TRANSACTION.AVG} |
Average | Depends on:
|
| PostgreSQL: Idle in transaction high | Number of idle in transaction connections >= |
min(/PostgreSQL by ODBC/pgsql.connections.sum.idle_in_transaction,5m) >= {$PG.IDLE.TRANSACTION.HIGH} |
High | |
| PostgreSQL: Connection usage warning | Total connections >= |
min(/PostgreSQL by ODBC/pgsql.connections.sum.total_pct,5m) >= {$PG.CONNECTION.COUNT.WARN} |
Warning | Depends on:
|
| PostgreSQL: Connection usage average | Total connections >= |
min(/PostgreSQL by ODBC/pgsql.connections.sum.total_pct,5m) >= {$PG.CONNECTION.COUNT.AVG} |
Average | Depends on:
|
| PostgreSQL: Connection usage high | Total connections >= |
min(/PostgreSQL by ODBC/pgsql.connections.sum.total_pct,5m) >= {$PG.CONNECTION.COUNT.HIGH} |
High | |
| PostgreSQL: Waiting connections warning | Number of connections waiting >= |
min(/PostgreSQL by ODBC/pgsql.connections.sum.waiting,5m) >= {$PG.WAITING.WARN} |
Warning | Depends on:
|
| PostgreSQL: Waiting connections average | Number of connections waiting >= |
min(/PostgreSQL by ODBC/pgsql.connections.sum.waiting,5m) >= {$PG.WAITING.AVG} |
Average | Depends on:
|
| PostgreSQL: Waiting connections high | Number of connections waiting >= |
min(/PostgreSQL by ODBC/pgsql.connections.sum.waiting,5m) >= {$PG.WAITING.HIGH} |
High | |
| PostgreSQL: Idle in transaction (aborted) warning | Number of idle in transaction (aborted) connections >= |
min(/PostgreSQL by ODBC/pgsql.connections.sum.idle_in_transaction_aborted,5m) >= {$PG.IDLE.TRANSACTION.ABORTED.WARN} |
Warning | Depends on:
|
| PostgreSQL: Idle in transaction (aborted) average | Number of idle in transaction (aborted) connections >= |
min(/PostgreSQL by ODBC/pgsql.connections.sum.idle_in_transaction_aborted,5m) >= {$PG.IDLE.TRANSACTION.ABORTED.AVG} |
Average | Depends on:
|
| PostgreSQL: Idle in transaction (aborted) high | Number of idle in transaction (aborted) connections >= |
min(/PostgreSQL by ODBC/pgsql.connections.sum.idle_in_transaction_aborted,5m) >= {$PG.IDLE.TRANSACTION.ABORTED.HIGH} |
High | |
| PostgreSQL: Oldest active XID warning | Oldest active XID >= |
min(/PostgreSQL by ODBC/db.odbc.select[pgsql.oldest.xid,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"],15m) >= {$PG.XID_ACTIVE.WARN} |
Warning | Depends on:
|
| PostgreSQL: Oldest active XID average | Oldest active XID >= |
min(/PostgreSQL by ODBC/db.odbc.select[pgsql.oldest.xid,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"],15m) >= {$PG.XID_ACTIVE.AVG} |
Average | Depends on:
|
| PostgreSQL: Oldest active XID high | Oldest active XID >= |
min(/PostgreSQL by ODBC/db.odbc.select[pgsql.oldest.xid,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"],15m) >= {$PG.XID_ACTIVE.HIGH} |
High | |
| 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: LRQ duration average | Query running longer than |
last(/PostgreSQL by ODBC/pgsql.longest.running.query.duration) >= {$PG.LRQ.TIME.AVG} |
Average | Depends on:
|
| PostgreSQL: LRQ duration high | Query running longer than |
last(/PostgreSQL by ODBC/pgsql.longest.running.query.duration) >= {$PG.LRQ.TIME.HIGH} |
High | |
| 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 |
LLD rule Workload metrics discovery (v18+)
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Workload metrics discovery (v18+) | Discovers |
Dependent item | pgsql.workload.stats.version.18.discovery Preprocessing
|
Item prototypes for Workload metrics discovery (v18+)
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Workload: Get data | Collects top queries from IMPORTANT! Ensure |
Database monitor | db.odbc.select[pgsql.workload.snapshot.version.18.get{#SINGLETON},,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] Preprocessing
|
| Workload: PGSS version | Version of |
Dependent item | pgsql.workload.pgss.version.18[{#SINGLETON}] Preprocessing
|
| Workload: Average execution | Average query execution time from |
Dependent item | pgsql.workload.avg.exec.time.version.18[{#SINGLETON}] Preprocessing
|
| Workload: Max execution | Slowest query execution time from |
Dependent item | pgsql.workload.max_exec_time.version.18[{#SINGLETON}] Preprocessing
|
| Workload: Temporary blocks written | Number of temporary blocks written to disk (spills). |
Dependent item | pgsql.workload.temp.blocks.written.version.18[{#SINGLETON}] Preprocessing
|
| Workload: Temporary blocks read | Number of temporary blocks read from disk (spills). |
Dependent item | pgsql.workload.temp.blocks.read.version.18[{#SINGLETON}] Preprocessing
|
| Workload: Temporary blocks total | Total number of temporary blocks read and written to disk. |
Calculated | pgsql.workload.temp.blocks.total.version.18[{#SINGLETON}] Preprocessing
|
| Workload: Total calls | Total number of calls executed, as reported by |
Dependent item | pgsql.workload.total.calls.version.18[{#SINGLETON}] Preprocessing
|
| Workload: Rows inserted | Total number of rows inserted, as reported by |
Dependent item | pgsql.workload.rows.inserted.version.18[{#SINGLETON}] Preprocessing
|
| Workload: Rows updated | Total number of rows updated, as reported by |
Dependent item | pgsql.workload.rows.updated.version.18[{#SINGLETON}] Preprocessing
|
| Workload: Rows deleted | Total number of rows deleted, as reported by |
Dependent item | pgsql.workload.rows.deleted.version.18[{#SINGLETON}] Preprocessing
|
| Workload: Plan count | Time spent planning each individual query. |
Dependent item | pgsql.workload.total.plans.version.18[{#SINGLETON}] Preprocessing
|
| Workload: Total plan time | Total time spent planning all queries combined. |
Dependent item | pgsql.workload.total.plan.time.version.18[{#SINGLETON}] Preprocessing
|
| Workload: Plan time average | Average time per plan execution. |
Dependent item | pgsql.workload.avg.plan.time.version.18[{#SINGLETON}] Preprocessing
|
| Workload: Distinct statements | Number of distinct SQL statements tracked in |
Dependent item | pgsql.workload.distinct.statements.version.18[{#SINGLETON}] Preprocessing
|
| Workload: Track level | Track configuration in |
Dependent item | pgsql.workload.track.level.version.18[{#SINGLETON}] Preprocessing
|
| Workload: Nested track | Track nested configuration in |
Dependent item | pgsql.workload.track.nested.version.18[{#SINGLETON}] Preprocessing
|
| Workload: Max statements | Maximum number of statements tracked by |
Dependent item | pgsql.workload.max.statements.version.18[{#SINGLETON}] Preprocessing
|
| Workload: Min plan time | Minimum time spent planning queries. |
Dependent item | pgsql.workload.min.plan.time.version.18[{#SINGLETON}] Preprocessing
|
| Workload: Max plan time | Maximum time spent planning queries. |
Dependent item | pgsql.workload.max.plan.time.version.18[{#SINGLETON}] Preprocessing
|
| Workload: Min execution | Minimum query execution time. |
Dependent item | pgsql.workload.min.exec.time.version.18[{#SINGLETON}] Preprocessing
|
LLD rule Workload metrics discovery (v17)
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Workload metrics discovery (v17) | Discovers |
Dependent item | pgsql.workload.stats.version.17.discovery Preprocessing
|
Item prototypes for Workload metrics discovery (v17)
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Workload: Get data | Collects top queries from IMPORTANT! Ensure |
Database monitor | db.odbc.select[pgsql.workload.snapshot.version.17.get{#SINGLETON},,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] Preprocessing
|
| Workload: PGSS version | Version of |
Dependent item | pgsql.workload.pgss.version.17[{#SINGLETON}] Preprocessing
|
| Workload: Average execution | Average query execution time from |
Dependent item | pgsql.workload.avg.exec.time.version.17[{#SINGLETON}] Preprocessing
|
| Workload: Max execution | Slowest query execution time from |
Dependent item | pgsql.workload.max.exec.time.version.17[{#SINGLETON}] Preprocessing
|
| Workload: Temporary blocks written | Number of temporary blocks written to disk (spills). |
Dependent item | pgsql.workload.temp.blocks.written.version.17[{#SINGLETON}] Preprocessing
|
| Workload: Total calls | Total number of calls executed, as reported by |
Dependent item | pgsql.workload.total.calls.version.17[{#SINGLETON}] Preprocessing
|
| Workload: Rows inserted | Total number of rows inserted, as reported by |
Dependent item | pgsql.workload.rows.inserted.version.17[{#SINGLETON}] Preprocessing
|
| Workload: Rows updated | Total number of rows updated, as reported by |
Dependent item | pgsql.workload.rows.updated.version.17[{#SINGLETON}] Preprocessing
|
| Workload: Rows deleted | Total number of rows deleted, as reported by |
Dependent item | pgsql.workload.rows.deleted.version.17[{#SINGLETON}] Preprocessing
|
| Workload: Temporary blocks read | Number of temporary blocks read from disk (spills). |
Dependent item | pgsql.workload.temp.blocks.read.version.17[{#SINGLETON}] Preprocessing
|
| Workload: Temporary blocks total | Total number of temporary blocks read and written to disk. |
Calculated | pgsql.workload.temp.blocks.total.version.17[{#SINGLETON}] Preprocessing
|
| Workload: Plan count | Number of times each query plan was executed. |
Dependent item | pgsql.workload.total.plans.version.17[{#SINGLETON}] Preprocessing
|
| Workload: Total plan time | Total time spent planning all queries combined. |
Dependent item | pgsql.workload.total.plan.time.version.17[{#SINGLETON}] Preprocessing
|
| Workload: Plan time average | Average time per plan execution. |
Dependent item | pgsql.workload.avg.plan.time.version.17[{#SINGLETON}] Preprocessing
|
| Workload: Distinct statements | Number of distinct SQL statements tracked in |
Dependent item | pgsql.workload.distinct.statements.version.17[{#SINGLETON}] Preprocessing
|
| Workload: Track level | Track configuration in |
Dependent item | pgsql.workload.track.level.version.17[{#SINGLETON}] Preprocessing
|
| Workload: Nested track | Track nested configuration in |
Dependent item | pgsql.workload.track.nested.version.17[{#SINGLETON}] Preprocessing
|
| Workload: Max statements | Maximum number of statements tracked by |
Dependent item | pgsql.workload.max.statements.version.17[{#SINGLETON}] Preprocessing
|
LLD rule Workload metrics discovery (v15–16)
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Workload metrics discovery (v15–16) | Discovers |
Dependent item | pgsql.workload.stats.above.15.discovery Preprocessing
|
Item prototypes for Workload metrics discovery (v15–16)
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Workload: Get data | Collects top queries from IMPORTANT! Ensure |
Database monitor | db.odbc.select[pgsql.workload.snapshot.above.15.get{#SINGLETON},,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] Preprocessing
|
| Workload: PGSS version | Version of |
Dependent item | pgsql.workload.pgss.version.above.15[{#SINGLETON}] Preprocessing
|
| Workload: Average execution | Average query execution time from |
Dependent item | pgsql.workload.avg_exec_time.above.15[{#SINGLETON}] Preprocessing
|
| Workload: Max execution | Slowest query execution time from |
Dependent item | pgsql.workload.max_exec_time.above.15[{#SINGLETON}] Preprocessing
|
| Workload: Temporary blocks written | Number of temporary blocks written to disk (spills). |
Dependent item | pgsql.workload.temp.blocks.written.above.15[{#SINGLETON}] Preprocessing
|
| Workload: Total calls | Total number of calls executed, as reported by |
Dependent item | pgsql.workload.total.calls.above.15[{#SINGLETON}] Preprocessing
|
| Workload: Rows inserted | Total number of rows inserted, as reported by |
Dependent item | pgsql.workload.rows.inserted.above.15[{#SINGLETON}] Preprocessing
|
| Workload: Rows updated | Total number of rows updated, as reported by |
Dependent item | pgsql.workload.rows.updated.above.15[{#SINGLETON}] Preprocessing
|
| Workload: Rows deleted | Total number of rows deleted, as reported by |
Dependent item | pgsql.workload.rows.deleted.above.15[{#SINGLETON}] Preprocessing
|
LLD rule Workload metrics discovery (v12)
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Workload metrics discovery (v12) | Discovers |
Dependent item | pgsql.workload.stats.below.13.discovery Preprocessing
|
Item prototypes for Workload metrics discovery (v12)
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Workload: Get data | Collects top queries from IMPORTANT! Ensure |
Database monitor | db.odbc.select[pgsql.workload.snapshot.below.13.get{#SINGLETON},,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] Preprocessing
|
| Workload: PGSS version | Version of |
Dependent item | pgsql.workload.pgss.version.below.13[{#SINGLETON}] Preprocessing
|
LLD rule Workload metrics discovery (v13–14)
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Workload metrics discovery (v13–14) | Discovers |
Dependent item | pgsql.workload.stats.below.15.discovery Preprocessing
|
Item prototypes for Workload metrics discovery (v13–14)
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Workload: Get data | Collects top queries from IMPORTANT! Ensure |
Database monitor | db.odbc.select[pgsql.workload.snapshot.below.15.get{#SINGLETON},,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] Preprocessing
|
| Workload: PGSS version | Version of |
Dependent item | pgsql.workload.pgss.version.below.15[{#SINGLETON}] Preprocessing
|
| Workload: Average execution | Average query execution time from |
Dependent item | pgsql.workload.avg.exec.time.below.15[{#SINGLETON}] Preprocessing
|
| Workload: Max execution | Slowest query execution time from |
Dependent item | pgsql.workload.max.exec.time.below.15[{#SINGLETON}] Preprocessing
|
| Workload: Temporary blocks written | Number of temporary blocks written to disk (spills). |
Dependent item | pgsql.workload.temp.blocks.written.below.15[{#SINGLETON}] Preprocessing
|
| Workload: Total calls | Total number of calls executed, as reported by |
Dependent item | pgsql.workload.total.calls.below.15[{#SINGLETON}] Preprocessing
|
LLD rule Relation schema discovery
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Relation schema discovery | Discovers all PostgreSQL schemas in the primary core database. |
Dependent item | pgsql.relation.discovery Preprocessing
|
Item prototypes for Relation schema discovery
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Relation [{#SCHEMA.NAME}]: Size | Total on-disk size of all relations in schema. |
Dependent item | pgsql.relation.size[{#SCHEMA.NAME}] Preprocessing
|
| Relation [{#SCHEMA.NAME}]: Count | Number of tables in schema. |
Dependent item | pgsql.relation.tables[{#SCHEMA.NAME}] Preprocessing
|
LLD rule Tablespace discovery
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Tablespace discovery | Discovers tablespaces. |
Dependent item | pgsql.tablespace.discovery Preprocessing
|
Item prototypes for Tablespace discovery
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Tablespace [{#TABLESPACE.NAME}]: Get data | Collects tablespace metrics. |
Dependent item | pgsql.tablespace.inventory.preprocessing.data.get[{#TABLESPACE.NAME}] Preprocessing
|
| Tablespace [{#TABLESPACE.NAME}]: Size | Size of the tablespace |
Dependent item | pgsql.tablespace.size[{#TABLESPACE.NAME}] Preprocessing
|
| Tablespace [{#TABLESPACE.NAME}]: Owner | Owner of the tablespace |
Dependent item | pgsql.tablespace.owner[{#TABLESPACE.NAME}] Preprocessing
|
| Tablespace [{#TABLESPACE.NAME}]: Location | Filesystem path for the tablespace |
Dependent item | pgsql.tablespace.location[{#TABLESPACE.NAME}] Preprocessing
|
| Tablespace [{#TABLESPACE.NAME}]: Default | Indicates whether the tablespace |
Dependent item | pgsql.tablespace.is_default[{#TABLESPACE.NAME}] Preprocessing
|
Trigger prototypes for Tablespace discovery
| Name | Description | Expression | Severity | Dependencies and additional info |
|---|---|---|---|---|
| PostgreSQL: Tablespace [{#TABLESPACE.NAME}]: Size warning | Tablespace |
min(/PostgreSQL by ODBC/pgsql.tablespace.size[{#TABLESPACE.NAME}],5m) >= {$PG.TABLESPACE.SIZE.WARN:"{#TABLESPACE.NAME}"} |
Warning | Depends on:
|
| PostgreSQL: Tablespace [{#TABLESPACE.NAME}]: Size average | Tablespace |
min(/PostgreSQL by ODBC/pgsql.tablespace.size[{#TABLESPACE.NAME}],5m) >= {$PG.TABLESPACE.SIZE.AVG:"{#TABLESPACE.NAME}"} |
Average | Depends on:
|
| PostgreSQL: Tablespace [{#TABLESPACE.NAME}]: Size high | Tablespace |
min(/PostgreSQL by ODBC/pgsql.tablespace.size[{#TABLESPACE.NAME}],5m) >= {$PG.TABLESPACE.SIZE.HIGH:"{#TABLESPACE.NAME}"} |
High |
LLD rule Replication slots metrics discovery (v12–14)
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Replication slots metrics discovery (v12–14) | Discovers |
Dependent item | pgsql.replication.slots.below_15.discovery Preprocessing
|
Item prototypes for Replication slots metrics discovery (v12–14)
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Replication slots: Get slots | Collects raw replication slot information from IMPORTANT! Ensure logical replication is enabled: set |
Database monitor | db.odbc.select[pgsql.replication.slots.below.15.get{#SINGLETON},,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] Preprocessing
|
| Replication slots: Slots total | Total number of replication slots. |
Dependent item | pgsql.replication.slots.total.below.15[{#SINGLETON}] Preprocessing
|
| Replication slots: Slots active | Number of active replication slots. |
Dependent item | pgsql.replication.slots.active.below.15[{#SINGLETON}] Preprocessing
|
| Replication slots: Slots inactive | Number of inactive replication slots. |
Dependent item | pgsql.replication.slots.inactive.below.15[{#SINGLETON}] Preprocessing
|
LLD rule Replication slots metrics discovery (v15+)
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Replication slots metrics discovery (v15+) | Discovers |
Dependent item | pgsql.replication.slots.above.15.discovery Preprocessing
|
Item prototypes for Replication slots metrics discovery (v15+)
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Replication slots: Get slots | Collects raw replication slot information from IMPORTANT! Ensure logical replication is enabled: set |
Database monitor | db.odbc.select[pgsql.replication.slots.above.15.get{#SINGLETON},,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] Preprocessing
|
| Replication slots: Slots total | Total number of replication slots. |
Dependent item | pgsql.replication.slots.total.above.15[{#SINGLETON}] Preprocessing
|
| Replication slots: Slots active | Number of active replication slots. |
Dependent item | pgsql.replication.slots.active.above.15[{#SINGLETON}] Preprocessing
|
| Replication slots: Slots inactive | Number of inactive replication slots. |
Dependent item | pgsql.replication.slots.inactive.above.15[{#SINGLETON}] Preprocessing
|
| Replication slots: Max WAL | Maximum amount of WAL retained by any replication slot. |
Dependent item | pgsql.replication.slots.max.safe.wal.size.above.15[{#SINGLETON}] Preprocessing
|
| Replication slots: Worst lag | Maximum replication lag (in bytes) of the worst slot. |
Dependent item | pgsql.replication.slots.worst.lag.above.15[{#SINGLETON}] Preprocessing
|
| Replication slots: Slots retaining | Number of inactive replication slots that are still retaining WAL. |
Dependent item | pgsql.replication.slots.inactive.retaining.above.15[{#SINGLETON}] Preprocessing
|
Trigger prototypes for Replication slots metrics discovery (v15+)
| Name | Description | Expression | Severity | Dependencies and additional info |
|---|---|---|---|---|
| PostgreSQL: Replication slots: Retaining WAL average | Slots retaining WAL >= |
min(/PostgreSQL by ODBC/pgsql.replication.slots.inactive.retaining.above.15[{#SINGLETON}],5m) >= {$PG.REPLICATION.SLOTS.RETAINING.AVG} |
Average | Depends on:
|
| PostgreSQL: Replication slots: Retaining WAL high | Slots retaining WAL >= |
min(/PostgreSQL by ODBC/pgsql.replication.slots.inactive.retaining.above.15[{#SINGLETON}],5m) >= {$PG.REPLICATION.SLOTS.RETAINING.HIGH} |
High |
LLD rule WAL statistics metrics discovery (v14+)
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| WAL statistics metrics discovery (v14+) | Discovers |
Dependent item | pgsql.wal.stats.above.14.discovery Preprocessing
|
Item prototypes for WAL statistics metrics discovery (v14+)
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| WAL statistics: Get data | Collects WAL activity metrics from |
Database monitor | db.odbc.select[pgsql.wal.stats.above.14.get{#SINGLETON},,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] Preprocessing
|
| WAL statistics: Bytes generated total | Total number of WAL bytes generated since last statistics reset. |
Dependent item | pgsql.wal.stats.bytes.total.above.14[{#SINGLETON}] Preprocessing
|
| WAL statistics: Records total | Total number of WAL records generated since last statistics reset. |
Dependent item | pgsql.wal.stats.records.above.14[{#SINGLETON}] Preprocessing
|
| WAL statistics: Buffers full total | Total number of times WAL buffers were full since last statistics reset. A non-zero or increasing value indicates WAL buffer pressure and possible performance impact. |
Dependent item | pgsql.wal.stats.buffers.full.above.14[{#SINGLETON}] Preprocessing
|
| WAL statistics: Reset time | Timestamp of the last reset of WAL statistics. |
Dependent item | pgsql.wal.stats.reset.above.14[{#SINGLETON}] Preprocessing
|
| WAL statistics: Full page images total | Total number of full page images written to WAL since last statistics reset. Higher values increase WAL volume and may indicate frequent checkpoints or cold page writes. |
Dependent item | pgsql.wal.stats.fpi.above.14[{#SINGLETON}] Preprocessing
|
LLD rule SLRU metrics discovery (v13+)
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| SLRU metrics discovery (v13+) | Discovers |
Dependent item | pgsql.slru.above_13.discovery Preprocessing
|
Item prototypes for SLRU metrics discovery (v13+)
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| SLRU: Get data | Collects SLRU (Simple Least Recently Used) cache statistics from |
Database monitor | db.odbc.select[pgsql.stat.slru.get{#SINGLETON},,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] |
| SLRU: Blocks read total | Total number of SLRU (Simple Least Recently Used) blocks read since last statistics reset. |
Dependent item | pgsql.slru.blks_read.total[{#SINGLETON}] Preprocessing
|
| SLRU: Blocks hit total | Total number of SLRU (Simple Least Recently Used) blocks found in cache (hits) since last statistics reset. |
Dependent item | pgsql.slru.blks_hit.total[{#SINGLETON}] Preprocessing
|
| SLRU: Blocks read per second | Rate of SLRU (Simple Least Recently Used) blocks read per second. |
Dependent item | pgsql.slru.blks_read.rate[{#SINGLETON}] Preprocessing
|
| SLRU: Buffer hit ratio | Percentage of SLRU (Simple Least Recently Used) blocks served from cache (hits / total blocks). Higher means better performance. |
Dependent item | pgsql.slru.hit.ratio[{#SINGLETON}] Preprocessing
|
Trigger prototypes for SLRU metrics discovery (v13+)
| Name | Description | Expression | Severity | Dependencies and additional info |
|---|---|---|---|---|
| PostgreSQL: SLRU: Buffer hit warning | SLRU buffer hit ratio <= |
max(/PostgreSQL by ODBC/pgsql.slru.hit.ratio[{#SINGLETON}],5m) <= {$PG.SLRU.CACHE.WARN} |
Warning | Depends on:
|
| PostgreSQL: SLRU: Buffer hit average | SLRU buffer hit ratio <= |
max(/PostgreSQL by ODBC/pgsql.slru.hit.ratio[{#SINGLETON}],5m) <= {$PG.SLRU.CACHE.AVG} |
Average | Depends on:
|
| PostgreSQL: SLRU: Buffer hit high | SLRU buffer hit ratio <= |
max(/PostgreSQL by ODBC/pgsql.slru.hit.ratio[{#SINGLETON}],5m) <= {$PG.SLRU.CACHE.HIGH} |
High |
LLD rule Subscription stats metrics discovery
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Subscription stats metrics discovery | Logical replication subscription metrics discovery. |
Dependent item | pgsql.subscription.discover Preprocessing
|
Item prototypes for Subscription stats metrics discovery
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Subscription stats [{#SUBNAME}]: Get data | Preprocessed data for each subscription object array. |
Dependent item | pgsql.subscription.data.preprocessing.data.get[{#SUBNAME}] Preprocessing
|
| Subscription stats [{#SUBNAME}]: Apply errors | Number of errors that occurred while applying changes for this logical replication subscription. |
Dependent item | pgsql.subscription.apply.error[{#SUBNAME}] Preprocessing
|
| Subscription stats [{#SUBNAME}]: Sync errors | Number of errors that occurred during the initial synchronization phase of this logical replication subscription. |
Dependent item | pgsql.subscription.sync.error[{#SUBNAME}] Preprocessing
|
| Subscription stats [{#SUBNAME}]: Total errors | Total number of errors for this logical replication subscription, from both |
Calculated | pgsql.subscription.total.error.count[{#SUBNAME}] Preprocessing
|
| Subscription stats [{#SUBNAME}]: Reset time | Unix timestamp of the last reset of subscription statistics. The value |
Dependent item | pgsql.subscription.reset.time[{#SUBNAME}] Preprocessing
|
| Subscription stats [{#SUBNAME}]: Time since last reset | Time in seconds that has passed since the last reset of subscription statistics. If the value is zero or negative, the subscription has never been reset. |
Calculated | pgsql.subscription.reset.time.since[{#SUBNAME}] |
Trigger prototypes for Subscription stats metrics discovery
| Name | Description | Expression | Severity | Dependencies and additional info |
|---|---|---|---|---|
| PostgreSQL: Subscription stats [{#SUBNAME}]: Apply errors average | Apply subscription errors >= |
min(/PostgreSQL by ODBC/pgsql.subscription.apply.error[{#SUBNAME}],5m) >= {$PG.SUBSCRIPTION.APPLY.ERROR.AVG} |
Average | Depends on:
|
| PostgreSQL: Subscription stats [{#SUBNAME}]: Apply errors high | Apply subscription errors >= |
min(/PostgreSQL by ODBC/pgsql.subscription.apply.error[{#SUBNAME}],5m) >= {$PG.SUBSCRIPTION.APPLY.ERROR.HIGH} |
High | |
| PostgreSQL: Subscription stats [{#SUBNAME}]: Sync errors average | Sync subscription errors >= |
min(/PostgreSQL by ODBC/pgsql.subscription.sync.error[{#SUBNAME}],5m) >= {$PG.SUBSCRIPTION.SYNC.ERROR.AVG} |
Average | Depends on:
|
| PostgreSQL: Subscription stats [{#SUBNAME}]: Sync errors high | Sync subscription errors >= |
min(/PostgreSQL by ODBC/pgsql.subscription.sync.error[{#SUBNAME}],5m) >= {$PG.SUBSCRIPTION.SYNC.ERROR.HIGH} |
High | |
| PostgreSQL: Subscription stats [{#SUBNAME}]: Total errors average | Total subscription errors (sync + apply) >= |
min(/PostgreSQL by ODBC/pgsql.subscription.total.error.count[{#SUBNAME}],5m) >= {$PG.SUBSCRIPTION.TOTAL.ERROR.AVG} |
Average | Depends on:
|
| PostgreSQL: Subscription stats [{#SUBNAME}]: Total errors high | Total subscription errors (sync + apply) >= |
min(/PostgreSQL by ODBC/pgsql.subscription.total.error.count[{#SUBNAME}],5m) >= {$PG.SUBSCRIPTION.TOTAL.ERROR.HIGH} |
High |
LLD rule I/O metrics discovery (v16–17)
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| I/O metrics discovery (v16–17) | Discovers |
Dependent item | pgsql.io.discovery.version.below.18 Preprocessing
|
Item prototypes for I/O metrics discovery (v16–17)
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| I/O: Get data | Aggregated |
Database monitor | db.odbc.select[pgsql.stat.io.version.below.18.get{#SINGLETON},,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] |
| I/O: Read bytes total | Total number of bytes read by PostgreSQL. |
Dependent item | pgsql.io.read.bytes.below.18[{#SINGLETON}] Preprocessing
|
| I/O: Write bytes total | Total number of bytes written by PostgreSQL. |
Dependent item | pgsql.io.write.bytes.version.below.18[{#SINGLETON}] Preprocessing
|
LLD rule I/O metrics discovery (v18+)
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| I/O metrics discovery (v18+) | Discovers |
Dependent item | pgsql.io.discovery.version.above.18 Preprocessing
|
Item prototypes for I/O metrics discovery (v18+)
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| I/O: Get data | Aggregated |
Database monitor | db.odbc.select[pgsql.stat.io.version.above.18.get{#SINGLETON},,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] |
| I/O: Read bytes total | Total number of bytes read by PostgreSQL. |
Dependent item | pgsql.io.read.bytes.version.above.18[{#SINGLETON}] Preprocessing
|
| I/O: Write bytes total | Total number of bytes written by PostgreSQL. |
Dependent item | pgsql.io.write.bytes.version.above.18[{#SINGLETON}] Preprocessing
|
| I/O: WAL write bytes total | Total number of bytes written to WAL. |
Dependent item | pgsql.io.wal.write.bytes.version.above.18[{#SINGLETON}] Preprocessing
|
| I/O: Time total | Total time spent on I/O operations (read + write). IMPORTANT! Requires Otherwise, this metric will always be |
Dependent item | pgsql.io.time.ms.version.above.18[{#SINGLETON}] Preprocessing
|
| I/O: Buffer hit ratio | Percentage of buffer cache hits. |
Dependent item | pgsql.io.hit.ratio.version.above.18[{#SINGLETON}] Preprocessing
|
Trigger prototypes for I/O metrics discovery (v18+)
| Name | Description | Expression | Severity | Dependencies and additional info |
|---|---|---|---|---|
| PostgreSQL: I/O:Buffer hit warning | I/O buffer hit ratio <= |
max(/PostgreSQL by ODBC/pgsql.io.hit.ratio.version.above.18[{#SINGLETON}],5m) <= {$PG.IO.CACHE.WARN} |
Warning | Depends on:
|
| PostgreSQL: I/O:Buffer hit average | I/O buffer hit ratio <= |
max(/PostgreSQL by ODBC/pgsql.io.hit.ratio.version.above.18[{#SINGLETON}],5m) <= {$PG.IO.CACHE.AVG} |
Average | Depends on:
|
| PostgreSQL: I/O:Buffer hit high | I/O buffer hit ratio <= |
max(/PostgreSQL by ODBC/pgsql.io.hit.ratio.version.above.18[{#SINGLETON}],5m) <= {$PG.IO.CACHE.HIGH} |
High |
LLD rule Replication discovery
| 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
|
Item prototypes for Replication discovery
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Application [{#APPLICATION_NAME}]: Get data | Collects metrics from |
Dependent item | pgsql.replication.get["{#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 |
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 |
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 |
Dependent item | pgsql.replication.process.write_lag["{#APPLICATION_NAME}"] Preprocessing
|
LLD rule Database discovery
| 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}"] |
Item prototypes for Database discovery
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| DB [{#DBNAME}]: Get data | Get |
Dependent item | pgsql.dbstat.get["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Get data | Get locks metrics for database |
Dependent item | pgsql.locks.get["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Get data | Get query metrics for database |
Dependent item | pgsql.queries.get["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Database age | Age of the database in transactions (XID distance from |
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 in the buffer cache, making a read unnecessary. |
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 |
Dependent item | pgsql.locks.accessexclusive["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Num of accessshare locks | Number of |
Dependent item | pgsql.locks.accessshare["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Num of exclusive locks | Number of |
Dependent item | pgsql.locks.exclusive["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Num of rowexclusive locks | Number of |
Dependent item | pgsql.locks.rowexclusive["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Num of rowshare locks | Number of |
Dependent item | pgsql.locks.rowshare["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Num of sharerowexclusive locks | Number of total |
Dependent item | pgsql.locks.sharerowexclusive["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Num of shareupdateexclusive locks | Number of |
Dependent item | pgsql.locks.shareupdateexclusive["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Num of share locks | Number of |
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 of maintenance query time for this database. |
Dependent item | pgsql.queries.mro.time_sum["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries sum query time | Sum of query time for this database. |
Dependent item | pgsql.queries.query.time_sum["{#DBNAME}"] Preprocessing
|
| DB [{#DBNAME}]: Queries sum transaction time | Sum of transaction query time for this database. |
Dependent item | pgsql.queries.tx.time_sum["{#DBNAME}"] Preprocessing
|
Trigger prototypes for Database discovery
| Name | Description | Expression | Severity | Dependencies and additional info |
|---|---|---|---|---|
| PostgreSQL: DB [{#DBNAME}]: Size warning | Database |
min(/PostgreSQL by ODBC/db.odbc.select[pgsql.db.size,,"Database={#DBNAME};{$PG.CONNSTRING.ODBC}"],5m) >= {$PG.DATABASE.SIZE.WARN:"{#DBNAME}"} |
Warning | Depends on:
|
| PostgreSQL: DB [{#DBNAME}]: Size average | Database |
min(/PostgreSQL by ODBC/db.odbc.select[pgsql.db.size,,"Database={#DBNAME};{$PG.CONNSTRING.ODBC}"],5m) >= {$PG.DATABASE.SIZE.AVG:"{#DBNAME}"} |
Average | Depends on:
|
| PostgreSQL: DB [{#DBNAME}]: Size high | Database |
min(/PostgreSQL by ODBC/db.odbc.select[pgsql.db.size,,"Database={#DBNAME};{$PG.CONNSTRING.ODBC}"],5m) >= {$PG.DATABASE.SIZE.HIGH:"{#DBNAME}"} |
High | |
| 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 has exceeded |
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 has exceeded the limit of |
min(/PostgreSQL by ODBC/pgsql.queries.query.slow_count["{#DBNAME}"],5m)>{$PG.SLOW_QUERIES.MAX.WARN:"{#DBNAME}"} |
Warning |
LLD rule Bgwriter metrics discovery (v<=17)
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Bgwriter metrics discovery (v<=17) | Discovers |
Dependent item | pgsql.bgwriter.below_17.discovery Preprocessing
|
Item prototypes for Bgwriter metrics discovery (v<=17)
| 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 |
Database monitor | db.odbc.select[pgsql.bgwriter.below_17.get{#SINGLETON},,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] |
| Bgwriter: Postmaster start time | The time when the postmaster was last started. |
Dependent item | pgsql.bgwriter.postmaster_start_epoch.below_17[{#SINGLETON}] Preprocessing
|
| Bgwriter: Buffers allocated per second | 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 | 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 | 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 | Number of buffers written during checkpoints per second. |
Dependent item | pgsql.bgwriter.buffers_checkpoint.rate.below_17[{#SINGLETON}] Preprocessing
|
| Checkpoint: Scheduled per second | 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 | Number of requested checkpoints that have been performed per second. |
Dependent item | pgsql.bgwriter.checkpoints_req.rate.below_17[{#SINGLETON}] Preprocessing
|
| Checkpoint: Checkpoint write 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.below_17[{#SINGLETON}] Preprocessing
|
| Bgwriter: Checkpoint sync 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.below_17[{#SINGLETON}] 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.below_17[{#SINGLETON}] 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.below_17[{#SINGLETON}] Preprocessing
|
LLD rule Bgwriter metrics discovery (v17+)
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Bgwriter metrics discovery (v17+) | Discovers |
Dependent item | pgsql.bgwriter.above_17.discovery Preprocessing
|
Item prototypes for Bgwriter metrics discovery (v17+)
| 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 |
Database monitor | db.odbc.select[pgsql.bgwriter.above_17.get{#SINGLETON},,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"] |
| Bgwriter: Postmaster start time | The time when the postmaster was last started. |
Dependent item | pgsql.bgwriter.postmaster_start_epoch.above_17[{#SINGLETON}] Preprocessing
|
| Bgwriter: Buffers allocated per second | 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 | 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 | 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 | Number of buffers written during checkpoints per second. |
Dependent item | pgsql.bgwriter.buffers_checkpoint.rate.above_17[{#SINGLETON}] Preprocessing
|
| Checkpoint: Scheduled per second | 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 | Number of requested checkpoints that have been performed per second. |
Dependent item | pgsql.bgwriter.checkpoints_req.rate.above_17[{#SINGLETON}] Preprocessing
|
| Checkpoint: Checkpoint write 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.above_17[{#SINGLETON}] Preprocessing
|
| Bgwriter: Checkpoint sync 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.above_17[{#SINGLETON}] Preprocessing
|
Feedback
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
PostgreSQL by Zabbix agent active
Overview
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.
Requirements
Zabbix version: 8.0 and higher.
Tested versions
This template has been tested on:
- PostgreSQL 10-18
Configuration
Zabbix should be configured according to the instructions in the Templates out of the box section.
Setup
Note:
- The template requires
pg_isreadyandpsqlutilities to be installed on the same host with Zabbix agent.
- Deploy Zabbix agent and create the PostgreSQL user for monitoring (
<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;
- Copy the
postgresql/directory to thezabbixuser home directory -/var/lib/zabbix/. Thepostgresql/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
- Copy the
template_db_postgresql.conffile, containing user parameters, to the Zabbix agent configuration directory/etc/zabbix/zabbix_agentd.d/and restart Zabbix agent service.
Note: the template and these files are shipped together and have to be updated together. The postgresql/ directory and template_db_postgresql.conf carry a revision number, reported by the User parameters revision item. If the deployed files are older than the template requires, the trigger User parameters are outdated is raised - copy both the directory and the configuration file of the current template version to the host and restart Zabbix agent. Newer files always work with an older template, so the agent side can be updated first.
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.
- Edit the
pg_hba.confconfiguration file to allow connections for the userzbx_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}.
Macros used
| Name | Description | Default |
|---|---|---|
| {$PG.HOST} | Hostname or IP of PostgreSQL host. |
localhost |
| {$PG.PORT} | PostgreSQL service port. |
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.SCHEMA} | Filter of discoverable schemas. |
.+ |
| {$PG.LLD.FILTER.SUBSCRIPTION} | Filter of discoverable logical replication subscriptions. |
.+ |
| {$PG.LLD.FILTER.TABLESPACE} | Filter of discoverable tablespaces. |
.+ |
| {$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.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.IO.CACHE.MIN.WARN} | Minimum shared buffers hit ratio percentage for trigger expression. |
90 |
| {$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.QUERY_EXECUTION_TIME.MAX.WARN} | Execution time limit for count of slow queries. |
30 |
| {$PG.REPLICATION.SLOTS.RETAINING.MAX.HIGH} | Critical number of inactive replication slots retaining WAL for trigger expression. |
2 |
| {$PG.REPLICATION.SLOTS.RETAINING.MAX.WARN} | Maximum number of inactive replication slots retaining WAL for trigger expression. |
1 |
| {$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.SLRU.CACHE.MIN.HIGH} | Critical SLRU cache hit ratio percentage for trigger expression. |
95 |
| {$PG.SLRU.CACHE.MIN.WARN} | Minimum SLRU cache hit ratio percentage for trigger expression. |
98 |
| {$PG.SUBSCRIPTION.ERRORS.MAX.WARN} | Maximum number of logical replication subscription errors for trigger expression. |
2 |
| {$PG.TABLESPACE.SIZE.MAX.HIGH} | Critical tablespace size for trigger expression. |
15G |
| {$PG.TABLESPACE.SIZE.MAX.WARN} | Maximum tablespace size for trigger expression. |
5G |
| {$PG.WAL.BUFFERS_FULL.MAX.WARN} | Maximum number of WAL buffer exhaustions per second for trigger expression. |
10 |
Items
| 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. Available in PostgreSQL versions prior to 17. |
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). Available in PostgreSQL versions prior to 17. |
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
|
| Get bgwriter | Collect all metrics from pg_stat_bgwriter: https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-BGWRITER-VIEW |
Zabbix agent (active) | pgsql.bgwriter["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Cache hit ratio, % | Cache hit ratio. |
Zabbix agent (active) | pgsql.cache.hit["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Config hash | PostgreSQL configuration hash. |
Zabbix agent (active) | 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
|
| 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 (active) | pgsql.connections.sum["{$PG.HOST}","{$PG.PORT}","{$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 (active) | pgsql.dbstat["{$PG.HOST}","{$PG.PORT}","{$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 (active) | pgsql.locks["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Ping time | Used to get the |
Zabbix agent (active) | pgsql.ping.time["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] Preprocessing
|
| 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 (active) | pgsql.ping["{$PG.HOST}","{$PG.PORT}"] Preprocessing
|
| Get queries | Collect all metrics by query execution time. |
Zabbix agent (active) | pgsql.queries["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}","{$PG.QUERY_EXECUTION_TIME.MAX.WARN}"] |
| Get relation sizes | Collects the on-disk size of the tables, their indexes and TOAST data, summed per schema of the "{$PG.DATABASE}" database. Reads the size metadata of every relation, therefore it is polled less frequently than the other metrics. |
Zabbix agent (active) | pgsql.relation.size["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Replication: Standby count | Number of standby servers. |
Zabbix agent (active) | pgsql.replication.count["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Replication: Lag in seconds | Replication lag with master, in seconds. |
Zabbix agent (active) | pgsql.replication.lag.sec["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Replication: Recovery role | Replication role: 1 — recovery is still in progress (standby mode), 0 — master mode. |
Zabbix agent (active) | pgsql.replication.recovery_role["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Replication: Status | Replication status: 0 — streaming is down, 1 — streaming is up, 2 — master mode. |
Zabbix agent (active) | pgsql.replication.status["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Get subscription stats | Collects the error counters of the logical replication subscriptions from https://www.postgresql.org/docs/current/monitoring-stats.html#MONITORING-PG-STAT-SUBSCRIPTION-STATS |
Zabbix agent (active) | pgsql.subscription.stats["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Get tablespace sizes | Collects the size, location and owner of every tablespace of the instance. Scans the tablespace directories, therefore it is polled less frequently than the other metrics. |
Zabbix agent (active) | pgsql.tablespace.size["{$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
|
| Get transactions | Collect metrics by transaction execution time. |
Zabbix agent (active) | pgsql.transactions["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Uptime | Time since the server started. |
Zabbix agent (active) | pgsql.uptime["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| User parameters revision | Revision of the user parameter files deployed on the host with Zabbix agent. Reported by the |
Zabbix agent (active) | pgsql.userparam.revision Preprocessing
|
| Version | PostgreSQL version. |
Zabbix agent (active) | pgsql.version["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] Preprocessing
|
| Version (numeric) | The PostgreSQL version as an integer, the same way |
Dependent item | pgsql.version.num Preprocessing
|
| Version validator | Converts the PostgreSQL version into low-level discovery data: one entry with a Discovery rules filter on those macros, which is how version-specific metrics are created only where PostgreSQL provides them. |
Dependent item | pgsql.version.validator Preprocessing
|
| WAL: Segments count | Number of WAL segments. |
Dependent item | pgsql.wal.count Preprocessing
|
| Get WAL | Collect write-ahead log (WAL) metrics. |
Zabbix agent (active) | 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
|
Triggers
| 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 active/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 active/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 active/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 active/pgsql.config.hash["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"],#1)<>last(/PostgreSQL by Zabbix agent active/pgsql.config.hash["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"],#2) and length(last(/PostgreSQL by Zabbix agent active/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 active/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 active/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 active/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 active/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 active/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 active/pgsql.uptime["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]) < 10m |
Average | |
| PostgreSQL: User parameters are outdated | The user parameter files deployed on the host with Zabbix agent are older than this template version, so some items cannot collect data. |
last(/PostgreSQL by Zabbix agent active/pgsql.userparam.revision) < 2 |
Warning | |
| PostgreSQL: Version has changed | The PostgreSQL version has changed. Check whether the update was planned, since a major version change can affect the availability of the collected metrics. |
last(/PostgreSQL by Zabbix agent active/pgsql.version["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"],#1)<>last(/PostgreSQL by Zabbix agent active/pgsql.version["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"],#2) and length(last(/PostgreSQL by Zabbix agent active/pgsql.version["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]))>0 |
Info |
LLD rule Database discovery
| 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 (active) | pgsql.discovery.db["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
Item prototypes for Database discovery
| 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 (active) | 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 (active) | 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 (active) | pgsql.scans["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{#DBNAME}"] |
Trigger prototypes for Database discovery
| 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 active/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 active/pgsql.dbstat.deadlocks.rate["{#DBNAME}"],5m) > {$PG.DEADLOCKS.MAX.WARN:"{#DBNAME}"} |
High | |
| PostgreSQL: DB [{#DBNAME}]: VACUUM FREEZE is required to prevent wraparound | Preventing Transaction ID Wraparound Failures: |
last(/PostgreSQL by Zabbix agent active/pgsql.frozenxid.prc_before_stop["{#DBNAME}"])<{$PG.FROZENXID_PCT_STOP.MIN.HIGH:"{#DBNAME}"} |
Average | |
| PostgreSQL: DB [{#DBNAME}]: Number of locks is too high | The number of locks in the database "{#DBNAME}" has exceeded {$PG.LOCKS.MAX.WARN:"{#DBNAME}"} for 5m. A growing number of locks indicates contention between transactions and can lead to queries waiting instead of being executed. |
min(/PostgreSQL by Zabbix agent active/pgsql.locks.total["{#DBNAME}"],5m)>{$PG.LOCKS.MAX.WARN:"{#DBNAME}"} |
Warning | |
| 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 active/pgsql.queries.query.slow_count["{#DBNAME}"],5m)>{$PG.SLOW_QUERIES.MAX.WARN:"{#DBNAME}"} |
Warning |
LLD rule WAL statistics metrics discovery
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| WAL statistics metrics discovery | Discovers the |
Dependent item | pgsql.stat.wal.discovery Preprocessing
|
Item prototypes for WAL statistics metrics discovery
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| WAL statistics: Get data | Collects write-ahead log activity from https://www.postgresql.org/docs/current/monitoring-stats.html#MONITORING-PG-STAT-WAL-VIEW |
Zabbix agent (active) | pgsql.stat.wal["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}","{#SINGLETON}"] |
| WAL statistics: Bytes generated total | Total amount of WAL generated since the last statistics reset. |
Dependent item | pgsql.stat.wal.bytes[{#SINGLETON}] Preprocessing
|
| WAL statistics: Records total | Total number of WAL records generated since the last statistics reset. |
Dependent item | pgsql.stat.wal.records[{#SINGLETON}] Preprocessing
|
| WAL statistics: Full page images total | Total number of full page images written to WAL since the last statistics reset. Full page images increase the WAL volume and are usually caused by frequent checkpoints. |
Dependent item | pgsql.stat.wal.fpi[{#SINGLETON}] Preprocessing
|
| WAL statistics: Buffers full total | Total number of times the WAL buffers were full and WAL had to be written out before the transaction could continue, since the last statistics reset. A growing value indicates WAL buffer pressure - consider increasing |
Dependent item | pgsql.stat.wal.buffers_full[{#SINGLETON}] Preprocessing
|
| WAL statistics: Buffers full per second | Number of times per second the WAL buffers were full and had to be written out. |
Dependent item | pgsql.stat.wal.buffers_full.rate[{#SINGLETON}] Preprocessing
|
| WAL statistics: Statistics reset time | Time of the last reset of the WAL statistics. The totals above are counted from this moment. |
Dependent item | pgsql.stat.wal.reset_time[{#SINGLETON}] Preprocessing
|
Trigger prototypes for WAL statistics metrics discovery
| Name | Description | Expression | Severity | Dependencies and additional info |
|---|---|---|---|---|
| PostgreSQL: WAL statistics: WAL buffers are full too often | The WAL buffers are exhausted more than {$PG.WAL.BUFFERS_FULL.MAX.WARN} times per second, so backends have to flush WAL themselves instead of doing useful work. |
min(/PostgreSQL by Zabbix agent active/pgsql.stat.wal.buffers_full.rate[{#SINGLETON}],15m) > {$PG.WAL.BUFFERS_FULL.MAX.WARN} |
Warning |
LLD rule SLRU metrics discovery
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| SLRU metrics discovery | Discovers the |
Dependent item | pgsql.stat.slru.discovery Preprocessing
|
Item prototypes for SLRU metrics discovery
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| SLRU: Get data | Collects the SLRU cache statistics from https://www.postgresql.org/docs/current/monitoring-stats.html#MONITORING-PG-STAT-SLRU-VIEW |
Zabbix agent (active) | pgsql.stat.slru["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}","{#SINGLETON}"] |
| SLRU: Blocks read total | Total number of blocks read from disk into the SLRU caches since the last statistics reset. |
Dependent item | pgsql.stat.slru.blks_read[{#SINGLETON}] Preprocessing
|
| SLRU: Blocks read per second | Number of blocks per second read from disk into the SLRU caches. |
Dependent item | pgsql.stat.slru.blks_read.rate[{#SINGLETON}] Preprocessing
|
| SLRU: Blocks hit total | Total number of blocks found in the SLRU caches since the last statistics reset. |
Dependent item | pgsql.stat.slru.blks_hit[{#SINGLETON}] Preprocessing
|
| SLRU: Blocks written total | Total number of dirty SLRU blocks written to disk since the last statistics reset. |
Dependent item | pgsql.stat.slru.blks_written[{#SINGLETON}] Preprocessing
|
| SLRU: Cache hit ratio | Percentage of the SLRU cache lookups served from memory, over all caches. A dropping ratio means the transaction status and multixact caches no longer fit, which shows up as extra disk reads under high concurrency. |
Dependent item | pgsql.stat.slru.hit_ratio[{#SINGLETON}] Preprocessing
|
Trigger prototypes for SLRU metrics discovery
| Name | Description | Expression | Severity | Dependencies and additional info |
|---|---|---|---|---|
| PostgreSQL: SLRU: Cache hit ratio too low | The SLRU caches serve less than {$PG.SLRU.CACHE.MIN.WARN}% of their lookups from memory. Check the disk load and the concurrency of transactions using multixacts ( |
max(/PostgreSQL by Zabbix agent active/pgsql.stat.slru.hit_ratio[{#SINGLETON}],5m) < {$PG.SLRU.CACHE.MIN.WARN} |
Warning | Depends on:
|
| PostgreSQL: SLRU: Cache hit ratio is critically low | The SLRU caches serve less than {$PG.SLRU.CACHE.MIN.HIGH}% of their lookups from memory, so the instance is doing significant extra I/O for transaction status lookups. |
max(/PostgreSQL by Zabbix agent active/pgsql.stat.slru.hit_ratio[{#SINGLETON}],5m) < {$PG.SLRU.CACHE.MIN.HIGH} |
High |
LLD rule Replication slots metrics discovery
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Replication slots metrics discovery | Discovers the |
Dependent item | pgsql.replication.slots.discovery Preprocessing
|
Item prototypes for Replication slots metrics discovery
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Replication slots: Get data | Collects the state of the replication slots from https://www.postgresql.org/docs/current/view-pg-replication-slots.html |
Zabbix agent (active) | pgsql.replication.slots["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}","{#SINGLETON}"] |
| Replication slots: Total | Total number of replication slots. |
Dependent item | pgsql.replication.slots.total[{#SINGLETON}] Preprocessing
|
| Replication slots: Active | Number of replication slots currently in use by a connected consumer. |
Dependent item | pgsql.replication.slots.active[{#SINGLETON}] Preprocessing
|
| Replication slots: Inactive | Number of replication slots without a connected consumer. |
Dependent item | pgsql.replication.slots.inactive[{#SINGLETON}] Preprocessing
|
| Replication slots: Worst slot lag | Amount of WAL the most lagging slot has not confirmed yet. Reported as 0 on a standby, where the current WAL position is not defined. |
Dependent item | pgsql.replication.slots.worst_lag[{#SINGLETON}] Preprocessing
|
| Replication slots: Min safe WAL size | Amount of WAL that can still be written before the slot closest to the limit starts losing the data it needs. Turns negative once that slot is past its safety margin: the WAL it needs is only kept until the next checkpoint. Always 0 when |
Dependent item | pgsql.replication.slots.min_safe_wal_size[{#SINGLETON}] Preprocessing
|
| Replication slots: Inactive retaining WAL | Number of inactive replication slots that still hold WAL segments. Such slots prevent WAL cleanup and are the usual cause of a slowly filling disk on the primary. |
Dependent item | pgsql.replication.slots.inactive_retaining[{#SINGLETON}] Preprocessing
|
Trigger prototypes for Replication slots metrics discovery
| Name | Description | Expression | Severity | Dependencies and additional info |
|---|---|---|---|---|
| PostgreSQL: Replication slots: Inactive slots are retaining WAL | Inactive replication slots are holding WAL segments. Check whether the consumers are gone for good and drop the slots that are no longer needed. |
min(/PostgreSQL by Zabbix agent active/pgsql.replication.slots.inactive_retaining[{#SINGLETON}],5m) > {$PG.REPLICATION.SLOTS.RETAINING.MAX.WARN} |
Warning | Depends on:
|
| PostgreSQL: Replication slots: Too many inactive slots are retaining WAL | Several inactive replication slots are holding WAL segments, which can fill the disk and stop the instance from accepting writes. Drop the slots that are no longer needed. |
min(/PostgreSQL by Zabbix agent active/pgsql.replication.slots.inactive_retaining[{#SINGLETON}],5m) > {$PG.REPLICATION.SLOTS.RETAINING.MAX.HIGH} |
High |
LLD rule Subscription discovery
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Subscription discovery | Discovers the logical replication subscriptions of the instance. |
Dependent item | pgsql.subscription.discovery Preprocessing
|
Item prototypes for Subscription discovery
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Subscription [{#SUBNAME}]: Get subscription stats | Subscription stats of the "{#SUBNAME}" subscription. |
Dependent item | pgsql.subscription.get_metrics["{#SUBNAME}"] Preprocessing
|
| Subscription [{#SUBNAME}]: Apply errors | Number of errors that occurred while applying the changes received from the publisher, since the last statistics reset. |
Dependent item | pgsql.subscription.apply_errors["{#SUBNAME}"] Preprocessing
|
| Subscription [{#SUBNAME}]: Sync errors | Number of errors that occurred during the initial data copy of the subscribed tables, since the last statistics reset. |
Dependent item | pgsql.subscription.sync_errors["{#SUBNAME}"] Preprocessing
|
| Subscription [{#SUBNAME}]: Statistics reset time | Time of the last reset of the subscription statistics. The error counters above are counted from this moment. |
Dependent item | pgsql.subscription.reset_time["{#SUBNAME}"] Preprocessing
|
Trigger prototypes for Subscription discovery
| Name | Description | Expression | Severity | Dependencies and additional info |
|---|---|---|---|---|
| PostgreSQL: Subscription [{#SUBNAME}]: Errors while applying changes | The subscription "{#SUBNAME}" fails to apply the changes it receives, so the subscriber data is drifting away from the publisher. Check the subscription worker errors in the PostgreSQL log. |
min(/PostgreSQL by Zabbix agent active/pgsql.subscription.apply_errors["{#SUBNAME}"],5m) > {$PG.SUBSCRIPTION.ERRORS.MAX.WARN:"{#SUBNAME}"} |
Warning | |
| PostgreSQL: Subscription [{#SUBNAME}]: Errors while synchronizing tables | The initial table synchronization of the subscription "{#SUBNAME}" keeps failing, so the subscribed tables never reach a consistent state. Check the table sync worker errors in the PostgreSQL log. |
min(/PostgreSQL by Zabbix agent active/pgsql.subscription.sync_errors["{#SUBNAME}"],5m) > {$PG.SUBSCRIPTION.ERRORS.MAX.WARN:"{#SUBNAME}"} |
Warning |
LLD rule I/O metrics discovery
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| I/O metrics discovery | Discovers the |
Dependent item | pgsql.stat.io.discovery Preprocessing
|
Item prototypes for I/O metrics discovery
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| I/O: Get data | Collects the I/O activity of the instance from https://www.postgresql.org/docs/current/monitoring-stats.html#MONITORING-PG-STAT-IO-VIEW |
Zabbix agent (active) | pgsql.stat.io["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}","{#SINGLETON}"] |
| I/O: Reads per second | Number of read operations per second the instance issues to the storage. Reads mean the data was not found in the shared buffers. |
Dependent item | pgsql.stat.io.reads.rate[{#SINGLETON}] Preprocessing
|
| I/O: Writes per second | Number of write operations per second the instance issues to the storage. |
Dependent item | pgsql.stat.io.writes.rate[{#SINGLETON}] Preprocessing
|
| I/O: Read per second | Amount of data per second the instance reads from the storage. |
Dependent item | pgsql.stat.io.read_bytes.rate[{#SINGLETON}] Preprocessing
|
| I/O: Written per second | Amount of data per second the instance writes to the storage. |
Dependent item | pgsql.stat.io.write_bytes.rate[{#SINGLETON}] Preprocessing
|
| I/O: Fsyncs per second | Number of Most of them are normally done by the checkpointer, so a high rate from other backends points at a checkpoint or WAL configuration problem. |
Dependent item | pgsql.stat.io.fsyncs.rate[{#SINGLETON}] Preprocessing
|
| I/O: Time spent per second | Time per second the instance spends waiting for reads and writes to complete. Requires |
Dependent item | pgsql.stat.io.time.rate[{#SINGLETON}] Preprocessing
|
| I/O: Buffer hit ratio | Percentage of the block requests served from the shared buffers instead of the storage, since the last statistics reset. A low value means the working set does not fit into |
Dependent item | pgsql.stat.io.hit_ratio[{#SINGLETON}] Preprocessing
|
Trigger prototypes for I/O metrics discovery
| Name | Description | Expression | Severity | Dependencies and additional info |
|---|---|---|---|---|
| PostgreSQL: I/O: Buffer hit ratio too low | Less than {$PG.IO.CACHE.MIN.WARN}% of the block requests are served from the shared buffers, so the instance keeps going to the storage for data. Consider increasing |
max(/PostgreSQL by Zabbix agent active/pgsql.stat.io.hit_ratio[{#SINGLETON}],15m) < {$PG.IO.CACHE.MIN.WARN} |
Warning |
LLD rule Schema discovery
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Schema discovery | Discovers the schemas of the "{$PG.DATABASE}" database, except the system ones. |
Dependent item | pgsql.relation.discovery Preprocessing
|
Item prototypes for Schema discovery
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Schema [{#SCHEMA.NAME}]: Size | Total on-disk size of the tables of the schema "{#SCHEMA.NAME}", including their indexes and TOAST data. |
Dependent item | pgsql.relation.size["{#SCHEMA.NAME}"] Preprocessing
|
| Schema [{#SCHEMA.NAME}]: Number of tables | Number of tables in the schema "{#SCHEMA.NAME}", partitioned tables included. |
Dependent item | pgsql.relation.tables["{#SCHEMA.NAME}"] Preprocessing
|
LLD rule Tablespace discovery
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Tablespace discovery | Discovers the tablespaces of the instance, including the built-in |
Dependent item | pgsql.tablespace.discovery Preprocessing
|
Item prototypes for Tablespace discovery
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Tablespace [{#TABLESPACE.NAME}]: Get tablespace data | Data of the tablespace "{#TABLESPACE.NAME}". |
Dependent item | pgsql.tablespace.get_metrics["{#TABLESPACE.NAME}"] Preprocessing
|
| Tablespace [{#TABLESPACE.NAME}]: Size | Total size of the files stored in the tablespace "{#TABLESPACE.NAME}". |
Dependent item | pgsql.tablespace.size["{#TABLESPACE.NAME}"] Preprocessing
|
| Tablespace [{#TABLESPACE.NAME}]: Location | Directory the tablespace "{#TABLESPACE.NAME}" is stored in. Empty for the built-in |
Dependent item | pgsql.tablespace.location["{#TABLESPACE.NAME}"] Preprocessing
|
| Tablespace [{#TABLESPACE.NAME}]: Owner | Owner of the tablespace "{#TABLESPACE.NAME}". |
Dependent item | pgsql.tablespace.owner["{#TABLESPACE.NAME}"] Preprocessing
|
Trigger prototypes for Tablespace discovery
| Name | Description | Expression | Severity | Dependencies and additional info |
|---|---|---|---|---|
| PostgreSQL: Tablespace [{#TABLESPACE.NAME}]: Size is too big | The tablespace "{#TABLESPACE.NAME}" has grown beyond the expected size. Check the storage capacity and the growth rate before it becomes a problem. |
min(/PostgreSQL by Zabbix agent active/pgsql.tablespace.size["{#TABLESPACE.NAME}"],5m) > {$PG.TABLESPACE.SIZE.MAX.WARN:"{#TABLESPACE.NAME}"} |
Warning | Depends on:
|
| PostgreSQL: Tablespace [{#TABLESPACE.NAME}]: Size is critically big | The tablespace "{#TABLESPACE.NAME}" is close to exhausting its storage. Free up space or move relations to another tablespace - a full disk stops the instance from accepting writes. |
min(/PostgreSQL by Zabbix agent active/pgsql.tablespace.size["{#TABLESPACE.NAME}"],5m) > {$PG.TABLESPACE.SIZE.MAX.HIGH:"{#TABLESPACE.NAME}"} |
High |
Feedback
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
PostgreSQL by Zabbix agent 2 active
Overview
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.
Requirements
Zabbix version: 8.0 and higher.
Tested versions
This template has been tested on:
- PostgreSQL 10-17
Configuration
Zabbix should be configured according to the instructions in the Templates out of the box section.
Setup
-
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 rolepg_monitor:
CREATE USER zbx_monitor WITH PASSWORD '<PASSWORD>' INHERIT;
GRANT pg_monitor TO zbx_monitor;
- Edit the
pg_hba.confconfiguration file to allow connections for the userzbx_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.
- Set the connection string for the PostgreSQL instance in the
{$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.
- Set the password that you specified in step 2 in the macro
{$PG.PASSWORD}.
Macros used
| 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 |
Items
| 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 (active) | pgsql.bgwriter["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Get archive | Collect archive status metrics. |
Zabbix agent (active) | 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 (active) | 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 (active) | 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 (active) | pgsql.connections["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Get WAL | Collect write-ahead log (WAL) metrics. |
Zabbix agent (active) | 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 (active) | 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 (active) | 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 (active) | pgsql.replication.process["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Get queries | Collect all metrics by query execution time. |
Zabbix agent (active) | pgsql.queries["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}","{$PG.QUERY_ETIME.MAX.WARN}"] |
| Version | PostgreSQL version. |
Zabbix agent (active) | 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 (active) | pgsql.oldest.xid["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Count of autovacuum workers | Number of autovacuum workers. |
Zabbix agent (active) | 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 (active) | pgsql.uptime["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Replication: Lag in bytes | Replication lag with master, in bytes. |
Zabbix agent (active) | 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 (active) | 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 (active) | pgsql.replication.recovery_role["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Replication: Standby count | Number of standby servers. |
Zabbix agent (active) | 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 (active) | 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 (active) | pgsql.ping["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] Preprocessing
|
Triggers
| Name | Description | Expression | Severity | Dependencies and additional info |
|---|---|---|---|---|
| PostgreSQL: Version has changed | last(/PostgreSQL by Zabbix agent 2 active/pgsql.version["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"],#1)<>last(/PostgreSQL by Zabbix agent 2 active/pgsql.version["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"],#2) and length(last(/PostgreSQL by Zabbix agent 2 active/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 active/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 active/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 active/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 active/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 active/pgsql.ping["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"])=0 |
High |
LLD rule Replication discovery
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Replication discovery | Discovers replication lag metrics. |
Zabbix agent (active) | pgsql.replication.process.discovery["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
Item prototypes for Replication discovery
| 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
|
LLD rule Database discovery
| 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 (active) | pgsql.db.discovery["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
Item prototypes for Database discovery
| 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 (active) | pgsql.db.age["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{#DBNAME}"] |
| DB [{#DBNAME}]: Bloating tables | Number of bloating tables. |
Zabbix agent (active) | pgsql.db.bloating_tables["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{#DBNAME}"] |
| DB [{#DBNAME}]: Database size | Database size. |
Zabbix agent (active) | 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
|
Trigger prototypes for Database discovery
| 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 active/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 active/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 active/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 active/pgsql.queries.query.slow_count["{#DBNAME}"],5m)>{$PG.SLOW_QUERIES.MAX.WARN:"{#DBNAME}"} |
Warning |
Feedback
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
Vendor and Community integrations are created by third parties and are not verified by Zabbix. Zabbix is not responsible for their functionality or quality.
Zabbix community templates
1 Contributed to the zabbix/community-templates repositoryI 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 run multiple instances on each server so I create a host for each database and use the {HOST.NAME} macro in the item key. If you want to use a different macro like {$DATABASE.NAME} then do a find and replace before you import this. As well all items have the name zabbix set as the user and the password set as " my_password". Again you may want to do a find and replace before importing.Then import this template and add it to the host you are using and then go through and double check the items.I know this functionality was in Zabbix 3 so this may work there but I created this in 4 so that is all I know it works with. I hope some one finds this useful.
Community repositories
8 Independent projects on GitHubZabbixDBA 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
Scripts for partitioning the Zabbix database on PostgreSQL.
Scripts to install, manage, and remove PostgreSQL partitioning for Zabbix DB
Docker container for Zabbix DB on postrges, automatic partitioning.
Monitoring will be based on SQL queries to the statistics tables.
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
Backup Zabbix postgresql
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 utility.
PostgreSQL by Zabbix agent
Overview
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.
Requirements
Zabbix version: 7.4 and higher.
Tested versions
This template has been tested on:
- PostgreSQL 10-17
Configuration
Zabbix should be configured according to the instructions in the Templates out of the box section.
Setup
Note:
- The template requires
pg_isreadyandpsqlutilities to be installed on the same host with Zabbix agent.
- Deploy Zabbix agent and create the PostgreSQL user for monitoring (
<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;
- Copy the
postgresql/directory to thezabbixuser home directory -/var/lib/zabbix/. Thepostgresql/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
- Copy the
template_db_postgresql.conffile, 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.
- Edit the
pg_hba.confconfiguration file to allow connections for the userzbx_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}.
Macros used
| Name | Description | Default |
|---|---|---|
| {$PG.HOST} | Hostname or IP of PostgreSQL host. |
localhost |
| {$PG.PORT} | PostgreSQL service port. |
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.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.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.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.CONN_TOTAL_PCT.MAX.WARN} | Maximum percentage of current connections for trigger expression. |
90 |
| {$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.CONFLICTS.MAX.WARN} | Maximum number of recovery conflicts for trigger expression. |
0 |
Items
| 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. Available in PostgreSQL versions prior to 17. |
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). Available in PostgreSQL versions prior to 17. |
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
|
| 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}"] |
| Cache hit ratio, % | Cache hit ratio. |
Zabbix agent | pgsql.cache.hit["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| 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
|
| 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}"] |
| 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}"] |
| 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}"] |
| Ping time | Used to get the |
Zabbix agent | pgsql.ping.time["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] Preprocessing
|
| 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
|
| 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}"] |
| Replication: Standby count | Number of standby servers. |
Zabbix agent | pgsql.replication.count["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| 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}"] |
| 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}"] |
| 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
|
| Get transactions | Collect metrics by transaction execution time. |
Zabbix agent | pgsql.transactions["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Uptime | Time since the server started. |
Zabbix agent | pgsql.uptime["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| 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
|
| 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
|
Triggers
| 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 |
LLD rule Database discovery
| 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}"] |
Item prototypes for Database discovery
| 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}"] |
Trigger prototypes for Database discovery
| 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/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/pgsql.dbstat.deadlocks.rate["{#DBNAME}"],5m) > {$PG.DEADLOCKS.MAX.WARN:"{#DBNAME}"} |
High | |
| PostgreSQL: 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 | |
| PostgreSQL: DB [{#DBNAME}]: Number of locks is too high | min(/PostgreSQL by Zabbix agent/pgsql.locks.total["{#DBNAME}"],5m)>{$PG.LOCKS.MAX.WARN:"{#DBNAME}"} |
Warning | ||
| 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/pgsql.queries.query.slow_count["{#DBNAME}"],5m)>{$PG.SLOW_QUERIES.MAX.WARN:"{#DBNAME}"} |
Warning |
Feedback
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
PostgreSQL by Zabbix agent
Overview
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.
Requirements
Zabbix version: 7.2 and higher.
Tested versions
This template has been tested on:
- PostgreSQL 10-17
Configuration
Zabbix should be configured according to the instructions in the Templates out of the box section.
Setup
Note:
- The template requires
pg_isreadyandpsqlutilities to be installed on the same host with Zabbix agent.
- Deploy Zabbix agent and create the PostgreSQL user for monitoring (
<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;
- Copy the
postgresql/directory to thezabbixuser home directory -/var/lib/zabbix/. Thepostgresql/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
- Copy the
template_db_postgresql.conffile, 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.
- Edit the
pg_hba.confconfiguration file to allow connections for the userzbx_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}.
Macros used
| 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> |
Items
| 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. Available in PostgreSQL versions prior to 17. |
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). Available in PostgreSQL versions prior to 17. |
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
|
| 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}"] |
| Cache hit ratio, % | Cache hit ratio. |
Zabbix agent | pgsql.cache.hit["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| 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
|
| 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}"] |
| 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}"] |
| 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}"] |
| Ping time | Used to get the |
Zabbix agent | pgsql.ping.time["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] Preprocessing
|
| 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
|
| 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}"] |
| Replication: Standby count | Number of standby servers. |
Zabbix agent | pgsql.replication.count["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| 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}"] |
| 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}"] |
| 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
|
| Get transactions | Collect metrics by transaction execution time. |
Zabbix agent | pgsql.transactions["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Uptime | Time since the server started. |
Zabbix agent | pgsql.uptime["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| 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
|
| 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
|
Triggers
| 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 |
LLD rule Database discovery
| 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}"] |
Item prototypes for Database discovery
| 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}"] |
Trigger prototypes for Database discovery
| 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/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/pgsql.dbstat.deadlocks.rate["{#DBNAME}"],5m) > {$PG.DEADLOCKS.MAX.WARN:"{#DBNAME}"} |
High | |
| PostgreSQL: 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 | |
| PostgreSQL: DB [{#DBNAME}]: Number of locks is too high | min(/PostgreSQL by Zabbix agent/pgsql.locks.total["{#DBNAME}"],5m)>{$PG.LOCKS.MAX.WARN:"{#DBNAME}"} |
Warning | ||
| 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/pgsql.queries.query.slow_count["{#DBNAME}"],5m)>{$PG.SLOW_QUERIES.MAX.WARN:"{#DBNAME}"} |
Warning |
Feedback
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
PostgreSQL by Zabbix agent
Overview
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.
Requirements
Zabbix version: 7.0 and higher.
Tested versions
This template has been tested on:
- PostgreSQL 10-17
Configuration
Zabbix should be configured according to the instructions in the Templates out of the box section.
Setup
Note:
- The template requires
pg_isreadyandpsqlutilities to be installed on the same host with Zabbix agent.
- Deploy Zabbix agent and create the PostgreSQL user for monitoring (
<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;
- Copy the
postgresql/directory to thezabbixuser home directory -/var/lib/zabbix/. Thepostgresql/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
- Copy the
template_db_postgresql.conffile, 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.
- Edit the
pg_hba.confconfiguration file to allow connections for the userzbx_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}.
Macros used
| 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> |
Items
| 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. Available in PostgreSQL versions prior to 17. |
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). Available in PostgreSQL versions prior to 17. |
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
|
| 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}"] |
| Cache hit ratio, % | Cache hit ratio. |
Zabbix agent | pgsql.cache.hit["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| 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
|
| 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}"] |
| 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}"] |
| 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}"] |
| Ping time | Used to get the |
Zabbix agent | pgsql.ping.time["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] Preprocessing
|
| 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
|
| 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}"] |
| Replication: Standby count | Number of standby servers. |
Zabbix agent | pgsql.replication.count["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| 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}"] |
| 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}"] |
| 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
|
| Get transactions | Collect metrics by transaction execution time. |
Zabbix agent | pgsql.transactions["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Uptime | Time since the server started. |
Zabbix agent | pgsql.uptime["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| 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
|
| 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
|
Triggers
| 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 |
LLD rule Database discovery
| 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}"] |
Item prototypes for Database discovery
| 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}"] |
Trigger prototypes for Database discovery
| 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/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/pgsql.dbstat.deadlocks.rate["{#DBNAME}"],5m) > {$PG.DEADLOCKS.MAX.WARN:"{#DBNAME}"} |
High | |
| PostgreSQL: 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 | |
| PostgreSQL: DB [{#DBNAME}]: Number of locks is too high | min(/PostgreSQL by Zabbix agent/pgsql.locks.total["{#DBNAME}"],5m)>{$PG.LOCKS.MAX.WARN:"{#DBNAME}"} |
Warning | ||
| 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/pgsql.queries.query.slow_count["{#DBNAME}"],5m)>{$PG.SLOW_QUERIES.MAX.WARN:"{#DBNAME}"} |
Warning |
Feedback
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
PostgreSQL by Zabbix agent 2
Overview
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.
Requirements
Zabbix version: 7.4 and higher.
Tested versions
This template has been tested on:
- PostgreSQL 10-17
Configuration
Zabbix should be configured according to the instructions in the Templates out of the box section.
Setup
-
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 rolepg_monitor:
CREATE USER zbx_monitor WITH PASSWORD '<PASSWORD>' INHERIT;
GRANT pg_monitor TO zbx_monitor;
- Edit the
pg_hba.confconfiguration file to allow connections for the userzbx_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.
- Set the connection string for the PostgreSQL instance in the
{$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.
- Set the password that you specified in step 2 in the macro
{$PG.PASSWORD}.
Macros used
| 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 |
Items
| 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
|
Triggers
| 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 |
LLD rule Replication discovery
| 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}"] |
Item prototypes for Replication discovery
| 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
|
LLD rule Database discovery
| 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}"] |
Item prototypes for Database discovery
| 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
|
Trigger prototypes for Database discovery
| 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 |
Feedback
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
PostgreSQL by Zabbix agent 2
Overview
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.
Requirements
Zabbix version: 7.2 and higher.
Tested versions
This template has been tested on:
- PostgreSQL 10-17
Configuration
Zabbix should be configured according to the instructions in the Templates out of the box section.
Setup
-
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 rolepg_monitor:
CREATE USER zbx_monitor WITH PASSWORD '<PASSWORD>' INHERIT;
GRANT pg_monitor TO zbx_monitor;
- Edit the
pg_hba.confconfiguration file to allow connections for the userzbx_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.
- Set the connection string for the PostgreSQL instance in the
{$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.
- Set the password that you specified in step 2 in the macro
{$PG.PASSWORD}.
Macros used
| 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 |
Items
| 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
|
Triggers
| 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 |
LLD rule Replication discovery
| 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}"] |
Item prototypes for Replication discovery
| 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
|
LLD rule Database discovery
| 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}"] |
Item prototypes for Database discovery
| 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
|
Trigger prototypes for Database discovery
| 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 |
Feedback
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
PostgreSQL by Zabbix agent 2
Overview
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.
Requirements
Zabbix version: 7.0 and higher.
Tested versions
This template has been tested on:
- PostgreSQL 10-17
Configuration
Zabbix should be configured according to the instructions in the Templates out of the box section.
Setup
-
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 rolepg_monitor:
CREATE USER zbx_monitor WITH PASSWORD '<PASSWORD>' INHERIT;
GRANT pg_monitor TO zbx_monitor;
- Edit the
pg_hba.confconfiguration file to allow connections for the userzbx_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.
- Set the connection string for the PostgreSQL instance in the
{$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.
- Set the password that you specified in step 2 in the macro
{$PG.PASSWORD}.
Macros used
| 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 |
Items
| 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
|
Triggers
| 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 |
LLD rule Replication discovery
| 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}"] |
Item prototypes for Replication discovery
| 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
|
LLD rule Database discovery
| 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}"] |
Item prototypes for Database discovery
| 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
|
Trigger prototypes for Database discovery
| 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 |
Feedback
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
PostgreSQL by Zabbix agent 2
Overview
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.
Requirements
Zabbix version: 6.4 and higher.
Tested versions
This template has been tested on:
- PostgreSQL 10-15
Configuration
Zabbix should be configured according to the instructions in the Templates out of the box section.
Setup
-
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 rolepg_monitor:
CREATE USER zbx_monitor WITH PASSWORD '<PASSWORD>' INHERIT;
GRANT pg_monitor TO zbx_monitor;
- Edit the
pg_hba.confconfiguration file to allow connections for the userzbx_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.
- Set the connection string for the PostgreSQL instance in the
{$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.
- Set the password that you specified in step 2 in the macro
{$PG.PASSWORD}.
Macros used
| 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 |
Items
| 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
|
Triggers
| 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 |
LLD rule Replication discovery
| 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}"] |
Item prototypes for Replication discovery
| 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
|
LLD rule Database discovery
| 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}"] |
Item prototypes for Database discovery
| 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
|
Trigger prototypes for Database discovery
| 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 |
Feedback
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
PostgreSQL by Zabbix agent 2
Overview
For Zabbix version: 6.2 and higher. The template is developed to monitor DBMS PostgreSQL and its forks.
This template has been tested on:
- PostgreSQL, version 10-15
Setup
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 rolepg_monitor:
CREATE USER zbx_monitor WITH PASSWORD '<PASSWORD>' INHERIT;
GRANT pg_monitor TO zbx_monitor;
- Edit
pg_hba.confto 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.
Zabbix configuration
No specific Zabbix configuration is required.
Macros used
| 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 |
Template links
There are no template links in this template.
Discovery rules
| 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 |
Items collected
| 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}"] |
Triggers
| 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 |
Feedback
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.
PostgreSQL by Zabbix agent 2
Overview
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.
Requirements
Zabbix version: 6.0 and higher.
Tested versions
This template has been tested on:
- PostgreSQL 10-15
Configuration
Zabbix should be configured according to the instructions in the Templates out of the box section.
Setup
-
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 rolepg_monitor:
CREATE USER zbx_monitor WITH PASSWORD '<PASSWORD>' INHERIT;
GRANT pg_monitor TO zbx_monitor;
- Edit the
pg_hba.confconfiguration file to allow connections for the userzbx_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.
- Set the connection string for the PostgreSQL instance in the
{$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.
- Set the password that you specified in step 2 in the macro
{$PG.PASSWORD}.
Macros used
| 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 |
Items
| 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
|
Triggers
| 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 |
LLD rule Replication discovery
| 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}"] |
Item prototypes for Replication discovery
| 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
|
LLD rule Database discovery
| 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}"] |
Item prototypes for Database discovery
| 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
|
Trigger prototypes for Database discovery
| 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 |
Feedback
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
PostgreSQL by Zabbix agent 2
Overview
For Zabbix version: 5.4 and higher
The template is developed for monitoring DBMS PostgreSQL and its forks.
This template was tested on:
- PostgreSQL, version 10, 11, 12
Setup
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.
Zabbix configuration
No specific Zabbix configuration is required.
Macros used
| 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 |
Template links
There are no template links in this template.
Discovery rules
| 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 |
Items collected
| 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}"] |
Triggers
| 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 |
Feedback
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.
Template DB PostgreSQL by Zabbix agent 2
Overview
For Zabbix version: 5.0 and higher.
The template is developed to monitor DBMS PostgreSQL and its forks.
This template has been tested on:
- PostgreSQL, version 10, 11, 12
- Zabbix, version 5.0
Setup
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 rolepg_monitor:
CREATE USER zbx_monitor WITH PASSWORD '<PASSWORD>' INHERIT;
GRANT pg_monitor TO zbx_monitor;
- Edit
pg_hba.confto 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.
Zabbix configuration
No specific Zabbix configuration is required.
Macros used
| 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 |
Template links
There are no template links in this template.
Discovery rules
| 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 |
Items collected
| 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}"] |
Triggers
| 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 |
Feedback
Please report any issues with the template at https://support.zabbix.com.
PostgreSQL by ODBC
Overview
This template is designed for the effortless deployment of PostgreSQL monitoring by Zabbix via ODBC and doesn't require any external scripts.
Requirements
Zabbix version: 7.4 and higher.
Tested versions
This template has been tested on:
- PostgreSQL 11-17
Configuration
Zabbix should be configured according to the instructions in the Templates out of the box section.
Setup
- Create the PostgreSQL user for monitoring (
<password>at your discretion) and inherit permissions from the default rolepg_monitor:
CREATE USER zbx_monitor WITH PASSWORD '<PASSWORD>' INHERIT;
GRANT pg_monitor TO zbx_monitor;
- Edit the
pg_hba.confconfiguration file to allow TCP connections for the userzbx_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 documentationfor details about ODBC checks andrecommended 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 theodbcinst.inifile) 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
- Set the password that you specified in step 1 in the macro
{$PG.PASSWORD}.
Macros used
| 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 |
Items
| 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
|
Triggers
| 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 |
LLD rule Replication discovery
| 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
|
Item prototypes for Replication discovery
| 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
|
LLD rule Database discovery
| 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}"] |
Item prototypes for Database discovery
| 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
|
Trigger prototypes for Database discovery
| 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 |
LLD rule Bgwriter metrics discovery (versions below 17)
| 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 |
Item prototypes for Bgwriter metrics discovery (versions below 17)
| 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
|
LLD rule Bgwriter metrics discovery (versions above 17)
| 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 |
Item prototypes for Bgwriter metrics discovery (versions above 17)
| 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
|
Feedback
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
PostgreSQL by ODBC
Overview
This template is designed for the effortless deployment of PostgreSQL monitoring by Zabbix via ODBC and doesn't require any external scripts.
Requirements
Zabbix version: 7.2 and higher.
Tested versions
This template has been tested on:
- PostgreSQL 11-17
Configuration
Zabbix should be configured according to the instructions in the Templates out of the box section.
Setup
- Create the PostgreSQL user for monitoring (
<password>at your discretion) and inherit permissions from the default rolepg_monitor:
CREATE USER zbx_monitor WITH PASSWORD '<PASSWORD>' INHERIT;
GRANT pg_monitor TO zbx_monitor;
- Edit the
pg_hba.confconfiguration file to allow TCP connections for the userzbx_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 documentationfor details about ODBC checks andrecommended 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 theodbcinst.inifile) 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
- Set the password that you specified in step 1 in the macro
{$PG.PASSWORD}.
Macros used
| 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 |
Items
| 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
|
Triggers
| 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 |
LLD rule Replication discovery
| 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
|
Item prototypes for Replication discovery
| 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
|
LLD rule Database discovery
| 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}"] |
Item prototypes for Database discovery
| 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
|
Trigger prototypes for Database discovery
| 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 |
LLD rule Bgwriter metrics discovery (versions below 17)
| 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 |
Item prototypes for Bgwriter metrics discovery (versions below 17)
| 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
|
LLD rule Bgwriter metrics discovery (versions above 17)
| 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 |
Item prototypes for Bgwriter metrics discovery (versions above 17)
| 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
|
Feedback
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
PostgreSQL by ODBC
Overview
This template is designed for the effortless deployment of PostgreSQL monitoring by Zabbix via ODBC and doesn't require any external scripts.
Requirements
Zabbix version: 7.0 and higher.
Tested versions
This template has been tested on:
- PostgreSQL 11-17
Configuration
Zabbix should be configured according to the instructions in the Templates out of the box section.
Setup
- Create the PostgreSQL user for monitoring (
<password>at your discretion) and inherit permissions from the default rolepg_monitor:
CREATE USER zbx_monitor WITH PASSWORD '<PASSWORD>' INHERIT;
GRANT pg_monitor TO zbx_monitor;
- Edit the
pg_hba.confconfiguration file to allow TCP connections for the userzbx_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 documentationfor details about ODBC checks andrecommended 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 theodbcinst.inifile) 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
- Set the password that you specified in step 1 in the macro
{$PG.PASSWORD}.
Macros used
| 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 |
Items
| 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
|
Triggers
| 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 |
LLD rule Replication discovery
| 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
|
Item prototypes for Replication discovery
| 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
|
LLD rule Database discovery
| 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}"] |
Item prototypes for Database discovery
| 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
|
Trigger prototypes for Database discovery
| 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 |
LLD rule Bgwriter metrics discovery (versions below 17)
| 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 |
Item prototypes for Bgwriter metrics discovery (versions below 17)
| 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
|
LLD rule Bgwriter metrics discovery (versions above 17)
| 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 |
Item prototypes for Bgwriter metrics discovery (versions above 17)
| 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
|
Feedback
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
PostgreSQL by ODBC
Overview
This template is designed for the effortless deployment of PostgreSQL monitoring by Zabbix via ODBC and doesn't require any external scripts.
Requirements
Zabbix version: 6.4 and higher.
Tested versions
This template has been tested on:
- PostgreSQL 11-15
Configuration
Zabbix should be configured according to the instructions in the Templates out of the box section.
Setup
- Create the PostgreSQL user for monitoring (
<password>at your discretion) and inherit permissions from the default rolepg_monitor:
CREATE USER zbx_monitor WITH PASSWORD '<PASSWORD>' INHERIT;
GRANT pg_monitor TO zbx_monitor;
- Edit the
pg_hba.confconfiguration file to allow TCP connections for the userzbx_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 documentationfor details about ODBC checks andrecommended 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 theodbcinst.inifile) 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
- Set the password that you specified in step 1 in the macro
{$PG.PASSWORD}.
Macros used
| 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 |
Items
| 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
|
Triggers
| 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 |
LLD rule Replication discovery
| 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
|
Item prototypes for Replication discovery
| 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
|
LLD rule Database discovery
| 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}"] |
Item prototypes for Database discovery
| 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
|
Trigger prototypes for Database discovery
| 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 |
Feedback
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
PostgreSQL by ODBC
Overview
This template is designed for the effortless deployment of PostgreSQL monitoring by Zabbix via ODBC and doesn't require any external scripts.
Requirements
Zabbix version: 6.0 and higher.
Tested versions
This template has been tested on:
- PostgreSQL 11-15
Configuration
Zabbix should be configured according to the instructions in the Templates out of the box section.
Setup
- Create the PostgreSQL user for monitoring (
<password>at your discretion) and inherit permissions from the default rolepg_monitor:
CREATE USER zbx_monitor WITH PASSWORD '<PASSWORD>' INHERIT;
GRANT pg_monitor TO zbx_monitor;
- Edit the
pg_hba.confconfiguration file to allow TCP connections for the userzbx_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 documentationfor details about ODBC checks andrecommended 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 theodbcinst.inifile) 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
- Set the password that you specified in step 1 in the macro
{$PG.PASSWORD}.
Macros used
| 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 |
Items
| 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
|
Triggers
| 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 |
LLD rule Replication discovery
| 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
|
Item prototypes for Replication discovery
| 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
|
LLD rule Database discovery
| 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}"] |
Item prototypes for Database discovery
| 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
|
Trigger prototypes for Database discovery
| 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 |
Feedback
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
PostgreSQL by Zabbix agent active
Overview
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.
Requirements
Zabbix version: 7.4 and higher.
Tested versions
This template has been tested on:
- PostgreSQL 10-17
Configuration
Zabbix should be configured according to the instructions in the Templates out of the box section.
Setup
Note:
- The template requires
pg_isreadyandpsqlutilities to be installed on the same host with Zabbix agent.
- Deploy Zabbix agent and create the PostgreSQL user for monitoring (
<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;
- Copy the
postgresql/directory to thezabbixuser home directory -/var/lib/zabbix/. Thepostgresql/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
- Copy the
template_db_postgresql.conffile, 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.
- Edit the
pg_hba.confconfiguration file to allow connections for the userzbx_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}.
Macros used
| Name | Description | Default |
|---|---|---|
| {$PG.HOST} | Hostname or IP of PostgreSQL host. |
localhost |
| {$PG.PORT} | PostgreSQL service port. |
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.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.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.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.CONN_TOTAL_PCT.MAX.WARN} | Maximum percentage of current connections for trigger expression. |
90 |
| {$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.CONFLICTS.MAX.WARN} | Maximum number of recovery conflicts for trigger expression. |
0 |
Items
| 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. Available in PostgreSQL versions prior to 17. |
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). Available in PostgreSQL versions prior to 17. |
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
|
| Get bgwriter | Collect all metrics from pg_stat_bgwriter: https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-BGWRITER-VIEW |
Zabbix agent (active) | pgsql.bgwriter["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Cache hit ratio, % | Cache hit ratio. |
Zabbix agent (active) | pgsql.cache.hit["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Config hash | PostgreSQL configuration hash. |
Zabbix agent (active) | 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
|
| 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 (active) | pgsql.connections.sum["{$PG.HOST}","{$PG.PORT}","{$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 (active) | pgsql.dbstat["{$PG.HOST}","{$PG.PORT}","{$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 (active) | pgsql.locks["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Ping time | Used to get the |
Zabbix agent (active) | pgsql.ping.time["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] Preprocessing
|
| 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 (active) | pgsql.ping["{$PG.HOST}","{$PG.PORT}"] Preprocessing
|
| Get queries | Collect all metrics by query execution time. |
Zabbix agent (active) | pgsql.queries["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}","{$PG.QUERY_ETIME.MAX.WARN}"] |
| Replication: Standby count | Number of standby servers. |
Zabbix agent (active) | pgsql.replication.count["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Replication: Lag in seconds | Replication lag with master, in seconds. |
Zabbix agent (active) | pgsql.replication.lag.sec["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Replication: Recovery role | Replication role: 1 — recovery is still in progress (standby mode), 0 — master mode. |
Zabbix agent (active) | pgsql.replication.recovery_role["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Replication: Status | Replication status: 0 — streaming is down, 1 — streaming is up, 2 — master mode. |
Zabbix agent (active) | 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
|
| Get transactions | Collect metrics by transaction execution time. |
Zabbix agent (active) | pgsql.transactions["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Uptime | Time since the server started. |
Zabbix agent (active) | pgsql.uptime["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Version | PostgreSQL version. |
Zabbix agent (active) | 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
|
| Get WAL | Collect write-ahead log (WAL) metrics. |
Zabbix agent (active) | 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
|
Triggers
| 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 active/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 active/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 active/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 active/pgsql.config.hash["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"],#1)<>last(/PostgreSQL by Zabbix agent active/pgsql.config.hash["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"],#2) and length(last(/PostgreSQL by Zabbix agent active/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 active/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 active/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 active/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 active/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 active/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 active/pgsql.uptime["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]) < 10m |
Average | |
| PostgreSQL: Version has changed | last(/PostgreSQL by Zabbix agent active/pgsql.version["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"],#1)<>last(/PostgreSQL by Zabbix agent active/pgsql.version["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"],#2) and length(last(/PostgreSQL by Zabbix agent active/pgsql.version["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]))>0 |
Info |
LLD rule Database discovery
| 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 (active) | pgsql.discovery.db["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
Item prototypes for Database discovery
| 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 (active) | 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 (active) | 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 (active) | pgsql.scans["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{#DBNAME}"] |
Trigger prototypes for Database discovery
| 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 active/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 active/pgsql.dbstat.deadlocks.rate["{#DBNAME}"],5m) > {$PG.DEADLOCKS.MAX.WARN:"{#DBNAME}"} |
High | |
| PostgreSQL: DB [{#DBNAME}]: VACUUM FREEZE is required to prevent wraparound | Preventing Transaction ID Wraparound Failures: |
last(/PostgreSQL by Zabbix agent active/pgsql.frozenxid.prc_before_stop["{#DBNAME}"])<{$PG.FROZENXID_PCT_STOP.MIN.HIGH:"{#DBNAME}"} |
Average | |
| PostgreSQL: DB [{#DBNAME}]: Number of locks is too high | min(/PostgreSQL by Zabbix agent active/pgsql.locks.total["{#DBNAME}"],5m)>{$PG.LOCKS.MAX.WARN:"{#DBNAME}"} |
Warning | ||
| 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 active/pgsql.queries.query.slow_count["{#DBNAME}"],5m)>{$PG.SLOW_QUERIES.MAX.WARN:"{#DBNAME}"} |
Warning |
Feedback
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
PostgreSQL by Zabbix agent active
Overview
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.
Requirements
Zabbix version: 7.2 and higher.
Tested versions
This template has been tested on:
- PostgreSQL 10-17
Configuration
Zabbix should be configured according to the instructions in the Templates out of the box section.
Setup
Note:
- The template requires
pg_isreadyandpsqlutilities to be installed on the same host with Zabbix agent.
- Deploy Zabbix agent and create the PostgreSQL user for monitoring (
<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;
- Copy the
postgresql/directory to thezabbixuser home directory -/var/lib/zabbix/. Thepostgresql/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
- Copy the
template_db_postgresql.conffile, 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.
- Edit the
pg_hba.confconfiguration file to allow connections for the userzbx_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}.
Macros used
| 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> |
Items
| 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. Available in PostgreSQL versions prior to 17. |
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). Available in PostgreSQL versions prior to 17. |
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
|
| Get bgwriter | Collect all metrics from pg_stat_bgwriter: https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-BGWRITER-VIEW |
Zabbix agent (active) | pgsql.bgwriter["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Cache hit ratio, % | Cache hit ratio. |
Zabbix agent (active) | pgsql.cache.hit["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Config hash | PostgreSQL configuration hash. |
Zabbix agent (active) | 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
|
| 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 (active) | pgsql.connections.sum["{$PG.HOST}","{$PG.PORT}","{$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 (active) | pgsql.dbstat["{$PG.HOST}","{$PG.PORT}","{$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 (active) | pgsql.locks["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Ping time | Used to get the |
Zabbix agent (active) | pgsql.ping.time["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] Preprocessing
|
| 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 (active) | pgsql.ping["{$PG.HOST}","{$PG.PORT}"] Preprocessing
|
| Get queries | Collect all metrics by query execution time. |
Zabbix agent (active) | pgsql.queries["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}","{$PG.QUERY_ETIME.MAX.WARN}"] |
| Replication: Standby count | Number of standby servers. |
Zabbix agent (active) | pgsql.replication.count["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Replication: Lag in seconds | Replication lag with master, in seconds. |
Zabbix agent (active) | pgsql.replication.lag.sec["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Replication: Recovery role | Replication role: 1 — recovery is still in progress (standby mode), 0 — master mode. |
Zabbix agent (active) | pgsql.replication.recovery_role["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Replication: Status | Replication status: 0 — streaming is down, 1 — streaming is up, 2 — master mode. |
Zabbix agent (active) | 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
|
| Get transactions | Collect metrics by transaction execution time. |
Zabbix agent (active) | pgsql.transactions["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Uptime | Time since the server started. |
Zabbix agent (active) | pgsql.uptime["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Version | PostgreSQL version. |
Zabbix agent (active) | 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
|
| Get WAL | Collect write-ahead log (WAL) metrics. |
Zabbix agent (active) | 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
|
Triggers
| 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 active/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 active/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 active/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 active/pgsql.config.hash["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"],#1)<>last(/PostgreSQL by Zabbix agent active/pgsql.config.hash["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"],#2) and length(last(/PostgreSQL by Zabbix agent active/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 active/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 active/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 active/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 active/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 active/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 active/pgsql.uptime["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]) < 10m |
Average | |
| PostgreSQL: Version has changed | last(/PostgreSQL by Zabbix agent active/pgsql.version["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"],#1)<>last(/PostgreSQL by Zabbix agent active/pgsql.version["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"],#2) and length(last(/PostgreSQL by Zabbix agent active/pgsql.version["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]))>0 |
Info |
LLD rule Database discovery
| 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 (active) | pgsql.discovery.db["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
Item prototypes for Database discovery
| 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 (active) | 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 (active) | 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 (active) | pgsql.scans["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{#DBNAME}"] |
Trigger prototypes for Database discovery
| 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 active/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 active/pgsql.dbstat.deadlocks.rate["{#DBNAME}"],5m) > {$PG.DEADLOCKS.MAX.WARN:"{#DBNAME}"} |
High | |
| PostgreSQL: DB [{#DBNAME}]: VACUUM FREEZE is required to prevent wraparound | Preventing Transaction ID Wraparound Failures: |
last(/PostgreSQL by Zabbix agent active/pgsql.frozenxid.prc_before_stop["{#DBNAME}"])<{$PG.FROZENXID_PCT_STOP.MIN.HIGH:"{#DBNAME}"} |
Average | |
| PostgreSQL: DB [{#DBNAME}]: Number of locks is too high | min(/PostgreSQL by Zabbix agent active/pgsql.locks.total["{#DBNAME}"],5m)>{$PG.LOCKS.MAX.WARN:"{#DBNAME}"} |
Warning | ||
| 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 active/pgsql.queries.query.slow_count["{#DBNAME}"],5m)>{$PG.SLOW_QUERIES.MAX.WARN:"{#DBNAME}"} |
Warning |
Feedback
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
PostgreSQL by Zabbix agent active
Overview
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.
Requirements
Zabbix version: 7.0 and higher.
Tested versions
This template has been tested on:
- PostgreSQL 10-17
Configuration
Zabbix should be configured according to the instructions in the Templates out of the box section.
Setup
Note:
- The template requires
pg_isreadyandpsqlutilities to be installed on the same host with Zabbix agent.
- Deploy Zabbix agent and create the PostgreSQL user for monitoring (
<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;
- Copy the
postgresql/directory to thezabbixuser home directory -/var/lib/zabbix/. Thepostgresql/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
- Copy the
template_db_postgresql.conffile, 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.
- Edit the
pg_hba.confconfiguration file to allow connections for the userzbx_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}.
Macros used
| 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> |
Items
| 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. Available in PostgreSQL versions prior to 17. |
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). Available in PostgreSQL versions prior to 17. |
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
|
| Get bgwriter | Collect all metrics from pg_stat_bgwriter: https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-BGWRITER-VIEW |
Zabbix agent (active) | pgsql.bgwriter["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Cache hit ratio, % | Cache hit ratio. |
Zabbix agent (active) | pgsql.cache.hit["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Config hash | PostgreSQL configuration hash. |
Zabbix agent (active) | 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
|
| 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 (active) | pgsql.connections.sum["{$PG.HOST}","{$PG.PORT}","{$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 (active) | pgsql.dbstat["{$PG.HOST}","{$PG.PORT}","{$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 (active) | pgsql.locks["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Ping time | Used to get the |
Zabbix agent (active) | pgsql.ping.time["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] Preprocessing
|
| 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 (active) | pgsql.ping["{$PG.HOST}","{$PG.PORT}"] Preprocessing
|
| Get queries | Collect all metrics by query execution time. |
Zabbix agent (active) | pgsql.queries["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}","{$PG.QUERY_ETIME.MAX.WARN}"] |
| Replication: Standby count | Number of standby servers. |
Zabbix agent (active) | pgsql.replication.count["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Replication: Lag in seconds | Replication lag with master, in seconds. |
Zabbix agent (active) | pgsql.replication.lag.sec["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Replication: Recovery role | Replication role: 1 — recovery is still in progress (standby mode), 0 — master mode. |
Zabbix agent (active) | pgsql.replication.recovery_role["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Replication: Status | Replication status: 0 — streaming is down, 1 — streaming is up, 2 — master mode. |
Zabbix agent (active) | 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
|
| Get transactions | Collect metrics by transaction execution time. |
Zabbix agent (active) | pgsql.transactions["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Uptime | Time since the server started. |
Zabbix agent (active) | pgsql.uptime["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Version | PostgreSQL version. |
Zabbix agent (active) | 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
|
| Get WAL | Collect write-ahead log (WAL) metrics. |
Zabbix agent (active) | 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
|
Triggers
| 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 active/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 active/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 active/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 active/pgsql.config.hash["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"],#1)<>last(/PostgreSQL by Zabbix agent active/pgsql.config.hash["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"],#2) and length(last(/PostgreSQL by Zabbix agent active/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 active/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 active/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 active/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 active/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 active/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 active/pgsql.uptime["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]) < 10m |
Average | |
| PostgreSQL: Version has changed | last(/PostgreSQL by Zabbix agent active/pgsql.version["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"],#1)<>last(/PostgreSQL by Zabbix agent active/pgsql.version["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"],#2) and length(last(/PostgreSQL by Zabbix agent active/pgsql.version["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]))>0 |
Info |
LLD rule Database discovery
| 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 (active) | pgsql.discovery.db["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
Item prototypes for Database discovery
| 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 (active) | 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 (active) | 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 (active) | pgsql.scans["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{#DBNAME}"] |
Trigger prototypes for Database discovery
| 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 active/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 active/pgsql.dbstat.deadlocks.rate["{#DBNAME}"],5m) > {$PG.DEADLOCKS.MAX.WARN:"{#DBNAME}"} |
High | |
| PostgreSQL: DB [{#DBNAME}]: VACUUM FREEZE is required to prevent wraparound | Preventing Transaction ID Wraparound Failures: |
last(/PostgreSQL by Zabbix agent active/pgsql.frozenxid.prc_before_stop["{#DBNAME}"])<{$PG.FROZENXID_PCT_STOP.MIN.HIGH:"{#DBNAME}"} |
Average | |
| PostgreSQL: DB [{#DBNAME}]: Number of locks is too high | min(/PostgreSQL by Zabbix agent active/pgsql.locks.total["{#DBNAME}"],5m)>{$PG.LOCKS.MAX.WARN:"{#DBNAME}"} |
Warning | ||
| 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 active/pgsql.queries.query.slow_count["{#DBNAME}"],5m)>{$PG.SLOW_QUERIES.MAX.WARN:"{#DBNAME}"} |
Warning |
Feedback
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
PostgreSQL by Zabbix agent 2 active
Overview
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.
Requirements
Zabbix version: 7.4 and higher.
Tested versions
This template has been tested on:
- PostgreSQL 10-17
Configuration
Zabbix should be configured according to the instructions in the Templates out of the box section.
Setup
-
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 rolepg_monitor:
CREATE USER zbx_monitor WITH PASSWORD '<PASSWORD>' INHERIT;
GRANT pg_monitor TO zbx_monitor;
- Edit the
pg_hba.confconfiguration file to allow connections for the userzbx_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.
- Set the connection string for the PostgreSQL instance in the
{$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.
- Set the password that you specified in step 2 in the macro
{$PG.PASSWORD}.
Macros used
| 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 |
Items
| 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 (active) | pgsql.bgwriter["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Get archive | Collect archive status metrics. |
Zabbix agent (active) | 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 (active) | 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 (active) | 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 (active) | pgsql.connections["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Get WAL | Collect write-ahead log (WAL) metrics. |
Zabbix agent (active) | 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 (active) | 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 (active) | 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 (active) | pgsql.replication.process["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Get queries | Collect all metrics by query execution time. |
Zabbix agent (active) | pgsql.queries["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}","{$PG.QUERY_ETIME.MAX.WARN}"] |
| Version | PostgreSQL version. |
Zabbix agent (active) | 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 (active) | pgsql.oldest.xid["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Count of autovacuum workers | Number of autovacuum workers. |
Zabbix agent (active) | 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 (active) | pgsql.uptime["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Replication: Lag in bytes | Replication lag with master, in bytes. |
Zabbix agent (active) | 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 (active) | 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 (active) | pgsql.replication.recovery_role["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Replication: Standby count | Number of standby servers. |
Zabbix agent (active) | 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 (active) | 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 (active) | pgsql.ping["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] Preprocessing
|
Triggers
| Name | Description | Expression | Severity | Dependencies and additional info |
|---|---|---|---|---|
| PostgreSQL: Version has changed | last(/PostgreSQL by Zabbix agent 2 active/pgsql.version["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"],#1)<>last(/PostgreSQL by Zabbix agent 2 active/pgsql.version["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"],#2) and length(last(/PostgreSQL by Zabbix agent 2 active/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 active/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 active/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 active/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 active/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 active/pgsql.ping["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"])=0 |
High |
LLD rule Replication discovery
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Replication discovery | Discovers replication lag metrics. |
Zabbix agent (active) | pgsql.replication.process.discovery["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
Item prototypes for Replication discovery
| 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
|
LLD rule Database discovery
| 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 (active) | pgsql.db.discovery["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
Item prototypes for Database discovery
| 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 (active) | pgsql.db.age["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{#DBNAME}"] |
| DB [{#DBNAME}]: Bloating tables | Number of bloating tables. |
Zabbix agent (active) | pgsql.db.bloating_tables["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{#DBNAME}"] |
| DB [{#DBNAME}]: Database size | Database size. |
Zabbix agent (active) | 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
|
Trigger prototypes for Database discovery
| 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 active/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 active/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 active/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 active/pgsql.queries.query.slow_count["{#DBNAME}"],5m)>{$PG.SLOW_QUERIES.MAX.WARN:"{#DBNAME}"} |
Warning |
Feedback
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
PostgreSQL by Zabbix agent 2 active
Overview
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.
Requirements
Zabbix version: 7.2 and higher.
Tested versions
This template has been tested on:
- PostgreSQL 10-17
Configuration
Zabbix should be configured according to the instructions in the Templates out of the box section.
Setup
-
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 rolepg_monitor:
CREATE USER zbx_monitor WITH PASSWORD '<PASSWORD>' INHERIT;
GRANT pg_monitor TO zbx_monitor;
- Edit the
pg_hba.confconfiguration file to allow connections for the userzbx_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.
- Set the connection string for the PostgreSQL instance in the
{$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.
- Set the password that you specified in step 2 in the macro
{$PG.PASSWORD}.
Macros used
| 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 |
Items
| 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 (active) | pgsql.bgwriter["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Get archive | Collect archive status metrics. |
Zabbix agent (active) | 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 (active) | 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 (active) | 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 (active) | pgsql.connections["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Get WAL | Collect write-ahead log (WAL) metrics. |
Zabbix agent (active) | 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 (active) | 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 (active) | 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 (active) | pgsql.replication.process["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Get queries | Collect all metrics by query execution time. |
Zabbix agent (active) | pgsql.queries["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}","{$PG.QUERY_ETIME.MAX.WARN}"] |
| Version | PostgreSQL version. |
Zabbix agent (active) | 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 (active) | pgsql.oldest.xid["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Count of autovacuum workers | Number of autovacuum workers. |
Zabbix agent (active) | 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 (active) | pgsql.uptime["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Replication: Lag in bytes | Replication lag with master, in bytes. |
Zabbix agent (active) | 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 (active) | 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 (active) | pgsql.replication.recovery_role["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Replication: Standby count | Number of standby servers. |
Zabbix agent (active) | 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 (active) | 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 (active) | pgsql.ping["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] Preprocessing
|
Triggers
| Name | Description | Expression | Severity | Dependencies and additional info |
|---|---|---|---|---|
| PostgreSQL: Version has changed | last(/PostgreSQL by Zabbix agent 2 active/pgsql.version["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"],#1)<>last(/PostgreSQL by Zabbix agent 2 active/pgsql.version["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"],#2) and length(last(/PostgreSQL by Zabbix agent 2 active/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 active/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 active/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 active/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 active/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 active/pgsql.ping["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"])=0 |
High |
LLD rule Replication discovery
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Replication discovery | Discovers replication lag metrics. |
Zabbix agent (active) | pgsql.replication.process.discovery["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
Item prototypes for Replication discovery
| 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
|
LLD rule Database discovery
| 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 (active) | pgsql.db.discovery["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
Item prototypes for Database discovery
| 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 (active) | pgsql.db.age["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{#DBNAME}"] |
| DB [{#DBNAME}]: Bloating tables | Number of bloating tables. |
Zabbix agent (active) | pgsql.db.bloating_tables["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{#DBNAME}"] |
| DB [{#DBNAME}]: Database size | Database size. |
Zabbix agent (active) | 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
|
Trigger prototypes for Database discovery
| 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 active/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 active/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 active/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 active/pgsql.queries.query.slow_count["{#DBNAME}"],5m)>{$PG.SLOW_QUERIES.MAX.WARN:"{#DBNAME}"} |
Warning |
Feedback
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
PostgreSQL by Zabbix agent 2 active
Overview
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.
Requirements
Zabbix version: 7.0 and higher.
Tested versions
This template has been tested on:
- PostgreSQL 10-17
Configuration
Zabbix should be configured according to the instructions in the Templates out of the box section.
Setup
-
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 rolepg_monitor:
CREATE USER zbx_monitor WITH PASSWORD '<PASSWORD>' INHERIT;
GRANT pg_monitor TO zbx_monitor;
- Edit the
pg_hba.confconfiguration file to allow connections for the userzbx_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.
- Set the connection string for the PostgreSQL instance in the
{$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.
- Set the password that you specified in step 2 in the macro
{$PG.PASSWORD}.
Macros used
| 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 |
Items
| 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 (active) | pgsql.bgwriter["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Get archive | Collect archive status metrics. |
Zabbix agent (active) | 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 (active) | 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 (active) | 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 (active) | pgsql.connections["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Get WAL | Collect write-ahead log (WAL) metrics. |
Zabbix agent (active) | 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 (active) | 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 (active) | 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 (active) | pgsql.replication.process["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Get queries | Collect all metrics by query execution time. |
Zabbix agent (active) | pgsql.queries["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}","{$PG.QUERY_ETIME.MAX.WARN}"] |
| Version | PostgreSQL version. |
Zabbix agent (active) | 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 (active) | pgsql.oldest.xid["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Count of autovacuum workers | Number of autovacuum workers. |
Zabbix agent (active) | 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 (active) | pgsql.uptime["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Replication: Lag in bytes | Replication lag with master, in bytes. |
Zabbix agent (active) | 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 (active) | 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 (active) | pgsql.replication.recovery_role["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
| Replication: Standby count | Number of standby servers. |
Zabbix agent (active) | 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 (active) | 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 (active) | pgsql.ping["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] Preprocessing
|
Triggers
| Name | Description | Expression | Severity | Dependencies and additional info |
|---|---|---|---|---|
| PostgreSQL: Version has changed | last(/PostgreSQL by Zabbix agent 2 active/pgsql.version["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"],#1)<>last(/PostgreSQL by Zabbix agent 2 active/pgsql.version["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"],#2) and length(last(/PostgreSQL by Zabbix agent 2 active/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 active/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 active/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 active/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 active/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 active/pgsql.ping["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"])=0 |
High |
LLD rule Replication discovery
| Name | Description | Type | Key and additional info |
|---|---|---|---|
| Replication discovery | Discovers replication lag metrics. |
Zabbix agent (active) | pgsql.replication.process.discovery["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
Item prototypes for Replication discovery
| 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
|
LLD rule Database discovery
| 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 (active) | pgsql.db.discovery["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"] |
Item prototypes for Database discovery
| 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 (active) | pgsql.db.age["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{#DBNAME}"] |
| DB [{#DBNAME}]: Bloating tables | Number of bloating tables. |
Zabbix agent (active) | pgsql.db.bloating_tables["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{#DBNAME}"] |
| DB [{#DBNAME}]: Database size | Database size. |
Zabbix agent (active) | 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
|
Trigger prototypes for Database discovery
| 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 active/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 active/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 active/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 active/pgsql.queries.query.slow_count["{#DBNAME}"],5m)>{$PG.SLOW_QUERIES.MAX.WARN:"{#DBNAME}"} |
Warning |
Feedback
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