Search code examples
hbaseopentsdb

Deleting all data and metrices from OpenTSDB


I made two metrices in OpenTSDB for test purpose using the command:

./build/tsdb mkmetric temperatures
./build/tsdb mkmetric meterreadings

I also entered datapoints in these metrices as using Java:

put temperatures 1356998400 23.5 room=bedroom floor=1\n
put meterreading 1430568000 32800 accumulationBehaviour=4 commodity=1 dataQualifier=12 defaultQuality=0 flowDirection=1 intervalLength=900 intervalLength=900 kind=12 phase=769 powerOfTenMultiplier=0 timeAttribute=0 uom=72
put meterreading 1430568900 33624 accumulationBehaviour=4 commodity=1 dataQualifier=12 defaultQuality=0 flowDirection=1 intervalLength=900 intervalLength=900 kind=12 phase=769 powerOfTenMultiplier=0 timeAttribute=0 uom=72
put meterreading 1430569800 35192 accumulationBehaviour=4 commodity=1 dataQualifier=12 defaultQuality=0 flowDirection=1 intervalLength=900 intervalLength=900 kind=12 phase=769 powerOfTenMultiplier=0 timeAttribute=0 uom=72
put meterreading 1430570700 37928 accumulationBehaviour=4 commodity=1 dataQualifier=12 defaultQuality=0 flowDirection=1 intervalLength=900 intervalLength=900 kind=12 phase=769 powerOfTenMultiplier=0 timeAttribute=0 uom=72

Now I want to delete all the data and metrices, so that OpenTSDB behave as fresh installation.

In the documentation they mention using scan command, I am not sure how to use this command.


Solution

  • It is well-written in Opentsdb website. Also, they have google group where somebody already has written answer for it.

    Syntax:

    scan [--delete|--import] START-DATE [END-DATE] query [queries...]

    Examples:

    tsdb scan --delete 1970/01/01-00:00:00 sum temperatures

    tsdb scan --delete 1970/01/01-00:00:00 sum meterreadings

    If you want to specify zookepeer:
    tsdb scan --delete --zkquorum localhost 1970/01/01 min temperatures
    

    This will delete all the data stored in tsdb table. But I think it doesn't delete the entry from tsdb-uid table. You can most probably rename the metric name to new name.

    `tsdb uid rename metrics old.name new.name`