Question about TickScript

Hi all, I’m working to implement this tool in our company. I need you need to check if is possible create a Tick Script to check CPU and use differents Handlers for Warning and Critical states. Ex:
If the value is over Warning send a email but is over critical send a slack message.

If this is possible could you send me a example?.

Thanks you

I would do this as two separate TICKscript’s. One script

|where("state" == 'warning')
|alert()
  .email(...)

and the other script

|where("state" == 'critical')
    |alert()
      .slack()

Are the warning critical levels the ones generated by Kapcitor or are they field values?

Filtering on critical/warning might not work, if they are Kapacitor levels then the state would never exist until the alert is generated. Filtering this way would stop any OK messages from being sent/received as well as any points with OK in would not be processed.

You should be able to acheive this with one script, using two alert nodes.

var trigger = data
    |alert()
        .crit(lambda: "cpu_usage" > your_critical_threshold) 
        .message(message)
        .id(idVar)
        .idTag(idTag)
        .levelTag(levelTag)
        .messageField(messageField)
        .durationField(durationField)
        .slack()

var trigger = data
    |alert()
        .warn(lambda: "cpu_usage" > your_warning_threshold) 
        .message(message)
        .id(idVar)
        .idTag(idTag)
        .levelTag(levelTag)
        .messageField(messageField)
        .durationField(durationField)
        .email()

You might need to change the second trigger var name to trigger2 - I can’t remember or find the script I do this in. I needed to generate deadman alerts with different alert levels, this is how i achieved it.

1 Like