Aura Groot databases

Description of databases used by Aura Groot

Introduction

Currently, aura-groot uses two databases, described below.

  • Mongo DB
  • Redis + MongoDB

MongoDB

In order to reuse the code and clarify the development, all classes related with MongoDB storage are stored in the mongodb-storage.ts file within aura-bot-common repository.

MongoDbStorage

This storage class will be used by Bot Builder v4 to store the conversation and user’s data. An index is created to delete documents older than 24 hours (specified by config var AURA_MONGODB_BOT_COLLECTION_CONTEXT_INDEX_TTL).

The following aura-groot environment variables are used to initialize this class:

Var name Description Required/Optional
AURA_MONGODB_BOT_DATABASE Database name where the documents will be stored Required
AURA_MONGODB_BOT_COLLECTION_CONTEXT Collection name where the documents will be stored Required
AURA_MONGODB_BOT_COLLECTION_CONTEXT_INDEX_TTL Duration (in seconds) for which the documents will exist without updates before being deleted. By default, 86440. Optional

To create and initialize a MongoDbStorage, a code like the following below could be used:

    const storage = await MongoDbStorage.create(
            this.configuration.AURA_MONGODB_BOT_DATABASE,
            this.configuration.AURA_MONGODB_BOT_COLLECTION_CONTEXT,
            () => ConfigurationManager.instance.get('AURA_MONGODB_BOT_COLLECTION_CONTEXT_INDEX_TTL')
        );

Aura Groot cache module

The aura groot cache module allows the generation of different types of cache:

  • MetricCache: used for remote and local data. Is a TwoLevelsCache.

How to use cache module

This cache stores the timestamp when a request from the channel arrives at the aura-groot and is retrieved after the skill’s response to calculate the duration in the KPI GrootMessageEntity.

Variables for AuraGrootCache

The following aura-groot environment variables are used to initialize this class:

Var name Description Required/Optional
AURA_MONGODB_BOT_DATABASE Database name where the documents will be stored Required
AURA_MONGODB_CACHE_METRIC_COLLECTION Collection name where the documents will be stored. By default, metric-cache Optional
AURA_MONGODB_CACHE_METRIC_TTL Duration (in seconds) for which the documents will exist in local cache before being deleted. By default, 60. Optional
AURA_MONGODB_CACHE_METRIC_INDEX Index used in TwoLevelsCache of metric-cache. By default, correlator. Optional

Example of data storage:

{
    "_id" : "64d0e9608a473f63c8bda87b",
    "correlator" : "6eea808b-30f8-4358-9859-cd42892a962b",
    "data" : [
        2339137,
        419794024
    ],
    "lastAccess" : "2023-08-07T12:53:52.370Z"
}

Redis + MongoDB

If the configuration variable AURA_BOT_CONTEXT_DATABASE is set to REDIS-MONGODB, aura-groot uses a two-level cache to store the context Aura Redis Mongo Sync.

The following environment variables must be set for the two databases.

Variables

Var name Description Required/Optional
AURA_MONGODB_BOT_COLLECTION_CONTEXT Name of the collection where the context is stored. By default: aura-context. Required
AURA_MONGODB_BOT_DATABASE Name of the database where the bot collections are stored. By default: aura-bot Required
AURA_MONGODB_PASSWORD Password of the MongoDB. Required Required
AURA_MONGODB_POOL_SIZE Pool size of the MongoDB. By default: 60. Required
AURA_MONGODB_SSL Boolean value indicating if MongoDB connection uses SSL or not. By default: true. Required
AURA_MONGODB_URI URI of the MongoDB Required
AURA_MONGODB_USERNAME Username of the MongoDB Required
AURA_REDIS_CONFIGURATION_PREFIX Prefix for Redis configuration keys. By default: aura-config: Required
AURA_REDIS_CONTEXT_CACHE_PREFIX Prefix for Redis context cache keys. By default: context: Required
AURA_REDIS_CONTEXT_CACHE_SHADOW_KEY_PREFIX Prefix for Redis shadow key cache keys. By default: shadow-key: Required
AURA_REDIS_CONTEXT_CACHE_ACTIVE_CONTEXT_PREFIX Prefix for Redis active context cache keys. By default: active-context: Required
AURA_REDIS_CONTEXT_CACHE_SHARD_COUNT Number of shards to generate lists for storing unprocessed context. Required
AURA_REDIS_CONTEXT_CACHE_TTL Time in seconds to store a context in cache. By default: 60. Required
AURA_REDIS_MODE Mode of Redis distribution (Cluster, Sentinel or Single). By default: Single. Required
AURA_REDIS_PREFIX Prefix that will be used by all redis keys when using redis-connector. This allow mixing in a single redis service messages coming from different environments in the same Azure subscription. Required
AURA_REDIS_SENTINEL_INSTANCE_NAME Name of the Redis instance. Use in sentinel mode. Optional
AURA_REDIS_HOSTS A string with list of nodes (host:port) separate by comma. For example: “localhost:port,localhost2:port2”. Default: ‘127.0.0.0:6379’ Required
AURA_REDIS_DATABASE Database number for Single or Sentinel mode. By default: 0.
AURA_REDIS_PASSWORD A string with the password of Redis. Required
AURA_REDIS_MAX_RECONNECT_RETRIES Number of retries to connect to Redis. By default: 25. Required
AURA_REDIS_MAX_RECONNECT_INTERVAL Time in milliseconds to wait before reconnecting to Redis. By default: 5000. Required
AURA_REDIS_USE_CONNECTION_POOL Used connection pool for Redis connections. Default: true. Required
AURA_REDIS_CONNECTION_POOL_MIN Minimum number of connections in the pool. Default: 2. Required
AURA_REDIS_CONNECTION_POOL_MAX Maximum number of connections in the pool. Default: 100. Required