How-To Guides
Integration Guides

MongoDB Integration Guide

11min
review the following guide for setting up an integration between litmus edge and a mongodb database for this integration, you can use either the db mongodb or db mongodb v4+ connector see the the mongodb documentation for more information video user scenario in this guide you will deploy a mongodb database container from litmus edge and then integrate with the database using the db mongodb connector for your specific scenario you may use an external mongodb database to set up the integration if you do use an external mongodb database, make sure to use the appropriate connector depending on the version of mongodb you are using (db mongodb or db mongodb v4+) step 1 add device follow the steps to connect a device docid 3eyafppweuvmblcey17sq the device will be used to store tags that will be eventually used to create outbound topics in the connector make sure to select the enable data store checkbox step 2 add tags after connecting the device in litmus edge, you can add tags docid 8se7z3pmrfwl1nmzcwalx to the device create tags that you want to use to create outbound topics for the connector step 3 add mongodb marketplace application note the version used in this guide for mongodb is 4 4 4 to add the mongodb marketplace application in litmus edge, navigate to applications > marketplace click marketplace list and select default marketplace catalog click the mongodb application tile from the installation script version drop down list, select latest enter mongodb in the name field click launch navigate to applications > catalog apps the mongodb application appears, pulls the image, and then starts the application the mongodb application shows as running navigate to applications > containers the mongodb application container is running copy the ip address for the mongodb application step 4 add the db mongodb connector follow the steps to add a connector docid\ ogw7fkqbwidbabn4wl5rr and select the db mongodb provider configure the following parameters name enter a name for the connector hostname paste the ip address you copied in step 3 port the mongodb server port the default value is 27017 username (optional) leave the field blank password (optional) leave the field blank auth database (optional) the authentication database name the default value is admin auth mechanism select plain database enter db sample collection enter devicehub show mapping if you want to send data to a custom table, select this check box and unselect create table see work with tables in sql connectors (create table and show mapping) docid\ g834 z 0m5fp7j6p6pzwo to learn more to add key/value pairs for the custom table, see work with tables in sql connectors (create table and show mapping) docid\ g834 z 0m5fp7j6p6pzwo commit timeout enter the transaction commit timeout in (ms) max transaction size enter the maximum number of messages before a transaction is committed, regardless of timeout parameter throttling limit the maximum number of messages per second to be processed the default value is zero, which means that there is no limit persistent storage when enabled, this will cause messages to undergo a store and forward procedure messages will be stored within litmus edge when cloud providers are online queue mode select the queue mode as lifo (last in first out) or fifo (first in first out) selecting lifo means that the last data entry is processed first, and selecting fifo means the first data entry is processed first step 5 enable the connector after adding the connector, click the toggle in the connector tile to enable it if you see a failed status, you can review the manage connectors docid 3u7jzldinehy8shvifd d and relevant error messages step 6 create topics for connector you will now need to import the tags created in step 2 as topics for the mongodb connector the topics will be created as outbound topics to create outbound topics click the connector tile the connector dashboard appears click the topics tab click the import from devicehub tags icon the devicehub import dialog box appears select all the tags to import and click import after adding all required topics, navigate to the integration overview page and ensure the connector is not disabled and still shows a connected status step 7 enable topics ensure the topics you imported are enabled by returning to the topics tab and clicking the enable all topics icon step 8 make mongodb queries you can now verify that you can view data through the terminal command window update the database and collection names to your own specific configurations to make queries in the mongodb container terminal in litmus edge, navigate to applications > containers click the terminal icon next to the mongodb container the mongodb shell opens from the mongodb container terminal, enter mongo and press enter the mongodb shell version v4 4 4 appears and connects enter show databases and press enter the db sample database name appears in the console enter use db sample and press enter the directory switches to db sample enter show collections and press enter the devicehub collection list appears enter db devicehub find() and press enter confirm you see data being loaded into the collection