Visualize IoT Data With Kaa and MongoDB Compass
If you aren't familiar with it, Kaa is an open source middleware platform for IoT development. See how to put it to use to visualize your devices' data.
Join the DZone community and get the full member experience.Join For Free
Kaa is a highly flexible, open source middleware platform for Internet of Things product development. It provides a scalable, end-to-end IoT framework for large, cloud-connected IoT networks. Kaa enables data management and real-time bidirectional data exchange between the connected objects and backend infrastructure by providing server and endpoint SDK components.
The SDK components support multi-programming development, client server communication handling authentications, and so on. The SDK components can be virtually integrated with unlimited and any type of connected devices or microchips.
In this blog, let us discuss the quick installation of Kaa Sandbox using a VirtualBox environment and connecting a sample application with MongoDB log appenders.
- Download and install the following from the links below:
- Minimum system requirements (64-bit OS, 4 GB RAM)
- Virtualization enabled in BIOS
Installing Kaa Sandbox
To install Kaa Sandbox, perform the following:
- Download Sandbox image v0.10.0 from the download link.
Download the .ova file and provide a proper location in the local system.
- Download the VirtualBox platform packages. In our use case, Windows hosts are used.
- Locate the two downloaded files in the proper location for a better understanding.
Open VirtualBox and go to File --> Import Virtual Appliance.
- Import the downloaded kaa-sandbox-0.10.0.1.ova file.
Click the Next button, then select the proper configuration details such as Name, OS Type, CPU, RAM, and so on.
Note: A minimum of 4096 MB should be available to run in the environment.
- Upon verifying the configuration details, click Import to start the process.
Upon completing the import process, start Kaa Sandbox in a VM.
- Click the Start button (the green arrow) to start the process as shown in the below diagram:
Upon starting Kaa Sandbox in VirtualBox, the local host Kaa Dashboard Access Interfaces will be provided as shown below:
Screen 1 provides the local host for dashboard access and screen 2 provides the login to this virtual machine.
- Give the login credentials (user name "Kaa" and password "Kaa") to log in.
- Copy the Kaa Sandbox Web UI host (http://127.0.0.1:9080) and paste it into the browser to browse the URL.
Now, you can successfully access Kaa dashboard as shown in the below diagram:
Demonstrating a Sample Application
In this section, let's discuss a sample Kaa application in Kaa Sandbox.
This application sends temperature data at preset time periods from the endpoint to the server. A log appender is set up to collect data from the endpoint. In our use case, a MongoDB log appender is used.
The sample application is executed by:
- Generating a Java SDK
- Creating the log appenders
- Launching the application
- Fetching MongoDB logs from the appenders
Choosing the Application
The sample application here is named Data Collection Java Demo
Generating the SDK
To generate the SDK, perform the following:
- Download the Java SDK – DataCollectionDemo.jar by clicking the Binary button in the diagram below:
The corresponding SDK component will be built or generated. You can also download Objective C, C++, and Android files for the Java SDK.
- Click the Source button as shown in the above image to generate source code for the application as DataCollectionDemo.tar.gz.
- Log into the Administration UI by entering the default credentials (username: admin and password: admin123).
You can add or delete the application and get the application token required to communicate with the endpoint and the server.
Note: Copy this application token to fetch the data from the logs, which is required in further steps.
Creating Log Appenders
Developer credentials (username: devuser and password: devuser123) were used for developing the applications by creating schemas, log appenders, client configuration, and so on.
MongoDB's log appender is used in this use case.
Note: You can also choose REST, File, Cassandra, Couchbase, Kafka, Oracle NoSQL, and Flume.
To create a log appender, perform the following:
- Select the application name from the applications in the Administration UI.
- Select Data collection demo --> Log appenders --> Add log appender --> MongoDB appender.
Launching the Application
Launch the application (.jar file) in a command prompt.
C:\demo_app> java –jar DataCollectionDemo.jar
Kaa will be automatically started and the data will be sent to logs by the log appenders as shown in this screenshot:
Fetching Logs from MongoDB
To fetch logs from MongoDB, log into Kaa Sandbox and use the following command:
$ mongo kaa $db.logs_<application_token>.find() ---- (copied application token in Generate SDK section to be enter here)
Visualizing Logs in MongoDB Compass
Connecting to Host
Selecting Application Token
Viewing Startup Log
If you enjoyed this article and want to learn more about MongoDB, check out this collection of tutorials and articles on all things MongoDB.
Published at DZone with permission of Rathnadevi Manivannan. See the original article here.
Opinions expressed by DZone contributors are their own.
A Comprehensive Guide To Testing and Debugging AWS Lambda Functions
SRE vs. DevOps
Introduction to API Gateway in Microservices Architecture
Azure Virtual Machines