openstack-ansible-ops/cluster_metrics/kapacitor_files/tickscripts/mem_alert_stream.tick
Nish Patwa f0b26e6301 Added kapacitor scripts
Added kapacitor tickscripts to trigger alerts based on certain
thresholds.

Change-Id: I66d1b1e58d279405637d9a2f06b3aae19fa29cc3
Signed-off-by: Kevin Carter <kevin.carter@rackspace.com>
2017-01-26 22:10:45 +00:00

44 lines
977 B
Plaintext

// mem_alert_stream
// metric: used_percent
// available_fields: "active","available","available_percent","buffered","cached","free","inactive","total","used"
// TELEGRAF CONFIGURATION
// [[inputs.mem]]
// DEFINE: kapacitor define mem_alert_stream -type stream -tick mem/mem_alert_stream.tick -dbrp telegraf.autogen
// ENABLE: kapacitor enable mem_alert_stream
// Parameters
var info = 79
var warn = 89
var crit = 98
var period = 10s
var every = 10s
// Dataframe
var data = stream
|from()
.database('telegraf')
.retentionPolicy('autogen')
.measurement('mem')
.groupBy('host')
|window()
.period(period)
.every(every)
|mean('used_percent')
.as('stat')
// Thresholds
var alert = data
|alert()
.id('{{ index .Tags "host"}}/mem_used')
.message('{{ .ID }}:{{ index .Fields "stat" }}')
.info(lambda: "stat" > info)
.warn(lambda: "stat" > warn)
.crit(lambda: "stat" > crit)
// Alert
alert
.log('/tmp/mem_alert_log.txt')