migrate rrd files data to tsdb

446 views
Skip to first unread message

oc tsdb

unread,
Jan 20, 2014, 3:50:12 AM1/20/14
to open...@googlegroups.com
Hi all,

Is there a way(e.g. collector) to migrate data from rrd file to opentsdb?

Thanks
-OC

Filippo Giunchedi

unread,
Jan 20, 2014, 4:48:03 AM1/20/14
to OpenTSDB
On Mon, Jan 20, 2014 at 8:50 AM, oc tsdb <oc....@gmail.com> wrote:
> Hi all,
>
> Is there a way(e.g. collector) to migrate data from rrd file to opentsdb?

by migrate do you mean only once? if that is the case the easiest I
can think of is to use rrddump, get an xml dump and transform that
into the telnet interface format to be imported. Bear in mind of
course that the various RRAs inside will have done downsampling over
time and you'll have to figure out the metric/tags yourself. I guess a
sample script in contrib/ will be helpful if you get around to do it

HTH,
filippo

oc....@gmail.com

unread,
Jan 22, 2014, 11:57:55 AM1/22/14
to open...@googlegroups.com
Hi Filippo,

Thanks for your quick response.

Can we also use rrdtool fetch instead of rrdtool dump?
Can you please share any reference on rrdtool dump vs fetch.

Thanks
-OC

Filippo Giunchedi

unread,
Jan 23, 2014, 8:31:29 AM1/23/14
to OpenTSDB
On Wed, Jan 22, 2014 at 4:57 PM, <oc....@gmail.com> wrote:
> Hi Filippo,
>
> Thanks for your quick response.
>
> Can we also use rrdtool fetch instead of rrdtool dump?
> Can you please share any reference on rrdtool dump vs fetch.

sure you could also use rrdtool fetch, dump will just give you the raw
rrd contents with timestamp + value in xml

http://oss.oetiker.ch/rrdtool/doc/rrddump.en.html
http://oss.oetiker.ch/rrdtool/doc/rrdfetch.en.html

pla...@acipia.com

unread,
Jan 30, 2014, 5:24:05 AM1/30/14
to open...@googlegroups.com
hi,

i've just been in the same issue !
this is some bash code i used to convert rrd to a flat file which can be import using "tsdb import".

my files are arranged like hostname/target.rrd, the DS names are not used (i only have 1 metric here). you should be able to adapt it to suit your needs.
note that it create a timeserie for each DS * each RRA * each CF function

#!/bin/bash

FILE
=$1

if [ -f $FILE ] ; then

LC_ALL
=C \
    rrdtool
dump $FILE | \
    egrep
"\<row\>|\<cf\>" | grep -v NaN |
    awk
-v tmp=$FILE \
   
'BEGIN { rra=0 ; match(tmp, /\//) ; host=substr(tmp, 0, RSTART) ; target=substr(tmp, RSTART+1) ; } { if ($1=="<cf>") { rra++ ; cf=tolower($2) ; } else { for (i = 9; i < NF; i+=2) { printf "metric %s %.4s host=%s target=%s step=%s rra=%s%s\n", $6, $i, host, target, ((i-9)/2)+1, cf, rra } } }'

else
    echo
"no such file $FILE"
   
exit 1
fi


have fun !

P
Reply all
Reply to author
Forward
0 new messages