Bulk insert Data in KairosDB

1000 Views Asked by At

In this link it is given that we can import data in KairosDB as: this link

>bin/kairosdb.sh import -f export.txt
If you happened to compress the export you can pipe it back into the system like this:

>gzip -dc export.gz | bin/kairosdb.sh import

I am not sure what should be the format of export.txt file

I have a file(export.txt) like:

Building_id,building_type,meter_type,unit,timestamp,value
1,Elementary School,temperature,F,1359695700,34.85
2,Park,temperature,F,1359695700,0
3,Industrial,temperature,F,1359695700,0.07
4,Recreation Center,temperature,F,1359695700,0
5,Park,temperature,F,1359695700,2.2
6,Community Center,temperature,F,1359695700,31.41
7,Office,temperature,F,1359695700,0
8,Elementary School,temperature,F,1359695700,10.88
9,Elementary School,temperature,F,1359695700,42.27
.
.

And I want to bulk insert this data into kairosDB, how can I do this.

1

There are 1 best solutions below

0
On

the import/export features use a JSON format a bit similar to the format sent to push data via REST API (c.f. http://kairosdb.github.io/kairosdocs/restapi/AddDataPoints.html ). One JSON document per line.

{
    "name": "kairosdb.jvm.free_memory",
    "tags": {
        "host": "TTES"
    },
    "datapoints": [
        [
            1438184280003,
            850322752
        ],        
        [
            1438184281003,
            850322753
        ]

]
}

AFAIK the import command was designed to import data previously dumped using export commands, not for populating the database with new data (you may prefer to use the telnet or REST interfaces for that).