Skip to content

Instantly share code, notes, and snippets.

@xav-b
Last active December 4, 2015 06:17
Show Gist options
  • Save xav-b/cfbe3012bd688f831131 to your computer and use it in GitHub Desktop.
Save xav-b/cfbe3012bd688f831131 to your computer and use it in GitHub Desktop.
stream
// Select just the cpu_usage_idle measurement from our example database.
.from().measurement('cpu_usage_idle')
.alert()
.crit(lambda: "value" < 70)
// Whenever we get an alert write it to a file.
.log('/tmp/alerts.log')
#!/bin/bash
#
# stack
# - storage: InfluxDB
# - viz: Grafana
# - cli: Glances
# - systems metrics & aggregation: Telegraf
# - instrumentation: statsd client
# - alerting: Kapacitor
install_kapacitor() {
local version="0.1.1-1"
local arch="x86_64"
local url="https://s3.amazonaws.com/influxdb"
local pkg="kapacitor-${version}.${arch}.rpm"
wget ${url}/{pkg}
sudo yum localinstall -y ${pkg}
}
run_alerting() {
kapacitord config > kapacitor.conf
# NOTE no entreprise token configured
}
# create the task
kapacitor define \
-name cpu_alert \
-type stream \
-tick ./provisioning/alerts/cpu_alert.tick \
-dbrp telegraf.default
# test the script
rid=$(kapacitor record stream -name cpu_alert -duration 20s)
kapacitor replay -id $rid -name cpu_alert -tick cpu_alert.tick
# let's go wild
kapacitor enable cpu_alert
while true; do i=0; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment