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
logging_collector = on
log_min_duration_statement = 1000   # log statements slower than 1s
log_connections = on
log_disconnections = on

Configure the Collector

PostgreSQL entries can span multiple lines (statements, context). Use multiline keyed on the leading timestamp:
/etc/otel/config.yaml
receivers:
  filelog/postgresql:
    include:
      - /var/log/postgresql/*.log
    multiline:
      line_start_pattern: '^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}'
    resource:
      service.name: postgresql
      service.namespace: <YOUR_COLLECTION_NAME>

processors:
  batch:

exporters:
  otlphttp/brontologs:
    logs_endpoint: "https://ingestion.<REGION>.bronto.io/v1/logs"
    compression: gzip
    headers:
      x-bronto-api-key: <YOUR_API_KEY>

service:
  pipelines:
    logs:
      receivers: [filelog/postgresql]
      processors: [batch]
      exporters: [otlphttp/brontologs]
Set <REGION> to eu or us.

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
[INPUT]
    name  tail
    path  /var/log/postgresql/*.log
    tag   postgresql

[OUTPUT]
    name        http
    match       postgresql
    host        ingestion.<REGION>.bronto.io
    port        443
    tls         on
    format      json_lines
    compress    gzip
    header      x-bronto-api-key    <YOUR_API_KEY>
    header      x-bronto-dataset    postgresql
    header      x-bronto-collection <YOUR_COLLECTION_NAME>
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.