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 lints a rules file. The linter's aim is not to verify correctness but just YAML and PromQL expression formatting within the rule file. This command always edits in place, you can use the dry run flag (`-n`) if you'd like to perform a trial run that does not make any changes.
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.
It is important to note that a modification can be a PromQL expression lint or a label add to your aggregation.
92
+
71
93
## chunktool
72
94
73
95
This repo also contains the `chunktool`. A client meant to interact with chunks stored and indexed in cortex backends.
74
96
75
-
#### Chunk Delete
97
+
#####Chunk Delete
76
98
77
99
The delete command currently cleans all index entries pointing to chunks in the specified index. Only bigtable and the v10 schema are currently fully supported. This will not delete the entire index entry, only the corresponding chunk entries within the index row.
78
100
79
-
#### Chunk Migrate
101
+
#####Chunk Migrate
80
102
81
103
The migrate command helps with migrating chunks across cortex clusters. It also takes care of setting right index in the new cluster as per the specified schema config.
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
72
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
73
63
-
// List Rules Command
64
-
rulesCmd.Command("list", "List the rules currently in the cortex ruler.").Action(r.listRules)
74
+
// Register rule commands
75
+
listCmd:=rulesCmd.
76
+
Command("list", "List the rules currently in the cortex ruler.").
77
+
Action(r.listRules)
78
+
printRulesCmd:=rulesCmd.
79
+
Command("print", "Print the rules currently in the cortex ruler.").
80
+
Action(r.printRules)
81
+
getRuleGroupCmd:=rulesCmd.
82
+
Command("get", "Retreive a rulegroup from the ruler.").
83
+
Action(r.getRuleGroup)
84
+
deleteRuleGroupCmd:=rulesCmd.
85
+
Command("delete", "Delete a rulegroup from the ruler.").
86
+
Action(r.deleteRuleGroup)
87
+
loadRulesCmd:=rulesCmd.
88
+
Command("load", "load a set of rules to a designated cortex endpoint").
89
+
Action(r.loadRules)
90
+
diffRulesCmd:=rulesCmd.
91
+
Command("diff", "diff a set of rules to a designated cortex endpoint").
92
+
Action(r.diffRules)
93
+
syncRulesCmd:=rulesCmd.
94
+
Command("sync", "sync a set of rules to a designated cortex endpoint").
95
+
Action(r.syncRules)
96
+
prepareCmd:=rulesCmd.
97
+
Command("prepare", "modifies a set of rules by including an specific label in aggregations.").
98
+
Action(r.prepare)
99
+
lintCmd:=rulesCmd.
100
+
Command("lint", "formats a set of rule files. It reorders keys alphabetically, uses 4 spaces as indentantion, and formats PromQL expressions to a single line.").
101
+
Action(r.lint)
102
+
103
+
// 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)
140
+
// Sync Command
94
141
syncRulesCmd.Flag("ignored-namespaces", "comma-separated list of namespaces to ignore during a sync.").StringVar(&r.IgnoredNamespaces)
95
142
syncRulesCmd.Flag("rule-files", "The rule files to check. Flag can be reused to load multiple files.").StringVar(&r.RuleFiles)
96
143
syncRulesCmd.Flag(
97
144
"rule-dirs",
98
145
"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
146
).StringVar(&r.RuleFilesPath)
147
+
148
+
// Prepare Command
149
+
prepareCmd.Arg("rule-files", "The rule files to check.").Required().ExistingFilesVar(&r.RuleFilesList)
150
+
prepareCmd.Flag("rule-files", "The rule files to check. Flag can be reused to load multiple files.").StringVar(&r.RuleFiles)
151
+
prepareCmd.Flag(
152
+
"rule-dirs",
153
+
"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.",
154
+
).StringVar(&r.RuleFilesPath)
155
+
prepareCmd.Flag(
156
+
"in-place",
157
+
"edits the rule file in place",
158
+
).Short('i').BoolVar(&r.InPlaceEdit)
159
+
prepareCmd.Flag("label", "label to include as part of the aggregations.").Default(defaultPrepareAggregationLabel).Short('l').StringVar(&r.AggregationLabel)
160
+
161
+
// Lint Command
162
+
lintCmd.Arg("rule-files", "The rule files to check.").Required().ExistingFilesVar(&r.RuleFilesList)
163
+
lintCmd.Flag("rule-files", "The rule files to check. Flag can be reused to load multiple files.").StringVar(&r.RuleFiles)
164
+
lintCmd.Flag(
165
+
"rule-dirs",
166
+
"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.",
167
+
).StringVar(&r.RuleFilesPath)
168
+
lintCmd.Flag("dry-run", "Performs a trial run that doesn't make any changes and (mostly) produces the same outpupt as a real run.").Short('n').BoolVar(&r.LintDryRun)
0 commit comments