Configuring the Data Backend on Mlab

13 Sep
Guides > Setup Guides > Configuring the Data Backend on Mlab

Before continuing, print out this worksheet and fill it out as you move forward: Mlab, Github & Azure Account Info

Heroku as an Alternative

If you plan to use Heroku rather than Azure to host your Nightscout site, you do not need to set up Mlab separately. Heroku creates the Mlab portion automatically. Heroku site creation directions.

Note: If you plan to use Heroku rather than Azure, you do not need to set up Mlab separately. Move on to GitHub setup (Step 1 only) and then Heroku deployment and configuration.

Accounts and User Names

For ease of use, consider using the same name for every username. Do NOT use your “regular” passwords that you use for banking, emails or other sensitive accounts.  At times, when you need assistance, you may need to share the username & password of your Nightscout setup accounts with the individuals providing help to you.

Usernames and Passwords cannot contain ANY spaces, symbols or special characters.  Use Upper and lower case alpha-numeric characters only.  This includes letters and numbers.

Please use the worksheet linked above to keep track of this vital information.  Without this information, you cannot install Nightscout.

Sign up for an Mlab Account

Sign up for a FREE Sandbox account at http://www.mlab.com/plans.

mlab-createaccount

Note: Mongolab changed its name to Mlab in March of 2016. Any references to Mongolab in the documentation on the Nightscout site is synonymous with Mlab. This document has been updated, but you will see the term Mongolab used throughout the Nightscout site and directions. You should assume it means Mlab unless instructed otherwise.

After creating your account, open your e-mail to verify your e-mail address and sign back in to the Mlab web page.

Create a New MongoDB Database

  1. Click the “Create new” button on the right with the lightning bolt.
    mlab-lightningbolt
  2. On the “Create new subscription” page, you can choose from available cloud providers. Options may include: Amazon Web Services, Google Cloud Platform, or Microsoft Azure.  Select one.
    mlab-createnew
  3. Specify a region from the dropdown menu. The location represents where the sandbox is located, NOT where you are located. 
    mlab-location

    (The image above shows a sample screenshot for location options when Amazon Web Services has been selected as the Cloud Provider. You can choose whichever Cloud Provider and whichever location you wish.)

  4. Click the button for Single-Node Development to use the free option. This will entitle you to half a gig of data, which should last over 5 years with the current Nightscout setup. Continue to step 4.
    mlab-sandbox
  5. Click to select the free “Sandbox” option.
  6. Enter a database in the box. Note: The database name must be lower case. A good practice is to simply put db on the end of your username, but it’s entirely up to you. WRITE IT DOWN!
    mlab-new-dbname
  7. Click the “Create New MongoDB Deployment” button.
    mlab-create
  8. Note: If it doesn’t say $0, you have done something incorrectly. Be sure you have selected a Sandbox.

Create a User inside your Mlab Database
  1. Click on the name of the newly created database to open it. Mlab will show you an alert that you do not have a user and will display a link so you can create one.
    mlab-user
  2. Click the link to open the “Add New Database User” dialog.
    mlab-addnewuser
  3. Enter a database username and password and click the Create button.
    You’ll need these values later to complete the Mlab URI string. Write them down! Do not use any special characters such as @ or ) or ^.  The Cloud system will not recognize these special characters.  Use Upper and Lowercase alpha ONLY.  Do not select “Make read-only” or you will be unable to upload data to the database.

Record Your MongoDB Connection Strings

Once everything has been configured, on the Database Summary page, make note of the link at the top  just under “To connect using a driver via the standard URI”, as some of this information may be used to configure the uploader app and the Azure web server that will display your data.

IMPORTANT: If this information is not entered correctly in later steps, your system will not work!  At this time, you are only writing it down for later use.

mlab-uri

The above URI is a sample only. Yours will look different based on your own information. The URI will look something like these examples:

Generic URI code:

mongodb://<dbuser>:<password>@aabbb.mlab.com:11111/<database>

Sample URI with a sample person’s information (note that the < > symbols have been removed):

mongodb://sallyuser:sallypassword@aabb22.mlab.com:11111/nightscout

When recording the URI, replace <user> and <password> (delete the < > symbols also) with the Database Username & Password created in Step 3 above.

THIS MUST BE EXACTLY THE SAME AS THE DATABASE USERNAME & PASSWORD YOU CREATED ABOVE!  (This is not your Mongo login username & password).

Replace <database> with the name of the database that you created in step 2 above.  Remove the < > symbols.

Note: In March of 2016, Mongolab changed to Mlab. The syntax above is the new syntax using the mlab format.

This is all illustrated for you on the worksheet you printed from above and shows you exactly what items go where. 

You are only entering it into the worksheet right now, NOT into MongoDB.

Make sure you carefully check it several times!

  • There will be a colon (:) between username and password.
  • There is another colon (:) between .com and the numeric string at the end
  • There is one “at” symbol (@) following the password
  • There is one forward slash (/) before the database name.
  • Remove any marks (like >) in the string.

It is crucial that this string is absolutely correct or your Nightscout setup will not work. Absolutely will not work when you get to the completion steps.

Once you have verified that the string is correct, you can move on to the next steps.

Even if you think they are 100% correct, check it again.

Make sure you have easy access to your Mongo URI connection string for the following pages.

You are now finished setting up your MLab account.  On to the next step!

Setting Up a Second MongoDB

If you need to set up a second database (e.g., for a second T1D), return to the Mlab home screen, and repeat the steps above, beginning with step 1 of “Create a New MongoDB Database” to create a second database.

Next: Setting up Your Nightscout Website on Azure

2 thoughts on “Configuring the Data Backend on Mlab

  1. For the Mongo collection string, the directions say to highlight and copy the URI code. Am I copying the :…… Generic code or do I modify to personal DB user and password and highlight and copy? If I am personalizing before highlight and copy, how do I do it?
    Thanks,
    Greg
    greglynch@cox.net

Comments are closed.