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