diff --git a/rules/ast/functions.go b/rules/ast/functions.go index a27bc87ce..6a2c3ca5b 100644 --- a/rules/ast/functions.go +++ b/rules/ast/functions.go @@ -75,7 +75,7 @@ func (function *Function) CheckArgTypes(args []Node) error { // === time() clientmodel.SampleValue === func timeImpl(timestamp clientmodel.Timestamp, view *viewAdapter, args []Node) interface{} { - return clientmodel.SampleValue(time.Now().Unix()) + return clientmodel.SampleValue(timestamp.Unix()) } // === delta(matrix MatrixNode, isCounter ScalarNode) Vector === diff --git a/rules/rules_test.go b/rules/rules_test.go index d29a463af..8681499eb 100644 --- a/rules/rules_test.go +++ b/rules/rules_test.go @@ -496,6 +496,12 @@ func TestExpressions(t *testing.T) { fullRanges: 2, intervalRanges: 0, }, + { + expr: `time()`, + output: []string{`scalar: 3000 @[%v]`}, + fullRanges: 0, + intervalRanges: 0, + }, } tieredStorage, closer := newTestStorage(t)