MongoDB Realm logs all incoming requests and application events such as user authentication, trigger execution, and service interactions. You can access your application's logs from the Logs page in the Realm UI or request them programmatically through the Realm Admin API. MongoDB Realm saves logs for 30 days.
A log entry describes a single event within MongoDB Realm. Different events in MongoDB Realm execute in different ways, requiring various permissions, underlying components and services. MongoDB Realm groups log entries based on the type of event or request that they record. Each type of log contains fields that describe that particular event or request. As a result, your application logs may include entries of the following types:
- Authentication Requests, including user creation, login, and deletion.
- Functions, including both Realm Functions as well as individual queries to linked MongoDB Atlas data sources made using the MongoDB service of the Realm SDK.
- Triggers, including Database Triggers, Authentication Triggers, and Scheduled Triggers.
- Service Requests, including webhooks and service action calls issued from the Realm SDK.
- Change Stream, including any time a user opens or closes a stream of change events.
- Schema changes, including any events related to changes to an application's schema.
- Sync events, including all events related to data synchronization between client devices and MongoDB Atlas.
Parts of a Log Entry¶
|Metadata||MongoDB Realm logs contain details like the status, timestamp, elapsed time, unique id, user, name, and type of a given log entry.|
|Request Info||Log entries can contain several types of request details, including event arguments, service name, function call location, compute resources used, remote IP address, SDK, platform version, and performance metrics. Requesting log entries via the Realm Admin API will expose these as top-level fields in log entry objects. On the Realm UI, clicking on a log entry will expose this information.|
|Arguments||MongoDB Realm logs the arguments passed to Functions, including requests made via the MongoDB service. Other log entries do not preserve a record of arguments.|
|Error Info||When a MongoDB Realm event exits unsuccessfully, it generates an Error log entry containing debugging information that can help diagnose what caused the issue.|
Because MongoDB Realm creates log entries for most common kinds of user interaction, it can become difficult to find a specific group of logs due to the sheer volume of logs an application generates. For performance reasons, MongoDB Realm limits individual queries to a maximum of 100 log entries per page. You can filter entries by type, status, timestamp, user, and request ID to return only logs that are relevant to your query.
All MongoDB Realm log entries have one of two possible statuses:
Error. If an event exits successfully, MongoDB Realm
OK log entry based on the event. If an
event does not exit successfully for any reason, MongoDB Realm
creates a log entry with a status of the MongoDB Realm error that
caused the problem. You may encounter errors if you:
- Attempt to access data from MongoDB Atlas for which there is no applicable rule
- Fail to catch an exception or promise rejection in a Realm Function
context.services.get()for a service which does not exist
- Call a MongoDB Atlas service action with invalid or missing parameters
method. MongoDB Realm stringifies each console log and stores each string
as a single line. MongoDB Realm truncates lines to 256 bytes in length.
For ASCII character sets, this translates to 256 characters; depending
on the character set you use, you may see truncation at lower character
MongoDB Realm saves only the first 10 log lines for a given log entry.
MongoDB Realm stores each output as a single string in the log entry's
MongoDB Realm retains logs for 30 days, after which point they are deleted. If you require logs older than 30 days, you can use the admin log API prior to the 30 day expiration date of each log to extract and externally store your log history.
|Authentication Logs||This page describes the form and content of authentication logs as well as the events that lead to their creation.|
|Change Stream Logs||This page describes the form and content of change stream logs as well as the events that lead to their creation.|
|Function Logs||This page describes the form and content of function logs as well as the events that lead to their creation.|
|Trigger Logs||This page describes the form and content of trigger logs as well as the events that lead to their creation.|
|Schema Logs||This page describes the form and content of schema logs as well as the events that lead to their creation.|
|Sync Logs||This page describes the form and content of sync logs as well as the events that lead to their creation.|