Monitoring PostgreSQL with Zabbix templates: when your team needs it
If your team already runs Zabbix, or is choosing a monitoring platform for self-hosted PostgreSQL, Zabbix's official PostgreSQL templates are a practical place to start. The templates collect metrics and drive triggers once three things are in place: a dedicated monitoring user on the database, a collection method (Zabbix agent, Zabbix agent 2 or ODBC) and database discovery so new databases are picked up without manual host edits. Zabbix 7.4 supports PostgreSQL 13 to 18, and the open source Zabbix server carries no license fee, so the cost you carry is the work of configuration, testing and threshold design rather than software licensing.
That work matters more than the template import itself. Each template ships with default triggers, and those defaults are generic. A database with heavy batch writes, a large number of short-lived connections or a standby that is expected to lag will produce alerts that the operations team learns to ignore. Before go-live, the team should decide which triggers page someone, which only create a ticket and which are dashboards, and should record the reason for each threshold. Ask whoever owns the database to supply normal peaks for connections, WAL volume and replication lag so thresholds reflect your workload instead of a sample environment.
Check the Zabbix release you run against the life cycle policy before you invest in templates, because the templates and their item keys change between major releases. Confirm the exact supported template versions and the agent type that fits your platform in the Zabbix requirements documentation, then test the monitoring user's privileges on a staging cluster so collection does not fail silently after a PostgreSQL minor upgrade.
Choosing agent, agent 2 or ODBC for PostgreSQL
This table compares the three ways Zabbix can collect PostgreSQL data: the classic agent, agent 2 with its PostgreSQL plugin, and ODBC-based templates. Read each row as a question to answer for your environment, then match the column that fits your network, permissions and maintenance model. The main takeaway is that the choice changes where code runs and who maintains the connection, so settle it before building templates across many servers.
| Factor | Zabbix agent | Zabbix agent 2 (PostgreSQL plugin) | ODBC-based templates |
|---|---|---|---|
| Where it runs | Installed on the database host as a single agent process | Installed on the database host, with the PostgreSQL plugin loaded inside the agent | Runs on a Zabbix server or proxy and connects to PostgreSQL over the network |
| How it connects | Uses item keys and local checks; PostgreSQL access depends on the scripts or user-parameters you add | Connects directly to PostgreSQL through the plugin, using connection settings held in the agent configuration | Connects through an ODBC driver and data source name defined on the Zabbix side |
| Database discovery | Limited; discovery usually needs custom user-parameters or scripts | Supports low-level discovery of databases through the plugin; confirm the discovery items for your version | Supports discovery through the template's low-level discovery rules; confirm the queries against your PostgreSQL version |
| Network reach needed | Agent port reachable from the Zabbix server or proxy; PostgreSQL stays local | Agent port reachable from the Zabbix server or proxy; PostgreSQL reached from the host | PostgreSQL port reachable from the Zabbix server or proxy, which may cross network zones |
| Permissions | Depends on what the custom scripts can read; often broader than needed | A monitoring role with the privileges documented for the plugin, set in the agent configuration | A monitoring role used by the ODBC data source; the driver and credentials live on the Zabbix side |
| Maintenance effort | Scripts and user-parameters need upkeep on every host | Agent upgrades and plugin settings are managed per host; fewer custom scripts | Driver versions, data source names and credentials are maintained on each server or proxy |
| When it fits | Hosts already on classic agent with simple checks and few PostgreSQL metrics | Most new deployments that want the vendor-supported plugin close to the database | Central collection where installing software on database hosts is restricted |
| What to confirm | Whether the official template in your version expects agent items you can supply | Plugin availability and template version for your Zabbix release and PostgreSQL version | Driver support, template version and whether the ODBC path is still recommended for your release |
How to set up the PostgreSQL template in Zabbix
This sequence takes a PostgreSQL server from no monitoring to a Zabbix host that returns live data, with a least-privilege monitoring role, a configured collector, the official template linked and discovery confirmed. Each step ends with a check so problems surface before alerts are tuned.
Create a read-only monitoring role
The database administrator creates a dedicated login role for Zabbix and grants only the privileges the official PostgreSQL template needs to read statistics views. The role should not be a superuser and should have no write access to application schemas. Confirm the exact grants for your PostgreSQL major version and template release in the official Zabbix template documentation before running them. Done means that logging in as this role from the monitoring host succeeds and a test query against the statistics views returns rows, while an attempt to write to an application table fails.
Allow the monitoring host in pg_hba.conf
The database administrator adds a pg_hba.conf entry that permits only the monitoring role, from the Zabbix agent or collector address, using the authentication method your security standards require, and reloads the configuration. The file path depends on your installation method, so confirm its location for your package or container setup. Done means that a connection from the monitoring host as the monitoring role succeeds and a connection from any other host or with another role is rejected in the server log.
Configure the chosen collector and connection parameters
The monitoring engineer configures the collector you selected, whether the Zabbix agent 2 PostgreSQL plugin, the Zabbix agent with the PostgreSQL template scripts, or an ODBC setup, and sets the connection URI or session name, user and password stored in a secret store or protected file. Confirm the configuration keys and file paths for your Zabbix version in the official documentation, and restart the collector after the change. Done means the collector's own test or log shows a successful login to the PostgreSQL server with the monitoring role.
Link the official PostgreSQL template to the host
In the Zabbix frontend, the administrator creates or selects the host, sets its interface to the agent address, attaches the macros the template expects (such as the connection target or port) and links the official PostgreSQL template for your collector type. Macro names differ between template versions, so check them against the template you import. Done means the host shows the template under its linked templates and the latest data page starts listing PostgreSQL items within the next collection cycle.
Confirm items return data
The monitoring engineer opens the latest data view for the host and filters for PostgreSQL items such as availability, version, connections and database statistics. Each item should show a value and a recent timestamp, and items that show unsupported status should be opened to read the error text. Common causes are a missing grant, a wrong macro value or a blocked connection in pg_hba.conf. Done means the key availability and connection items return values and the unsupported item count for the host is zero or each remaining item has a known cause.
Check that low-level discovery finds the expected databases
The monitoring engineer opens the discovery rules attached to the template and reviews the discovered database prototypes on the host. The list should match the databases you expect to watch, and any system or scratch databases that appear should be noted for filtering. If an expected database is missing, check that the monitoring role can connect to it and has the needed visibility. Done means the discovered entities list matches the agreed set of databases, and each discovered item returns data like the server-level items.
Record the baseline before enabling triggers
Before alert notifications are routed to on-call staff, the monitoring engineer lets the host collect for a period long enough to see normal load and records typical values for connections, cache behavior and transaction activity. These observations form the baseline for later threshold tuning. Done means the team has a written record of normal values for the host and a list of triggers that fired during the baseline window, each marked as expected or needing adjustment.
Designing the monitoring user and its grants
A dedicated, read-only monitoring role is the first control to set when Zabbix connects to PostgreSQL, because the collector needs to read statistics, not data. Create a role such as zbx_monitor that is not a superuser, does not own any application objects, and has no write privileges on application schemas. Grant it the built-in pg_monitor role, which gives read access to the statistics views and the monitoring functions the templates query, rather than granting broad system privileges by hand. Keep the role's LOGIN capability and its connection limit separate from application roles so that a leaked monitoring credential cannot change data, and so that its activity is easy to filter in logs and pg_stat_activity.
Restrict where that role can connect from. In pg_hba.conf, add a host entry that matches the monitoring database or all databases, the role name, and only the address of the Zabbix agent or the ODBC host that runs the queries, with the narrowest netmask you can use. Put this line above any broader rule for the same network, because PostgreSQL applies the first matching entry. Use hostssl so the connection requires TLS, and set scram-sha-256 as the method. PostgreSQL 18 deprecates MD5 password authentication in favor of SCRAM, so do not configure md5 for a new monitoring role, and confirm that the password_encryption setting stores new passwords as SCRAM before you create the role.
Before you finalize the grants, check which statistics views and functions the Zabbix template you chose actually queries, and confirm them against your PostgreSQL major version. Views such as pg_stat_database, pg_stat_activity and pg_stat_replication differ in columns between releases, and a template built for one version can fail silently on another. Test the role by logging in as it with psql and running the template's key queries, then check the Zabbix item error messages after the first collection cycle. Record the role's grants and the pg_hba.conf line in your change record so that a later upgrade reviewer can see exactly what the collector is allowed to do.
Discovered databases, triggers and where alert noise starts
The PostgreSQL template set works through discovery rules, item prototypes and triggers, and each layer can generate alerts that are not actionable. Noise usually comes from the same few places: thresholds set too tight, triggers with no recovery logic, dependent alerts firing during outages, and planned work that nobody suppressed. The cards below map each source to the lever that reduces it.
Database discovery rules
The template's discovery rule finds the databases on each instance and creates item and trigger prototypes for them. Discovery picks up scratch, test and temporary databases as readily as production ones, so every new database starts producing alerts without review. Check which databases are discovered after a first run, then use the discovery filter to exclude system or throwaway databases by name pattern. Also confirm how removed databases are handled, so that stale items do not keep firing.
Zabbix server docsItem prototypes per database
Each discovered database gets its own copy of the item prototypes, so one host with fifty databases can produce several hundred items and their triggers. Per-database items for size, transaction counts and cache hit ratio are often useful for a few busy databases but noisy for the rest. Review which prototypes you keep, set sensible update intervals for slow-moving metrics, and disable prototypes that no one reads. Fewer items also lowers load on the monitoring database.
Trigger expressions and thresholds
Most noisy triggers compare a single sample against a fixed limit, so a brief spike in connections or a short lock wait opens an alert that closes minutes later. Replace single-sample checks with expressions that look at a window, such as an average or a count of samples over a period. Set thresholds from your own baseline for each database rather than from template defaults, and document who owns each threshold change. Record the threshold change history so you can explain why an alert moved.
Hysteresis and recovery expressions
A trigger with only a problem expression will flap when a metric hovers near its limit, opening and closing repeatedly. A recovery expression sets a different level for the alert to clear, which gives the trigger hysteresis, so a value must fall clearly below the problem level before the alert resolves. Use this on connection saturation, cache hit ratio and replication lag, where values often oscillate. Test the chosen gap against recent history before going live.
Trigger dependencies
When the host is unreachable, every PostgreSQL trigger on it also fails, and the on-call engineer receives a flood of alerts that all share one cause. Trigger dependencies let the host availability trigger suppress the database triggers beneath it, so only the root alert notifies. Confirm dependencies for every discovered database trigger, including those created by discovery, because manually added dependencies are not always carried over. Test by stopping the database service in a non-production environment and counting the alerts that fire.
Maintenance windows
Planned work such as minor upgrades, major upgrades, vacuum runs and restores will trip connection, replication and availability triggers in the same way an incident does. Maintenance periods in Zabbix suppress problem notifications for the hosts or host groups you select during the window, and you decide whether data collection continues. Schedule windows in advance with the change record, and check after each one that suppressed problems were cleared rather than left open. Confirm how your Zabbix version handles windows for discovered items.
How Zabbix collects PostgreSQL data
The flow starts with the Zabbix agent 2, agent or ODBC collector running next to or near PostgreSQL, using a dedicated monitoring role to read statistics. Collected values pass to the Zabbix server or a proxy, which stores them in the Zabbix database, where items, triggers and notifications act on them. Check the trust boundary: the monitoring role should have read-only access, and the network path from collector to database should be limited to the monitoring port and the monitoring host.
Data path from the PostgreSQL monitoring role through the collector to Zabbix storage and alerts.
Tuning thresholds to cut alert noise without missing failures
Set thresholds from your own baseline, not from template defaults. The PostgreSQL templates ship with trigger expressions that suit a generic workload, and a generic workload is rarely yours. Before you change anything, record normal values for each environment over a representative period: connection counts, transaction rate, replication lag, WAL volume, autovacuum activity and disk growth. Keep production, staging and test in separate baselines, because a batch-heavy reporting database and a busy OLTP primary will not share a sensible limit for long-running transactions or lag. Once you have the numbers, adjust the item thresholds and macros in the template to match, and record why each value was chosen so the next person can judge it. Confirm the exact macro names in your template version before editing, since they differ between releases.
Use time-based conditions and recovery expressions so alerts behave predictably. A single sample above a limit is usually noise, so require the condition to hold over a window, for example by using a trigger function that evaluates several recent values or the last() and avg() functions over a period you choose. Pair every problem trigger with a recovery expression so the event closes when the value returns to a healthy range, and add a hysteresis margin between the problem and recovery levels so a metric hovering near the limit does not flap. Route low-severity events, such as autovacuum running longer than usual or moderate connection growth, to a ticket queue or a daily digest. Keep availability and data-protection events, such as the server being unreachable, replication stopped or archiving failing, on an immediate paging path. Check that each path is tested, because a mis-set severity is one of the most common reasons a real failure goes unnoticed.
Review thresholds after every PostgreSQL major upgrade. A major upgrade can change planner behavior, statistics retention, autovacuum patterns and the activity views your items read, so a baseline from the old version may no longer describe normal. Plan a review window after each upgrade, compare the post-upgrade values with the stored baseline, and retune only where the workload has genuinely changed. Watch the alert log for the first weeks after the cutover, and track which triggers fire without anyone acting on them. Those are the candidates to widen or downgrade. Keep a short change record with each threshold change, the reason and the date, so noise reduction does not quietly remove the coverage you need.
Security and operational considerations for the Zabbix PostgreSQL setup
The monitoring setup touches credentials, network paths and the Zabbix frontend, so it needs the same design care as the database it watches. The cards below cover where the monitoring role's secrets live, how the connection is protected, who can see the data, where collectors sit and how versions stay aligned.
Monitoring role credential storage
The Zabbix PostgreSQL template reads a password through user macros, so the password can end up in the Zabbix database in readable form. Decide whether the value is stored as a secret user macro or resolved from an external vault integration, and confirm which option your Zabbix version supports for that macro type. Keep the monitoring role read-only, rotate its password on a schedule, and check that the value never appears in exported templates or host configuration shared with other teams.
Encryption of the monitoring connection
Collectors send database credentials and query results across the network, so the connection needs TLS where the path crosses a segment boundary. Configure PostgreSQL to accept encrypted connections for the monitoring role, and set the matching TLS parameters in the agent or ODBC data source. Confirm the certificate validation mode your collector uses, because a connection that encrypts without verifying the server identity still leaves room for interception.
Frontend access through user groups
Anyone with frontend access can view host inventory, item values and trigger details, and some may be able to edit templates. Build user groups around teams and host groups, grant read access only where needed, and limit configuration rights to the people who maintain templates. Review the authentication method configured for the frontend, such as internal, LDAP or SAML options, and confirm that disabled or departed accounts lose access promptly.
Zabbix authentication docsProxy placement in segmented networks
In segmented networks, a Zabbix proxy close to the database lets the collector reach PostgreSQL without opening database ports across zones. Place proxies where they can reach the monitored hosts and the Zabbix server, and size the firewall rules to the specific ports used. For high availability, use proxy groups so monitored hosts move to another proxy if one goes offline, and test that the database connection works from the new proxy.
Collector and server version alignment
The agent, Agent 2 or ODBC component, the template version and the Zabbix server should match a supported release line. Mismatched templates can reference item keys or parameters that an older collector does not provide, which shows up as unsupported items rather than a clear error. Record the versions in your change log, upgrade collectors in the same window as the server where possible, and check the PostgreSQL versions your Zabbix release supports before upgrading the database.
Zabbix release policyAlert review and ownership
Triggers and their thresholds need an owner, or noise grows until people stop reading notifications. Assign each PostgreSQL trigger group to a team, record why a threshold was chosen, and review unsupported items and flapping alerts on a set cadence. Keep the template changes in version control or a change record so a tuned threshold can be traced back and reverted if it hides a real fault.
Questions teams ask before monitoring PostgreSQL with Zabbix
What does it cost to set up PostgreSQL monitoring with Zabbix?
The Zabbix server and its templates are open source with no license fee, so the cost is the work of building the monitoring and the infrastructure it runs on. Costs come from configuring the PostgreSQL templates, creating the monitoring role on each database, setting up agents or ODBC connections, tuning triggers and running the environment. Some of this is one-time (initial build, threshold design) and some recurs (template upgrades, new databases, alert reviews). Costs rise with fleet size, the number of alert rules you want and how many systems must integrate. Ask any partner for a written scope and a quote that lists each deliverable separately.
How long does Zabbix PostgreSQL monitoring take to configure?
Duration depends mainly on how many PostgreSQL instances and databases you have, how many of them need discovery, and how much time goes into agreeing on alert design. A small set of clusters with clear owners moves much faster than a fleet where each team wants its own thresholds. Ask for a timeline in the written scope that separates the platform setup, the per-database onboarding and the alert tuning period, since tuning usually takes the longest once real data arrives. No fixed duration applies to every environment.
What does my team need to provide for the monitoring setup?
Expect to provide access and decisions, not just servers. The main inputs are:
- Network paths from the Zabbix server, proxies or agents to each PostgreSQL host and port
- A dedicated monitoring role on each database, created by a DBA who approves its privileges
- Named alert owners for each cluster who will accept, route and act on notifications
- Agreed severity levels and escalation contacts
- Access to the Zabbix frontend and any existing ticketing or paging system you want to connect
Missing alert owners is the most common reason monitoring becomes noisy, so confirm them before the build starts.
Can our own team set up Zabbix PostgreSQL monitoring without a partner?
Yes, if your team has Zabbix administration skills and someone who knows PostgreSQL well enough to review the monitoring role and the thresholds. The official templates handle much of the collection, so the work is mainly installation, correct agent or ODBC configuration, discovery, and trigger tuning. Teams without Zabbix experience usually underestimate the trigger tuning and the handling of maintenance windows. A partner is useful when you want the build delivered in a fixed scope, with documentation and a handover, or when you lack capacity. Either way, a written scope makes the choice clear.
Which Zabbix PostgreSQL template option fits our environment?
The choice depends on how Zabbix reaches the database and which agent you already run. Zabbix provides agent, agent 2 and ODBC-based PostgreSQL templates, and each has different connection and permission requirements. Confirm the exact template version and supported PostgreSQL range against the Zabbix requirements page for your Zabbix release, because Zabbix 7.4 lists PostgreSQL 13 to 18 as supported. Ask your engineers to test the chosen template against a non-production database before rolling it out to every cluster.
What does a Zabbix support subscription add, and how fast is the response?
The Zabbix software itself has no license fee, no device limits and no feature gates. A paid support subscription adds vendor technical support at tiers that differ by coverage and response time. Per the Zabbix support page, Silver offers 8x5 support with a 1 day response, Gold offers 8x5 with a 4 hour response, and Platinum, Enterprise and Global offer 24x7 support with 2 hour, 1.5 hour and 1 hour responses respectively. Choose a tier by how quickly you need an answer during an outage. Compare these against your own on-call hours and confirm current terms with Zabbix before buying.
How do we keep PostgreSQL alerts from becoming noise?
Start with a small set of alerts tied to real impact, such as availability, connection saturation and failed backups, and add others only when an owner needs them. Tune thresholds on observed data for a few weeks rather than copying defaults, and use maintenance windows for planned work. Review triggers that fire often and either fix the cause, change the threshold, or remove the alert. A written alert list with owners and severity makes this review routine. Ask any partner to show how they will run this tuning during the engagement.
How DeployOpen scopes and delivers PostgreSQL monitoring in Zabbix
DeployOpen treats Zabbix PostgreSQL monitoring as a written scope with defined deliverables, not a template import. We agree which PostgreSQL hosts, monitoring paths and alerts are covered, build them in your Zabbix environment, and hand over the configuration with documentation your operators can maintain.
How we scope
- Inventory every PostgreSQL instance, version and host that needs Zabbix coverage before choosing agent, Agent 2 or ODBC.
- Agree in writing which databases, discovery rules and alert classes are in scope for the engagement.
- Confirm your Zabbix version and PostgreSQL version against the vendor requirements before the build starts.
How we build
- Create the least-privilege monitoring role and verify it can read the statistics views without write access.
- Configure the chosen template, database discovery and triggers, then tune thresholds against observed baselines to reduce noise.
- Test each trigger with controlled conditions so that alerts fire when expected and stay quiet during normal operation.
How we hand over
- Deliver exported templates, host configuration and a record of every threshold change with the reason for it.
- Document the monitoring user, credential storage and the steps to add a new database to discovery.
- Walk your operators through dashboards, alert routing and the runbook for each trigger in the agreed scope.
How we support
- Engagements are fixed-scope, with deliverables and timelines agreed in writing before work starts.
- Ongoing support, Zabbix upgrades and template maintenance are available as a retainer.
- Ask any provider to confirm how template changes are reviewed and tested before they reach production hosts.

