Update check-rules to new format.

Signed-off-by: Goutham Veeramachaneni <cs14btech11014@iith.ac.in>
pull/2842/head
Goutham Veeramachaneni 2017-06-14 13:32:26 +05:30
parent 2d1e92513b
commit 1c08743721
No known key found for this signature in database
GPG Key ID: F1C217E8E9023CAD
1 changed files with 9 additions and 7 deletions

View File

@ -29,6 +29,7 @@ import (
"github.com/prometheus/prometheus/promql" "github.com/prometheus/prometheus/promql"
"github.com/prometheus/prometheus/util/cli" "github.com/prometheus/prometheus/util/cli"
"github.com/prometheus/prometheus/util/promlint" "github.com/prometheus/prometheus/util/promlint"
"github.com/prometheus/tsdb"
) )
// CheckConfigCmd validates configuration files. // CheckConfigCmd validates configuration files.
@ -175,16 +176,17 @@ func checkRules(t cli.Term, filename string) (int, error) {
return 0, fmt.Errorf("is a directory") return 0, fmt.Errorf("is a directory")
} }
content, err := ioutil.ReadFile(filename) rgs, errs := rulefmt.ParseFile(filename)
if err != nil { if errs != nil {
return 0, err return 0, tsdb.MultiError(errs)
} }
rules, err := promql.ParseStmts(string(content)) numRules := 0
if err != nil { for _, rg := range rgs.Groups {
return 0, err numRules += len(rg.Rules)
} }
return len(rules), nil
return numRules, nil
} }
// UpdateRulesCmd updates the rule files. // UpdateRulesCmd updates the rule files.