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

Prerequisites

Configure the Collector

MongoDB 4.4+ writes one structured JSON object per line. Parse it with the json_parser operator:
/etc/otel/config.yaml
receivers:
  filelog/mongodb:
    include:
      - /var/log/mongodb/mongod.log
    operators:
      - type: json_parser
    resource:
      service.name: mongodb
      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/mongodb]
      processors: [batch]
      exporters: [otlphttp/brontologs]
Set <REGION> to eu or us.

What you will see in Bronto

Open Search and filter by service.name = mongodb. Each entry carries a timestamp (t), severity (s), component (c — e.g. NETWORK, QUERY, REPL), context (ctx), and message (msg); slow operations include the command, namespace, and durationMillis under attr. The json_parser promotes these to searchable fields.

Troubleshooting

  • Older MongoDB (pre-4.4) writes plain text, not JSON. Drop the json_parser operator and let Bronto’s Custom Parser extract fields server-side.
  • Log volume: raising systemLog.verbosity greatly increases output — keep it low in production.
  • For general issues, see OTel Collector troubleshooting.

Alternative: Fluent Bit

If you already run Fluent Bit, tail the MongoDB log file and forward it over HTTP:
fluent-bit.conf
[INPUT]
    name  tail
    path  /var/log/mongodb/mongod.log
    tag   mongodb

[OUTPUT]
    name        http
    match       mongodb
    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    mongodb
    header      x-bronto-collection <YOUR_COLLECTION_NAME>
Set Format to json_lines, not json. See Connect Fluent Bit to Bronto for installation.