Docs » Available host and application monitors » Configure application receivers for databases » PostgreSQL

PostgreSQL ๐Ÿ”—

Description ๐Ÿ”—

The Splunk Distribution of OpenTelemetry Collector deploys this integration as the postgresql monitor type for the Smart Agent Receiver.

This monitor pulls metrics from all PostgreSQL databases from a specific Postgres server instance. This monitor pulls basic information that is applicable to any database and gathers these metrics using SQL queries.


This monitor is deprecated in favor of the postgresql receiver. Switch to that receiver as the Smart Agent is deprecated. To learn more, see PostgreSQL receiver.

Benefits ๐Ÿ”—

After you configure the integration, you can access these features:

  • View metrics. You can create your own custom dashboards, and most monitors provide built-in dashboards as well. For information about dashboards, see View dashboards in Observability Cloud.

  • View a data-driven visualization of the physical servers, virtual machines, AWS instances, and other resources in your environment that are visible to Infrastructure Monitoring. For information about navigators, see Splunk Infrastructure Monitoring navigators.

  • Access the Metric Finder and search for metrics sent by the monitor. For information, see Use the Metric Finder.

Installation ๐Ÿ”—

This monitor is provided by the Smart Agent and is available for the Smart Agent Receiver in the Splunk Distribution of OpenTelemetry Collector.

Follow these steps to deploy this integration:

  1. Deploy the Splunk Distribution of OpenTelemetry Collector to your host or container platform:

  2. Configure the monitor, as described in the Configuration section.

  3. Restart the Splunk Distribution of OpenTelemetry Collector.

To report all available metrics, activate the pg_stat_statements extension in your PostgreSQL deployment. This extension must be specified in the shared_preload_libraries configuration option in the main PostgreSQL configuration at server start up. You must also activate the extension for each database by running CREATE EXTENSION IF NOT EXISTS pg_stat_statements; on each database.

Note that to get consistent and accurate query execution time metrics, you must set the pg_stat_statements.max configuration option to larger than the number of distinct queries on the server.

Here is a sample configuration of Postgres to activate statement tracking.

This configuration was tested with PostgreSQL 9.2+.

If you want to collect additional metrics about PostgreSQL, use the sql monitor.

Configuration ๐Ÿ”—

To use this integration of a Smart Agent monitor with the Collector:

  1. Include the Smart Agent receiver in your configuration file.

  2. Add the monitor type to the Collector configuration, both in the receiver and pipelines sections.

    type: postgresql
    ...  # Additional config

To complete the monitor activation, you must also include the smartagent/postgresql receiver item in a metrics pipeline. To do this, add the receiver item to the service/pipelines/metrics/receivers section of your configuration file. For example:

      receivers: [smartagent/postgresql]

See configuration examples for specific use cases that show how the Splunk Distribution of OpenTelemetry Collector can integrate and complement existing environments.

Configuration settings ๐Ÿ”—

The following table shows the configuration options for the postgresql monitor:











(default: 0)




The โ€œmasterโ€ database to which the agent first connects to query the list of databases available in the server. This database should be accessible to the user specified with connectionString and params below, and that user should have permission to query pg_database. If you want to filter which databases are monitored, use the databases option below. (default: postgres)




See Connection String Parameters.



map of strings

Parameters to the connection string that can be templated into the connection string with the syntax {{.key}}.



list of strings

List of databases to send database-specific metrics about. If omitted, metrics about all databases will be sent. This is an overridable set. (default: [*])




How frequently to poll for new/deleted databases in the DB server. Defaults to the same as intervalSeconds if not set. (default: 0)




If true, queries will be logged at the info level. (default: false)




The number of top queries to consider when publishing query-related metrics (default: 10)

The following is an exampleย postgresqlย Smart Agent monitor configuration. This example uses the Vault remote configuration source to connect to PostgreSQL using the params map. This map allows you to pull out the username and password individually from Vault and interpolate them into the connectionString configuration option.

 - type: postgresql
   connectionString: 'sslmode=disable user={{.username}} password={{.password}}'
   params: &psqlParams
     username: {"#from": "vault:secret/my-database[username]"}
     password: {"#from": "vault:secret/my-database[password]"}
   discoveryRule: 'container_image =~ "postgres" && port == 5432'

 # This monitor will monitor additional queries from PostgreSQL using the
 # provided SQL queries.
 - type: sql
   dbDriver: postgres
   connectionString: 'sslmode=disable user={{.username}} password={{.password}}'
   # This is a YAML reference to avoid duplicating the above config.
   params: *psqlParams
     - query: 'SELECT COUNT(*) as count, country, status FROM customers GROUP BY country, status;'
         - metricName: "customers"
           valueColumn: "count"
           dimensionColumns: ["country", "status"]

Metrics ๐Ÿ”—

The following metrics are available for this integration:

Notes ๐Ÿ”—

  • Learn more about the available metric types in Observability Cloud.

  • Default metrics are those metrics included in host-based subscriptions in Observability Cloud, such as host, container, or bundled metrics. Custom metrics are not provided by default and might be subject to charges. See more about metric categories.

  • To add additional metrics, see how to configure extraMetrics using the Collector.

Metrics about replication ๐Ÿ”—

Replication metrics canโ€™t be available on some PostgreSQL servers. For now, this monitor automatically deactivates the replication metrics group if the monitor detects Aurora. This helps avoid following the error: Function pg_last_xlog_receive_location() is currently not supported for Aurora

The metric postgres_replication_state will be reported only for master and for postgres_replication_lag for the standby role (replica).

Get help ๐Ÿ”—

If you are not able to see your data in Splunk Observability Cloud, try these tips:

To learn about even more support options, see Splunk Customer Success.