MongoDB Analytics & Reporting - AgenticBI Integration

MongoDB is a leading NoSQL, document-oriented database. AgenticBI enables visualization, analysis, and reporting automation from MongoDB. If you have not started your AgenticBI trial, visit our Instant MongoDB Analytics & Reporting page to get started.

Overview

  1. Connect, extract, and transform data from your MongoDB, using one of the following options:

    a. Through our UI to connect directly, if your MongoDB servers are accessible from the cloud.

  2. Visualize and Automate your Reporting instantly.

UI Based Approach

Connecting

  1. Log in to AgenticBI and select Queries from the left sidebar.

  2. Click on New Datasource + button and select MongoDB. Either follow the prompts to set up connectivity to your own MongoDB database, or use the pre-configured settings in AgenticBI's own demo MongoDB database.

  3. Fill in the connection fields as described below:

Field Required Description
Datasource Name Yes A unique name to identify this datasource within AgenticBI.
Mongo Database No Select the type of MongoDB deployment you are connecting to (e.g. standard MongoDB, MongoDB Atlas).
Host(s) Yes The hostname or IP address of your MongoDB server. For replica sets, you can specify multiple hosts separated by commas.
Port No The port your MongoDB instance is listening on. Defaults to 27017 if not specified.
Database Name Yes The name of the MongoDB database you want to connect to.
User No The username for authenticating with your MongoDB database, if authentication is enabled.
Password No The password associated with the above user account.
Database Properties No Optional advanced connection properties, such as read preferences or SSL settings, specified as key-value pairs.
Legacy Version Support No Check this box if you are connecting to MongoDB version 4.4 or below. This enables compatibility mode required for older MongoDB deployments.
  1. You can optionally enable MongoDB as a writable destination. If selected, you can write datasets into this schema. When saving a query, this database will be available as a destination for the resulting dataset. Learn more about DBwrite here.

    a. When connecting from the UI directly to your MongoDB database, please follow the connectivity instructions to allow AgenticBI to access your database.

  2. Save the Connection. Click on the Configure Queries link on the success bar or click on the Start Querying button.

Query

Set up Query using a visual builder or query editor

Visual Builder

After connecting to the MongoDB datasource, AgenticBI will pull out a list of collections along with field samples.

Step 1: Generate queries through our visual builder in a no-code environment by either dragging and dropping fields or making your selections through the drop-down.

Step 2: Define data execution strategy by using any of the following two options:

Direct Execution: Directly execute the Query on the original MongoDB datasource, without any storage in between. In this case, when a widget is displayed, it will fetch the data in real time from the underlying Datasource.

Non-Direct Execution: For non-direct queries, results will be stored in AgenticBI's Elastic Store. Benefits include- long-running queries, reduced load on your database, and more. Non-direct execution can be put into action if you choose to run the Query once or at scheduled intervals.

For more information, please refer to this documentation- Defining Data Execution Strategy

Step 3: Click on Preview to review the results and fine-tune the desired output, if required.

The result of your Query is called Dataset.

After reviewing the results, name your dataset and then hit the Create & Run button

Query Editor

A versatile text editor designed for editing code that comes with a number of language modes including MongoDB Query Language (MQL) and add-ons like Cloud9QL.

Step 1: Write your query using MongoDB Query Language (MQL) in the Query Editor. Optionally, apply Cloud9QL on top for additional transformations.

Step 2: Define data execution strategy by using any of the following two options:

Direct Execution: Directly execute the Query on the original MongoDB datasource, without any storage in between. In this case, when a widget is displayed, it will fetch the data in real-time from the underlying Datasource.

Non-Direct Execution: For non-direct queries, results will be stored in AgenticBI's Elastic Store. Benefits include- long-running queries, reduced load on your database, and more. Non-direct execution can be put into action if you choose to run the Query once or at scheduled intervals.

For more information, please refer to this documentation- Defining Data Execution Strategy

Step 3: Click on the Preview button to analyze the results of your Query and fine-tune the desired output, if required.

Map-Reduce

AgenticBI supports Map-Reduce useful for pushing down processing of large datasets into MongoDB (beyond MongoDB's aggregate function). Map-Reduce support includes Map, Reduce, Finalize functions, and "limit" and "scope" parameters. Note that the output results must be returned inline.

For example, if you have collection of events for each of customers with fields "customer" and "sent":

[
  {
    "customer":"Wells Fargo",
    "sent":"119992"
  },
  {
    "customer":"Wells Fargo",
    "sent":"130000"
  },
  {
    "customer":"Linked In",
    "sent":"23000"
  }
]

To calculate the sum of "sent" for each "customer":

db.sendingActivity.mapReduce(
  function(){
    emit(this.customer, this.sent);
  },
  function(key, values) {
    return Array.sum(values);
  },
  {
    out: { inline: 1 }
  }
)

Another example with "scope" and "finalize" feature, to get the total events count up to date for each data.

db.sendingActivity.mapReduce(
   function () {
     var date = new Date(this.date.valueOf() -     ( this.date.valueOf() % ( 1000 * 60 * 60 * 24 ) )     );
     var value =1; 
     emit(date, value);
   },
   function(key,values) {
       return Array.sum( values );
   },
   { 
       "scope": { "total": 0 },
       "finalize": function(key,reducedValue) {
           total += reducedValue;
           return total;
       },
      "out": { "inline":1 }
   }
)

Example of output:

[
  {
      "_id" : ISODate("2014-12-01T00:00:00.000Z"),
      "value" : 19.0
  },
  {
      "_id" : ISODate("2014-12-02T00:00:00.000Z"),
      "value" : 28.0
  },
  {
      "_id" : ISODate("2014-12-03T00:00:00.000Z"),
      "value" : 38.0
  }
]