Using the MongoDB Support Feature

Learn how to redirect the collection of metrics and audit data from the designated Policy Manager Database to the MongoDB Database.

Table of Contents

Introduction

The MongoDB Support plug-in redirects the collection of metrics and audit data from the designated Policy Manager Database (RDBMS) to the MongoDB database.

Use of this plug-in requires installation of MongoDB.

Redirecting the capture of metrics and auditing data can help to optimize performance by reducing the toll on your designated RDBMS. This is because metrics and roll-up data processes will now occur in MongoDB which will increase performance in the container by reducing query times and CPU/memory overhead.

  • This plug-in can be used exclusively with the Policy Manager product or in combination with Community Manager and/or Akana Envision.
  • Data stored includes Policy Manager Alerts, and all metrics and auditing log data that has a write operation.
  • Metrics and audit data collected from Network Director will be stored directly in MongoDB and will not be stored in the designated Policy Manager database (RDBMS). This would be data relating to how a particular API is performing; for example, response times and error rates.
  • Alert and audit trail data would be information such as when a specific service changed, who changed it, and the result of the change.
  • Audit data can be used both in Community Manager, Policy Manager, and Envision for various charts by configuring a Business Metrics Policy that allows you to configure what focus of data to extract from the payload.
  • In Policy Manager, logging data for historical charts and logs that can be viewed via the Monitoring tab in Services, Containers, and Contracts will now be fetched from MongoDB.
  • The logging data stored in MongoDB can also be used in your own third-party reporting tools.

Envision Only: Review MongoDB Setup Guide

If you're using Envision, before starting, review the information in MongoDB Setup Guide for Akana Envision.

Step 1: Download and Install MongoDB

Use of this plug-in requires installation of MongoDB. If you have already installed and started MongoDB skip to Step 4.

  1. Go to https://www.mongodb.com and download the MongoDB file for your platform. Windows 64-bit (MSI), Linux 64-bit (TGZ), and Solaris 64-bit (TGZ) are supported. If you are on a Mac you can install Mongo with homebrew using "brew install mongo."
  2. Install MongoDB on your platform.

Note: These instructions provide a basic MongoDB installation approach. For information on installation instructions and shutdown procedures for your specific deployment, refer to the MongoDB documentation, available at https://docs.mongodb.com.

Step 2: Create MongoDB Data Folder

  1. Create a MongoDB data folder. The default is /data/db. If you prefer to use a different location, use --dbpath.

Step 3: Start MongoDB

  1. Navigate to the MongoDB installation directory. For example: /MongoDB/Server/3.6/bin.
  2. Enter mongod.
  3. If MongoDB successfully starts, your command window displays the message waiting for connections, followed by the port number.

Step 4: Configure MongoDB Support Plug-in

  1. Log in to the Akana Administration Console of the target installation container instance using your default credentials.
  2. On the Available Features screen, from the Filter menu, select Plug-ins.
  3. Select the MongoDB Support plug-in and click Install Feature.
  4. After the installation is complete, click Configure and then click Continue.
  5. On the Configure MongoDB Database screen, specify the host name and port where the MongoDB database is installed in the MongoClientURI field. The default MongoDB port is 27017.
  6. Click Finish, and then click OK to restart the container. The URI is assigned and the system automatically configures seed data and adds schemas.

After the installation is complete, you can manage (install / uninstall) datasets via the Configuration tab by selecting Configure MongoDB Database.

Optimizing the MongoDB Index Creation

Creating MongoDB indices uses asynchronous APIs to improve performance and avoid situations in which execution could be blocked.

To install the configuration data and indexes in MongoDB

  1. Log in to the Akana Administration Console.
  2. Click the Configuration tab.
  3. On the left, under Configuration Categories, click Install Configuration Data and Indexes in MongoDB.
  4. Click Finish to install the MongoDB collection data and indexes.

Additional log statements are added to monitor the status of index creation, including Creating index [index_name], Created index [index_name], and Index creation failed for [indexName].

To create an index in MongoDB

Syntax

Creating index [index_name], on collection : [collection_name]

Example

Creating index [AUDIT_1AIdx], on collection : [PM_AUDIT.AUDIT]
  
2023-06-03 17:33:03, 091 INFO [MongoSchemaTaskHandler] AsyncBaseDaoImpl - Creating index [AUDIT_1AIdx], on collection : [PM_AUDIT.AUDIT]
2023-06-03 17:33:03, 094 INFO [MongoSchemaTaskHandler] AsyncBaseDaoImpl - Creating index [AUDIT_2AIdx], on collection : [PM_AUDIT.AUDIT]
2023-06-03 17:33:03, 098 INFO [MongoSchemaTaskHandler] AsyncBaseDaoImpl - Creating index [AUDIT_3AIdx], on collection : [PM_AUDIT.AUDIT]
2023-06-03 17:33:03, 099 INFO [MongoSchemaTaskHandler] AsyncBaseDaoImpl - Creating index [AUDIT_4AIdx], on collection : [PM_AUDIT.AUDIT]

To see logs after the completion of index creation

Syntax

Created index [index_name], on collection : [collection_name] in $sec seconds

Example

Created index [AUDIT_1AIdx], on collection : [PM_AUDIT.AUDIT] in 31 seconds
  
2023-06-03 17:33:03, 951 INFO [MongoSchemaTaskHandler] AsyncBaseDaoImpl - Creating index [oidc_gnt_pvdr_sts_exp_didx], on collection :[Akana.OAUTH_GRANTS]
2023-06-03 17:33:34, 880 INFO [Thread-33] AsyncBaseDaoImpl - Created index [AUDIT_1AIdx], on collection : [PM_AUDIT.AUDIT] in 31 seconds
2023-06-03 17:33:35, 747 INFO [Thread-28] AsyncBaseDaoImpl - Created index [AUDIT_2AIdx], on collection : [PM_AUDIT.AUDIT] in 32 seconds
2023-06-03 17:33:38, 207 INFO [Thread-31] AsyncBaseDaoImpl - Created index [AUDIT_3AIdx], on collection : [PM_AUDIT.AUDIT] in 35 seconds

To see logs for failed indexes

Syntax

Index creation failed for [indexName], on collection : [collectionName]

Example

Index creation failed for [AUDIT_1AIdx], on collection : [PM_AUDIT.AUDIT]
  
2023-06-03 18:58:13, 227 ERROR [Thread-87] AsyncBaseDaoImpl - Index creation failed for [AUDIT_MSG1_indexIdx], on collection :[PM_AUDIT.AUDIT_MSG]
2023-06-03 18:58:13, 226 ERROR [Thread-80] AsyncBaseDaoImpl - Index creation failed for [oidc_gnt_issue_updt_sts_didx], on collection : [AKANA.OAUTH_GRANTS] 
2023-06-03 18:58:13, 226 ERROR [Thread-89] AsyncBaseDaoImpl - Index creation failed for [AUDIT_MSG7_indexIdx], on collection : [PM_AUDIT.AUDIT_MSG] 
2023-06-03 18:58:13, 228 ERROR [Thread-102] AsyncBaseDaoImpl - Index creation failed for [AUDIT_MSG8_indexIdx], on collection : [PM_AUDIT.AUDIT_MSG] 

If the Akana application is terminated, index creation will still be running. You can check the indexes by executing the following query on the Mongo console, which returns the status of indexes that are in progress.

db.currentOp(
  {
    $or: [ 
     { op: "command", "command.createIndexes": { $exists: true } } 
    ]
  }
)

If the indexes are not created, you can check the logs where MongoDB is installed. By default, MongoDB creates the log file under /var/log/mongodb/mongodb.log.