-
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 count alert event? #313
Comments
Your message looks fine, its just that the value of the Once issue #93 is implemented you will be able to chain nodes off the alert node directly to perform these operations within TICKscript itself. Until #93 is implemented you can do this currently with a little bit of work. var warn_threshold = 70
var crit_threshold = 50
var data = stream
.from().measurement('cpu')
.groupBy('cpu')
// Do normal alerting
data.alert()
.warn(lambda: "usage_idle" < warn_threshold)
.crit(lambda: "usage_idle" < crit_threshold)
// Log alerts
.log('/home/maintain/alerts.log')
// Send alerts to slack
.slack()
// Count warn events
var warn_count = data.where(lambda: "usage_idle" < warn_threshold).mapReduce(influxql.count('usage_idle'))
var crit_count = data.where(lambda: "usage_idle" < crit_threshold).mapReduce(influxql.count('usage_idle'))
// Do what ever you want with the counts. Once #93 is finished it would look some like this: var warn_threshold = 70
var crit_threshold = 50
var data = stream
.from().measurement('cpu')
.groupBy('cpu')
.alert()
.warn(lambda: "usage_idle" < warn_threshold)
.crit(lambda: "usage_idle" < crit_threshold)
// Log alerts
.log('/home/maintain/alerts.log')
// Send alerts to slack
.slack()
.groupBy('level')
.mapReduce(influxql.count('value'))
// do what ever you want with the counts grouped by level |
Thanks it's perfect! |
Good Morning,
I need some help with tick script.
I generate critical and warning alerts and I want to count how much warning and alert I get for each element I have.
I want to count for each cpu when it's critical and when it's warning. How often it appears.
First I tried to use .message to generate json message but I can't use it because of the quote in .message(' ......')
What I want generate with tick script :
and What I generate :
My alerts.tick script:
Is it possible directly with the .message or script tick or I need to use another element to count my alert?
Thanks
The text was updated successfully, but these errors were encountered: