zabbix_export: version: '7.0' template_groups: - uuid: 748ad4d098d447d492bb935c907f652f name: Templates/Databases templates: - uuid: 399bd1ee587245ecac6f39beaa99886f template: 'PostgreSQL by Zabbix agent' name: 'PostgreSQL by Zabbix agent' description: | 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. Note: - The template requires `pg_isready` and `psql` utilities to be installed on the same host with Zabbix agent. - The template requires files with SQL queries and user parameters that can be found in the Zabbix official repository: https://git.zabbix.com/projects/ZBX/repos/zabbix/browse/templates/db/postgresql?at=refs%2Fheads%2Frelease%2F6.0 Setup: 1. Deploy Zabbix agent and create the PostgreSQL user for monitoring (`` at your discretion) with proper access rights to your PostgreSQL instance. For PostgreSQL version 10 and above: CREATE USER zbx_monitor WITH PASSWORD '' INHERIT; GRANT pg_monitor TO zbx_monitor; For PostgreSQL version 9.6 and below: CREATE USER zbx_monitor WITH PASSWORD ''; GRANT SELECT ON pg_stat_database TO zbx_monitor; ALTER USER zbx_monitor WITH SUPERUSER; 2. Copy the `postgresql/` directory to the `zabbix` user home directory - `/var/lib/zabbix/`. The `postgresql/` directory contains the files with SQL queries needed to obtain metrics from PostgreSQL instance. If the home directory of the `zabbix` user doesn't exist, create it first: mkdir -m u=rwx,g=rwx,o= -p /var/lib/zabbix chown zabbix:zabbix /var/lib/zabbix 3. Copy the `template_db_postgresql.conf` file, containing user parameters, to the Zabbix agent configuration directory `/etc/zabbix/zabbix_agentd.d/` and restart Zabbix agent service. 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 (https://www.postgresql.org/docs/current/libpq-ssl.html#LIBPQ-SSL-PROTECTION) and client connection parameters (https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNECT-SSLMODE). Also, it is assumed that you set up the PostgreSQL instance to work in the desired encryption mode. Check the PostgreSQL documentation (https://www.postgresql.org/docs/current/ssl-tcp.html) for details. 4. Edit the `pg_hba.conf` configuration file to allow connections for the user `zbx_monitor`. You can check the PostgreSQL documentation for examples (https://www.postgresql.org/docs/current/auth-pg-hba-conf.html). 5. Specify the host name or IP address in the `{$PG.HOST}` macro. Adjust the port number with `{$PG.PORT}` macro if needed. 6. Set the password that you specified in step 1 in the macro `{$PG.PASSWORD}`. You can discuss this template or leave feedback on our forum https://www.zabbix.com/forum/zabbix-suggestions-and-feedback/384190-%C2%A0discussion-thread-for-official-zabbix-template-db-postgresql Generated by official Zabbix template tool "Templator" 2.0.0 vendor: name: Zabbix version: 7.0-0 groups: - name: Templates/Databases items: - uuid: d17c6c15154d40d1afa5b1eafb2ed93e name: 'Bgwriter: Buffers allocated per second' type: DEPENDENT key: pgsql.bgwriter.buffers_alloc.rate delay: '0' history: 7d value_type: FLOAT units: Bps description: 'Number of buffers allocated per second.' preprocessing: - type: JSONPATH parameters: - $.buffers_alloc - type: CHANGE_PER_SECOND parameters: - '' master_item: key: 'pgsql.bgwriter["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]' tags: - tag: component value: bgwriter - uuid: 2c3ee691d4a54fb6b566739a3a648df4 name: 'Bgwriter: Buffers written directly by a backend per second' type: DEPENDENT key: pgsql.bgwriter.buffers_backend.rate delay: '0' history: 7d value_type: FLOAT units: Bps description: 'Number of buffers written directly by a backend per second.' preprocessing: - type: JSONPATH parameters: - $.buffers_backend - type: CHANGE_PER_SECOND parameters: - '' master_item: key: 'pgsql.bgwriter["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]' tags: - tag: component value: bgwriter - uuid: 77e1eb202a6346ce9df0f1bb2c078688 name: 'Bgwriter: Times a backend executed its own fsync per second' type: DEPENDENT key: pgsql.bgwriter.buffers_backend_fsync.rate delay: '0' history: 7d value_type: FLOAT description: 'Number of times a backend had to execute its own fsync call per second (normally the background writer handles those even when the backend does its own write).' preprocessing: - type: JSONPATH parameters: - $.buffers_backend_fsync - type: CHANGE_PER_SECOND parameters: - '' master_item: key: 'pgsql.bgwriter["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]' tags: - tag: component value: bgwriter - uuid: e29d26a48d0143579bf3acc6655cd659 name: 'Checkpoint: Buffers written during checkpoints per second' type: DEPENDENT key: pgsql.bgwriter.buffers_checkpoint.rate delay: '0' history: 7d value_type: FLOAT units: Bps description: 'Number of buffers written during checkpoints per second.' preprocessing: - type: JSONPATH parameters: - $.buffers_checkpoint - type: CHANGE_PER_SECOND parameters: - '' master_item: key: 'pgsql.bgwriter["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]' tags: - tag: component value: bgwriter - uuid: 5151183461a54d2bbfaad04b8cab3798 name: 'Checkpoint: Buffers written by the background writer per second' type: DEPENDENT key: pgsql.bgwriter.buffers_clean.rate delay: '0' history: 7d value_type: FLOAT units: Bps description: 'Number of buffers written by the background writer per second.' preprocessing: - type: JSONPATH parameters: - $.buffers_clean - type: CHANGE_PER_SECOND parameters: - '' master_item: key: 'pgsql.bgwriter["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]' tags: - tag: component value: bgwriter - uuid: ff290c0602b9447e87240c1ecf467050 name: 'Checkpoint: Requested per second' type: DEPENDENT key: pgsql.bgwriter.checkpoints_req.rate delay: '0' history: 7d value_type: FLOAT description: 'Number of requested checkpoints that have been performed per second.' preprocessing: - type: JSONPATH parameters: - $.checkpoints_req - type: CHANGE_PER_SECOND parameters: - '' master_item: key: 'pgsql.bgwriter["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]' tags: - tag: component value: bgwriter triggers: - uuid: 65e7954489854ad3ad1698dead7c4c02 expression: 'last(/PostgreSQL by Zabbix agent/pgsql.bgwriter.checkpoints_req.rate) > {$PG.CHECKPOINTS_REQ.MAX.WARN}' name: 'PostgreSQL: Required checkpoints occur too frequently' event_name: 'PostgreSQL: Required checkpoints occur too frequently (over {$PG.CHECKPOINTS_REQ.MAX.WARN})' priority: AVERAGE description: | Checkpoints are points in the sequence of transactions at which it is guaranteed that the heap and index data files have been updated with all information written before that checkpoint. At checkpoint time, all dirty data pages are flushed to disk and a special checkpoint record is written to the log file. https://www.postgresql.org/docs/current/wal-configuration.html tags: - tag: scope value: performance - uuid: a5271230be8b431cb96580180e099b98 name: 'Checkpoint: Scheduled per second' type: DEPENDENT key: pgsql.bgwriter.checkpoints_timed.rate delay: '0' history: 7d value_type: FLOAT description: 'Number of scheduled checkpoints that have been performed per second.' preprocessing: - type: JSONPATH parameters: - $.checkpoints_timed - type: CHANGE_PER_SECOND parameters: - '' master_item: key: 'pgsql.bgwriter["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]' tags: - tag: component value: bgwriter - uuid: 782d2368763b48ad8663aa9fb75c3326 name: 'Checkpoint: Checkpoint sync time per second' type: DEPENDENT key: pgsql.bgwriter.checkpoint_sync_time.rate delay: '0' history: 7d value_type: FLOAT units: s description: 'Total amount of time per second that has been spent in the portion of checkpoint processing where files are synchronized to disk.' preprocessing: - type: JSONPATH parameters: - $.checkpoint_sync_time - type: MULTIPLIER parameters: - '0.001' - type: CHANGE_PER_SECOND parameters: - '' master_item: key: 'pgsql.bgwriter["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]' tags: - tag: component value: bgwriter - uuid: b5e5f463978c46dd9401963f48ea72eb name: 'Checkpoint: Checkpoint write time per second' type: DEPENDENT key: pgsql.bgwriter.checkpoint_write_time.rate delay: '0' history: 7d value_type: FLOAT units: s description: 'Total amount of time per second that has been spent in the portion of checkpoint processing where files are written to disk.' preprocessing: - type: JSONPATH parameters: - $.checkpoint_write_time - type: MULTIPLIER parameters: - '0.001' - type: CHANGE_PER_SECOND parameters: - '' master_item: key: 'pgsql.bgwriter["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]' tags: - tag: component value: bgwriter - uuid: f273c71f92bf4ac0b6ec5a0a88d1239c name: 'Bgwriter: Number of bgwriter cleaning scan stopped per second' type: DEPENDENT key: pgsql.bgwriter.maxwritten_clean.rate delay: '0' history: 7d value_type: FLOAT description: 'Number of times the background writer stopped a cleaning scan because it had written too many buffers per second.' preprocessing: - type: JSONPATH parameters: - $.maxwritten_clean - type: CHANGE_PER_SECOND parameters: - '' master_item: key: 'pgsql.bgwriter["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]' tags: - tag: component value: bgwriter - uuid: 1fc5ba48a0974bd7bf965b5f130deded name: 'PostgreSQL: Get bgwriter' key: 'pgsql.bgwriter["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]' history: 1h trends: '0' value_type: TEXT description: | Collect all metrics from pg_stat_bgwriter: https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-BGWRITER-VIEW tags: - tag: component value: raw triggers: - uuid: 768d28b9360b46cda3065f5082ba97ac expression: 'nodata(/PostgreSQL by Zabbix agent/pgsql.bgwriter["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"],30m) = 1' name: 'PostgreSQL: Failed to get items' event_name: 'PostgreSQL: Failed to get items (no data for 30m)' priority: WARNING description: 'Zabbix has not received any data for items for the last 30 minutes.' dependencies: - name: 'PostgreSQL: Service is down' expression: 'last(/PostgreSQL by Zabbix agent/pgsql.ping["{$PG.HOST}","{$PG.PORT}"]) = 0' tags: - tag: scope value: availability - uuid: 70a7581fabd14e05bda762b79811187c name: 'PostgreSQL: Cache hit ratio, %' key: 'pgsql.cache.hit["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]' history: 7d value_type: FLOAT units: '%' description: 'Cache hit ratio.' tags: - tag: component value: cache triggers: - uuid: 4d87cc71b40f4b59ad27f30f33b15a69 expression: 'max(/PostgreSQL by Zabbix agent/pgsql.cache.hit["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"],5m) < {$PG.CACHE_HITRATIO.MIN.WARN}' name: 'PostgreSQL: Cache hit ratio too low' event_name: 'PostgreSQL: Cache hit ratio too low (under {$PG.CACHE_HITRATIO.MIN.WARN} in 5m)' priority: WARNING description: 'Cache hit ratio is lower than {$PG.CACHE_HITRATIO.MIN.WARN} for 5m.' tags: - tag: scope value: performance - uuid: 248cbe5067324b9ca435f2aced5e2a5f name: 'PostgreSQL: Config hash' key: 'pgsql.config.hash["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]' delay: 15m history: 7d trends: '0' value_type: TEXT description: 'PostgreSQL configuration hash.' preprocessing: - type: DISCARD_UNCHANGED_HEARTBEAT parameters: - 1h tags: - tag: component value: application triggers: - uuid: b727cfa6d3de4063b6a2dcb6cc84e27b expression: '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' name: 'PostgreSQL: Configuration has changed' priority: INFO description: 'PostgreSQL configuration has changed.' tags: - tag: scope value: notice - uuid: c78116d3acf24e6990ed27ba8008728c name: 'Connections sum: Active' type: DEPENDENT key: pgsql.connections.sum.active delay: '0' history: 7d description: 'Total number of connections executing a query.' preprocessing: - type: JSONPATH parameters: - $.active master_item: key: 'pgsql.connections.sum["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]' tags: - tag: component value: connections - uuid: be6eb6ecbfad420b889c58d1f1550b23 name: 'Connections sum: Idle' type: DEPENDENT key: pgsql.connections.sum.idle delay: '0' history: 7d description: 'Total number of connections waiting for a new client command.' preprocessing: - type: JSONPATH parameters: - $.idle master_item: key: 'pgsql.connections.sum["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]' tags: - tag: component value: connections - uuid: 6471d014722c4072ae045df4c69578e3 name: 'Connections sum: Idle in transaction' type: DEPENDENT key: pgsql.connections.sum.idle_in_transaction delay: '0' history: 7d description: 'Total number of connections in a transaction state but not executing a query.' preprocessing: - type: JSONPATH parameters: - $.idle_in_transaction master_item: key: 'pgsql.connections.sum["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]' tags: - tag: component value: connections - uuid: 197cc14f55db485b891614c7b7ee2a51 name: 'Connections sum: Prepared' type: DEPENDENT key: pgsql.connections.sum.prepared delay: '0' history: 7d description: | Total number of prepared transactions: https://www.postgresql.org/docs/current/sql-prepare-transaction.html preprocessing: - type: JSONPATH parameters: - $.prepared master_item: key: 'pgsql.connections.sum["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]' tags: - tag: component value: connections - uuid: 24d23377c7cd4cc5b63f98a261c2501c name: 'Connections sum: Total' type: DEPENDENT key: pgsql.connections.sum.total delay: '0' history: 7d description: 'Total number of connections.' preprocessing: - type: JSONPATH parameters: - $.total master_item: key: 'pgsql.connections.sum["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]' tags: - tag: component value: connections - uuid: 488050d9aa8e4c2ea5b3e991ec5ddacc name: 'Connections sum: Total, %' type: DEPENDENT key: pgsql.connections.sum.total_pct delay: '0' history: 7d units: '%' description: 'Total number of connections, in percentage.' preprocessing: - type: JSONPATH parameters: - $.total_pct master_item: key: 'pgsql.connections.sum["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]' tags: - tag: component value: connections triggers: - uuid: 54ef12b8ff1e4383a3097c71478ceefa expression: 'min(/PostgreSQL by Zabbix agent/pgsql.connections.sum.total_pct,5m) > {$PG.CONN_TOTAL_PCT.MAX.WARN}' name: 'PostgreSQL: Total number of connections is too high' event_name: 'PostgreSQL: Total number of connections is too high (over {$PG.CONN_TOTAL_PCT.MAX.WARN} in 5m)' priority: AVERAGE description: 'Total number of current connections exceeds the limit of {$PG.CONN_TOTAL_PCT.MAX.WARN}% out of the maximum number of concurrent connections to the database server (the "max_connections" setting).' tags: - tag: scope value: performance - uuid: fadd1333189c4ed29db57cf2acd158d0 name: 'Connections sum: Waiting' type: DEPENDENT key: pgsql.connections.sum.waiting delay: '0' history: 7d description: | Total number of waiting connections: https://www.postgresql.org/docs/current/monitoring-stats.html#WAIT-EVENT-TABLE preprocessing: - type: JSONPATH parameters: - $.waiting master_item: key: 'pgsql.connections.sum["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]' tags: - tag: component value: connections - uuid: b0da0c4856a645ca8ef03405d2d8d4a5 name: 'PostgreSQL: Get connections sum' key: 'pgsql.connections.sum["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]' history: '0' trends: '0' value_type: TEXT description: | Collect all metrics from pg_stat_activity: https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-ACTIVITY-VIEW tags: - tag: component value: raw - uuid: b44f263fb33e461e8c3d700fb7688c7b name: 'PostgreSQL: Get dbstat' key: 'pgsql.dbstat["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]' history: '0' trends: '0' value_type: TEXT description: | Collect all metrics from pg_stat_database per database: https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-DATABASE-VIEW tags: - tag: component value: raw - uuid: 7cee21f6225340ef80e9cdef7ce20b10 name: 'PostgreSQL: Get locks' key: 'pgsql.locks["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]' history: '0' trends: '0' value_type: TEXT description: | Collect all metrics from pg_locks per database: https://www.postgresql.org/docs/current/explicit-locking.html#LOCKING-TABLES tags: - tag: component value: raw - uuid: f42bd73b3af6451b8a3a6113dcc1b675 name: 'PostgreSQL: Ping time' key: 'pgsql.ping.time["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]' history: 7d value_type: FLOAT units: s description: 'Used to get the `SELECT 1` query execution time.' preprocessing: - type: REGEX parameters: - 'Time:\s+(\d+\.\d+)\s+ms' - \1 - type: MULTIPLIER parameters: - '0.001' tags: - tag: component value: application - tag: component value: health triggers: - uuid: e19b5630737b4c63886b5df77a3c748c expression: 'min(/PostgreSQL by Zabbix agent/pgsql.ping.time["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"],5m) > {$PG.PING_TIME.MAX.WARN}' name: 'PostgreSQL: Response too long' event_name: 'PostgreSQL: Response too long (over {$PG.PING_TIME.MAX.WARN})' priority: AVERAGE description: 'Response is taking too long (over {$PG.PING_TIME.MAX.WARN} for 5m).' dependencies: - name: 'PostgreSQL: Service is down' expression: 'last(/PostgreSQL by Zabbix agent/pgsql.ping["{$PG.HOST}","{$PG.PORT}"]) = 0' tags: - tag: scope value: availability - tag: scope value: performance - uuid: f5bd615243b344cb88dac1e83436cc85 name: 'PostgreSQL: Ping' key: 'pgsql.ping["{$PG.HOST}","{$PG.PORT}"]' history: 7d description: 'Used to test a connection to see if it is alive. It is set to 0 if the instance doesn''t accept the connections.' valuemap: name: 'Service state' preprocessing: - type: JAVASCRIPT parameters: - 'return value.search(/accepting connections/)>0 ? 1 : 0' - type: DISCARD_UNCHANGED_HEARTBEAT parameters: - 1h tags: - tag: component value: application - tag: component value: health triggers: - uuid: 6d9c2b5353ce4f6baeeb0f254fb7d1e2 expression: 'last(/PostgreSQL by Zabbix agent/pgsql.ping["{$PG.HOST}","{$PG.PORT}"]) = 0' name: 'PostgreSQL: Service is down' priority: HIGH description: 'Last test of a connection was unsuccessful.' tags: - tag: scope value: availability - uuid: 47bf580e1e4e48cf9c0e94fcf90288ac name: 'PostgreSQL: Get queries' key: 'pgsql.queries["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}","{$PG.QUERY_ETIME.MAX.WARN}"]' history: '0' trends: '0' value_type: TEXT description: 'Collect all metrics by query execution time.' tags: - tag: component value: raw - uuid: d8a509bd011a4ecda5d439295e257e9d name: 'PostgreSQL: Replication: Standby count' key: 'pgsql.replication.count["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]' history: 7d description: 'Number of standby servers.' tags: - tag: component value: replication - uuid: 21f8bea1141249c7a4dfafad5bc3ef41 name: 'PostgreSQL: Replication: Lag in seconds' key: 'pgsql.replication.lag.sec["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]' history: 7d units: s description: 'Replication lag with master, in seconds.' tags: - tag: component value: replication triggers: - uuid: 11831c52e86445498eed42de6a629b65 expression: '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}' name: 'PostgreSQL: Streaming lag with {#MASTER} is too high' event_name: 'PostgreSQL: Streaming lag with {#MASTER} is too high (over {$PG.REPL_LAG.MAX.WARN} in 5m)' priority: AVERAGE description: 'Replication lag with master is higher than {$PG.REPL_LAG.MAX.WARN} for 5m.' tags: - tag: scope value: availability - tag: scope value: performance - uuid: 09f696124fca4c5b844bf66c9c912b87 name: 'PostgreSQL: Replication: Recovery role' key: 'pgsql.replication.recovery_role["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]' history: 7d description: 'Replication role: 1 — recovery is still in progress (standby mode), 0 — master mode.' valuemap: name: 'PostgreSQL recovery role' tags: - tag: component value: replication - uuid: d449017462704508a4aad51a6b45fb30 name: 'PostgreSQL: Replication: Status' key: 'pgsql.replication.status["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]' history: 7d description: 'Replication status: 0 — streaming is down, 1 — streaming is up, 2 — master mode.' valuemap: name: 'PostgreSQL replication status' tags: - tag: component value: replication triggers: - uuid: aef1e1d2bab540f8ab738b4a3fad863c expression: 'max(/PostgreSQL by Zabbix agent/pgsql.replication.status["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"],5m)=0' name: 'PostgreSQL: Replication is down' priority: AVERAGE description: 'Replication is enabled and data streaming was down for 5m.' tags: - tag: scope value: availability - uuid: 4883717865c84c19b48d46f009317de2 name: 'Transactions: Max active transaction time' type: DEPENDENT key: pgsql.transactions.active delay: '0' history: 7d value_type: FLOAT units: s description: 'Current max active transaction time.' preprocessing: - type: JSONPATH parameters: - $.active master_item: key: 'pgsql.transactions["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]' tags: - tag: component value: transactions - uuid: 4c89121d71a14c15b6169417ea69d0a3 name: 'Transactions: Max idle transaction time' type: DEPENDENT key: pgsql.transactions.idle delay: '0' history: 7d value_type: FLOAT units: s description: 'Current max idle transaction time.' preprocessing: - type: JSONPATH parameters: - $.idle master_item: key: 'pgsql.transactions["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]' tags: - tag: component value: transactions - uuid: 0ee43ddd9da246d19097107b45e4c8e8 name: 'Transactions: Max prepared transaction time' type: DEPENDENT key: pgsql.transactions.prepared delay: '0' history: 7d value_type: FLOAT units: s description: 'Current max prepared transaction time.' preprocessing: - type: JSONPATH parameters: - $.prepared master_item: key: 'pgsql.transactions["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]' tags: - tag: component value: transactions - uuid: da341b2011714a1f994ecbe96bd52155 name: 'Transactions: Max waiting transaction time' type: DEPENDENT key: pgsql.transactions.waiting delay: '0' history: 7d value_type: FLOAT units: s description: 'Current max waiting transaction time.' preprocessing: - type: JSONPATH parameters: - $.waiting master_item: key: 'pgsql.transactions["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]' tags: - tag: component value: transactions - uuid: ff26a1c256bd40978f49a7a025538aa1 name: 'PostgreSQL: Get transactions' key: 'pgsql.transactions["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]' history: '0' trends: '0' value_type: TEXT description: 'Collect metrics by transaction execution time.' tags: - tag: component value: raw - uuid: 6418a2f286e64ecabf2295fca063f8af name: 'PostgreSQL: Uptime' key: 'pgsql.uptime["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]' history: 7d units: uptime description: 'Time since the server started.' tags: - tag: component value: application triggers: - uuid: 85565aba402740868a16c0e4639a98fc expression: 'last(/PostgreSQL by Zabbix agent/pgsql.uptime["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]) < 10m' name: 'PostgreSQL: Service has been restarted' event_name: 'PostgreSQL: Service has been restarted (uptime < 10m)' priority: AVERAGE description: 'PostgreSQL uptime is less than 10 minutes.' tags: - tag: scope value: notice - uuid: 321525ebcea44396922e96deec2e8ad1 name: 'PostgreSQL: Version' key: 'pgsql.version["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]' delay: 15m history: 7d trends: '0' value_type: CHAR description: 'PostgreSQL version.' preprocessing: - type: DISCARD_UNCHANGED_HEARTBEAT parameters: - 1d tags: - tag: component value: application triggers: - uuid: 8111eb42b0e74fffb43da474677ebc2f expression: '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' name: 'PostgreSQL: Version has changed' event_name: 'PostgreSQL: Version has changed (new version value received: {ITEM.VALUE})' priority: INFO tags: - tag: scope value: notice - uuid: 5385ec7d39514039a641d18cba335ddc name: 'WAL: Segments count' type: DEPENDENT key: pgsql.wal.count delay: '0' history: 7d description: 'Number of WAL segments.' preprocessing: - type: JSONPATH parameters: - $.count master_item: key: 'pgsql.wal.stat["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]' tags: - tag: component value: wal - uuid: 7cd6c524ecab41f9a22489866d503361 name: 'PostgreSQL: Get WAL' key: 'pgsql.wal.stat["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]' delay: 5m history: '0' trends: '0' value_type: TEXT description: 'Collect write-ahead log (WAL) metrics.' tags: - tag: component value: raw - uuid: 5cc9c67621cc46e0a42b1eb79bda83b3 name: 'WAL: Bytes written' type: DEPENDENT key: pgsql.wal.write delay: '0' history: 7d units: B description: 'WAL write, in bytes.' preprocessing: - type: JSONPATH parameters: - $.write - type: CHANGE_PER_SECOND parameters: - '' master_item: key: 'pgsql.wal.stat["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]' tags: - tag: component value: wal discovery_rules: - uuid: 5c4c658507394f5bb362e601f7c59d63 name: 'Database discovery' key: 'pgsql.discovery.db["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]' delay: 1h filter: conditions: - macro: '{#DBNAME}' value: '{$PG.LLD.FILTER.DBNAME}' formulaid: A description: | Discovers databases (DB) in the database management system (DBMS), except: - templates; - default "postgres" DB; - DBs that do not allow connections. item_prototypes: - uuid: 69575e9785184ef5be2502e3cc282220 name: 'DB [{#DBNAME}]: Database size' key: 'pgsql.db.size["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}","{#DBNAME}"]' delay: 15m history: 7d units: B description: 'Database size.' tags: - tag: component value: storage - tag: database value: '{#DBNAME}' - uuid: 615e6567a85e421bb06ab8cac0eaba69 name: 'DB [{#DBNAME}]: Blocks hit per second' type: DEPENDENT key: 'pgsql.dbstat.blks_hit.rate["{#DBNAME}"]' delay: '0' history: 7d value_type: FLOAT description: 'Total number of times per second disk blocks were found already in the buffer cache, so that a read was not necessary.' preprocessing: - type: JSONPATH parameters: - $.blks_hit - type: CHANGE_PER_SECOND parameters: - '' master_item: key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]' tags: - tag: component value: cache - tag: database value: '{#DBNAME}' - uuid: 9136517d08b447869e5b8f5fd684c3b9 name: 'DB [{#DBNAME}]: Disk blocks read per second' type: DEPENDENT key: 'pgsql.dbstat.blks_read.rate["{#DBNAME}"]' delay: '0' history: 7d value_type: FLOAT description: 'Total number of disk blocks read per second in this database.' preprocessing: - type: JSONPATH parameters: - $.blks_read - type: CHANGE_PER_SECOND parameters: - '' master_item: key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]' tags: - tag: component value: storage - tag: database value: '{#DBNAME}' - uuid: a76f6d28995441ff9fe28bbc09445e64 name: 'DB [{#DBNAME}]: Detected conflicts per second' type: DEPENDENT key: 'pgsql.dbstat.conflicts.rate["{#DBNAME}"]' delay: '0' history: 7d value_type: FLOAT description: 'Total number of queries canceled due to conflicts with recovery in this database per second.' preprocessing: - type: JSONPATH parameters: - $.conflicts - type: CHANGE_PER_SECOND parameters: - '' master_item: key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]' tags: - tag: component value: queries - tag: database value: '{#DBNAME}' trigger_prototypes: - uuid: 3b51f02258bd4e02829f04ca016dd01d expression: 'min(/PostgreSQL by Zabbix agent/pgsql.dbstat.conflicts.rate["{#DBNAME}"],5m) > {$PG.CONFLICTS.MAX.WARN:"{#DBNAME}"}' name: 'DB [{#DBNAME}]: Too many recovery conflicts' event_name: 'DB [{#DBNAME}]: Too many recovery conflicts (over {$PG.CONFLICTS.MAX.WARN:"{#DBNAME}"} in 5m)' priority: AVERAGE description: | The primary and standby servers are in many ways loosely connected. Actions on the primary will have an effect on the standby. As a result, there is potential for negative interactions or conflicts between them. https://www.postgresql.org/docs/current/hot-standby.html#HOT-STANDBY-CONFLICT tags: - tag: scope value: performance - uuid: b874cc2dd80643208c2479ad25fae0ac name: 'DB [{#DBNAME}]: Detected deadlocks per second' type: DEPENDENT key: 'pgsql.dbstat.deadlocks.rate["{#DBNAME}"]' delay: '0' history: 7d value_type: FLOAT description: 'Total number of detected deadlocks in this database per second.' preprocessing: - type: JSONPATH parameters: - $.deadlocks - type: CHANGE_PER_SECOND parameters: - '' master_item: key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]' tags: - tag: component value: deadlocks - tag: database value: '{#DBNAME}' trigger_prototypes: - uuid: 3bee63fa04d94586937e22aafab9bdd8 expression: 'min(/PostgreSQL by Zabbix agent/pgsql.dbstat.deadlocks.rate["{#DBNAME}"],5m) > {$PG.DEADLOCKS.MAX.WARN:"{#DBNAME}"}' name: 'DB [{#DBNAME}]: Deadlock occurred' event_name: 'DB [{#DBNAME}]: Deadlock occurred (over {$PG.DEADLOCKS.MAX.WARN:"{#DBNAME}"} in 5m)' priority: HIGH description: 'Number of deadlocks detected per second exceeds {$PG.DEADLOCKS.MAX.WARN:"{#DBNAME}"} for 5m.' tags: - tag: scope value: availability - uuid: 52c20fc8faad42ae8d255990ce14d3cd name: 'DB [{#DBNAME}]: Get dbstat' type: DEPENDENT key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]' delay: '0' history: '0' trends: '0' value_type: TEXT description: 'Get dbstat metrics for database "{#DBNAME}".' preprocessing: - type: JSONPATH parameters: - '$[''{#DBNAME}'']' error_handler: DISCARD_VALUE master_item: key: 'pgsql.dbstat["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]' tags: - tag: component value: raw - tag: database value: '{#DBNAME}' - uuid: d235ead54c8b41f9a91398c75383e5d7 name: 'DB [{#DBNAME}]: Temp_bytes written per second' type: DEPENDENT key: 'pgsql.dbstat.temp_bytes.rate["{#DBNAME}"]' delay: '0' history: 7d units: B description: 'Total amount of data written to temporary files by queries in this database.' preprocessing: - type: JSONPATH parameters: - $.temp_bytes - type: CHANGE_PER_SECOND parameters: - '' master_item: key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]' tags: - tag: component value: storage - tag: database value: '{#DBNAME}' - uuid: af4e35eee1764d3f97d9c1218867f885 name: 'DB [{#DBNAME}]: Temp_files created per second' type: DEPENDENT key: 'pgsql.dbstat.temp_files.rate["{#DBNAME}"]' delay: '0' history: 7d description: 'Total number of temporary files created by queries in this database.' preprocessing: - type: JSONPATH parameters: - $.temp_files - type: CHANGE_PER_SECOND parameters: - '' master_item: key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]' tags: - tag: component value: storage - tag: database value: '{#DBNAME}' - uuid: 35c6f93aefe4439bbc36f2f358440b16 name: 'DB [{#DBNAME}]: Tuples deleted per second' type: DEPENDENT key: 'pgsql.dbstat.tup_deleted.rate["{#DBNAME}"]' delay: '0' history: 7d value_type: FLOAT description: 'Total number of rows deleted by queries in this database per second.' preprocessing: - type: JSONPATH parameters: - $.tup_deleted - type: CHANGE_PER_SECOND parameters: - '' master_item: key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]' tags: - tag: component value: queries - tag: database value: '{#DBNAME}' - uuid: 92f33d96f8a348088cdba593c0e66929 name: 'DB [{#DBNAME}]: Tuples fetched per second' type: DEPENDENT key: 'pgsql.dbstat.tup_fetched.rate["{#DBNAME}"]' delay: '0' history: 7d value_type: FLOAT description: 'Total number of rows fetched by queries in this database per second.' preprocessing: - type: JSONPATH parameters: - $.tup_fetched - type: CHANGE_PER_SECOND parameters: - '' master_item: key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]' tags: - tag: component value: queries - tag: database value: '{#DBNAME}' - uuid: 8c03c87a44fe43928c32087ca7561e88 name: 'DB [{#DBNAME}]: Tuples inserted per second' type: DEPENDENT key: 'pgsql.dbstat.tup_inserted.rate["{#DBNAME}"]' delay: '0' history: 7d value_type: FLOAT description: 'Total number of rows inserted by queries in this database per second.' preprocessing: - type: JSONPATH parameters: - $.tup_inserted - type: CHANGE_PER_SECOND parameters: - '' master_item: key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]' tags: - tag: component value: queries - tag: database value: '{#DBNAME}' - uuid: f6d378f4e38e455fa5a12467fe977657 name: 'DB [{#DBNAME}]: Tuples returned per second' type: DEPENDENT key: 'pgsql.dbstat.tup_returned.rate["{#DBNAME}"]' delay: '0' history: 7d value_type: FLOAT description: 'Number of rows returned by queries in this database per second.' preprocessing: - type: JSONPATH parameters: - $.tup_returned - type: CHANGE_PER_SECOND parameters: - '' master_item: key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]' tags: - tag: component value: queries - tag: database value: '{#DBNAME}' - uuid: 4c8de8c1064d43ffa18c4f37fead37f7 name: 'DB [{#DBNAME}]: Tuples updated per second' type: DEPENDENT key: 'pgsql.dbstat.tup_updated.rate["{#DBNAME}"]' delay: '0' history: 7d value_type: FLOAT description: 'Total number of rows updated by queries in this database per second.' preprocessing: - type: JSONPATH parameters: - $.tup_updated - type: CHANGE_PER_SECOND parameters: - '' master_item: key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]' tags: - tag: component value: queries - tag: database value: '{#DBNAME}' - uuid: 81c33f5b3c31475fa5f28f4ad149a328 name: 'DB [{#DBNAME}]: Commits per second' type: DEPENDENT key: 'pgsql.dbstat.xact_commit.rate["{#DBNAME}"]' delay: '0' history: 7d value_type: FLOAT description: 'Number of transactions in this database that have been committed per second.' preprocessing: - type: JSONPATH parameters: - $.xact_commit - type: CHANGE_PER_SECOND parameters: - '' master_item: key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]' tags: - tag: component value: transactions - tag: database value: '{#DBNAME}' - uuid: 8e5080186d034323be21473099b0b0ce name: 'DB [{#DBNAME}]: Rollbacks per second' type: DEPENDENT key: 'pgsql.dbstat.xact_rollback.rate["{#DBNAME}"]' delay: '0' history: 7d value_type: FLOAT description: 'Total number of transactions in this database that have been rolled back.' preprocessing: - type: JSONPATH parameters: - $.xact_rollback - type: CHANGE_PER_SECOND parameters: - '' master_item: key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]' tags: - tag: component value: transactions - tag: database value: '{#DBNAME}' - uuid: df9dd9bac2a54f1085b29fb22b394a1f name: 'DB [{#DBNAME}]: Frozen XID before autovacuum, %' type: DEPENDENT key: 'pgsql.frozenxid.prc_before_av["{#DBNAME}"]' delay: '0' history: 7d value_type: FLOAT units: '%' description: | Preventing Transaction ID Wraparound Failures: https://www.postgresql.org/docs/current/routine-vacuuming.html#VACUUM-FOR-WRAPAROUND preprocessing: - type: JSONPATH parameters: - $.prc_before_av master_item: key: 'pgsql.frozenxid["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{#DBNAME}"]' tags: - tag: component value: transactions - tag: database value: '{#DBNAME}' - uuid: 44ddd66ea37449cb8fab6979b98dfd3c name: 'DB [{#DBNAME}]: Frozen XID before stop, %' type: DEPENDENT key: 'pgsql.frozenxid.prc_before_stop["{#DBNAME}"]' delay: '0' history: 7d value_type: FLOAT units: '%' description: | Preventing Transaction ID Wraparound Failures: https://www.postgresql.org/docs/current/routine-vacuuming.html#VACUUM-FOR-WRAPAROUND preprocessing: - type: JSONPATH parameters: - $.prc_before_stop master_item: key: 'pgsql.frozenxid["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{#DBNAME}"]' tags: - tag: component value: transactions - tag: database value: '{#DBNAME}' trigger_prototypes: - uuid: 709df9c1e29a4ff68a3de9423ff7ae58 expression: 'last(/PostgreSQL by Zabbix agent/pgsql.frozenxid.prc_before_stop["{#DBNAME}"])<{$PG.FROZENXID_PCT_STOP.MIN.HIGH:"{#DBNAME}"}' name: 'DB [{#DBNAME}]: VACUUM FREEZE is required to prevent wraparound' event_name: 'DB [{#DBNAME}]: VACUUM FREEZE is required to prevent wraparound (frozen XID less than {$PG.FROZENXID_PCT_STOP.MIN.HIGH:"{#DBNAME}"} %)' priority: AVERAGE description: | Preventing Transaction ID Wraparound Failures: https://www.postgresql.org/docs/current/routine-vacuuming.html#VACUUM-FOR-WRAPAROUND tags: - tag: scope value: availability - uuid: ddf6d0b7b5fe4cbbb540687051b8e5f5 name: 'DB [{#DBNAME}]: Get frozen XID' key: 'pgsql.frozenxid["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{#DBNAME}"]' history: '0' trends: '0' value_type: TEXT tags: - tag: component value: raw - tag: database value: '{#DBNAME}' - uuid: 3d0acf4b45fc4a72bb2a214222f93f2a name: 'DB [{#DBNAME}]: Num of locks total' type: DEPENDENT key: 'pgsql.locks.total["{#DBNAME}"]' delay: '0' history: 7d description: 'Total number of locks in this database.' preprocessing: - type: JSONPATH parameters: - '$[''{#DBNAME}''].total' master_item: key: 'pgsql.locks["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]' tags: - tag: component value: locks - tag: database value: '{#DBNAME}' trigger_prototypes: - uuid: ef7d3c9866df44aa9b378e7f125a34de expression: 'min(/PostgreSQL by Zabbix agent/pgsql.locks.total["{#DBNAME}"],5m)>{$PG.LOCKS.MAX.WARN:"{#DBNAME}"}' name: 'DB [{#DBNAME}]: Number of locks is too high' event_name: 'DB [{#DBNAME}]: Number of locks is too high (over {$PG.LOCKS.MAX.WARN:"{#DBNAME}"} in 5m)' priority: WARNING tags: - tag: scope value: availability - uuid: ac226e85268c463786e297944339ccf5 name: 'DB [{#DBNAME}]: Get queries' type: DEPENDENT key: 'pgsql.queries.get_metrics["{#DBNAME}"]' delay: '0' history: '0' trends: '0' value_type: TEXT description: 'Get queries metrics for database "{#DBNAME}".' preprocessing: - type: JSONPATH parameters: - '$[''{#DBNAME}'']' error_handler: DISCARD_VALUE master_item: key: 'pgsql.queries["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}","{$PG.QUERY_ETIME.MAX.WARN}"]' tags: - tag: component value: raw - tag: database value: '{#DBNAME}' - uuid: 939ab05c71ed4be9979662203ebba980 name: 'DB [{#DBNAME}]: Queries slow maintenance count' type: DEPENDENT key: 'pgsql.queries.mro.slow_count["{#DBNAME}"]' delay: '0' history: 7d description: 'Slow maintenance query count for this database.' preprocessing: - type: JSONPATH parameters: - $.mro_slow_count master_item: key: 'pgsql.queries.get_metrics["{#DBNAME}"]' tags: - tag: component value: queries - tag: database value: '{#DBNAME}' - uuid: bbc8f9bf86394cf28e0c2db44ee4711d name: 'DB [{#DBNAME}]: Queries max maintenance time' type: DEPENDENT key: 'pgsql.queries.mro.time_max["{#DBNAME}"]' delay: '0' history: 7d units: s description: 'Max maintenance query time for this database.' preprocessing: - type: JSONPATH parameters: - $.mro_time_max master_item: key: 'pgsql.queries.get_metrics["{#DBNAME}"]' tags: - tag: component value: queries - tag: database value: '{#DBNAME}' - uuid: f1427228bfa14ad3b7bb9d63bcfaec59 name: 'DB [{#DBNAME}]: Queries sum maintenance time' type: DEPENDENT key: 'pgsql.queries.mro.time_sum["{#DBNAME}"]' delay: '0' history: 7d units: s description: 'Sum maintenance query time for this database.' preprocessing: - type: JSONPATH parameters: - $.mro_time_sum master_item: key: 'pgsql.queries.get_metrics["{#DBNAME}"]' tags: - tag: component value: queries - tag: database value: '{#DBNAME}' - uuid: 5d937f46f4684f1e8253ec62e0f75379 name: 'DB [{#DBNAME}]: Queries slow query count' type: DEPENDENT key: 'pgsql.queries.query.slow_count["{#DBNAME}"]' delay: '0' history: 7d description: 'Slow query count for this database.' preprocessing: - type: JSONPATH parameters: - $.query_slow_count master_item: key: 'pgsql.queries.get_metrics["{#DBNAME}"]' tags: - tag: component value: queries - tag: database value: '{#DBNAME}' trigger_prototypes: - uuid: facc8f6976664da4ad5567d270f0f311 expression: 'min(/PostgreSQL by Zabbix agent/pgsql.queries.query.slow_count["{#DBNAME}"],5m)>{$PG.SLOW_QUERIES.MAX.WARN:"{#DBNAME}"}' name: 'DB [{#DBNAME}]: Too many slow queries' event_name: 'DB [{#DBNAME}]: Too many slow queries (over {$PG.SLOW_QUERIES.MAX.WARN:"{#DBNAME}"} in 5m)' priority: WARNING description: 'The number of detected slow queries exceeds the limit of {$PG.SLOW_QUERIES.MAX.WARN:"{#DBNAME}"}.' tags: - tag: scope value: performance - uuid: 044cc16d0a2f46b28d88eff86c33b30b name: 'DB [{#DBNAME}]: Queries max query time' type: DEPENDENT key: 'pgsql.queries.query.time_max["{#DBNAME}"]' delay: '0' history: 7d units: s description: 'Max query time for this database.' preprocessing: - type: JSONPATH parameters: - $.query_time_max master_item: key: 'pgsql.queries.get_metrics["{#DBNAME}"]' tags: - tag: component value: queries - tag: database value: '{#DBNAME}' - uuid: c6232400b39c4564a30a403859ffb4ee name: 'DB [{#DBNAME}]: Queries sum query time' type: DEPENDENT key: 'pgsql.queries.query.time_sum["{#DBNAME}"]' delay: '0' history: 7d units: s description: 'Sum query time for this database.' preprocessing: - type: JSONPATH parameters: - $.query_time_sum master_item: key: 'pgsql.queries.get_metrics["{#DBNAME}"]' tags: - tag: component value: queries - tag: database value: '{#DBNAME}' - uuid: f7099043ea6345f0a5531f70f9573a3e name: 'DB [{#DBNAME}]: Queries slow transaction count' type: DEPENDENT key: 'pgsql.queries.tx.slow_count["{#DBNAME}"]' delay: '0' history: 7d description: 'Slow transaction query count for this database.' preprocessing: - type: JSONPATH parameters: - $.tx_slow_count master_item: key: 'pgsql.queries.get_metrics["{#DBNAME}"]' tags: - tag: component value: queries - tag: database value: '{#DBNAME}' - uuid: c6800ca30a564766ba745e875cb4e929 name: 'DB [{#DBNAME}]: Queries max transaction time' type: DEPENDENT key: 'pgsql.queries.tx.time_max["{#DBNAME}"]' delay: '0' history: 7d units: s description: 'Max transaction query time for this database.' preprocessing: - type: JSONPATH parameters: - $.tx_time_max master_item: key: 'pgsql.queries.get_metrics["{#DBNAME}"]' tags: - tag: component value: queries - tag: database value: '{#DBNAME}' - uuid: 0eda974576794768ac9ddc592ff27e19 name: 'DB [{#DBNAME}]: Queries sum transaction time' type: DEPENDENT key: 'pgsql.queries.tx.time_sum["{#DBNAME}"]' delay: '0' history: 7d units: s description: 'Sum transaction query time for this database.' preprocessing: - type: JSONPATH parameters: - $.tx_time_sum master_item: key: 'pgsql.queries.get_metrics["{#DBNAME}"]' tags: - tag: component value: queries - tag: database value: '{#DBNAME}' - uuid: cafcc00cce824c33a321da0e9ecc7f6e name: 'DB [{#DBNAME}]: Index scans per second' type: DEPENDENT key: 'pgsql.scans.idx.rate["{#DBNAME}"]' delay: '0' history: 7d description: 'Number of index scans in the database per second.' preprocessing: - type: JSONPATH parameters: - $.idx - type: CHANGE_PER_SECOND parameters: - '' master_item: key: 'pgsql.scans["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{#DBNAME}"]' tags: - tag: component value: scans - tag: database value: '{#DBNAME}' - uuid: f07396ca9d224e1b819f22efe6c4259d name: 'DB [{#DBNAME}]: Sequential scans per second' type: DEPENDENT key: 'pgsql.scans.seq.rate["{#DBNAME}"]' delay: '0' history: 7d value_type: FLOAT description: 'Number of sequential scans in this database per second.' preprocessing: - type: JSONPATH parameters: - $.seq - type: CHANGE_PER_SECOND parameters: - '' master_item: key: 'pgsql.scans["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{#DBNAME}"]' tags: - tag: component value: scans - tag: database value: '{#DBNAME}' - uuid: 4bf92e4b0fed4d32b808b299d9e1fb0c name: 'DB [{#DBNAME}]: Get scans' key: 'pgsql.scans["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{#DBNAME}"]' history: '0' trends: '0' value_type: TEXT description: 'Number of scans done for table/index in this database.' tags: - tag: component value: raw - tag: database value: '{#DBNAME}' graph_prototypes: - uuid: 3f8124b817f2437096c620d62ec2e055 name: 'DB [{#DBNAME}]: Block hit/read' ymin_type_1: FIXED graph_items: - color: 199C0D item: host: 'PostgreSQL by Zabbix agent' key: 'pgsql.dbstat.blks_hit.rate["{#DBNAME}"]' - sortorder: '1' color: F63100 item: host: 'PostgreSQL by Zabbix agent' key: 'pgsql.dbstat.blks_read.rate["{#DBNAME}"]' - uuid: 6bd0a0d65b8d43ad946b145cf8a8b533 name: 'DB [{#DBNAME}]: Database size' ymin_type_1: FIXED graph_items: - color: 199C0D item: host: 'PostgreSQL by Zabbix agent' key: 'pgsql.db.size["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}","{#DBNAME}"]' - uuid: 41e765d906324595a396d8985b204ff5 name: 'DB [{#DBNAME}]: Events' ymin_type_1: FIXED graph_items: - drawtype: GRADIENT_LINE color: 199C0D item: host: 'PostgreSQL by Zabbix agent' key: 'pgsql.dbstat.xact_commit.rate["{#DBNAME}"]' - sortorder: '1' color: F63100 item: host: 'PostgreSQL by Zabbix agent' key: 'pgsql.dbstat.conflicts.rate["{#DBNAME}"]' - sortorder: '2' color: 00611C item: host: 'PostgreSQL by Zabbix agent' key: 'pgsql.dbstat.deadlocks.rate["{#DBNAME}"]' - sortorder: '3' color: F7941D item: host: 'PostgreSQL by Zabbix agent' key: 'pgsql.dbstat.xact_rollback.rate["{#DBNAME}"]' - uuid: 2b260fdf7623476095429434b5c79041 name: 'DB [{#DBNAME}]: Locks' ymin_type_1: FIXED graph_items: - color: 199C0D item: host: 'PostgreSQL by Zabbix agent' key: 'pgsql.locks.total["{#DBNAME}"]' - uuid: 8a60a92b41b146f49145b86bab559b2e name: 'DB [{#DBNAME}]: Queries' ymin_type_1: FIXED graph_items: - color: 199C0D yaxisside: RIGHT item: host: 'PostgreSQL by Zabbix agent' key: 'pgsql.queries.mro.time_max["{#DBNAME}"]' - sortorder: '1' color: F63100 yaxisside: RIGHT item: host: 'PostgreSQL by Zabbix agent' key: 'pgsql.queries.query.time_max["{#DBNAME}"]' - sortorder: '2' color: 00611C yaxisside: RIGHT item: host: 'PostgreSQL by Zabbix agent' key: 'pgsql.queries.tx.time_max["{#DBNAME}"]' - sortorder: '3' drawtype: GRADIENT_LINE color: F7941D item: host: 'PostgreSQL by Zabbix agent' key: 'pgsql.queries.mro.time_sum["{#DBNAME}"]' - sortorder: '4' drawtype: GRADIENT_LINE color: FC6EA3 item: host: 'PostgreSQL by Zabbix agent' key: 'pgsql.queries.query.time_sum["{#DBNAME}"]' - sortorder: '5' drawtype: GRADIENT_LINE color: 6C59DC item: host: 'PostgreSQL by Zabbix agent' key: 'pgsql.queries.tx.time_sum["{#DBNAME}"]' - uuid: 93518b06f71e46ada3dabefa1726b867 name: 'DB [{#DBNAME}]: Slow queries' ymin_type_1: FIXED graph_items: - color: 199C0D item: host: 'PostgreSQL by Zabbix agent' key: 'pgsql.queries.mro.slow_count["{#DBNAME}"]' - sortorder: '1' color: F63100 item: host: 'PostgreSQL by Zabbix agent' key: 'pgsql.queries.query.slow_count["{#DBNAME}"]' - sortorder: '2' color: 00611C item: host: 'PostgreSQL by Zabbix agent' key: 'pgsql.queries.tx.slow_count["{#DBNAME}"]' - uuid: 779b872280ad46c7a6cdf95c2df7c646 name: 'DB [{#DBNAME}]: Temp files' graph_items: - drawtype: GRADIENT_LINE color: 199C0D item: host: 'PostgreSQL by Zabbix agent' key: 'pgsql.dbstat.temp_bytes.rate["{#DBNAME}"]' - sortorder: '1' color: F63100 yaxisside: RIGHT item: host: 'PostgreSQL by Zabbix agent' key: 'pgsql.dbstat.temp_files.rate["{#DBNAME}"]' - uuid: f10be22e3bac4d66936c34ec99446c64 name: 'DB [{#DBNAME}]: Tuples' ymin_type_1: FIXED graph_items: - color: 199C0D item: host: 'PostgreSQL by Zabbix agent' key: 'pgsql.dbstat.tup_deleted.rate["{#DBNAME}"]' - sortorder: '1' color: F63100 item: host: 'PostgreSQL by Zabbix agent' key: 'pgsql.dbstat.tup_fetched.rate["{#DBNAME}"]' - sortorder: '2' color: 00611C item: host: 'PostgreSQL by Zabbix agent' key: 'pgsql.dbstat.tup_inserted.rate["{#DBNAME}"]' - sortorder: '3' color: F7941D item: host: 'PostgreSQL by Zabbix agent' key: 'pgsql.dbstat.tup_returned.rate["{#DBNAME}"]' - sortorder: '4' color: FC6EA3 item: host: 'PostgreSQL by Zabbix agent' key: 'pgsql.dbstat.tup_updated.rate["{#DBNAME}"]' tags: - tag: class value: database - tag: target value: postgresql macros: - macro: '{$PG.CACHE_HITRATIO.MIN.WARN}' value: '90' description: 'Minimum cache hit ratio percentage for trigger expression.' - macro: '{$PG.CHECKPOINTS_REQ.MAX.WARN}' value: '5' description: 'Maximum required checkpoint occurrences for trigger expression.' - macro: '{$PG.CONFLICTS.MAX.WARN}' value: '0' description: 'Maximum number of recovery conflicts for trigger expression.' - macro: '{$PG.CONN_TOTAL_PCT.MAX.WARN}' value: '90' description: 'Maximum percentage of current connections for trigger expression.' - macro: '{$PG.DATABASE}' value: postgres description: 'Default PostgreSQL database for the connection.' - macro: '{$PG.DEADLOCKS.MAX.WARN}' value: '0' description: 'Maximum number of detected deadlocks for trigger expression.' - macro: '{$PG.FROZENXID_PCT_STOP.MIN.HIGH}' value: '75' description: 'Minimum frozen XID before stop percentage for trigger expression.' - macro: '{$PG.HOST}' value: localhost description: 'Hostname or IP of PostgreSQL host.' - macro: '{$PG.LLD.FILTER.DBNAME}' value: .+ description: 'Filter of discoverable databases.' - macro: '{$PG.LOCKS.MAX.WARN}' value: '100' description: 'Maximum number of locks for trigger expression.' - macro: '{$PG.PASSWORD}' value: '' description: 'PostgreSQL user password.' - macro: '{$PG.PING_TIME.MAX.WARN}' value: 1s description: 'Maximum time of connection response for trigger expression.' - macro: '{$PG.PORT}' value: '5432' description: 'PostgreSQL service port.' - macro: '{$PG.QUERY_ETIME.MAX.WARN}' value: '30' description: 'Execution time limit for count of slow queries.' - macro: '{$PG.REPL_LAG.MAX.WARN}' value: 10m description: 'Maximum replication lag time for trigger expression.' - macro: '{$PG.SLOW_QUERIES.MAX.WARN}' value: '5' description: 'Slow queries count threshold for a trigger.' - macro: '{$PG.USER}' value: zbx_monitor description: 'PostgreSQL username.' dashboards: - uuid: d95f29826778497a9ed265e0c335fd0f name: 'PostgreSQL databases' pages: - widgets: - type: graphprototype width: '12' height: '5' fields: - type: INTEGER name: columns value: '1' - type: INTEGER name: rows value: '1' - type: GRAPH_PROTOTYPE name: graphid value: host: 'PostgreSQL by Zabbix agent' name: 'DB [{#DBNAME}]: Tuples' - type: graphprototype x: '12' width: '12' height: '5' fields: - type: INTEGER name: columns value: '1' - type: INTEGER name: rows value: '1' - type: GRAPH_PROTOTYPE name: graphid value: host: 'PostgreSQL by Zabbix agent' name: 'DB [{#DBNAME}]: Events' - type: graphprototype 'y': '5' width: '12' height: '5' fields: - type: INTEGER name: columns value: '1' - type: INTEGER name: rows value: '1' - type: GRAPH_PROTOTYPE name: graphid value: host: 'PostgreSQL by Zabbix agent' name: 'DB [{#DBNAME}]: Block hit/read' - type: graphprototype x: '12' 'y': '5' width: '12' height: '5' fields: - type: INTEGER name: columns value: '1' - type: INTEGER name: rows value: '1' - type: GRAPH_PROTOTYPE name: graphid value: host: 'PostgreSQL by Zabbix agent' name: 'DB [{#DBNAME}]: Temp files' - type: graphprototype 'y': '10' width: '12' height: '5' fields: - type: INTEGER name: columns value: '1' - type: INTEGER name: rows value: '1' - type: GRAPH_PROTOTYPE name: graphid value: host: 'PostgreSQL by Zabbix agent' name: 'DB [{#DBNAME}]: Locks' - type: graphprototype x: '12' 'y': '10' width: '12' height: '5' fields: - type: INTEGER name: columns value: '1' - type: INTEGER name: rows value: '1' - type: GRAPH_PROTOTYPE name: graphid value: host: 'PostgreSQL by Zabbix agent' name: 'DB [{#DBNAME}]: Database size' - type: graphprototype 'y': '15' width: '12' height: '5' fields: - type: INTEGER name: columns value: '1' - type: INTEGER name: rows value: '1' - type: GRAPH_PROTOTYPE name: graphid value: host: 'PostgreSQL by Zabbix agent' name: 'DB [{#DBNAME}]: Queries' - type: graphprototype x: '12' 'y': '15' width: '12' height: '5' fields: - type: INTEGER name: columns value: '1' - type: INTEGER name: rows value: '1' - type: GRAPH_PROTOTYPE name: graphid value: host: 'PostgreSQL by Zabbix agent' name: 'DB [{#DBNAME}]: Slow queries' - uuid: f2ceabf59fd64ca9828ea55e9b9668bd name: 'PostgreSQL stat' pages: - widgets: - type: graph width: '12' height: '5' fields: - type: GRAPH name: graphid value: host: 'PostgreSQL by Zabbix agent' name: 'PostgreSQL connections' - type: graph x: '12' width: '12' height: '5' fields: - type: GRAPH name: graphid value: host: 'PostgreSQL by Zabbix agent' name: 'PostgreSQL transactions' - type: graph 'y': '5' width: '12' height: '5' fields: - type: GRAPH name: graphid value: host: 'PostgreSQL by Zabbix agent' name: 'PostgreSQL ping' - type: graph x: '12' 'y': '5' width: '12' height: '5' fields: - type: GRAPH name: graphid value: host: 'PostgreSQL by Zabbix agent' name: 'PostgreSQL uptime' - type: graph 'y': '10' width: '12' height: '5' fields: - type: GRAPH name: graphid value: host: 'PostgreSQL by Zabbix agent' name: 'PostgreSQL replication lag' - type: graph x: '12' 'y': '10' width: '12' height: '5' fields: - type: GRAPH name: graphid value: host: 'PostgreSQL by Zabbix agent' name: 'PostgreSQL WAL' - type: graph 'y': '15' width: '12' height: '5' fields: - type: GRAPH name: graphid value: host: 'PostgreSQL by Zabbix agent' name: 'PostgreSQL bgwriter' - type: graph x: '12' 'y': '15' width: '12' height: '5' fields: - type: GRAPH name: graphid value: host: 'PostgreSQL by Zabbix agent' name: 'PostgreSQL checkpoints' valuemaps: - uuid: 2e376ee568d04e7bbe98cbae4181f313 name: 'PostgreSQL recovery role' mappings: - value: '0' newvalue: Master - value: '1' newvalue: Standby - uuid: 7f553f18ef6544ceaa4b50c4ebf0e583 name: 'PostgreSQL replication status' mappings: - value: '0' newvalue: Down - value: '1' newvalue: Up - value: '2' newvalue: Master - uuid: 372bc939f3924aafa13c4821b83a9276 name: 'Service state' mappings: - value: '0' newvalue: Down - value: '1' newvalue: Up graphs: - uuid: 6b4b92c62cb94e10b11f218ed35f6211 name: 'PostgreSQL bgwriter' ymin_type_1: FIXED graph_items: - color: 199C0D yaxisside: RIGHT item: host: 'PostgreSQL by Zabbix agent' key: pgsql.bgwriter.buffers_alloc.rate - sortorder: '1' color: F63100 yaxisside: RIGHT item: host: 'PostgreSQL by Zabbix agent' key: pgsql.bgwriter.buffers_clean.rate - sortorder: '2' color: 00611C yaxisside: RIGHT item: host: 'PostgreSQL by Zabbix agent' key: pgsql.bgwriter.buffers_backend.rate - sortorder: '3' color: F7941D yaxisside: RIGHT item: host: 'PostgreSQL by Zabbix agent' key: pgsql.bgwriter.buffers_checkpoint.rate - sortorder: '4' color: FC6EA3 item: host: 'PostgreSQL by Zabbix agent' key: pgsql.bgwriter.maxwritten_clean.rate - sortorder: '5' color: 6C59DC item: host: 'PostgreSQL by Zabbix agent' key: pgsql.bgwriter.buffers_backend_fsync.rate - uuid: 4a105d193df64be7898ac19a2f07faa4 name: 'PostgreSQL checkpoints' ymin_type_1: FIXED graph_items: - color: 199C0D item: host: 'PostgreSQL by Zabbix agent' key: pgsql.bgwriter.checkpoints_timed.rate - sortorder: '1' color: F63100 item: host: 'PostgreSQL by Zabbix agent' key: pgsql.bgwriter.checkpoints_req.rate - sortorder: '2' color: 00611C yaxisside: RIGHT item: host: 'PostgreSQL by Zabbix agent' key: pgsql.bgwriter.checkpoint_sync_time.rate - sortorder: '3' color: F7941D yaxisside: RIGHT item: host: 'PostgreSQL by Zabbix agent' key: pgsql.bgwriter.checkpoint_write_time.rate - uuid: 8d41d719832049a5a1fcd6f4da67fb6a name: 'PostgreSQL connections' ymin_type_1: FIXED graph_items: - drawtype: GRADIENT_LINE color: 199C0D yaxisside: RIGHT item: host: 'PostgreSQL by Zabbix agent' key: pgsql.connections.sum.total - sortorder: '1' color: F63100 item: host: 'PostgreSQL by Zabbix agent' key: pgsql.connections.sum.total_pct - sortorder: '2' color: 00611C yaxisside: RIGHT item: host: 'PostgreSQL by Zabbix agent' key: pgsql.connections.sum.active - sortorder: '3' color: F7941D yaxisside: RIGHT item: host: 'PostgreSQL by Zabbix agent' key: pgsql.connections.sum.idle - sortorder: '4' color: FC6EA3 yaxisside: RIGHT item: host: 'PostgreSQL by Zabbix agent' key: pgsql.connections.sum.idle_in_transaction - sortorder: '5' color: 6C59DC yaxisside: RIGHT item: host: 'PostgreSQL by Zabbix agent' key: pgsql.connections.sum.prepared - sortorder: '6' color: C7A72D yaxisside: RIGHT item: host: 'PostgreSQL by Zabbix agent' key: pgsql.connections.sum.waiting - uuid: 1e9a55ee61824779a9f46f42ec21abef name: 'PostgreSQL ping' ymin_type_1: FIXED graph_items: - drawtype: GRADIENT_LINE color: 199C0D item: host: 'PostgreSQL by Zabbix agent' key: 'pgsql.ping["{$PG.HOST}","{$PG.PORT}"]' - sortorder: '1' color: F63100 yaxisside: RIGHT item: host: 'PostgreSQL by Zabbix agent' key: 'pgsql.ping.time["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]' - uuid: d8cf31fc39584a63b9384d9c3ebf40ee name: 'PostgreSQL replication lag' ymin_type_1: FIXED graph_items: - color: 199C0D item: host: 'PostgreSQL by Zabbix agent' key: 'pgsql.replication.lag.sec["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]' - uuid: 10d1de74e9d848399ca038055e5cc8ce name: 'PostgreSQL transactions' ymin_type_1: FIXED graph_items: - color: 199C0D yaxisside: RIGHT item: host: 'PostgreSQL by Zabbix agent' key: pgsql.transactions.active - sortorder: '1' color: F63100 yaxisside: RIGHT item: host: 'PostgreSQL by Zabbix agent' key: pgsql.transactions.idle - sortorder: '2' color: 00611C yaxisside: RIGHT item: host: 'PostgreSQL by Zabbix agent' key: pgsql.transactions.prepared - sortorder: '3' color: F7941D yaxisside: RIGHT item: host: 'PostgreSQL by Zabbix agent' key: pgsql.transactions.waiting - uuid: 45fe7967596741129b4f2462922636bf name: 'PostgreSQL uptime' show_triggers: 'NO' ymin_type_1: FIXED graph_items: - color: 199C0D item: host: 'PostgreSQL by Zabbix agent' key: 'pgsql.uptime["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]' - sortorder: '1' color: F63100 yaxisside: RIGHT item: host: 'PostgreSQL by Zabbix agent' key: 'pgsql.cache.hit["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]' - uuid: 93ca2dc7a3ff4a458c45e2a56390ce72 name: 'PostgreSQL WAL' ymin_type_1: FIXED graph_items: - color: 199C0D item: host: 'PostgreSQL by Zabbix agent' key: pgsql.wal.write - sortorder: '1' color: F63100 yaxisside: RIGHT item: host: 'PostgreSQL by Zabbix agent' key: pgsql.wal.count