Monitoring PostgreSQL with the OpenTelemetry Collector: when it fits
Use the Collector's PostgreSQL receiver when you want database metrics to travel through the same pipeline as your application traces, under one telemetry standard. OpenTelemetry is a vendor-neutral framework for generating, exporting and collecting traces, metrics and logs. It does not store or visualize that data, so you still need a backend such as Prometheus, a Grafana stack or another OTLP-capable store. The PostgreSQL receiver connects to the database, reads statistics and emits them as metrics that the Collector can process and export. Its metrics are marked beta in the receiver README, so plan for configuration changes between Collector releases and confirm the metric names your dashboards and alerts depend on before you rely on them.
The receiver fits best when a team already runs the Collector on the application side, wants database health (connections, transactions, locks, replication state) beside request latency for the same service, and prefers one place to change exporters and resource attributes. It is a weaker choice when your existing Prometheus stack already scrapes a mature PostgreSQL exporter with alert rules and dashboards in place, because replacing working monitoring carries cost without a clear gain. Ask whether your team needs query-level detail, such as slow statements or plan analysis, which the receiver's metrics do not replace. Confirm each metric you need against the receiver README before deciding.
Plan the monitoring user before anything else. The receiver's monitoring account must be granted SELECT on pg_stat_database, and you should grant only the additional read access your chosen metrics require. Decide who owns that role, how its password is stored (the Collector security guidance recommends encrypted, authenticated configuration), and whether a separate Collector instance will reach the database over a network your security team has approved. Those choices shape the rest of the rollout, so settle them with your database and security owners first.
How PostgreSQL metrics flow through the Collector
The flow starts at the PostgreSQL server, where the monitoring user holds the SELECT grant on pg_stat_database that the receiver needs. The PostgreSQL receiver polls from the Collector side of a trust boundary, so the database network only needs to accept that one connection. Processors then apply redaction and batching before the exporter sends metrics to the back end you chose. Application traces enter the same pipeline from the other side, so a reviewer can follow one Collector configuration end to end. Check the grant, the network path and what the redaction step removes before going live.
Metrics and traces share one Collector pipeline across the database boundary.
Granting the monitoring user the access it needs
The PostgreSQL receiver only reads statistics, so the monitoring role should hold the smallest set of grants that lets the metrics return. Each card below covers one part of that role, from the minimum grant to the checks that prove it cannot reach application data.
The minimum grant
The receiver's README requires the monitoring user to hold SELECT on pg_stat_database. That view supplies the database-level counters the receiver reports, so it is the starting point for every role you create for this pipeline. Create the role with a login and a password or certificate that your secrets process controls, and grant nothing else until a specific metric needs it.
Receiver READMEWhy no write rights
The receiver issues read-only queries against statistics views and never changes data, schema or configuration. A role with INSERT, UPDATE, DELETE or CREATE privileges adds risk without adding metrics, so review any existing role that the team proposes to reuse. If a rights review flags a write privilege, it is almost always a leftover from an application role rather than a requirement of this receiver.
Confirming the role cannot read application tables
Connect as the monitoring user with psql and try SELECT against a few application tables that hold sensitive rows. The query should fail with a permission error. Also check the role's table privileges in information_schema.role_table_grants and confirm it is not a member of any group role that inherits broader access. Record the output as evidence for your access review.
Metrics that need further grants
Some database-level and per-table metrics read other statistics views, and those views may require additional privileges or may expose more data than you expect. Do not assume the minimum grant covers every metric you enable. Confirm each extra grant against the receiver README for the Collector version you deploy, and enable only the metrics your alerts actually use.
Keeping the role under review
Store the monitoring password in your secrets system, not in the Collector configuration file, and rotate it on your standard schedule. Re-run the grant checks after each Collector upgrade, because receiver changes can add queries that need new privileges. Tie the role to a named owner so that removals and new grants go through the same change process as other database access.
Receiver configuration options and when each fits
This table compares the PostgreSQL receiver settings a team decides on before deployment, from endpoint and TLS to deployment placement. Read each row as a decision with a default-leaning choice, then confirm the exact keys and their current stability in the receiver README before writing configuration.
| Setting | Choose it when | Trade-off and what to confirm |
|---|---|---|
| Endpoint and TLS mode | The database is reached over a private network and the Collector connects directly to it | Confirm the endpoint format and supported TLS modes in the README. Plaintext connections should be avoided across network segments you do not control. |
| Database scope | One or a few databases matter for a service, so the receiver collects only those | Narrower scope lowers noise and cluster load. Confirm whether database-level metrics are collected per database or across the instance before limiting scope. |
| Collection interval | Metrics feed alerts that need fast detection, or dashboards need finer resolution | Shorter intervals add query load on the database and data volume downstream. Start with a conservative interval and adjust against observed impact. |
| Metric groups enabled | You need only core health signals such as connections and throughput for a first rollout | Enabling more groups widens coverage but adds queries and cardinality. Confirm each group's stability level and required privileges in the README. |
| Agent next to the database | The Collector runs on the database host or alongside it and one database per Collector is the norm | Each agent needs its own credentials and config. Patching and scaling grow with host count. Confirm the Collector can reach the database socket or port from that location. |
| Gateway in front of several databases | Many instances share one team's collection path and you want central config and credentials | A gateway concentrates network access and credentials, so it needs strict access control. Confirm throughput limits and failure behavior for the gateway before consolidating. |
What metric coverage the receiver gives you, and what it leaves out
The PostgreSQL receiver is beta for metrics, so treat its metric set as something you verify rather than assume. Before you commit to dashboards or alert rules, open the receiver's README in the contrib repository and check the stability level for each metric you plan to use. Record the Collector version you tested against, because metric names, attributes and defaults can change between releases. Plan a short regression check after every Collector upgrade that confirms the metrics your alerts depend on still arrive with the same names and labels. Ask whether any metric you rely on is still in development before it reaches your production pipeline.
The receiver reads cluster-level statistics that PostgreSQL exposes through its statistics views, so the gaps sit outside that scope. Teams commonly add other tooling for query-level analysis, which needs the statistics extension and its own collection and retention decisions, and for replication lag details, which depend on how your standbys are configured and which views you read. Host-level signals such as CPU, memory, disk latency and filesystem space come from host or node collectors, not from the database receiver. Confirm each gap against the README and the PostgreSQL documentation for your major version before you decide who owns it, and write the owner and data source into your monitoring design.
Make the coverage list an explicit deliverable of the design. For each alert you intend to fire, name the metric, its stability level, the Collector version that produced it and the tool that supplies any missing context. Where a gap blocks an alert, decide whether to accept the gap, add a second collector, or query PostgreSQL directly from a separate job. Keeping this table current is what lets your operations team tell a genuine database problem from a change in what the receiver reports.
Setting up the PostgreSQL receiver step by step
This sequence takes a PostgreSQL instance from an unmonitored database to a Collector pipeline that sends database metrics to your chosen back end, with a check at each stage. Each step closes with evidence that it worked, so a fault can be traced to the step that introduced it.
Confirm PostgreSQL and Collector versions
The platform team checks that the PostgreSQL major version is still within its support window, using the PostgreSQL versioning policy, and confirms that the Collector distribution in use includes the PostgreSQL receiver. Most teams use the contrib distribution, which the Collector releases ship with signed artifacts and SBOM files. Confirm the receiver's current stability for metrics in its README before relying on it in production. The step is done when you have a written record of the PostgreSQL version, the Collector version and the receiver's status, and the database owner has agreed the version is one you will operate.
Create the monitoring role with SELECT
A database administrator creates a dedicated login role for the Collector and grants it SELECT on pg_stat_database, the view the receiver's README names as required. Do not reuse an application account or grant superuser rights. Ask the administrator to record exactly which privileges the role holds, because later grant errors will be easier to read against that record. The step is done when a test connection with the new role succeeds and a query against pg_stat_database returns rows, while a query against an application table is denied as intended.
Store the monitoring credentials securely
Place the role's password in your secrets mechanism, such as a Kubernetes secret, a vault or your configuration management tool's encrypted store, and reference it from the Collector configuration instead of writing it into the file. OpenTelemetry's security guidance recommends storing Collector configuration securely and using encryption and authentication. Confirm who can read the secret and that the Collector runtime, not your version control system, is the only consumer. The step is done when the configuration file contains a reference rather than a literal password, and a search of the repository for the password returns nothing.
Configure the PostgreSQL receiver
Add a postgresql receiver block to the Collector configuration with the endpoint, the monitoring username and the secret reference, and list the databases to monitor. Confirm the exact configuration keys against the receiver README for your Collector version, because option names and defaults can change between releases. Restrict the Collector's own server endpoints so they bind to a controlled interface. The step is done when the configuration passes the Collector's validation command on a test host and the file reviewer confirms that no credential appears in plain text.
Wire the receiver into a metrics pipeline
Connect the receiver to a metrics pipeline with the processors your standards require, and add an exporter for your chosen back end, such as an OTLP endpoint or Prometheus-compatible storage. Start with a small set of processors and add more only after you have seen the metric output. Enable the Collector's own health and telemetry endpoints so you can confirm it is running. The step is done when the Collector starts without errors, the health endpoint reports ready, and the pipeline appears in the Collector's startup log with the receiver and exporter both listed.
Send metrics to the chosen back end
Run the Collector in its target pattern, either as an agent beside the database host or as a gateway that several databases report to, and confirm that metrics reach the back end. Check that the back end's ingestion endpoint accepts the authentication you configured and that the exporter is not dropping batches. Note that this is the point where network path, TLS and back end credentials are first exercised together. The step is done when the back end shows data points for the database within the interval you configured, with the database identifier attached as an attribute or label.
Verify metric names, values and grant errors
Compare the metric names the back end shows against the receiver's documented metric list for your version, and spot-check a few values against the database itself, such as connection counts or transaction totals from pg_stat_database. Review the Collector logs for permission errors, since a missing SELECT grant usually appears there rather than as a missing metric. Rerun a query with the monitoring role to confirm the grant you expect. The step is done when each metric you plan to alert on has a value that matches the database, and the logs show no repeated grant or authentication errors over a full collection cycle.
Alerting on database health alongside application traces
The main reason to collect PostgreSQL metrics through the Collector is to answer a specific question during an incident: is a slow endpoint slow because of database load? That only works if the database metrics and the application's OTLP traces can be joined. Both pass through the same Collector, so the resource processor can add shared attributes such as service.name, deployment.environment and the host or cluster identifiers to the PostgreSQL metrics. Confirm with the application team which resource attributes their SDKs send, and whether the database hostname in their spans matches the host.name or server.address value the receiver emits. If the names differ, the join fails silently, and the first real incident is the wrong time to find out.
Alert design for this data should stay general until the team has a baseline. Alert on symptoms that matter to users and on conditions the database cannot recover from by itself, such as connections approaching the configured limit, replication falling behind on a standby, or a sustained rise in lock waits. Thresholds belong in the alerting back end, where they can be tuned, versioned and tested against the metric history, not hard-coded into the Collector configuration. The receiver's metrics are in beta, so check each metric name against the receiver README for the Collector version you deploy before writing rules that depend on it, and plan to review the rules after each Collector upgrade.
Once alerts fire, the trace and metric views should be linked in the back end so an on-call engineer can move from a slow span to the matching database panel in one step. Test this with a planned load test, not an outage: generate slow queries against a non-production database, confirm the spans and metrics carry the same identifiers, and confirm the alert routes to the right team. Record the results and the threshold values in the runbook, because the baseline you measure today is the reference for the next tuning cycle.
Securing the database connection and the telemetry it produces
The PostgreSQL receiver needs a database login, a network path to the server and a Collector that handles credentials and sensitive values. Each of the controls below closes a different gap, and they are best planned together before the first metric leaves the database.
Least-privilege monitoring grants
Create a dedicated monitoring role instead of reusing an application or administrator account. The receiver needs SELECT on pg_stat_database to read its metrics, so start there and add nothing else until a specific metric requires it. Confirm the grant set against the receiver README for your Collector version, and check that the role cannot read application tables or change settings.
Receiver READMEEncrypted connections to PostgreSQL
Configure the receiver's connection so that credentials and query results cross the network under TLS, and verify the server certificate rather than skipping verification. Check the pg_hba.conf entry that matches the monitoring role so that it requires an encrypted connection from the Collector's address only. Confirm the TLS settings your Collector version supports in the receiver documentation before you rely on them.
Stronger password authentication
Confirm that the monitoring role uses SCRAM rather than MD5 password authentication, since PostgreSQL 18 deprecated MD5 in favor of SCRAM. Review which authentication methods your server accepts for remote connections, and document the choice in the same change record as the grant. If your organization uses centralized identity, ask whether the database supports that method for this role before you adopt it.
Authentication methodsStoring Collector configuration securely
The receiver configuration holds the database password, so keep it out of plain-text files in source control and out of container images. Load credentials from a secret store or environment injection managed by your platform, restrict read access to the Collector's service account, and rotate the monitoring password on a schedule your security team sets. Ask who can view the rendered configuration in your deployment tooling.
Config best practicesRedacting sensitive attributes
Query-related telemetry can carry values that should not reach a back end, so add the redaction processor to remove sensitive attributes before export. Review what each signal contains in a test environment, then write rules for the attribute names you find. Treat this as a check to repeat after each Collector upgrade, because attribute sets can change between releases.
Binding servers and building minimal distributions
Since v0.110.0, Collector server components bind to localhost by default, so any receiver you expose to other hosts needs an explicit bind address and an authentication extension. Build your Collector with the Collector Builder and include only the receivers, processors and exporters this pipeline uses. Confirm the bind and component list in the release notes for the version you deploy.
Collector configurationWhich PostgreSQL versions and upgrades affect the receiver
PostgreSQL 18, 17, 16, 15 and 14 are the versions still receiving support, with end dates of November 14, 2030, November 8, 2029, November 9, 2028, November 11, 2027 and November 12, 2026 respectively. Confirm your exact major version with a query such as SHOW server_version; before you write the receiver configuration, because metric names and available views can differ between majors.
- Version 18: First released September 25, 2025, and supported until November 14, 2030, the longest window in the current list.
- Version 17 and 16: Supported until November 8, 2029 and November 9, 2028. Check your fleet for mixed majors, since one receiver config may cover several clusters.
- Version 15: Supported until November 11, 2027. Plan its upgrade path while the receiver is still in service.
- Version 14: Supported until November 12, 2026. Treat it as the nearest end-of-life date on your list and schedule a major upgrade ahead of it.
- Receiver check: After any version change, confirm the monitoring user can still read
pg_stat_databaseand that the metrics you alert on still appear.
Record the major version in your monitoring inventory so alert owners know which end-of-support date applies to each cluster.
PostgreSQL 13 and earlier no longer receive community fixes. The receiver itself does not stop working on those versions by default, but an unsupported database server is a security and stability risk that monitoring cannot offset. Treat any cluster on these versions as an upgrade item before you rely on its metrics for compliance evidence or incident response.
- Security exposure: Unsupported releases do not receive new security patches, so the database layer stays exposed even when the Collector is hardened.
- Metric drift: Behavior and statistics views may differ from supported releases. Compare a sample of metrics against a supported cluster before you accept them.
- Planning: Ask your platform team which clusters remain on 13 or earlier and whether any are in a dependency chain you cannot upgrade quickly.
- Receiver check: If you keep an older cluster temporarily, document the exception, the receiver version and the review date in your risk register.
- Scope note: Ask the vendor or your database team to confirm any extended support arrangements, since none are described in the supplied sources.
Before you remove an unsupported cluster from monitoring, confirm the metrics you need are available from its replacement so alerts do not go silent.
Minor PostgreSQL releases do not change the internal storage format. Updating means replacing the executables and restarting the server, so data files stay where they are. PostgreSQL publishes minor releases at least once every three months, which makes this the most frequent change your receiver will see. Because the data format is unchanged, the receiver configuration usually does not need to change either.
- Executables and restart: Replace binaries, then restart the server. Plan a window for the restart and for the Collector to reconnect.
- Connection checks: Confirm the monitoring user can still log in after the restart, especially if you rotated credentials or authentication settings during the update.
- Metric continuity: Check that counters from
pg_stat_databaseresume normally, and that dashboards do not show a false reset that triggers an alert. - Receiver version: Check whether the Collector release you run supports the server version you now use. The Collector release notes are the place to verify this.
- Rollback record: Keep the previous binary package and the change ticket so you can return quickly if a regression appears.
After each minor update, run one scrape and compare the result with the last known good baseline before you close the change.
A major upgrade changes the on-disk format, so you must choose a migration method. The documented options are a dump and restore with pg_dumpall, pg_upgrade, or logical replication between versions. Logical replication allows a major upgrade with only several seconds of downtime, according to PostgreSQL's upgrading documentation, but it needs more preparation. Each method changes the database object identifiers and statistics in different ways, so the receiver must be re-verified after the cutover.
- Dump and restore: Simplest to reason about, but downtime grows with data size. Re-create the monitoring user and its grants on the new cluster.
- pg_upgrade: Faster for large clusters. For PostgreSQL 18, pg_upgrade retains planner statistics and adds parallel jobs and a
--swapoption, which affects how quickly the new cluster is ready for queries. - Logical replication: Lowest downtime, with extra work to set up publications, subscriptions and conflict handling. Confirm the publisher and subscriber versions are both supported.
- Receiver check: After any path, confirm
pg_stat_databaseis readable by the monitoring user, the connection string points at the new cluster and the metrics you alert on have current values. - Verification: Compare the first hour of metrics with a pre-upgrade baseline to catch silent gaps.
Ask your database team to confirm which method suits your data volume and downtime limit, then write that decision into the change plan.
Limits to confirm in your environment before rollout
The PostgreSQL receiver depends on several moving parts: its own maturity, the Collector release line, the connection path between the receiver and the database, and the replication and failover setup behind the server it scrapes. Each card names one limit and what to confirm before a production rollout.
Beta metric status
The receiver's metrics are in beta, so their names, attributes and behavior may change between Collector releases. Before rollout, read the receiver README for the metrics you plan to alert on, decide which ones your dashboards and alert rules depend on, and record the Collector version you tested. Pin that version in your deployment so a routine upgrade does not silently change what your alerts see.
- Metrics stability
- Beta
Per-metric stability differences
Stability is set per component and can differ by metric, so a receiver can be usable overall while some of its metrics are less settled. Confirm each metric your alerting needs against the component README rather than assuming the receiver's headline status applies to all of them. Keep a short list of the metrics your runbooks rely on, and review it at each Collector upgrade.
OpenTelemetry statusCollector release cadence
Contrib Collector releases arrive every few weeks. The latest supplied release is v0.163.0, published on October 16, 2026, after v0.162.0 on September 29 and v0.161.0 on September 16, 2026. Plan a regular review window for Collector upgrades, check release notes for receiver changes, and confirm which release line your organization will standardize on before you build dashboards on top of it.
Collector releasesPgBouncer changes the server seen
If applications connect through PgBouncer, the receiver's connection path determines which server and which pool statistics it reads. Confirm whether the receiver connects directly to PostgreSQL or through the pooler, and whether per-database statistics still match what you expect. Connection pooling changes the answer to the question "which backend is this?", so document the endpoint each receiver instance scrapes.
PgBouncer projectReplicas and failover left to you
PostgreSQL supports hot standby servers and both synchronous and asynchronous replication, but it does not detect a primary failure or notify a standby. Automatic failover needs external tools, so the receiver target must follow your failover design. Confirm which node is the primary after a switchover, how the receiver is repointed, and whether standby metrics are monitored separately.
PostgreSQL failover docsTest on a non-production cluster first
Run the receiver against a non-production cluster with a monitoring user that has the same grants planned for production. Confirm that the receiver reads the expected database, that metrics arrive at the back end with the expected names, and that connection counts stay within limits. Only promote the configuration after a failover drill and a Collector restart have been tested.
Questions buyers ask before monitoring PostgreSQL with the Collector
Can our team set up PostgreSQL monitoring with the Collector without a partner?
Yes, a team with PostgreSQL administration and Collector experience can usually do the basic setup in-house. The receiver is configured in the Collector, and the work centers on creating a monitoring role with the SELECT grant on pg_stat_database that the receiver README describes, then wiring metrics to your back end. The harder parts are deciding which metrics matter, protecting the monitoring connection, and building alerts that your on-call team will trust. If nobody on the team has run the Collector in production, a partner can shorten the learning curve, but the decision depends on your skills and staffing, not on the receiver alone.
What does the work need from our team?
You need a PostgreSQL owner who can approve a monitoring role and confirm which databases and clusters are in scope, an application owner who can explain which services produce traces, and someone who controls the back end where metrics will be stored. You also need access to the Collector host or Kubernetes namespace, and a decision on how credentials will be stored. Expect the database team to review grants and the security team to review network paths between the Collector and PostgreSQL. Agreeing these owners early prevents most delays in a fixed-scope engagement.
What drives the effort and cost of this work up or down?
The main drivers are the number of PostgreSQL instances, whether they run as primaries, hot standbys or behind a pooler such as PgBouncer, and how many back ends receive the data. Cost also rises with the number of alert rules, dashboards and application trace links you ask for, and with the security review your organization requires for database credentials. Work goes down when instances follow a single pattern and a Collector deployment already exists. Ask the provider to list each cluster, back end and review step as separate line items in the written scope.
How long does setup take?
Duration depends on scope, so no fixed figure applies. The timeline is driven by the number of database clusters, the readiness of your Collector and back end, the time needed for database and security approvals, and how many alert and dashboard reviews you require. A single instance with an existing Collector and back end is much simpler than a fleet across several networks. Ask for milestones tied to specific deliverables, such as a working receiver for one instance, verified metric coverage, and handover of alert rules, rather than one overall date.
Does the PostgreSQL receiver replace our existing PostgreSQL monitoring tool?
Not automatically. The receiver collects database metrics and sends them through the Collector, but it does not decide what your alerts or dashboards show, and it does not replace the storage and visualization your team already uses. Many teams run it alongside an existing monitoring product during a transition so they can compare coverage before retiring anything. Check each metric you depend on against the receiver's documentation, because the PostgreSQL receiver is beta for metrics, and confirm that the receiver covers the signals your runbooks use before removing any existing check.
Which security risks should we review before connecting the Collector to PostgreSQL?
Review the monitoring role first, because it should have only the grants the receiver needs, and confirm that the connection uses encryption and authentication. OpenTelemetry's security guidance recommends storing Collector configuration securely, building only the components you need with the Collector Builder, and using the redaction processor to remove sensitive attributes. Also check that the Collector's server components are not exposed beyond the networks that need them, since they bind to localhost by default from v0.110.0 onward. Ask the provider to show how credentials are stored and rotated.
What should we ask for in a written quote?
Ask for a list of in-scope PostgreSQL instances and versions, the back end and Collector deployment pattern, and the specific metrics and alerts to be delivered. Request the monitoring role design, the credential handling method, and the test plan showing which metrics were verified. Confirm who performs each task, which items are one-time and which recur, such as Collector upgrades or alert tuning, and what happens if scope changes. Also ask what your team must provide and by when. DeployOpen plans engagements as fixed scope, with deliverables and timelines agreed in writing before work starts.
How DeployOpen scopes and delivers PostgreSQL monitoring
DeployOpen approaches Monitoring PostgreSQL with the OpenTelemetry Collector as a written, fixed-scope piece of work inside your own infrastructure. We agree which databases, metrics and monitoring roles are in scope, then build, test, document and hand over the receiver configuration and the alerting it feeds.
How we scope
- We list the PostgreSQL clusters, versions and hosts that the receiver will monitor, and which databases are included.
- We agree the monitoring role, its grants and how credentials are stored and rotated in your secrets system.
- We record which metrics feed dashboards and alerts, and which signals are out of scope, in a written document before work starts.
How we build
- We configure the PostgreSQL receiver in your Collector deployment, including connection settings and TLS where your policy requires it.
- We connect the database metrics to the same pipeline as application traces, so teams can compare query latency with database load.
- We test the receiver against a non-production cluster, confirm the monitoring user can read the required views, and check dropped or missing metrics.
How we hand over
- We deliver the Collector configuration, grant scripts and a record of the Collector version and components used.
- We document alert rules, dashboard panels, known metric gaps and the steps for adding a new PostgreSQL instance.
- We walk your platform and database teams through the runbook so they can change thresholds and roles without us.
How we support
- Ongoing support, Collector upgrades and continuous testing are available as retainers, agreed separately from the fixed scope.
- We plan Collector version changes against the receiver's beta metric status and retest after each upgrade you approve.
- Before a PostgreSQL major upgrade, we can review whether the receiver, grants and dashboards still match the new version's views.

