Skip to Main Content
Blog

Getting started with MongoDB dashboards

A step-by-step guide to visualizing your MongoDB data with SquaredUp dashboards.

MongoDB is a popular NoSQL database used by many modern web applications. Once your web application is up and running, you might find you need to monitor the application data for operational purposes. For example, you may need to report on user sign-ups, or monitor for problems like invalid data. SquaredUp is an easy-to-use dashboard that plugs directly into your MongoDB database to visualize and monitor your data.

In this article we’ll create a movie application dashboard like this:

Let’s get started.

Connecting to MongoDB

For this example we will connect to a database on MongoDB Atlas – MongoDB’s cloud hosted offering. For data, we’ll use the MFlix sample database to dashboard some movie stats.

SquaredUp can also connect to self-hosted MongoDB databases and any database that is compatible with MongoDB such as AWS DocumentDB. It can even connect to Azure Cosmos DB and Google Firestore which offer MongoDB compatible options.

To connect to our MongoDB database, we will need:

The connection string can be found in the Atlas UI. SquaredUp requires the database name to be part of the connection string. For example to access our movie sample data we will use the connection string:

mongodb+srv://sandbox.ki1um44.mongodb.net/sample_mflix

When using MongoDB Atlas, it’s important to whitelist the SquaredUp IP addresses, otherwise SquaredUp will not be able to connect. In the Atlas UI this can be configured under Security > Network Access. The two SquaredUp IP addresses (primary and backup) can be found in the MongoDB data source documentation.

Now for the dashboarding. If you don’t already have a SquaredUp account, it’s free and easy to sign up here.

Once you’re logged into SquaredUp, find MongoDB in the data source catalog. You’ll be prompted to enter the connection details:

The username and password may already be part of the connection string, but we recommend removing them from the connection string and providing them as explicit credentials to ensure they remain secure.

Once the details are entered, click ‘Test and add’.

Connecting should take a second or two. If it takes a long time and fails to connect, you’ve probably forgotten to whitelist the SquaredUp IP address. See above for details.

Once we have verified the connection, we can start dashboarding. Let’s get some movie stats on our screen!

Creating a custom MongoDB dashboard

SquaredUp makes it easy to query MongoDB. However, MongoDB doesn’t have a query language like SQL, so you will need to be comfortable with the MongoDB query concepts and some basic JSON syntax. You can learn more about the query syntax on the MongoDB Atlas documentation.

To get started, we add a new tile to our dashboard, select the ‘MongoDB’ data source, and select the ‘Query’ data source.

In the Parameters section, we’ll see that there are several different query operations:

In this example tile, we’re going to use a simple ‘Find’ query. More information on the different data streams can be found in the MongoDB data source documentation.

Our first tile will show Wes Anderson movies sorted by Rotten Tomatoes view rating.

First we select the 'movies' collection. Then we filter to Wes Anderson movies using the following Filter:

{

"directors.0": "Wes Anderson"

}

We’re only interested in the title and rating, so we use a Projection to only bring back those fields:

{

"title": 1,

"tomatoes.viewer.rating": 1

}

And finally we will sort descending by Rotten Tomatoes view rating using the following Sort configuration:

{

"tomatoes.viewer.rating": -1

}

Once we’re done, hit apply.

In the results window at the bottom of the screen we can see our data. The visualization has automatically selected a bar chart, which is what we wanted.

We’ll change the x-axis to use the movie title instead of the document ID, and change the bar chart to a horizontal layout. We’ll also give the tile a title – “Wes Anderson movies by Rotten Tomatoes viewer rating” – and hit save. Our new dashboard has its first tile!

With some more of the same, we can populate our dashboard with tiles using different data sets and visualizations. Here’s the finished article.

Sharing MongoDB dashboards

How about if we want to share our beautiful dashboard with others? Well, sharing is very simple in SquaredUp. We just hit the Share button and have the option of inviting a user to our SquaredUp workspace, or we can share the dashboard via a simple link:

Monitoring MongoDB data

SquaredUp makes it easy to monitor the data in our dashboards, so that we can be alerted about problems and changes without having to look at the dashboard. For example, we could set a threshold on the Wes Anderson movie tile to be alerted if a new movie is entered into the database.

The tile status is currently green, but if a new movie is added, the tile will go red. Not only can I see this in SquaredUp, I can also set up Notifications. Notifications can be sent via email, Slack, Teams or via any system that supports webhooks. Read our docs to learn more about monitoring.

Get started with SquaredUp dashboards for MongoDB

This was a quick walkthrough of creating a MongoDB dashboard using SquaredUp. In addition to MongoDB, SquaredUp supports over 60 other data sources, enabling you to bring all of your data together into a single pane of glass.

Get started with SquaredUp today with a free account.

Share this article to LinkedInShare this article on XShare this article to Facebook

Visualize over 60 data sources, including:

View all 60+ plugins