Connecting Tableau to MongoDB

The MongoDB Connector for Business Intelligence lets you use MongoDB as a data source for SQL-based analytics and data visualization tools like Tableau. Seamlessly create the Tableau visualizations and dashboards that will help you extract the insights and hidden value in your multi-structured data.

The MongoDB Connector for BI is part of MongoDB Enterprise Advanced. Get started by downloading the MongoDB Connector for BI from here. You can review our evaluation agreement here.

Connecting From Tableau

Here’s a brief tutorial on how to connect to the BI Connector from Tableau with or without MongoDB authentication enabled.

Basic connection with no authentication

Before connecting, you should have the BI Connector running. If needed, review the documentation for installing the BI Connector.

Open Tableau and click on the connection named MongoDB BI in Tableau’s left hand column. The connection window will appear where you may enter your credentials. If you are connecting to an instance of MongoDB where authentication is not enabled, you will not need to enter a username or password. Simply enter the host and port on which mongosqld is listening, and click Sign In to connect. By default, mongld binds to port 3307.

Connecting with SSL

When the you use the BI Connector with an instance of MongoDB with --auth enabled you will need to authenticate in Tableau as an existing user already declared in MongoDB. This is called “pass-through” authentication since the BI Connector “passes through” the authentication process to the underlying MongoDB instance. For security purposes pass-through authentication requires that an encrypted SSL connection is made between the BI Connector and Tableau. Here are the steps to connect when auth is enabled.

Step 1: Set up Mongosqld

You may activate pass-through authentication in mongoslqd with the use of the --auth parameter. Take the following command line example.

$ ./mongosqld --schemaDirectory /home/vagrant/schema - --addr= --auth --sslPEMKeyFile=/mongosqld-server.pem

In this example mongosqld has been started with the --auth flag along with a required SSL certificate necessary to authenticate the BI Connector to clients like Tableau. In this example mongosqld-server.pem is a self signed certificate we’ve generated for this tutorial. If you are unfamiliar with SSL certificates you may execute this script to generate your own self signed certificates. The script will generate all the certificates you’d need to implement complete bi-directional authentication between mongod, mongosqld, and Tableau. However, a basic set up only requires mongosqld-server.pem.

Step 2: Connect from Tableau

Once mongosqld is running with pass-through authentication, you may connect from Tableau by adding your username and credentials in the connection window. Users management in MongoDB is unique in that users are associated to a home database. This is often the database in which the user was first declared when the user was created. The BI Connector requires that you specify the database in which the user has been created by passing it as a key/value pair as part of the username. In the example below, the user has been declared in the “test” database, so we specify that home database using the ?source=test option concatenated to the username. More details on MongoDB’s username string format is available in our documentation.

Once you have added the properly formatted username and password into pop-up you may click “sign in” and Tableau will complete the connection.

If you require that Tableau authenticate mongosqld’s certificate, check the “Require SSL” checkbox. The pop-up window will expand with additional file selection fields you may use to specify the CA cert used to sign the mongosqld’s mongosqld-server.pem certificate. This tutorial uses a self-signed certificate, generated with the bash script we’ve linked to earlier. This certificate is called ca.crt and is the certificate you need to select with the “browse” button.

Click on “No custom configuration file specified” to activate the browse button, as shown below.

Once you have selected the right certificate, you can complete the connection by clicking “sign in” and Tableau will complete the connection to the BI Connector. MongoDB databases will be available to you on the right.