Skill Level: Intermediate

Recipe expects usage skills on IBM Watson IoT Platform and Cloudant NoSQL DB Service on IBM Bluemix

In this recipe, we describe about how the device data gets stored on Cloudant NoSQL DB and showcase how to configure and store device data on to Cloudant NoSQL DB as Historian Data Storage


  1. Introduction

    Connecting a IBM® Cloudant® NoSQL DB for Bluemix® service to IBM® Watson™ IoT Platform allows us to store and access device data. Device data is stored in daily, weekly, or monthly databases depending on selected bucket interval.

    When we begin using a Cloudant NoSQL DB to store device data three databases are automatically created, one database is created for the current bucket interval, one for the upcoming interval, and one configuration database. Design documents can be added to the configuration database and will be copied to new databases as they are created. When the end of an interval is reached device data is stored in the bucket database for the new interval, and a new database is created for the following interval.

    When device data is sent to a database it can be stored in one of two ways. If the data is valid JSON and the format of the device event is set to JSON, the device data will be stored in the following format:


    If the device data is not valid JSON or if the format is not set to JSON the device data will be stored as a base64 encoded string under the payload field in the following format:



    Next section, we'll see how we can configure and store device data on to Cloudant NoSQL DB as Historian Data Storage.

  2. Before we begin

    Before connecting a Cloudant NoSQL DB to IBM Watson™ IoT Platform service, please complete the following tasks:

    • Set up a Cloudant NoSQL DB in the same Bluemix space as Watson IoT Platform by using the Bluemix Catalog

    Ensure that we have developer privileges in the Bluemix organization and we are signed in via Bluemix. If we are not signed in through Bluemix, or do not have developer privileges in this Bluemix organization, we will not be able to authorize the binding of the Cloudant NoSQL DB and the Watson IoT Platform.

  3. Connecting a Cloudant NoSQL DB with IBM Watson IoT Platform

    Here are the steps to connect Cloudant NoSQL DB with Watson IoT Platform and configure Historian Service to use Cloudant NoSQL DB:

    1. On Watson™ IoT Platform dashboard, click Extensions in the navigation bar.
    2. In the Historical Data Storage tile, click Setup.
    3. All available Cloudant NoSQL DB services within the same Bluemix space as our Watson™ IoT Platform service are listed in the Configure historical data storage section.
    4. Select the Cloudant NoSQL DB service that we wish to connect.
    5. Select Cloudant NoSQL DB configuration options:
      1. Select a bucket interval.
      2. Select a time zone.
      3. Choose options that determine the database name.
    6. Clicking on Done, we should see a popup window asking for authorize the connection to Cloudant Service. Note: If Popup windows are blocked by browser, then you may not see the below shown popup window asking for “Confirm Authrorization”. In that case, enable allow pop-ups in the browser and try again.
    7. Clicking on CONFIRM in authorization dialog box, we should see Authorization Success message in the popup window.
    8. With successful completion of configuring the Cloudant NoSQL DB to be used as Historian Service for Watson IoT, we should see Historical Data Storage status as configured:
    9. Our device data is now being stored in Cloudant® NoSQL DB

    In this section, we have described the steps required to configure Cloudant NoSQL DB as Historian Service for IBM Watson IoT Platform. Coming sections, we'll see how to view device data stored in Cloudant NoSQL DB and query the device data.


  4. Conclusion & Next Steps

    This recipe is good starting point for the audience who wants to explore on connecting Cloudant NoSQL DB as Historian Data Storage for IBM Watson IoT Platform. In this recipe, we have described about:

    • Details about the format of the data stored in Cloudant NoSQL DB.
    • Configuring Cloudant NoSQL DB to be used as Historian Data Storage for IBM Watson IoT Platform.

    To know about:

    • Sample queries to retrieve device data from configured Cloudant NoSQL DB using cURL statements.
    • Sample queries and data processing operations on the device data retrieved from Cloudant NoSQL DB using Python Code.
    • Device Data processing from multiple Cloudant NoSQL databases in Python.

    Refer to the recipe: Query and Process Watson IoT Device Data from Cloudant NoSQL DB.

    To know, how to link between Line Chart Cards and Historian Data Storage to display device data on Watson IoT Platform Dashboard, refer to Visualize Watson IoT Device Data stored in Cloudant NoSQL DB.

Join The Discussion