Prerequisites
- A ClickHouse Observability service
- Docker and
curl - For your own metrics, PostgreSQL 14 or newer reachable from the collector, and a monitoring user
Connection details
- Fully managed
- Self-managed
Open ClickHouse Observability and go to Team Settings → Data → Managed Telemetry. Copy your OTLP HTTP endpoint and API key. You can use Copy connection details to copy the configuration, or Reveal key to view the masked key.For the OTLP exporter examples below, set these variables in the terminal where you will run the collector:Replace the placeholders with the exact endpoint, including its port, and API key from your service. Use the base HTTP endpoint without a
/v1/metrics suffix; the exporter appends the signal path.http://host.docker.internal:4318. The Docker commands below include the host mapping.
Integration with existing PostgreSQL
1
Configure the monitoring user
As a PostgreSQL administrator, create a monitoring user if you do not already have one, and grant access to statistics:Grant For PostgreSQL on the Docker host, use
CONNECT on each database you want to monitor. Ensure PostgreSQL accepts connections from the collector through its network and pg_hba.conf settings.Set the database connection variables in the same terminal as your OTLP connection variables:host.docker.internal:5432. For containers on a shared Docker network, use the database container hostname and add --network YOUR_NETWORK to the collector command.2
Configure the collector
Save this as This configuration enables TLS and verifies the server certificate. For a private CA, set
postgres-metrics.yaml. Replace the databases list with your database names:tls.ca_file and mount the CA file into the collector. For a local PostgreSQL server without TLS, set tls.insecure: true; this disables TLS for the database connection. See the PostgreSQL receiver configuration.3
Run the collector
4
Verify metrics
Open Chart Explorer, select your Metrics source, filter for
ServiceName:postgresql-service, and select Last 15 minutes. Look for postgresql.backends, postgresql.commits, or postgresql.db_size.Demo dataset
The sample contains 8,928 gauge and sum points sampled every five minutes across 24 hours. It preserves the original dataset’s connection spikes, cache activity, rollbacks, and deadlocks. The sample includes database-level metrics; live collection also provides table and index metrics. Set the connection variables before starting.1
Download the sample metrics
Download the sample bundle (about 64 KB) and extract
postgres-metrics-demo.json into your working directory.2
Configure the demo collector
Save this as
postgres-metrics-demo.yaml:The demo-only transform refreshes timestamps while preserving metric values and the interval between each point’s start and end timestamps. Omit it for live PostgreSQL metrics. The batch limit keeps uploads small enough for the destination collector.
3
Run the demo collector
From the directory containing the configuration, run the collector and leave this terminal open:
4
Send the sample
In another terminal, run this command from the download directory:A response such as
{} or {"partialSuccess":{}} indicates the local collector accepted the request. Check the collector terminal for export errors and allow a few seconds for forwarding. Stop it with Ctrl+C after verifying the data. Sending the sample again can produce duplicate points.5
Verify the metrics
Import the dashboard in the next section, filter for
ServiceName:postgresql-demo, and select Last 2 days. The sample includes both gauge and sum metrics; no direct database access is needed.Dashboards and visualization
1
2
Import the dashboard
- Open Dashboards and click Import in the upper-right corner.
- Upload
postgres-metrics-dashboard.json. - Map the charts to your Metrics source and click Finish Import.
3
View the dashboard
For the sample, optionally filter for
ServiceName:postgresql-demo and select Last 2 days. For your own metrics, use ServiceName:postgresql-service and Last 15 minutes.Troubleshooting
Collector fails to start
Check the collector output for configuration errors. Confirm the configuration file is mounted and the connection variables are set in the terminal where Docker runs.No metrics appearing
Check the collector output for database connection or export errors. Confirm the database hostname is reachable from the container, the database names are correct, and PostgreSQL allows the monitoring user’s connection. Check your Metrics source, service-name filter, and time range.Authentication or TLS errors
Confirm the monitoring user haspg_monitor and CONNECT permissions. Test the database credentials with psql from a host that can reach PostgreSQL:
Next steps
- Set up alerts for connection limits, rollback rates, or cache performance.
- Collect PostgreSQL logs alongside your metrics.
- See Sending OpenTelemetry data for collector deployment guidance.