You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This command prepares a rules file for upload to Cortex. It lints all your PromQL expressions and adds an specific label to your PromQL query aggregations in the file. Unlike, the previous command this one does not interact with your Cortex cluster.
rulesCmd:=app.Command("rules", "View & edit rules stored in cortex.").PreAction(r.setup)
59
-
rulesCmd.Flag("address", "Address of the cortex cluster, alternatively set CORTEX_ADDRESS.").Envar("CORTEX_ADDRESS").Required().StringVar(&r.ClientConfig.Address)
60
-
rulesCmd.Flag("id", "Cortex tenant id, alternatively set CORTEX_TENANT_ID.").Envar("CORTEX_TENANT_ID").Required().StringVar(&r.ClientConfig.ID)
61
69
rulesCmd.Flag("key", "Api key to use when contacting cortex, alternatively set $CORTEX_API_KEY.").Default("").Envar("CORTEX_API_KEY").StringVar(&r.ClientConfig.Key)
62
70
63
-
// List Rules Command
64
-
rulesCmd.Command("list", "List the rules currently in the cortex ruler.").Action(r.listRules)
71
+
// Register rule commands
72
+
listCmd:=rulesCmd.
73
+
Command("list", "List the rules currently in the cortex ruler.").
74
+
Action(r.listRules)
75
+
printRulesCmd:=rulesCmd.
76
+
Command("print", "Print the rules currently in the cortex ruler.").
77
+
Action(r.printRules)
78
+
getRuleGroupCmd:=rulesCmd.
79
+
Command("get", "Retreive a rulegroup from the ruler.").
80
+
Action(r.getRuleGroup)
81
+
deleteRuleGroupCmd:=rulesCmd.
82
+
Command("delete", "Delete a rulegroup from the ruler.").
83
+
Action(r.deleteRuleGroup)
84
+
loadRulesCmd:=rulesCmd.
85
+
Command("load", "load a set of rules to a designated cortex endpoint").
86
+
Action(r.loadRules)
87
+
diffRulesCmd:=rulesCmd.
88
+
Command("diff", "diff a set of rules to a designated cortex endpoint").
89
+
Action(r.diffRules)
90
+
syncRulesCmd:=rulesCmd.
91
+
Command("sync", "sync a set of rules to a designated cortex endpoint").
92
+
Action(r.syncRules)
93
+
prepareCmd:=rulesCmd.
94
+
Command("prepare", "modifies a set of rules by including an specific label in aggregations.").
95
+
Action(r.prepare)
96
+
97
+
// Require Cortex cluster address and tentant ID on all these commands
syncRulesCmd:=rulesCmd.Command("sync", "sync a set of rules to a designated cortex endpoint").Action(r.syncRules)
134
+
// Sync Command
94
135
syncRulesCmd.Flag("ignored-namespaces", "comma-separated list of namespaces to ignore during a sync.").StringVar(&r.IgnoredNamespaces)
95
136
syncRulesCmd.Flag("rule-files", "The rule files to check. Flag can be reused to load multiple files.").StringVar(&r.RuleFiles)
96
137
syncRulesCmd.Flag(
97
138
"rule-dirs",
98
139
"Comma seperated list of paths to directories containing rules yaml files. Each file in a directory with a .yml or .yaml suffix will be parsed.",
99
140
).StringVar(&r.RuleFilesPath)
141
+
142
+
// Prepare Command
143
+
prepareCmd.Arg("rule-files", "The rule files to check.").Required().ExistingFilesVar(&r.RuleFilesList)
144
+
prepareCmd.Flag("rule-files", "The rule files to check. Flag can be reused to load multiple files.").StringVar(&r.RuleFiles)
145
+
prepareCmd.Flag(
146
+
"rule-dirs",
147
+
"Comma seperated list of paths to directories containing rules yaml files. Each file in a directory with a .yml or .yaml suffix will be parsed.",
148
+
).StringVar(&r.RuleFilesPath)
149
+
prepareCmd.Flag(
150
+
"in-place",
151
+
"edits the rule file in place",
152
+
).Short('i').BoolVar(&r.InPlaceEdit)
153
+
prepareCmd.Flag("label", "label to include as part of the aggregations.").Default(defaultPrepareAggregationLabel).Short('l').StringVar(&r.AggregationLabel)
0 commit comments