-
Notifications
You must be signed in to change notification settings - Fork 492
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
How to check last n continue value #281
Comments
Right now there is a way to do this but its a bit complex, more details below. What you really want is a way to tell the alert node how to treat of window of data. Right now it is hard coded to trigger an alert if Something like this: stream.from()...
.window()
.period(20s)
.every(10s)
.alert()
.all()// Only fire alert if all points in a window match
.warn(lambda: "used" > 80.0)
.crit(lambda: "used" > 90.0)
.all() Here is a workaround which involves counting the number of points in a window before and after the condition is applied. var data = stream.from()...
.window()
.period(20s)
.every(10s)
var origCount = data.mapReduce(influxql.count('used'))
var filteredCount = data.where(lambda: "used" > 90).mapReduce(influxql.count('used'))
origCount.join(filteredCount)
.as('orig', 'filtered')
.alert()
.crit(lambda: "orig.count" == "filtered.count") Obviously overly complex and not good idea. Will definitely add the |
I am also looking for something like this :) Related: Can I compute the MEAN over a given time interval to alert only, if the MEAN is above a threshold? For example I would like to look at the MEAN over the last 5 minutes. |
@hrzbrg Using a time interval is possible and quite easy to do. Counting specific points is not so easy at the moment. Example: stream.from()...
.window()
.period(5m)
.every(5m)
.mapReduce(influxql.mean('value'))
.alert()
.crit(lambda: "mean" > 10) |
@nathanielc |
@haowells Its not implemented yet. My example is a proposed solution. |
but the value when the alarm is restored is the value when the alarm is triggered. |
want to check cpu usage value for last 3 data sample ponits, when all of these data points match condition, then tirgger alarm. how to write it ?
var data = stream.from().measurement('cpu')
var data = data.where(lambda: hour("time") >= 10 AND hour("time") <= 17)
data
.groupBy('host', 'cpu')
//.window()
// .period(20s)
// .every(10s)
.eval(lambda: 100.0 - "usage_idle").as('used')
.alert()
.id('{{ .Name}}/{{ index .Tags "host" }}/{{ index .Tags "cpu"}}')
.message('this is msg')
.details('this is detail')
.warn(lambda: "used" > 80.0)
//.crit(lambda: "used" > 90.0)
.log('/tmp/alarms.log')
//.stateChangesOnly()var data = stream.from().measurement('cpu')
var data = data.where(lambda: hour("time") >= 10 AND hour("time") <= 17)
//var data = data.where(lambda: "cpu" == 'cpu1')
//var data_jq = stream.from().measurement('cpu').where(lambda: "dc" == 'jq')
//var data_njq = stream.from().measurement('cpu').where(lambda: "dc" != 'jq')
The text was updated successfully, but these errors were encountered: