Update function name for kapacitor's formatting of values

pull/10616/head
Chris Goller 2017-02-10 10:06:26 -06:00
parent a523350bf0
commit 27bafdab53
1 changed files with 4 additions and 8 deletions

View File

@ -40,10 +40,7 @@ func Vars(rule chronograf.AlertRule) (string, error) {
%s
var crit = %s
`
// If critical value is a string, we'll
// need to single-quote it.
crit := critVar(rule.TriggerValues.Value)
return fmt.Sprintf(vars, common, crit), nil
return fmt.Sprintf(vars, common, formatValue(rule.TriggerValues.Value)), nil
} else {
vars := `
%s
@ -181,10 +178,9 @@ func whereFilter(q chronograf.QueryConfig) string {
return "lambda: TRUE"
}
// critVar return the same string if a numeric type
// or if it is a string will return it as a kapacitor
// formatted single-quoted string
func critVar(value string) string {
// formatValue return the same string if a numeric type or if it is a string
// will return it as a kapacitor formatted single-quoted string
func formatValue(value string) string {
// Test if numeric if it can be converted to a float
if _, err := strconv.ParseFloat(value, 64); err == nil {
return value