Skip to content

Commit e160016

Browse files
committed
cmd: Moved all no-service commands under new tools subcommand.
This will allow better extensibility for future for non-bucket related tools we plan to add. Signed-off-by: Bartlomiej Plotka <bwplotka@gmail.com>
1 parent 8af5266 commit e160016

File tree

13 files changed

+209
-192
lines changed

13 files changed

+209
-192
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ We use *breaking* word for marking changes that are not backward compatible (rel
2222
### Changed
2323

2424
- [#2505](https://github.com/thanos.io/thanos/pull/2505) Store: remove obsolete `thanos_store_node_info` metric.
25-
- [#2508](https://github.com/thanos.io/thanos/pull/2508) Dockerfile: Leveraging docker layer caching.
25+
- [2513](https://github.com/thanos-io/thanos/pull/2513) Tools: Moved `thanos bucket` commands to `thanos tools bucket`, also
26+
moved `thanos check rules` to `thanos tools rules-check`. `thanos tools rules-check` also takes rules by `--rules` repeated flag not argument
27+
anymore.
2628

2729
## [v0.12.1](https://github.com/thanos-io/thanos/releases/tag/v0.12.1) - 2020.04.20
2830

cmd/thanos/main.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,8 @@ func main() {
6060
registerQuery(cmds, app)
6161
registerRule(cmds, app)
6262
registerCompact(cmds, app)
63-
registerBucket(cmds, app, "bucket")
63+
registerTools(cmds, app)
6464
registerReceive(cmds, app)
65-
registerChecks(cmds, app, "check")
6665

6766
cmd, err := app.Parse(os.Args[1:])
6867
if err != nil {
Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,18 @@ import (
1717
"gopkg.in/yaml.v2"
1818
)
1919

20-
func registerChecks(m map[string]setupFunc, app *kingpin.Application, name string) {
21-
cmd := app.Command(name, "Linting tools for Thanos")
22-
registerCheckRules(m, cmd, name)
20+
func registerTools(m map[string]setupFunc, app *kingpin.Application) {
21+
cmd := app.Command("tools", "Tools utility commands")
22+
23+
registerBucket(m, cmd, "tools")
24+
registerCheckRules(m, cmd, "tools")
2325
}
2426

25-
func registerCheckRules(m map[string]setupFunc, root *kingpin.CmdClause, name string) {
26-
checkRulesCmd := root.Command("rules", "Check if the rule files are valid or not.")
27-
ruleFiles := checkRulesCmd.Arg(
28-
"rule-files",
29-
"The rule files to check.",
30-
).Required().ExistingFiles()
27+
func registerCheckRules(m map[string]setupFunc, app *kingpin.CmdClause, pre string) {
28+
checkRulesCmd := app.Command("rules-check", "Check if the rule files are valid or not.")
29+
ruleFiles := checkRulesCmd.Flag("rules", "The rule files glob to check (repeated).").Required().ExistingFiles()
3130

32-
m[name+" rules"] = func(g *run.Group, logger log.Logger, reg *prometheus.Registry, _ opentracing.Tracer, _ <-chan struct{}, _ bool) error {
31+
m[pre+" rules-check"] = func(g *run.Group, logger log.Logger, reg *prometheus.Registry, _ opentracing.Tracer, _ <-chan struct{}, _ bool) error {
3332
// Dummy actor to immediately kill the group after the run function returns.
3433
g.Add(func() error { return nil }, func(error) {})
3534
return checkRulesFiles(logger, ruleFiles)
Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,17 @@ var (
6464
inspectColumns = []string{"ULID", "FROM", "UNTIL", "RANGE", "UNTIL-DOWN", "#SERIES", "#SAMPLES", "#CHUNKS", "COMP-LEVEL", "COMP-FAILED", "LABELS", "RESOLUTION", "SOURCE"}
6565
)
6666

67-
func registerBucket(m map[string]setupFunc, app *kingpin.Application, name string) {
68-
cmd := app.Command(name, "Bucket utility commands")
67+
func registerBucket(m map[string]setupFunc, app *kingpin.CmdClause, pre string) {
68+
cmd := app.Command("bucket", "Bucket utility commands")
6969

70+
pre += " bucket"
7071
objStoreConfig := regCommonObjStoreFlags(cmd, "", true)
71-
registerBucketVerify(m, cmd, name, objStoreConfig)
72-
registerBucketLs(m, cmd, name, objStoreConfig)
73-
registerBucketInspect(m, cmd, name, objStoreConfig)
74-
registerBucketWeb(m, cmd, name, objStoreConfig)
75-
registerBucketReplicate(m, cmd, name, objStoreConfig)
76-
registerBucketDownsample(m, cmd, name, objStoreConfig)
72+
registerBucketVerify(m, cmd, pre, objStoreConfig)
73+
registerBucketLs(m, cmd, pre, objStoreConfig)
74+
registerBucketInspect(m, cmd, pre, objStoreConfig)
75+
registerBucketWeb(m, cmd, pre, objStoreConfig)
76+
registerBucketReplicate(m, cmd, pre, objStoreConfig)
77+
registerBucketDownsample(m, cmd, pre, objStoreConfig)
7778
}
7879

7980
func registerBucketVerify(m map[string]setupFunc, root *kingpin.CmdClause, name string, objStoreConfig *extflag.PathOrContent) {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"github.com/thanos-io/thanos/pkg/testutil"
1111
)
1212

13-
func Test_checkRules(t *testing.T) {
13+
func Test_CheckRules(t *testing.T) {
1414

1515
validFiles := []string{
1616
"./testdata/rules-files/valid.yaml",

docs/components/check.md

Lines changed: 0 additions & 84 deletions
This file was deleted.

docs/components/compact.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ menu: components
66

77
# Compactor
88

9-
The compactor component of Thanos applies the compaction procedure of the Prometheus 2.0 storage engine to block data stored in object storage.
9+
The `thanos compact` command applies the compaction procedure of the Prometheus 2.0 storage engine to block data stored in object storage.
1010
It is generally not semantically concurrency safe and must be deployed as a singleton against a bucket.
1111

1212
It is also responsible for downsampling of data:
@@ -17,7 +17,7 @@ It is also responsible for downsampling of data:
1717
Example:
1818

1919
```bash
20-
$ thanos compact --data-dir /tmp/thanos-compact --objstore.config-file=bucket.yml
20+
thanos compact --data-dir /tmp/thanos-compact --objstore.config-file=bucket.yml
2121
```
2222

2323
The content of `bucket.yml`:

docs/components/query.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ menu: components
66

77
# Querier/Query
88

9-
The Querier component (also known as "Query") implements the [Prometheus HTTP v1 API](https://prometheus.io/docs/prometheus/latest/querying/api/) to query data in a Thanos cluster via PromQL.
9+
The `thanos query` command (also known as "Querier") implements the [Prometheus HTTP v1 API](https://prometheus.io/docs/prometheus/latest/querying/api/) to query data in a Thanos cluster via PromQL.
1010

1111
In short, it gathers the data needed to evaluate the query from underlying [StoreAPIs](../../pkg/store/storepb/rpc.proto), evaluates the query and returns the result.
1212

@@ -15,7 +15,7 @@ Querier is fully stateless and horizontally scalable.
1515
Example command to run Querier:
1616

1717
```bash
18-
$ thanos query \
18+
thanos query \
1919
--http-address "0.0.0.0:9090" \
2020
--store "<store-api>:<grpc-port>" \
2121
--store "<store-api2>:<grpc-port>"
@@ -81,7 +81,7 @@ This also hides gaps in collection of a single data source.
8181
If we configure Querier like this:
8282

8383
```
84-
$ thanos query \
84+
thanos query \
8585
--http-address "0.0.0.0:9090" \
8686
--query.replica-label "replica" \
8787
--store "<store-api>:<grpc-port>" \
@@ -106,7 +106,7 @@ WITHOUT this replica flag (deduplication turned off), we will get 3 results:
106106
* Prometheus + sidecar "A" in different cluster: `cluster=2,env=2,replica=A,replicaX=A`
107107

108108
```
109-
$ thanos query \
109+
thanos query \
110110
--http-address "0.0.0.0:9090" \
111111
--query.replica-label "replica" \
112112
--query.replica-label "replicaX" \

docs/components/rule.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ _**NOTE:** It is recommended to keep deploying rules inside the relevant Prometh
1010

1111
_The rule component should in particular not be used to circumvent solving rule deployment properly at the configuration management level._
1212

13-
The rule component evaluates Prometheus recording and alerting rules against chosen query API via repeated `--query` (or FileSD via `--query.sd`). If more than one query is passed, round robin balancing is performed.
13+
The `thanos rule` command evaluates Prometheus recording and alerting rules against chosen query API via repeated `--query` (or FileSD via `--query.sd`). If more than one query is passed, round robin balancing is performed.
1414

1515
Rule results are written back to disk in the Prometheus 2.0 storage format. Rule nodes at the same time participate in the system as source store nodes, which means that they expose StoreAPI and upload their generated TSDB blocks to an object store.
1616

@@ -20,7 +20,7 @@ The data of each Rule node can be labeled to satisfy the clusters labeling schem
2020
Read more about Ruler in HA [here](rule.md#ruler-ha)
2121

2222
```bash
23-
$ thanos rule \
23+
thanos rule \
2424
--data-dir "/path/to/data" \
2525
--eval-interval "30s" \
2626
--rule-file "/path/to/rules/*.rules.yaml" \

docs/components/sidecar.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ menu: components
66

77
# Sidecar
88

9-
The sidecar component of Thanos gets deployed along with a Prometheus instance. This allows sidecar to optionally upload metrics to object storage and allow [Queriers](./query.md) to query Prometheus data with common, efficient StoreAPI.
9+
The `thanos sidecar` command runs a component that gets deployed along with a Prometheus instance. This allows sidecar to optionally upload metrics to object storage and allow [Queriers](./query.md) to query Prometheus data with common, efficient StoreAPI.
1010

1111
In details:
1212

@@ -49,14 +49,14 @@ Thanos sidecar can watch `--reloader.config-file=CONFIG_FILE` configuration file
4949
## Example basic deployment
5050

5151
```bash
52-
$ prometheus \
52+
prometheus \
5353
--storage.tsdb.max-block-duration=2h \
5454
--storage.tsdb.min-block-duration=2h \
5555
--web.enable-lifecycle
5656
```
5757

5858
```bash
59-
$ thanos sidecar \
59+
thanos sidecar \
6060
--tsdb.path "/path/to/prometheus/data/dir" \
6161
--prometheus.url "http://localhost:9090" \
6262
--objstore.config-file "bucket.yml"

0 commit comments

Comments
 (0)