In this post, we will discuss on how you can download the MongoDB logs from MongoDB atlas. This will allow you to get the server logs into your local machine where you can pass them to tools such as Elasticsearch.
Let’s dive in and explore.
Install the Atlas CLI
Before proceeding to learn how to download the logs from your Atlas instance, it is good to ensure that we have the Atlas CLI installed on our system.
For this tutorial, we will install the Atlas CLI tools on Debian system. However, you can check the MongoDB documentation for installation instructions on the other systems.
Start by updating the system repositories:
Install the GNUPG package:
Import the MongoDB public GPG key with the following command:
Create the repository file for MongoDB with the following command:
Refresh the system packages:
Install the MongoDB Atlas and Atlas CLI using the following command:
Verify that the installation is completed successfully. Run the following command to show the current Atlas version:
The previous command should return an output as shown in the following:
git version: 2ac7d5cf94baa17b50e783a0f8a579695d9d0b4e
Go version: go1.18.2
os: linux
arch: amd64
compiler: gc
Connect Atlas CLI
The next step is to connect your Atlas CLI to your account. Run the following command in the terminal:
The previous command should generate a code and open a link to MongoDB Atlas login page. Paste the generated code from the terminal and enter to your authorization window.
This should connect your Atlas account to the Atlas CLI on your local machine.
Atlas CLI Download Logs
To download the logs from your MongoDB instance, use the Atlas CLI command as shown in the following:
You can also use the Atlas UI to download the logs you need.
Open the Altas interface and select the target project. Click on the ellipsis icon next to the cluster whose logs you wish to download.
Select the Download logs option and choose the logs that you wish to download.
Conclusion
This short tutorial discussed how to use the Atlas CLI and Atlas UI to download the logs from a MongoDB Atlas cluster.