Skip to content

Commit

Permalink
Promtail: force the log level on any Loki Push API target servers to …
Browse files Browse the repository at this point in the history
…match Promtail's log level. (#2475)

* force the log level on any Loki Push API target servers to match Promtail's log level.

* also include logformat
  • Loading branch information
slim-bean committed Aug 10, 2020
1 parent b8a6135 commit 7418d42
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pkg/promtail/promtail.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,15 @@ func New(cfg config.Config, dryRun bool, opts ...Option) (*Promtail, error) {
cfg.ClientConfigs = append(cfg.ClientConfigs, cfg.ClientConfig)
}

// This is a bit crude but if the Loki Push API target is specified,
// force the log level to match the promtail log level
for i := range cfg.ScrapeConfig {
if cfg.ScrapeConfig[i].PushConfig != nil {
cfg.ScrapeConfig[i].PushConfig.Server.LogLevel = cfg.ServerConfig.LogLevel
cfg.ScrapeConfig[i].PushConfig.Server.LogFormat = cfg.ServerConfig.LogFormat
}
}

var err error
if dryRun {
promtail.client, err = client.NewLogger(promtail.logger, cfg.ClientConfig.ExternalLabels, cfg.ClientConfigs...)
Expand Down

0 comments on commit 7418d42

Please sign in to comment.