influxdb/kapacitor/influxout.go

29 lines
698 B
Go
Raw Normal View History

2016-11-03 00:59:25 +00:00
package kapacitor
import (
"fmt"
"github.com/influxdata/chronograf"
)
2016-11-03 00:59:25 +00:00
// InfluxOut creates a kapacitor influxDBOut node to write alert data to Database, RP, Measurement.
func InfluxOut(rule chronograf.AlertRule) string {
// For some of the alert, the data needs to be renamed (normalized)
// before being sent to influxdb.
rename := ""
if rule.Trigger == "deadman" {
rename = `|eval(lambda: field).as('value')`
}
return fmt.Sprintf(`
2016-11-03 00:59:25 +00:00
trigger
%s
2016-11-03 00:59:25 +00:00
|influxDBOut()
.create()
.database(output_db)
.retentionPolicy(output_rp)
.measurement(output_mt)
.tag('alertName', name)
.tag('triggerType', triggerType)
`, rename)
2016-11-03 00:59:25 +00:00
}