MongoDB

Atlas Download Logs

MongoDB Atlas is a full-managed cloud database for deploying and managing your MongoDB database on cloud services such as AWS, Google Cloud, Azure, etc.

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:

$ sudo apt-get update

Install the GNUPG package:

$ sudo apt-get install gnupg -y

Import the MongoDB public GPG key with the following command:

$ wget -qO - https://pgp.mongodb.com/server-5.0.asc | sudo apt-key add -

Create the repository file for MongoDB with the following command:

$ echo "deb http://repo.mongodb.org/apt/debian buster/mongodb-org/5.0 main" | sudo tee /etc/apt/sources.list.d/mongodb-org-5.0.list

Refresh the system packages:

$ sudo apt-get update

Install the MongoDB Atlas and Atlas CLI using the following command:

$ sudo apt-get install mongodb-atlas mongodb-atlas-cli

Verify that the installation is completed successfully. Run the following command to show the current Atlas version:

$ atlas --version

The previous command should return an output as shown in the following:

atlascli version: 1.1.7
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:

$ atlas auth login

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:

$ atlas logs download <hostname> <mongodb.gz|mongos.gz|mongosqld.gz|mongodb-audit-log.gz|mongos-audit-log.gz> [options]

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.

About the author

John Otieno

My name is John and am a fellow geek like you. I am passionate about all things computers from Hardware, Operating systems to Programming. My dream is to share my knowledge with the world and help out fellow geeks. Follow my content by subscribing to LinuxHint mailing list