简体   繁体   中英

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.

the import/export features use a JSON format a bit similar to the format sent to push data via REST API (cf 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).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM