Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bulk insert Data in KairosDB

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.

like image 677
Bharthan Avatar asked Feb 14 '26 07:02

Bharthan


1 Answers

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).

like image 75
Loic Avatar answered Feb 17 '26 01:02

Loic



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!