Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
A basic TICK script that reads anomalies and sends notifications to the default Slack channel
var model
var from_measurement
var out_db
var retention_policy
var out_measurement
var data = stream
|eval(lambda: model)
var saved = data
var pos = data
|stateCount(lambda: "is_anomaly" == TRUE)
// Warn after 1 point
.warn(lambda: "state_count" >= 1)
// Critical after 5 points
.crit(lambda: "state_count" >= 5 AND "score" > 90.0)
.message('{{ .Time }}: Hey, unexpected situation detected by model={{ index .Fields "model" }} state=ongoing score={{ index .Fields "score" | printf "%0.3f" }}.')
var neg = data
|stateCount(lambda: "is_anomaly" == FALSE)
.info(lambda: "state_count" == 1)
.message('{{ .Time }}: situation back to normal model={{ index .Fields "model" }} state=finished score={{ index .Fields "score" | printf "%0.3f" }}.')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.