Skip to content

Instantly share code, notes, and snippets.

@thomastaylor312
Created November 4, 2016 18:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thomastaylor312/c5f5330fabe22d0c54ed445b6eef8639 to your computer and use it in GitHub Desktop.
Save thomastaylor312/c5f5330fabe22d0c54ed445b6eef8639 to your computer and use it in GitHub Desktop.
An example Kapacitor alert
stream
// The following stream alerts based on changes in cpu/usage
// Every minute the rate of change for the cpu/usage is calculated
// Alerts are sent out when that rate is unusually high
|from()
.measurement('cpu/usage')
.where(lambda: "type" == 'node' AND "nodename" =~/.*cassandra.*/)
.groupBy('nodename')
|derivative('value')
.unit(60s)
.nonNegative()
|window()
.period(1m)
.every(1m)
|alert()
.id('{{ .Name }}/{{ index .Tags "nodename" }}')
.message('{{ .ID }} is increasing at a {{ .Level }} rate. value:{{ index .Fields "value" }}')
// Sigma is a built in Kapacitor function used to calculate standard deviations
// 2 standard deviations away is about 95% greater than normal
.warn(lambda: sigma("value")> 2)
.crit(lambda: sigma("value")> 2.5)
.slack()
.channel('#alerts')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment