diff --git a/cmd/loki/main.go b/cmd/loki/main.go index 1151d52c1c89..7455f12bd7fb 100644 --- a/cmd/loki/main.go +++ b/cmd/loki/main.go @@ -33,6 +33,7 @@ var lineReplacer = strings.NewReplacer("\n", "\\n ") type Config struct { loki.Config `yaml:",inline"` printVersion bool + verifyConfig bool printConfig bool logConfig bool configFile string @@ -40,6 +41,7 @@ type Config struct { func (c *Config) RegisterFlags(f *flag.FlagSet) { f.BoolVar(&c.printVersion, "version", false, "Print this builds version information") + f.BoolVar(&c.verifyConfig, "verify-config", false, "Verify config file and exits") f.BoolVar(&c.printConfig, "print-config-stderr", false, "Dump the entire Loki config object to stderr") f.BoolVar(&c.logConfig, "log-config-reverse-order", false, "Dump the entire Loki config object at Info log "+ "level with the order reversed, reversing the order makes viewing the entries easier in Grafana.") @@ -87,6 +89,11 @@ func main() { os.Exit(1) } + if config.verifyConfig { + level.Info(util.Logger).Log("msg", "config is valid") + os.Exit(0) + } + if config.printConfig { err := logutil.PrintConfig(os.Stderr, &config) if err != nil {