Visualize IoT data with Kaa and MongoDB Compass

Visualize IoT data with Kaa and MongoDB Compass

Overview

Kaa is a highly flexible, open source middleware platform for Internet of Things (IoT) 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 about quick installation of Kaa Sandbox using Virtual Box environment and connecting a sample application with MongoDB log appenders.

Pre-requisites

Installing Kaa Sandbox

To install Kaa Sandbox, perform the following:

  • Download Sandbox image v0.10.0 from the download link as shown in the below diagram:

kaa_download

  • Download .ova file and provide proper location in the local system.
  • Download VirtualBox platform packages.
    In our use case, Windows hosts are used.

virtual_box

  • Locate the two downloaded files in proper location for better understanding.

kaa_location

  • Open the VirtualBox and go to File –> Import Virtual Appliance.
  • Import the downloaded kaa-sandbox-0.10.0.1.ova file as shown in the below diagram:

select

  • On clicking Next button, select proper configuration details such as Name, OS Type, CPU, RAM, and so on.
    Note: Minimum of 4096 MB should be available to run in the environment.
  • On verifying the configuration details, click Import to start the process.

select

  • On completing the import process, start Kaa Sandbox in VM.
  • Click Start arrow button to start the process as shown in the below diagram:

select

On starting Kaa Sandbox in VirtualBox, the local host Kaa Dashboard Access Interfaces will be provided as shown below:

kaa_sandbox_window

Screen 1 provides the local host for dashboard access and screen 2 provides login to this virtual machine.

  • Give log in credentials (user name “Kaa” and password “Kaa”) to log in.
  • Copy Kaa Sandbox Web UI host (http://127.0.0.1:9080) and paste it into browser to browse the URL.
    Now, you can successfully access Kaa dashboard as shown in the below diagram:

sandbox1

Demonstrating Sample Application

In this section, let us discuss about demonstrating a sample Kaa application in Kaa Sandbox.

This application sends temperature data at preset time period from the endpoint to the server. A Log appender is setup to collect data from the endpoint. In our use case, MongoDB log appender is used.

The sample application is executed by:

  • Generating Java SDK
  • Creating log appenders
  • Launching the application
  • Fetching MongoDB logs from the appenders

Choosing Application

The sample application named Data Collection Java Demo is chosen.

Generating SDK

To generate SDK, perform the following:

  • Download Java SDK – DataCollectionDemo.jar by clicking Binary button in the below diagram:

data_collection_java_demoThe corresponding SDK component will be built or generated. You can also download Objective C, C++, and Android files for Java SDK.

  • Click Source button as shown in the above image to generate source code for the application as DataCollectionDemo.tar.gz.
  • Log in to Administration UI by entering the default credentials (username: admin and password: admin123).

kaa_admin_ui

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.

kaa_admin_ui2

MongoDB log appender is used in this use case.

Note: You can also choose Rest, File, Cassandra, Couchbase, Kafka, Oracle NoSQL, and Flume.

To create 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.

select

Launching Application

Launch the application (.jar file) in command prompt.

For example, C:\demo_app> java –jar DataCollectionDemo.jar

Kaa will be automatically started and the data will be sent to logs by log appenders as shown in the below diagram:

kaa_log

Fetching Logs from MongoDB

To fetch logs from MongoDB, log in to Kaa Sandbox and use the below command:

fetching_logs_from_mongodb

Visualizing Logs in MongoDB Compass

Connecting to Host

connecting_to_host

Selecting Application Token

selecting_application_token

selecting_application_token1

Applying Query

applying_query

Viewing Startup Log

viewing_startup_log

Conclusion

In this blog, we discussed about basic steps to install Kaa Sandbox using Virtual Machine for Kaa project Internet of Things (IoT). We also discussed about executing the demo application by generating Java SDK, creating log appenders, launching the application, and fetching MongoDB logs from the appenders.

References

2480 Views 3 Views Today