-
Notifications
You must be signed in to change notification settings - Fork 489
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
reseting window over time #727
Comments
Use derivative with the nonNegative flag so that is skips negative results. This will compute the difference between each pair of points. Skipping the one pair of points where the rate is negative. Then you can sum or average the rate across the whole batch in order to get back the rate for the whole window. Its not exactly the same but it should work well. |
For exmaple: var windows = stream
|from()
.measurment('DisconnectionsCounter')
|where(labmda: "server_name" == 'TestServer' and "path" =~ /^(.*)\.DisconnectionsCounter$/)
|window()
.period(10m)
.every(10s)
.align()
|derivative()
.as('rate')
.nonNegative()
|sum('rate')
.as('rate')
|alert()
.id('DisconnectionsCounterOnTestServer')
.info(labmda: "rate" >= 0)
.crit(labmda: "rate" > 0)
.post('http://MyTestServer:8323') |
This might work for disconnection counters where the value needed is zero or more. |
The derivative also has a |
var windows = stream
|from()
.measurment('InsertionsCounter')
|where(labmda: "server_name" == 'TestServer' and "path" =~ /^(.*)\.InsertionsCounter$/)
|window()
.period(10m)
.every(10s)
.align()
|derivative()
.as('rate')
.nonNegative()
|sum('rate')
.as('rate')
|alert()
.id('DisconnectionsCounterOnTestServer')
.info(labmda: "rate" >= 100)
.crit(labmda: "rate" > 100)
.post('http://MyTestServer:8323') It's pretty close to the disconnection counter. The only difference is that I need it to be more a 100 and not just something or nothing |
If you add a
I am going to test this out locally to make sure I am understanding this correctly. |
Playing around with the But I had another idea that is simpler. What about always using the var windows = stream
|from()
.measurment('DisconnectionsCounter')
|where(labmda: "server_name" == 'TestServer' and "path" =~ /^(.*)\.DisconnectionsCounter$/)
|window()
.period(10m)
.every(10s)
.align()
var previous = windows
|min('value')
var current = windows
|last('value')
previous
|join(current)
.as('previous', 'current')
|eval(lambda: "current.last" - "previous.min")
.as('rate')
|alert()
.id('DisconnectionsCounterOnTestServer')
.info(labmda: "rate" == 0 OR "rate" > 0)
.crit(labmda: "rate" > 0)
.post('http://MyTestServer:8323') Will that work? Also #745 is adding |
Hi,
I'm using Kapacitor in order to alert when a rate of some increasing value changes over time.
For example: The disconnection of servers on the last 10 minutes.
Now, if i reset the value once a day the rate value is negative, bacause the last value is higher than the value after reseting(zero),
and so for the period(10m) of the window i have no way to tell if there were any disconnections.
The optimal solution for me is to "somehow" reset the window when i reset my disconnections counter or do the next logic
As you can see, I need to do some if logic in eval. is it possible? or is there any patch i can to in order to achieve such behavior?
The text was updated successfully, but these errors were encountered: