Remove EvalRaw methods from Rule interface

pull/779/head
Fabian Reinartz 10 years ago
parent 7943aa834c
commit 83d07516e8

@ -126,19 +126,14 @@ func (rule *AlertingRule) Name() string {
return rule.name
}
// EvalRaw returns the raw value of the rule expression, without creating alerts.
func (rule *AlertingRule) EvalRaw(timestamp clientmodel.Timestamp, engine *promql.Engine) (promql.Vector, error) {
// Eval evaluates the rule expression and then creates pending alerts and fires
// or removes previously pending alerts accordingly.
func (rule *AlertingRule) Eval(timestamp clientmodel.Timestamp, engine *promql.Engine) (promql.Vector, error) {
query, err := engine.NewInstantQuery(rule.Vector.String(), timestamp)
if err != nil {
return nil, err
}
return query.Exec().Vector()
}
// Eval evaluates the rule expression and then creates pending alerts and fires
// or removes previously pending alerts accordingly.
func (rule *AlertingRule) Eval(timestamp clientmodel.Timestamp, engine *promql.Engine) (promql.Vector, error) {
exprResult, err := rule.EvalRaw(timestamp, engine)
exprResult, err := query.Exec().Vector()
if err != nil {
return nil, err
}

@ -34,18 +34,13 @@ type RecordingRule struct {
// Name returns the rule name.
func (rule RecordingRule) Name() string { return rule.name }
// EvalRaw returns the raw value of the rule expression.
func (rule RecordingRule) EvalRaw(timestamp clientmodel.Timestamp, engine *promql.Engine) (promql.Vector, error) {
// Eval evaluates the rule and then overrides the metric names and labels accordingly.
func (rule RecordingRule) Eval(timestamp clientmodel.Timestamp, engine *promql.Engine) (promql.Vector, error) {
query, err := engine.NewInstantQuery(rule.vector.String(), timestamp)
if err != nil {
return nil, err
}
return query.Exec().Vector()
}
// Eval evaluates the rule and then overrides the metric names and labels accordingly.
func (rule RecordingRule) Eval(timestamp clientmodel.Timestamp, engine *promql.Engine) (promql.Vector, error) {
vector, err := rule.EvalRaw(timestamp, engine)
vector, err := query.Exec().Vector()
if err != nil {
return nil, err
}

@ -26,9 +26,6 @@ import (
type Rule interface {
// Name returns the name of the rule.
Name() string
// EvalRaw evaluates the rule's vector expression without triggering any
// other actions, like recording or alerting.
EvalRaw(clientmodel.Timestamp, *promql.Engine) (promql.Vector, error)
// Eval evaluates the rule, including any associated recording or alerting actions.
Eval(clientmodel.Timestamp, *promql.Engine) (promql.Vector, error)
// DotGraph returns a Graphviz dot graph of the rule.

Loading…
Cancel
Save