Kapacitor condition to do not spam alerts

Hello,

I have a very basic metric “if CPU > 75% than send alert to email”. But problem that I receive a lot of spam in case if this load happens during 10-15 minutes.

How to prevent it and send second message for example only after 5 minutes in case if this load still exist?

Thank you.

1 Like

Post your tickscript!

1 Like

Hello! I was wondering the same thing! Here’s my TickScript.
var db = ‘windows’

var rp = ‘server_rp’

var measurement = ‘win_cpu’

var groupBy =

var whereFilter = lambda: (“host” == ‘HOSTNAME’)

var name = ‘Windows Testing’

var idVar = name

var message = ‘{{.Tags}}’

var idTag = ‘alertID’

var levelTag = ‘level’

var messageField = ‘message’

var durationField = ‘duration’

var outputDB = ‘chronograf’

var outputRP = ‘autogen’

var outputMeasurement = ‘alerts’

var triggerType = ‘threshold’

var details = ‘CPU over 50% on {{.Tags}}’

var crit = 75

var data = stream
|from()
.database(db)
.retentionPolicy(rp)
.measurement(measurement)
.groupBy(groupBy)
.where(whereFilter)
|eval(lambda: “Percent_Privileged_Time”)
.as(‘value’)

var trigger = data
|alert()
.crit(lambda: “value” > crit)
.message(message)
.id(idVar)
.idTag(idTag)
.levelTag(levelTag)
.messageField(messageField)
.durationField(durationField)
.details(details)
.stateChangesOnly()
.email()
.to(‘myemail@email.com’)

trigger
|eval(lambda: float(“value”))
.as(‘value’)
.keep()
|influxDBOut()
.create()
.database(outputDB)
.retentionPolicy(outputRP)
.measurement(outputMeasurement)
.tag(‘alertName’, name)
.tag(‘triggerType’, triggerType)

trigger
|httpOut(‘output’)

Hello,

Add .stateChangesOnly() to your alert node docs

Unless it’s in the wrong place, I do have that in there no?

Ah yeah, i missed it. I normally hae it further up in the node. My bad. One thing i did notice, you’re using hostname in your whereFilter. your groupBy() looks empty. Try adding the hostname tag to your group by