Dash0 Logo
Infrastructure MonitoringLog ManagementApplication Performance ManagementDistributed TracingKubernetes MonitoringWebsite MonitoringSynthetic MonitoringDashboardsAlertingService MapIntegrationsTransparent CostObservability as Code
PricingDocs
GuidesBlogKnowledgeComparisonsPodcastNewsletterIntegerationsChangelog
Contact usMeet our TeamCareersSecurity
  • Book A Demo
  • Sign In
  • Start Free Trial
Book a demoSign in
Start Free Trial

Resources

  • Pricing
  • Blog
  • Guides
  • Knowledge
  • Comparisons
  • Integrations
  • Documentation
  • Glossary
  • OTelBin.io
  • Sitemap

Company

  • Our Team
  • Careers
  • Trust Center
  • Security

Compare

  • Datadog
  • Grafana
  • Dynatrace
  • New Relic
  • Elastic
  • Honeycomb
  • Sentry

Contact

  • Contact us
  • GitHub
  • LinkedIn
  • X
  • YouTube
  • Dash0 Newsletter
  • Terms and Conditions
  • Privacy Policy
  • Data Processing Agreement
  • Vulnerability Disclosure

©2025 Dash0 Inc.

Hub/PostgreSQL

Technology

PostgreSQL

Monitor PostgreSQL database performance, query execution, and resource utilization. Track connection pools, disk usage, replication lag, and database health.

Overview

Overview

PostgreSQL is a powerful, open-source relational database system renowned for its reliability, feature robustness, and performance. It supports advanced SQL features, complex queries, and provides extensibility with custom data types, operators, and functions.

Use Cases

  • Monitor database connection pools and active sessions
  • Track query execution time and slow queries
  • Analyze disk usage and table statistics
  • Monitor replication lag and streaming replication health
  • Track transaction rates, commits, and rollbacks
  • Monitor buffer cache efficiency and I/O operations

Dashboards

PostgreSQL Overview

PostgreSQL monitoring dashboard showing database metrics, connection health, and performance statistics

[database]
[performance]
[postgresql]
PostgreSQL overview
In this section
    TechnologyOverviewUse CasesSetupOverviewPrerequisitesSetting up PostgreSQLManual PostgreSQL SetupCollector ConfigurationCollector ConfigurationCollector DeploymentVerificationReferencesDashboards

Setup

Overview

PostgreSQL exposes comprehensive metrics through its built-in statistics views that can be collected using the OpenTelemetry Collector's PostgreSQL receiver. This integration provides deep visibility into database performance, query execution, connection management, and resource utilization.

Prerequisites

Before setting up PostgreSQL monitoring, ensure:

  • PostgreSQL is running and accessible
  • You have credentials to connect to the PostgreSQL database
  • The pg_stat_statements extension is enabled for query-level metrics (optional but recommended)
  • OpenTelemetry Collector is deployed in your environment using the OpenTelemetry Collector Contrib distribution.

Setting up PostgreSQL

For Kubernetes environments, we recommend using a PostgreSQL operator for production-ready deployments. Here's an example using CloudNativePG, which provides comprehensive PostgreSQL clusters with built-in monitoring capabilities.

Note: This is just one example of a production setup. You can use any PostgreSQL deployment method (including other operators like Zalando PostgreSQL Operator, CrunchyData PGO, or manual deployments) as long as the PostgreSQL receiver can connect to your database.

Install CloudNativePG Operator

Deploy a PostgreSQL Cluster

Here's a simple example that relies on CloudNativePG's defaults:

Production Tips

For production environments:

  1. Use Kubernetes Secrets - Use CloudNativePG's secret management features instead of inline passwords
  2. Set instances: 3 for high availability
  3. Use dedicated app user instead of postgres superuser as the database owner
  4. Adjust resources based on your workload
  5. Use secure storage class with encryption at rest

Manual PostgreSQL Setup

For non-Kubernetes environments or custom setups:

Enable pg_stat_statements Extension

For comprehensive query monitoring, enable the pg_stat_statements extension:

PostgreSQL Configuration

Add to your postgresql.conf:

Enable the Extension

Connect to your database and run:

Create Monitoring User

For security best practices, create a dedicated monitoring user with the built-in pg_monitor role:

Collector Configuration

The OpenTelemetry Collector uses the PostgreSQL receiver to collect metrics from PostgreSQL statistics views. Add the following configuration to your OpenTelemetry collector:

Collector Configuration

Add the PostgreSQL receiver to your collector configuration:

For more options see the PostgreSQL receiver documentation

Collector Deployment

Deploy the OpenTelemetry Collector with the PostgreSQL receiver configuration. For detailed deployment instructions, see our other integrations for deploying the OpenTelemetry Collector:

  • OpenTelemetry Operator for Kubernetes
  • Helm Chart for The OpenTelemetry Collector

Verification

After configuring the collector, verify that metrics are being collected:

  1. Check the collector logs for successful connections to PostgreSQL
  2. Navigate to the Metrics Explorer in Dash0
  3. Search for metrics with prefix postgresql.*
  4. Confirm connections and capacity metrics are visible:
    • postgresql.backends (active connections)
    • postgresql.connection.max (configured max connections)
    • postgresql.db_size (database size in bytes)
    • postgresql.commits (transaction commits)
    • postgresql.rollbacks (transaction rollbacks)

References

  • OpenTelemetry PostgreSQL Receiver Documentation
  • CloudNativePG Documentation
  • CloudNativePG Security Guide
  • PostgreSQL Statistics Views
  • pg_stat_statements Extension
  • PostgreSQL Monitoring Best Practices