Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Kapacitor alert to warn on inodes percent used
// inodes_alert example
// DEFINE: kapacitor define inodes_alert -type stream -tick inodes_alert.tick -dbrp telegraf.ninety_days
// ENABLE: kapacitor enable inodes_alert
// Parameters
var period = 5m
var every = 30s
var warn = 90
var crit = 95
var used = stream
|from()
.measurement('disk')
.groupBy('host', 'path')
|window()
.period(period)
.every(every)
|max('inodes_used')
var total = stream
|from()
.measurement('disk')
.groupBy('host', 'path')
|window()
.period(period)
.every(every)
|max('inodes_total')
var alert = used
|join(total)
.as('used','total')
.tolerance(1s)
|eval(lambda: float("used.max" / "total.max") * 100.00).as('inodes_used_percent')
// Thresholds
|alert()
.id('{{ index .Tags "host"}}')
.message('{{ .Level }}: Volume {{ index .Tags "path"}} inodes used is {{ index .Fields "inodes_used_percent" }}% on HOST {{ .ID }}')
.warn(lambda: "inodes_used_percent" > warn)
.crit(lambda: "inodes_used_percent" > crit)
// .stateChangesOnly()
// Alert
alert
.log('/tmp/inodes_alert_log.txt')
.hipChat()
// .room('ias_rampart_alerts')
.room('Kapacitor Testing')
.token('iprzorBbswdEbDTpOLC1V8I0uAZqllh9KooCGVxz')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment