示例#1
0
文件: expr.go 项目: aglagla/kapacitor
// Evaluate a given expression as a boolean predicate against a set of fields and tags
func EvalPredicate(se *tick.StatefulExpr, now time.Time, fields models.Fields, tags models.Tags) (bool, error) {
	vars, err := mergeFieldsAndTags(now, fields, tags)
	if err != nil {
		return false, err
	}
	b, err := se.EvalBool(vars)
	if err != nil {
		return false, err
	}
	return b, nil
}
示例#2
0
文件: expr.go 项目: md14454/kapacitor
// Evaluate a given expression as a boolean predicate against a set of fields and tags
func EvalPredicate(se *tick.StatefulExpr, fields models.Fields, tags map[string]string) (bool, error) {
	vars, err := mergeFieldsAndTags(fields, tags)
	if err != nil {
		return false, err
	}
	b, err := se.EvalBool(vars)
	if err != nil {
		return false, err
	}
	return b, nil
}