Skip to main content
Sumo Logic

Collect Logs and Metrics for MongoDB

This page provides instructions for configuring log and metric collection for the Sumo Logic App for MongoDB.

Collection Process Overview

Configuring log and metric collection for the MongoDB App includes the following tasks:

Step 1: Configure Fields in Sumo Logic

Create the following Fields in Sumo Logic prior to configuring collection. This ensures that your logs and metrics are tagged with relevant metadata, which is required by the app dashboards. For information on setting up fields, see the Fields help page.

If you are using MongoDB in a non-Kubernetes environment create the fields:

  • component
  • environment
  • db_system
  • db_cluster

If you are using MongoDB in a Kubernetes environment create the fields:

  • pod_labels_component
  • pod_labels_environment
  • pod_labels_db_system
  • pod_labels_db_cluster

Sample Log Message

{"t":{"$date":"2021-05-21T10:22:57.373+00:00"},"s":"I","c":"NETWORK","id":51800,"ctx":"conn500659","msg":"client metadata","attr":{"remote":"127.0.0.1:49472","client":"conn500659","doc":{"application":{"name":"MongoDB Shell"},"driver":{"name":"MongoDB Internal Client","version":"4.4.4"},"os":{"type":"Linux","name":"PRETTY_NAME=\"Debian GNU/Linux 10 (buster)\"","architecture":"x86_64","version":"Kernel 4.4.0-62-generic"}}}}

Query sample 

Dashboard: MongoDB - Errors and Warnings, Panel: Errors by Component

environment=* db_cluster=* db_system=mongodb  | json "log" as _rawlog nodrop
| if (isEmpty(_rawlog), _raw, _rawlog) as _raw
| json field=_raw "t.$date" as timestamp
| json field=_raw "s" as severity
| json field=_raw "c" as component
| json field=_raw "ctx" as context
| json field=_raw "msg" as msg
| where severity in ("E")
| count by component