I currently have a task that monitors for the number of docker containers
running dropping. For this type of alarm, I really don't need it to
recover or even have state levels. I just want to know if it occurred.
With the tick script below I get the alert indicating that the number has
dropped by one, but I don't want the state to go back to OK, i.e. just want
one alert.
Is there anyway to accomplish this with the alert node?
Thanks
TICK SCRIPT START
//This task will alert on changes in the number of running containers,
//if the number drops it could indicate that the container exited.
var data = stream
|from()
.database(database)
.retentionPolicy(retention_policy)
.measurement('docker')
.groupBy('host')
|where(lambda: "deployment" == deployment)
|eval(lambda: "n_containers")
.as('_n_containers')
.keep()
.quiet()
|window()
.period(1m)
.every(1m)
//|log() //Uncomment to debug
var min_value = data
|min('_n_containers')
.as('value')
var max_value = data
|max('_n_containers')
.as('value')
//Compute the delta between min and max, by joining two window outputs
//If negative change we lost a container
min_value
|join(max_value)
.as('min_running', 'max_running')
|eval(lambda: "min_running.value" - "max_running.value")
.as('change_delta')
|alert()
.info(lambda: "change_delta" < 0)
.infoReset(lambda: "change_delta" >= 0)
.message('\'{{.TaskName}}\' --> \'{{ .Level }}\'
Host \'{{ index .Tags "host" }}\'
Number of running containers has changed by \'{{ index .Fields
"change_delta" }}\'')
.slack()
.channel(slack_channel)
--
Remember to include the version number!
---
You received this message because you are subscribed to the Google Groups
"InfluxData" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/influxdb.
To view this discussion on the web visit
https://groups.google.com/d/msgid/influxdb/b8ce813a-5b88-41c1-ba05-dcbf9d227b64%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.