Skip to main content
Collect logs from a self-hosted PostgreSQL server — errors, slow queries, and connection activity — with the OpenTelemetry Collector. The same Collector can also forward traces and metrics from your apps — see Connect OpenTelemetry Collector to Bronto.

Prerequisites

  • A Bronto account and API key (how to create one)
  • PostgreSQL writing logs to disk. The default log_directory lives under the data directory; Debian/Ubuntu packages use /var/log/postgresql/
  • An OpenTelemetry Collector (recommended) or Fluent Bit installed on the same host
To capture useful detail, set these in postgresql.conf and reload:
postgresql.conf

Configure the Collector

PostgreSQL entries can span multiple lines (statements, context). Use multiline keyed on the leading timestamp:
/etc/otel/config.yaml
Set <REGION> to eu or us.

Metrics

The Collector Contrib postgresql receiver collects database size, connection, transaction, block, row, and replication metrics through a read-only database connection:
Add this receiver to the Bronto metrics pipeline. Check the Collector Contrib PostgreSQL receiver documentation for permissions and measurements available in your PostgreSQL and Collector versions.

What you will see in Bronto

Open Search and filter by service.name = postgresql. Entries include slow-query lines (with duration and statement text), connection and disconnection events, errors, and warnings — each prefixed with a timestamp, process ID, and severity. Bronto’s Custom Parser extracts these fields server-side.

Troubleshooting

  • Where are the logs? Run SHOW log_directory; and SHOW log_filename; in psql, or read $PGDATA/current_logfiles. Adjust the include path to match.
  • Want structured fields at the source? On PostgreSQL 15+, set log_destination = 'jsonlog' for JSON log files (*.json) and point include at them for direct field extraction.
  • For general issues, see OTel Collector troubleshooting.

Alternative: Fluent Bit

If you already run Fluent Bit, tail the PostgreSQL log files and forward them over HTTP:
fluent-bit.conf
Set Format to json_lines, not json. For statements that span lines, add a multiline.parser keyed on the leading timestamp. See Connect Fluent Bit to Bronto.