How to integrate Carriots with Ducksboard.


0. Introduction

By using the Carriots External API, you could send data to Ducksboard for monitoring your metrics. A real time visualization of your key performance indicators. Can you imagine the possibilities of this?.


1. How to use

To send data to Ducksboard with Carriots, the first step you have to do is create your Ducksboard account. Try it for free!. If you already have an account you could use it. Login into Ducksboard and select the custom widget you want to send data. Clic on it and select widget preferences. In our example the widget is a Custom Timeline.

  • Widget preferences

Once inside the preferences screen, in standard settings tab we have to take a look at two places. “Point your data to this url” and “your api key”. We will need this values later.

  • Info

Now we are ready to link data from Carriots to Ducksboard. There are two ways to connect, through a listener or via trigger.

Using Listener

To create a listener click on "Listeners" Menu option, inside "Rules Management". Then click on "New" button and create the listener. To know more about it, you could see the tutorial How to create a listener.

  • Create listener

Once the listener is created you have to put the ducksboard call into “Expresión Then” or “Expresión Else” text area.
Here is an example code:

  • import com.carriots.sdk.utils.BasicHttp;
    def basicHttp = new BasicHttp();

    Definition of BasicHttp class
  • def map= ["user" : "YOUR API-KEY", "password":"x"];

    User key : you have to assign “your api key value” from Ducksboard widget preference.
    Password key: You have to assing a value for password too, for example “x”. This value will be ignored but its mandatory.
  • basicHttp.url =" ID_WIDGET";
    basicHttp.verb ="POST";

    This is your url value from Ducksboard widget preferences.
  • basicHttp.payload={"value":{"title": "P3", "content":"C3"}};

    Payload value is a json string and is different for each widget, so you have to know how is formatted in each case. Is very easy to get, just click on the link “API Documentation” from Ducksboard widget preference. You will see something similar to this. Timeline is our example widget.

    • Timeline widget
    The payload value is marked, so you have to copy it and then custom it for your call. In our example we have used only title and content.
  • Checking Ducksboard
    You will see that there are new messages in your timeline widget, something like this.

    • Ducksboard

And that’s is all, now you are able to connect Carriots with Ducksboard via listener. Congratulations!

Using Trigger

To create a new trigger click on "Push" Menu option, inside "Data Management" and "Publish data". Then click on "New" button and create the Trigger. To know more about it, you could see the tutorial How to create a trigger.

  • Menu

Fill the fields and save the new trigger:

  • Name
    The name that you prefer.
  • Description
    The description that you prefer.
  • Max retries: 2
  • Push frequency: 5
  • Enabled: Checked
  • Id_service
    The Id_service that you prefer.
  • URL
    This is “your api key value” from Ducksboard widget preference.
  • Password
    It must have a character at least, in our example it has “x” value.
  • Payload
    This is the data for sending to Ducksboard custom widget, in our example:
    {"value":{"title": "P3", "content":"C3"}}
  • Create trigger

When you want to take data from the context and use it in your payload you have to use %%%context data here%%% notation. For example suppose your data stream is collecting temperature and humidity and it looks like the following.

If you want to send temperature and humidity values to ducksboard you will have to use this payload.

And that’s is all, now you are able to connect Carriots with Ducksboard via trigger. Congratulations!


2. Example code

All examples have the same apikey value. The url and payload values are different for each widget.

Call to a custom Timeline widget from a listener

  • Timeline widget

Example code:

Call to a Custom Trend Leaderboard from a listener

  • Trend Leaderboard widget

Example code: