From 8912f81ffe2b2d4219c00e0f7e2319a06c0af309 Mon Sep 17 00:00:00 2001 From: Callum Styan Date: Tue, 22 Aug 2017 15:25:30 -0700 Subject: [PATCH] check if file_sd files exist in checkConfig --- cmd/promtool/main.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/cmd/promtool/main.go b/cmd/promtool/main.go index eee3ac07f..0b72470cd 100644 --- a/cmd/promtool/main.go +++ b/cmd/promtool/main.go @@ -152,6 +152,21 @@ func checkConfig(filename string) ([]string, error) { return nil, err } } + + for _, filesd := range scfg.ServiceDiscoveryConfig.FileSDConfigs { + for _, file := range filesd.Files { + files, err := filepath.Glob(file) + if err != nil { + return nil, err + } + if len(files) != 0 { + // There was at least one match for the glob and we can assume checkFileExists + // for all matches would pass, we can continue the loop. + continue + } + fmt.Printf(" WARNING: file %q for file_sd in scrape job %q does not exist\n", file, scfg.JobName) + } + } } return ruleFiles, nil