f0b26e6301
Added kapacitor tickscripts to trigger alerts based on certain thresholds. Change-Id: I66d1b1e58d279405637d9a2f06b3aae19fa29cc3 Signed-off-by: Kevin Carter <kevin.carter@rackspace.com>
40 lines
1.0 KiB
Plaintext
40 lines
1.0 KiB
Plaintext
// conntrack_alert
|
|
|
|
// metric: {ip_conntrack_count,ip_conntrack_max}
|
|
|
|
// TELEGRAF CONFIGURATION
|
|
// [[inputs.conntrack]]
|
|
// files = ["ip_conntrack_count","ip_conntrack_max",
|
|
// "nf_conntrack_count","nf_conntrack_max"]
|
|
// dirs = ["/proc/sys/net/ipv4/netfilter","/proc/sys/net/netfilter"]
|
|
|
|
// DEFINE: kapacitor define conntrack_alert_batch -type batch -tick conntrack_alert_batch.tick -dbrp telegraf.autogen
|
|
// ENABLE: kapacitor enable conntrack_alert_batch
|
|
|
|
// Parameters
|
|
var info = 69
|
|
var warn = 79
|
|
var crit = 89
|
|
var period = 10s
|
|
var every = 10s
|
|
|
|
// Dataframe
|
|
var data = batch
|
|
|query('''select (mean(ip_conntrack_count)/mean(ip_conntrack_max))*100 as stat from "telegraf"."autogen".conntrack''')
|
|
.period(period)
|
|
.every(every)
|
|
.groupBy('host')
|
|
|
|
// Thresholds
|
|
var alert = data
|
|
|alert()
|
|
.id('{{ index .Tags "host"}}/connection_used')
|
|
.message('{{ .ID }}:{{ index .Fields "stat" }}')
|
|
.info(lambda: "stat" > info)
|
|
.warn(lambda: "stat" > warn)
|
|
.crit(lambda: "stat" > crit)
|
|
|
|
// Alert
|
|
alert
|
|
.log('/tmp/conntrack_alert_log.txt')
|