From 7e96e2a4d8965ff7d7c8cb94ef76645d68b891b3 Mon Sep 17 00:00:00 2001 From: Edward Welch Date: Thu, 6 Aug 2020 17:00:47 -0400 Subject: [PATCH 1/2] force the log level on any Loki Push API target servers to match Promtail's log level. --- pkg/promtail/promtail.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkg/promtail/promtail.go b/pkg/promtail/promtail.go index 259c864b9ae29..e36520c7ca0c4 100644 --- a/pkg/promtail/promtail.go +++ b/pkg/promtail/promtail.go @@ -50,6 +50,14 @@ 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 + } + } + var err error if dryRun { promtail.client, err = client.NewLogger(promtail.logger, cfg.ClientConfigs...) From 77baaf0fbb6751769aef86a651fac8abe595e30a Mon Sep 17 00:00:00 2001 From: Edward Welch Date: Thu, 6 Aug 2020 17:09:44 -0400 Subject: [PATCH 2/2] also include logformat --- pkg/promtail/promtail.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/promtail/promtail.go b/pkg/promtail/promtail.go index e36520c7ca0c4..67cc74fda49e3 100644 --- a/pkg/promtail/promtail.go +++ b/pkg/promtail/promtail.go @@ -55,6 +55,7 @@ func New(cfg config.Config, dryRun bool, opts ...Option) (*Promtail, error) { 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 } }