Last active
December 4, 2015 06:17
-
-
Save xav-b/cfbe3012bd688f831131 to your computer and use it in GitHub Desktop.
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
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') |
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
#!/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