0

I am checking if I can use kairosdb for my project. I was checking out the REST api's and I have a use case where I need to save both my device state and status (state tells if device is on or off and status tells if my device is occupied or empty)

kairosdb version: 1.1.1


I came across this link https://kairosdb.github.io/docs/build/html/restapi/AddDataPoints.html
but when I try to post data from REST client I am getting the error 400 BAD Request error. The error is 

{"errors":["Unregistered data point type 'complex-number'"]}

My request I am posting is ,
 {
      "name": "device_data",
      "type": "complex-number",
      "datapoints": [
          [
              1470897496,
              {
                  "state": 0,
                  "status": "empty"
              }
          ]
      ],
      "tags": {
          "device_id": "abc123"
      }
  }

In tried doing the same in Java as specified in  https://kairosdb.github.io/docs/build/html/kairosdevelopment/CustomData.html

I get the same error i Please let me know how to use complex-numbers or custom data types from REST

Madhu
  • 53
  • 1
  • 11

1 Answers1

3

Recently, I figured out how to use this.

Using the example from the official document of KairosDB.

  1. create 2 files called ComplexDataPoint.java and ComplexDataPointFactory.java and then paste the code provided by the tutorial on the doc: https://kairosdb.github.io/docs/build/html/kairosdevelopment/CustomData.html#example-for-creating-custom-types
  2. download the KairosDB source, then extract the .zip file.
  3. paste the 2 files in /KAIROSDB_DOWNLOADED_SOURCE/src/main/java/org/kairosdb/core/datapoints/
  4. configure the CoreModule.java at /KAIROSDB_DOWNLOADED_SOURCE/src/main/java/org/kairosdb/core/, add the following line in the function protected void configure():

    bind(ComplexDataPointFactory.class).in(Singleton.class);
    
  5. open terminal, cd to KAIROSDB_DOWNLOADED_SOURCE/, then follow the instruction in the file how_to_build.txt

  6. when complete, it will create a folder called build, the compiled kairosdb jar file is located in KAIROSDB_DOWNLOADED_SOURCE/build/jar

  7. in your kairosdb installation folder, backup the kairosdb-X.X.X.jar file in YOUR_KAIROSDB_INSTALLATION/lib

    mv kairosdb-X.X.X.jar kairosdb-X.X.X.jar.backup
    
  8. mv the newly compiled jar file to YOUR_KAIROSDB_INSTALLATION/lib

  9. modify the configuration file by adding the following line:

    kairosdb.datapoints.factory.complex=org.kairosdb.core.datapoints.ComplexDataPointFactory
    
  10. restart your kairosdb

For your query, since the registered name is kairosdb.datapoints.factory.complex, replace complex-number with complex in your query string.

Hope this will help you! I am now having a problem to plot the complex data. I am still figuring out...

Ishita Sinha
  • 2,168
  • 4
  • 25
  • 38
Andy Ho
  • 45
  • 8