2016-11-03 00:59:25 +00:00
|
|
|
package kapacitor
|
|
|
|
|
|
|
|
import "github.com/influxdata/chronograf"
|
|
|
|
import "fmt"
|
|
|
|
|
|
|
|
// Trigger returns the trigger mechanism for a tickscript
|
|
|
|
func Trigger(rule chronograf.AlertRule) (string, error) {
|
|
|
|
switch rule.Trigger {
|
|
|
|
case "deadman":
|
|
|
|
return DeadmanTrigger, nil
|
|
|
|
case "relative":
|
|
|
|
return execTemplate(RelativeTrigger, rule)
|
|
|
|
case "threshold":
|
|
|
|
return execTemplate(ThresholdTrigger, rule)
|
|
|
|
default:
|
2016-11-03 19:21:17 +00:00
|
|
|
return "", fmt.Errorf("Unknown trigger type: %s", rule.Trigger)
|
2016-11-03 00:59:25 +00:00
|
|
|
}
|
|
|
|
}
|