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
data_dir = "/var/lib/kapacitor" | |
[[slack]] | |
enabled = true | |
default = true | |
workspace = "your_workspace" | |
url = "your_url" | |
channel = "your_channel" | |
global = false | |
state-changes-only = false |
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 | |
var from_measurement | |
var out_db | |
var retention_policy | |
var out_measurement |
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' |
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
git clone https://github.com/regel/loudml | |
cd loudml/docker/compose | |
vim etc/kapacitor.conf # notifications settings | |
vim etc/loudml.yml # optional: database settings |
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
// the machine learning model name, as defined in settings | |
var model = 'telegraf_metrics_count_value_10s' | |
// the measurement name, used by Loud ML to output predictions; default = loudml | |
var from_measurement = 'loudml' | |
// the output database name for output data written by this pipeline | |
var out_db = 'telegraf' | |
// the retention policy; let's use the default | |
var retention_policy = 'autogen' | |
// the output measurement name for output data written by this pipeline | |
var out_measurement = 'predicted' |
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 data = stream | |
// this from node selects all input data received in the given measurement | |
|from() | |
.measurement(from_measurement) | |
.where(lambda: "model" == model) | |
// this eval node remembers the model name | |
|eval(lambda: model) | |
.as('model') | |
.keep() | |
// the next five lines save the data to the target database into a new measurement |
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 pos = data | |
// the next node counts abnormal data points | |
|stateCount(lambda: "is_anomaly" == TRUE) | |
|alert() | |
// Warn after 1 point | |
.warn(lambda: "state_count" >= 1) | |
// Critical after 5 points and abnormal higher than 90 / 100 | |
.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" }}.') | |
.slack() |
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 neg = data | |
|stateCount(lambda: "is_anomaly" == FALSE) | |
|alert() | |
.info(lambda: "state_count" == 1) | |
.message('{{ .Time }}: situation back to normal model={{ index .Fields "model" }} state=finished score={{ index .Fields "score" | printf "%0.3f" }}.') | |
.slack() |
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
data_dir = "/var/lib/kapacitor" | |
[pagerduty2] | |
enabled = true | |
routing-key = "" | |
url = "https://events.pagerduty.com/v2/enqueue" | |
global = false | |
[logging] | |
# Destination for logs |
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 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() |
OlderNewer