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 commit introduces a new command for the cortextool: `rules
prepare`. It allows users to "lint" and modify their rules files to
include a specific cluster in their aggregations.
Cortex users writing from multiple systems to a single tenant is not
uncommon when you want to have a global view. In this setup, you'd
typically use a label to differentiate identical series coming from
different systems.
Cortex users transitioning from Prometheus rule evaluation to the Cortex
ruler based under this setup could do with having a tool that helps them
aggregate by an specific label.
This is exactly what this command is for.
Signed-off-by: gotjosh <[email protected]>
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
70
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
71
63
-
// List Rules Command
64
-
rulesCmd.Command("list", "List the rules currently in the cortex ruler.").Action(r.listRules)
72
+
// Register rule commands
73
+
listCmd:=rulesCmd.
74
+
Command("list", "List the rules currently in the cortex ruler.").
75
+
Action(r.listRules)
76
+
printRulesCmd:=rulesCmd.
77
+
Command("print", "Print the rules currently in the cortex ruler.").
78
+
Action(r.printRules)
79
+
getRuleGroupCmd:=rulesCmd.
80
+
Command("get", "Retreive a rulegroup from the ruler.").
81
+
Action(r.getRuleGroup)
82
+
deleteRuleGroupCmd:=rulesCmd.
83
+
Command("delete", "Delete a rulegroup from the ruler.").
84
+
Action(r.deleteRuleGroup)
85
+
loadRulesCmd:=rulesCmd.
86
+
Command("load", "load a set of rules to a designated cortex endpoint").
87
+
Action(r.loadRules)
88
+
diffRulesCmd:=rulesCmd.
89
+
Command("diff", "diff a set of rules to a designated cortex endpoint").
90
+
Action(r.diffRules)
91
+
syncRulesCmd:=rulesCmd.
92
+
Command("sync", "sync a set of rules to a designated cortex endpoint").
93
+
Action(r.syncRules)
94
+
prepareCmd:=rulesCmd.
95
+
Command("prepare", "modifies a set of rules by including an specific label in aggregations.").
96
+
Action(r.prepare)
97
+
98
+
// 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)
135
+
// Sync Command
94
136
syncRulesCmd.Flag("ignored-namespaces", "comma-separated list of namespaces to ignore during a sync.").StringVar(&r.IgnoredNamespaces)
95
137
syncRulesCmd.Flag("rule-files", "The rule files to check. Flag can be reused to load multiple files.").StringVar(&r.RuleFiles)
96
138
syncRulesCmd.Flag(
97
139
"rule-dirs",
98
140
"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
141
).StringVar(&r.RuleFilesPath)
142
+
143
+
// Prepare Command
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