Skip to main content
Collect MongoDB server logs with the OpenTelemetry filelog receiver and send them to ClickHouse Observability. Use the demo dataset to try the integration without a MongoDB deployment.

Prerequisites

  • A ClickHouse Observability service
  • Docker and curl
  • For your own logs, a self-managed MongoDB 4.4 or newer deployment with access to its JSON log files

Connection details

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/logs suffix; the exporter appends the signal path.
The endpoint must be reachable from the collector container. For a destination collector running on this computer, use http://host.docker.internal:4318. The Docker commands below include the host mapping.

Integration with existing MongoDB

1

Verify MongoDB logging configuration

MongoDB 4.4 and newer use structured JSON server logs. Check the systemLog section in your MongoDB configuration file. A common Linux log path is /var/log/mongodb/mongod.log.If MongoDB logs only to stdout, configure file logging in mongod.conf:
Create the directory with permissions that let MongoDB write and the collector read it. For containerized deployments, share the log directory with the collector and ensure MongoDB loads the configuration file.Restart MongoDB using your deployment process, for example:
2

Configure the collector

Save this as mongodb-monitoring.yaml:
The parser reads MongoDB’s timestamp and severity fields, moves msg into the log body, and keeps fields such as c, ctx, id, and attr as log attributes. Keep $$date as written: the collector resolves the escaped dollar sign to MongoDB’s $date field. The live receiver reads new entries with start_at: end.
3

Run the collector

Set the connection variables, then run from the configuration directory. Adjust the host log path if needed. For group-readable files, add --group-add LOG_GROUP_ID using the numeric group shown by ls -ln /var/log/mongodb.
Leave the terminal open and generate server activity that writes new log entries. Stop with Ctrl+C when finished testing.
4

Verify logs

Open Search, select Logs, filter for ServiceName:mongodb-service, and select Last 15 minutes. You should see server messages with parsed timestamps and severity.

Demo dataset

The sample contains 6,956 MongoDB server log entries spanning approximately 24 hours. The collector refreshes their timestamps while preserving messages and structured attributes.
1

Download the sample

2

Configure the demo collector

Save this as mongodb-demo.yaml:
3

Run the demo collector

Set the connection variables, then run from the directory containing both files:
Leave the terminal open while verifying ingestion. Stop with Ctrl+C when finished. Running the demo again re-ingests the sample with refreshed timestamps.
4

Verify demo logs

Open Search, select Logs, filter for ServiceName:mongodb-demo, and select Last 2 days.

Dashboards and visualization

1

2

Import the dashboard

  1. Open Dashboards and click Import in the upper-right corner.
  2. Upload mongodb-logs-dashboard.json.
  3. Map the charts to your Logs source and click Finish Import.
3

View the dashboard

For the sample, optionally filter for ServiceName:mongodb-demo and select Last 2 days. For your own logs, use ServiceName:mongodb-service and a time range covering your records.

Troubleshooting

No logs appearing

Check the collector output for file permission, parsing, authentication, or export errors. Confirm your server writes to the mounted directory and the filenames match the receiver’s include list. The live configuration reads new entries only.

Logs not parsing correctly

Verify the file contains one JSON object per line:
The parser expects MongoDB 4.4+ JSON logs. Legacy text logs require a different parser. Preserve the $$date escaping in the collector configuration.

Next steps