Documentation forLoggly

MongoDB Logging

Loggly provides the infrastructure to aggregate and normalize log events so they are available to explore interactively, build visualizations, or create threshold-based alerting. In general, any method to send logs from a system or application to an external source can be adapted to send logs to Loggly. The following instructions provide one scenario for sending logs to Loggly.

You can send your MongoDB logs to Loggly. We will automatically parse fields like timestamp and module from the MongoDB log as well. This script configures the rsyslog daemon to monitor the log file for the newest events, and then sends them to Loggly. For alternatives, please see the Advanced Options section.

MongoDB Logging Setup

1. Setup File Monitoring for MongoDB

Use our automated script to setup file monitoring for the MongoDB log file, or manually configure file monitoring with rsyslog. Setup file monitoring for mongod.log file. This examples assumes Ubuntu. For RHEL and CentOS the file is /var/log/mongod.log.

curl -O https://www.loggly.com/install/configure-file-monitoring.sh
sudo bash configure-file-monitoring.sh -a SUBDOMAIN -u USERNAME -f /var/log/mongodb/mongod.log -l mongodb -tag MongoDB

Replace:

  • SUBDOMAIN: your account subdomain that you created when you signed up for Loggly
  • USERNAME: your Loggly username

2. Verify Events

Search Loggly for events with the tag MongoDB over the past hour. It may take few minutes to index the event. If if doesn’t work, see the troubleshooting section below.

tag:MongoDB

Click on one of the logs to show a list of mongo fields (see screenshot below). If you don’t see them, please check that you are using one of our automatically parsed formats.
MongoDB Logs Example

Advanced MongoDB Logging Options

  • MongoDB Automated Parsing – the lines we parse from the MongoDB logs
  • Log File Monitoring – how to setup file monitoring on any file
  • Log Rotation – if you use log rotation, you must add commands to refresh the files
  • RHEL and CentOS – the default file location is /var/log/mongod.log

Troubleshooting MongoDB Logs

If you don’t see any data show up in the verification step, then check for these common problems.

  • Wait a few minutes in case indexing needs to catch up
  • Check if mongodb log file exists on the path you included in the arguments and there are recent logs in it
  • Troubleshooting Rsyslog if the files are being written but not being sent to Loggly
  • Search or post your own MongoDB logging questions in the community forum.

The scripts are not supported under any SolarWinds support program or service. The scripts are provided AS IS without warranty of any kind. SolarWinds further disclaims all warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The risk arising out of the use or performance of the scripts and documentation stays with you. In no event shall SolarWinds or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the scripts or documentation.