Search code examples
alertinfluxdbkapacitor

How can I send just one alert with kapacitor if something is down?


I have the following stick script

stream
|from()
    .measurement('mymetric_value')
|deadman(1.0, 10s)
    .message('service is down!')
    .log('/tmp/alerts.log')
    .email('[email protected]')

It send an alert every 10 seconds that the service is down. How can I set it to send only one?


Solution

  • There is a property method stateChangesOnly() on Alert nodes in a TICKscript that will only issue an alert if the state of the alert changes. Your script would look like this:

    stream
    |from()
        .measurement('mymetric_value')
    |deadman(1.0, 10s)
        .message('service is down!')
        .log('/tmp/alerts.log')
        .email('[email protected]')
        .stateChangesOnly()
    

    See the kapacitor documentation on stateChangeOnly() for more information.