Last active
February 16, 2019 07:53
-
-
Save regel/b544cc76dcde36638bc17afeca00c19d to your computer and use it in GitHub Desktop.
TICKscript example triggering alerts on PagerDuty
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var model = 'telegraf_metrics_count_value_10s' | |
var from_measurement = 'loudml' | |
var out_db = 'telegraf' | |
var retention_policy = 'autogen' | |
var out_measurement = 'predicted' | |
var data = stream | |
|from() | |
.measurement(from_measurement) | |
.where(lambda: "model" == model) | |
|eval(lambda: model) | |
.as('model') | |
.keep() | |
var saved = data | |
|influxDBOut() | |
.database(out_db) | |
.retentionPolicy(retention_policy) | |
.measurement(out_measurement) | |
var pos = data | |
|changeDetect('is_anomaly') | |
|alert() | |
.warn(lambda: "is_anomaly" == TRUE) | |
.crit(lambda: "is_anomaly" == TRUE AND "score" > 90.0) | |
.message('{{if ne .Level "OK" }} Hey, unexpected situation detected score={{ index .Fields "score" | printf "%0.3f" }} {{else}} Back to normal {{end}}') | |
.pagerDuty2() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment