|
|
@ -48,9 +48,23 @@ func (rule RecordingRule) eval(timestamp clientmodel.Timestamp, engine *promql.E
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
vector, err := query.Exec().Vector()
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
result := query.Exec()
|
|
|
|
return nil, err
|
|
|
|
var vector promql.Vector
|
|
|
|
|
|
|
|
switch result.Value.(type) {
|
|
|
|
|
|
|
|
case promql.Vector:
|
|
|
|
|
|
|
|
vector, err = result.Vector()
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
return nil, err
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
case *promql.Scalar:
|
|
|
|
|
|
|
|
scalar, err := result.Scalar()
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
return nil, err
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
vector = promql.Vector{&promql.Sample{Value: scalar.Value, Timestamp: scalar.Timestamp}}
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
return nil, fmt.Errorf("rule result is not a vector or scalar")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Override the metric name and labels.
|
|
|
|
// Override the metric name and labels.
|
|
|
|