@@ -3,7 +3,6 @@ package ruler
33import (
44 "context"
55 "fmt"
6- "os"
76 "time"
87
98 "github.com/go-kit/log"
@@ -13,6 +12,7 @@ import (
1312 "github.com/grafana/loki/v3/pkg/logql"
1413 "github.com/grafana/loki/v3/pkg/logqlmodel"
1514 "github.com/grafana/loki/v3/pkg/util"
15+ util_log "github.com/grafana/loki/v3/pkg/util/log"
1616)
1717
1818const EvalModeLocal = "local"
@@ -32,7 +32,11 @@ func NewLocalEvaluator(engine *logql.Engine, logger log.Logger) (*LocalEvaluator
3232 return nil , fmt .Errorf ("given engine is nil" )
3333 }
3434
35- return & LocalEvaluator {engine : engine , logger : logger , insightsLogger : log .NewLogfmtLogger (os .Stderr )}, nil
35+ return & LocalEvaluator {
36+ engine : engine ,
37+ logger : logger ,
38+ insightsLogger : log .With (util_log .Logger , "msg" , "request timings" , "insight" , "true" , "source" , "loki_ruler" ),
39+ }, nil
3640}
3741
3842func (l * LocalEvaluator ) Eval (ctx context.Context , qs string , now time.Time ) (* logqlmodel.Result , error ) {
@@ -60,6 +64,6 @@ func (l *LocalEvaluator) Eval(ctx context.Context, qs string, now time.Time) (*l
6064 // Retrieve rule details from context
6165 ruleName , ruleType := GetRuleDetailsFromContext (ctx )
6266
63- level .Info (l .insightsLogger ).Log ("msg" , "request timings" , "insight" , "true" , "source" , "loki_ruler" , " rule_name" , ruleName , "rule_type" , ruleType , "total" , res .Statistics .Summary .ExecTime , "total_bytes" , res .Statistics .Summary .TotalBytesProcessed , "query_hash" , util .HashedQuery (qs ))
67+ level .Info (l .insightsLogger ).Log ("rule_name" , ruleName , "rule_type" , ruleType , "total" , res .Statistics .Summary .ExecTime , "total_bytes" , res .Statistics .Summary .TotalBytesProcessed , "query_hash" , util .HashedQuery (qs ))
6468 return & res , nil
6569}
0 commit comments