Forum Discussion

dragonflymr's avatar
dragonflymr
Icon for Cirrostratus rankCirrostratus
Mar 27, 2017

How to remove iStats keys

Hi,

 

I know that it's possible to reset iStats keys to 0 but is there a way to remove keys that are no longer needed?

 

Piotr

 

4 Replies

  • Hi,

     

    I know about ISTATS::remove command. Is this command working in different way than istats remove used via CLI? When I am using CLI command only result is that removed key is reset to 0 value (counter type) but key is still listed when using istats dump.

     

    Even if iRule commend is indeed removing key completely there is still problem how to bulk remove iStats keys if those keys were build using random values that are not known after creation (except by listing using istats dump).

     

    Piotr

     

  • Hi Piotr,

    unfortuantely there is no easy to use

    istats remove all
    command... 😞

    A while ago, I've used the following bash command to delete my ISTATS data.

    istats dump 2>&1>/dev/null | sed "s/\[//g;s/\]//g;s/=/ /g" | awk '{ print "istats remove \"" $1 " " $2 " counter " $3 "\"" }' | bash -x ;
    sleep 15s
    istats dump 2>&1>/dev/null | sed "s/\[//g;s/\]//g;s/=/ /g" | awk '{ print "istats remove \"" $1 " " $2 " string " $3 "\"" }' | bash -x ;
    sleep 15s
    istats dump 2>&1>/dev/null | sed "s/\[//g;s/\]//g;s/=/ /g" | awk '{ print "istats remove \"" $1 " " $2 " gauge " $3 "\"" }' | bash -x ;
    sleep 15s
    istats dump 2>&1>/dev/null | sed "s/\[//g;s/\]//g;s/=/ /g" | awk '{ print "istats remove \"" $1 " " $2 " min " $3 "\"" }' | bash -x ;
    sleep 15s
    istats dump 2>&1>/dev/null | sed "s/\[//g;s/\]//g;s/=/ /g" | awk '{ print "istats remove \"" $1 " " $2 " max " $3 "\"" }' | bash -x ;
    

    Note: The command parses the output of

    istats dump
    and then creates and executes a tailordered script to finaly remove the containing data. Its unfortunately required to call the command up to 5 times in a row, since
    istats dump
    does not output the used
    measure-type
    (but it has to match while removing). The
    sleep 15s
    command makes sure that ISTATS updates the statistic between the independent executions to reduce overhead.

    Note: Use the script at your own risk 😉

    Cheers, Kai

  • Hi Piotr,

    this one will work too...

    [user@unit:Active:Standalone] tmp  istats dump
    /var/tmstat/cluster.tm2 [READONLY]: nextBlockId=384, last update at 2017-03-29 14:53:35 
    
    all facts:
    
    [user@unit:Active:Standalone] tmp  istats set "aaa aaa string aaa" 1
    [user@unit:Active:Standalone] tmp  istats set "aaa aaa gauge aaa" 1
    [user@unit:Active:Standalone] tmp  istats set "aaa aaa counter aaa" 1
    [user@unit:Active:Standalone] tmp  istats set "aaa aaa min aaa" 1
    [user@unit:Active:Standalone] tmp  istats set "aaa aaa max aaa" 1
    [user@unit:Active:Standalone] tmp  istats dump
    /var/tmstat/cluster.tm2 [READONLY]: nextBlockId=1504, last update at 2017-03-29 14:54:05 
    
    all facts:
       [ aaa=aaa ][aaa] = 1 (2017-03-29 14:54:00)
       [ aaa=aaa ][aaa] = 1 (2017-03-29 14:54:00)
       [ aaa=aaa ][aaa] = 1 (2017-03-29 14:54:01)
       [ aaa=aaa ][aaa] = 1 (2017-03-29 14:54:00)
       [ aaa=aaa ][aaa] = 1 (2017-03-29 14:54:00)
    
    [user@unit:Active:Standalone] tmp  bigstart stop istatsd 
    [user@unit:Active:Standalone] tmp  rm -rf /var/tmstat2/cluster/* 
    [user@unit:Active:Standalone] tmp  rm -rf /var/tmstat2/blade/* 
    [user@unit:Active:Standalone] tmp  bigstart start istatsd
    [user@unit:Active:Standalone] tmp  istats dump
    /var/tmstat/cluster.tm2 [READONLY]: nextBlockId=384, last update at 2017-03-29 14:53:35 
    
    all facts:
    
    [user@unit:Active:Standalone] tmp  
    

    Cheers, Kai