Skip to content

Commit

Permalink
add component to ruler logger
Browse files Browse the repository at this point in the history
  • Loading branch information
ashwanthgoli committed Jan 19, 2024
1 parent 39871b3 commit fd9a102
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions pkg/loki/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -1029,13 +1029,15 @@ func (t *Loki) initQueryFrontend() (_ services.Service, err error) {
}

func (t *Loki) initRulerStorage() (_ services.Service, err error) {
logger := log.With(util_log.Logger, "component", "ruler-storage")

// if the ruler is not configured and we're in single binary then let's just log an error and continue.
// unfortunately there is no way to generate a "default" config and compare default against actual
// to determine if it's unconfigured. the following check, however, correctly tests this.
// Single binary integration tests will break if this ever drifts
legacyReadMode := t.Cfg.LegacyReadTarget && t.Cfg.isModuleEnabled(Read)
if (t.Cfg.isModuleEnabled(All) || legacyReadMode || t.Cfg.isModuleEnabled(Backend)) && t.Cfg.Ruler.StoreConfig.IsDefaults() && t.Cfg.RulerStorage.IsDefaults() {
level.Info(util_log.Logger).Log("msg", "Ruler storage is not configured; ruler will not be started.")
level.Info(logger).Log("msg", "Ruler storage is not configured; ruler will not be started.")
return
}

Expand All @@ -1048,9 +1050,9 @@ func (t *Loki) initRulerStorage() (_ services.Service, err error) {
}

if !t.Cfg.Ruler.StoreConfig.IsDefaults() {
t.RulerStorage, err = base_ruler.NewLegacyRuleStore(t.Cfg.Ruler.StoreConfig, t.Cfg.StorageConfig.Hedging, t.clientMetrics, ruler.GroupLoader{}, util_log.Logger)
t.RulerStorage, err = base_ruler.NewLegacyRuleStore(t.Cfg.Ruler.StoreConfig, t.Cfg.StorageConfig.Hedging, t.clientMetrics, ruler.GroupLoader{}, logger)
} else {
t.RulerStorage, err = base_ruler.NewRuleStore(context.Background(), t.Cfg.RulerStorage, nil, ruler.GroupLoader{}, util_log.Logger, prometheus.DefaultRegisterer)
t.RulerStorage, err = base_ruler.NewRuleStore(context.Background(), t.Cfg.RulerStorage, nil, ruler.GroupLoader{}, logger, prometheus.DefaultRegisterer)
}

return
Expand Down

0 comments on commit fd9a102

Please sign in to comment.