From f6817cba012a05b5990ae37da91c03c16079443c Mon Sep 17 00:00:00 2001 From: Bartlomiej Plotka Date: Thu, 23 Apr 2020 14:54:50 +0100 Subject: [PATCH] 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 --- CHANGELOG.md | 4 +- cmd/thanos/main.go | 3 +- cmd/thanos/{check.go => tools.go} | 19 +- cmd/thanos/{bucket.go => tools_bucket.go} | 17 +- cmd/thanos/{check_test.go => tools_test.go} | 2 +- docs/components/check.md | 84 -------- docs/components/compact.md | 4 +- docs/components/query.md | 8 +- docs/components/rule.md | 4 +- docs/components/sidecar.md | 6 +- docs/components/store.md | 5 +- docs/components/{bucket.md => tools.md} | 223 ++++++++++++++------ scripts/genflagdocs.sh | 20 +- 13 files changed, 207 insertions(+), 192 deletions(-) rename cmd/thanos/{check.go => tools.go} (81%) rename cmd/thanos/{bucket.go => tools_bucket.go} (97%) rename cmd/thanos/{check_test.go => tools_test.go} (94%) delete mode 100644 docs/components/check.md rename docs/components/{bucket.md => tools.md} (73%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3ac858e80b..4ddf2d7866 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,7 +22,9 @@ We use *breaking* word for marking changes that are not backward compatible (rel ### Changed - [#2505](https://github.com/thanos.io/thanos/pull/2505) Store: remove obsolete `thanos_store_node_info` metric. -- [#2508](https://github.com/thanos.io/thanos/pull/2508) Dockerfile: Leveraging docker layer caching. +- [2513](https://github.com/thanos-io/thanos/pull/2513) Tools: Moved `thanos bucket` commands to `thanos tools bucket`, also +moved `thanos check rules` to `thanos tools rules-check`. `thanos tools rules-check` also takes rules by `--rules` repeated flag not argument +anymore. ## [v0.12.1](https://github.com/thanos-io/thanos/releases/tag/v0.12.1) - 2020.04.20 diff --git a/cmd/thanos/main.go b/cmd/thanos/main.go index 0207cd1a86..87048a0070 100644 --- a/cmd/thanos/main.go +++ b/cmd/thanos/main.go @@ -60,9 +60,8 @@ func main() { registerQuery(cmds, app) registerRule(cmds, app) registerCompact(cmds, app) - registerBucket(cmds, app, "bucket") + registerTools(cmds, app) registerReceive(cmds, app) - registerChecks(cmds, app, "check") cmd, err := app.Parse(os.Args[1:]) if err != nil { diff --git a/cmd/thanos/check.go b/cmd/thanos/tools.go similarity index 81% rename from cmd/thanos/check.go rename to cmd/thanos/tools.go index ae0d43fa27..192b625744 100644 --- a/cmd/thanos/check.go +++ b/cmd/thanos/tools.go @@ -17,19 +17,18 @@ import ( "gopkg.in/yaml.v2" ) -func registerChecks(m map[string]setupFunc, app *kingpin.Application, name string) { - cmd := app.Command(name, "Linting tools for Thanos") - registerCheckRules(m, cmd, name) +func registerTools(m map[string]setupFunc, app *kingpin.Application) { + cmd := app.Command("tools", "Tools utility commands") + + registerBucket(m, cmd, "tools") + registerCheckRules(m, cmd, "tools") } -func registerCheckRules(m map[string]setupFunc, root *kingpin.CmdClause, name string) { - checkRulesCmd := root.Command("rules", "Check if the rule files are valid or not.") - ruleFiles := checkRulesCmd.Arg( - "rule-files", - "The rule files to check.", - ).Required().ExistingFiles() +func registerCheckRules(m map[string]setupFunc, app *kingpin.CmdClause, pre string) { + checkRulesCmd := app.Command("rules-check", "Check if the rule files are valid or not.") + ruleFiles := checkRulesCmd.Flag("rules", "The rule files glob to check (repeated).").Required().ExistingFiles() - m[name+" rules"] = func(g *run.Group, logger log.Logger, reg *prometheus.Registry, _ opentracing.Tracer, _ <-chan struct{}, _ bool) error { + m[pre+" rules-check"] = func(g *run.Group, logger log.Logger, reg *prometheus.Registry, _ opentracing.Tracer, _ <-chan struct{}, _ bool) error { // Dummy actor to immediately kill the group after the run function returns. g.Add(func() error { return nil }, func(error) {}) return checkRulesFiles(logger, ruleFiles) diff --git a/cmd/thanos/bucket.go b/cmd/thanos/tools_bucket.go similarity index 97% rename from cmd/thanos/bucket.go rename to cmd/thanos/tools_bucket.go index 0b75fa55d3..bfb48c7a9a 100644 --- a/cmd/thanos/bucket.go +++ b/cmd/thanos/tools_bucket.go @@ -64,16 +64,17 @@ var ( inspectColumns = []string{"ULID", "FROM", "UNTIL", "RANGE", "UNTIL-DOWN", "#SERIES", "#SAMPLES", "#CHUNKS", "COMP-LEVEL", "COMP-FAILED", "LABELS", "RESOLUTION", "SOURCE"} ) -func registerBucket(m map[string]setupFunc, app *kingpin.Application, name string) { - cmd := app.Command(name, "Bucket utility commands") +func registerBucket(m map[string]setupFunc, app *kingpin.CmdClause, pre string) { + cmd := app.Command("bucket", "Bucket utility commands") + pre += " bucket" objStoreConfig := regCommonObjStoreFlags(cmd, "", true) - registerBucketVerify(m, cmd, name, objStoreConfig) - registerBucketLs(m, cmd, name, objStoreConfig) - registerBucketInspect(m, cmd, name, objStoreConfig) - registerBucketWeb(m, cmd, name, objStoreConfig) - registerBucketReplicate(m, cmd, name, objStoreConfig) - registerBucketDownsample(m, cmd, name, objStoreConfig) + registerBucketVerify(m, cmd, pre, objStoreConfig) + registerBucketLs(m, cmd, pre, objStoreConfig) + registerBucketInspect(m, cmd, pre, objStoreConfig) + registerBucketWeb(m, cmd, pre, objStoreConfig) + registerBucketReplicate(m, cmd, pre, objStoreConfig) + registerBucketDownsample(m, cmd, pre, objStoreConfig) } func registerBucketVerify(m map[string]setupFunc, root *kingpin.CmdClause, name string, objStoreConfig *extflag.PathOrContent) { diff --git a/cmd/thanos/check_test.go b/cmd/thanos/tools_test.go similarity index 94% rename from cmd/thanos/check_test.go rename to cmd/thanos/tools_test.go index 66f94457f2..d9bcdbf7f8 100644 --- a/cmd/thanos/check_test.go +++ b/cmd/thanos/tools_test.go @@ -10,7 +10,7 @@ import ( "github.com/thanos-io/thanos/pkg/testutil" ) -func Test_checkRules(t *testing.T) { +func Test_CheckRules(t *testing.T) { validFiles := []string{ "./testdata/rules-files/valid.yaml", diff --git a/docs/components/check.md b/docs/components/check.md deleted file mode 100644 index 8c0599a7f4..0000000000 --- a/docs/components/check.md +++ /dev/null @@ -1,84 +0,0 @@ ---- -title: Check -type: docs -menu: components ---- - -# Check - -The check component contains tools for validation of Prometheus rules. - -## Deployment -## Flags - -[embedmd]:# (flags/check.txt $) -```$ -usage: thanos check [ ...] - -Linting tools for Thanos - -Flags: - -h, --help Show context-sensitive help (also try --help-long and - --help-man). - --version Show application version. - --log.level=info Log filtering level. - --log.format=logfmt Log format to use. Possible options: logfmt or json. - --tracing.config-file= - Path to YAML file with tracing configuration. See - format details: - https://thanos.io/tracing.md/#configuration - --tracing.config= - Alternative to 'tracing.config-file' flag (lower - priority). Content of YAML file with tracing - configuration. See format details: - https://thanos.io/tracing.md/#configuration - -Subcommands: - check rules ... - Check if the rule files are valid or not. - - -``` - - -### Rules - -`check rules` checks the Prometheus rules, used by the Thanos rule node, if they are valid. -The check should be equivalent for the `promtool check rules` but that cannot be used because -Thanos rule has extended rules file syntax, which includes `partial_response_strategy` field -which `promtool` does not allow. - -If the check fails the command fails with exit code `1`, otherwise `0`. - -Example: - -``` -$ ./thanos check rules cmd/thanos/testdata/rules-files/*.yaml -``` - -[embedmd]:# (flags/check_rules.txt) -```txt -usage: thanos check rules ... - -Check if the rule files are valid or not. - -Flags: - -h, --help Show context-sensitive help (also try --help-long and - --help-man). - --version Show application version. - --log.level=info Log filtering level. - --log.format=logfmt Log format to use. Possible options: logfmt or json. - --tracing.config-file= - Path to YAML file with tracing configuration. See - format details: - https://thanos.io/tracing.md/#configuration - --tracing.config= - Alternative to 'tracing.config-file' flag (lower - priority). Content of YAML file with tracing - configuration. See format details: - https://thanos.io/tracing.md/#configuration - -Args: - The rule files to check. - -``` diff --git a/docs/components/compact.md b/docs/components/compact.md index 2fd3d80883..4272a29cf1 100644 --- a/docs/components/compact.md +++ b/docs/components/compact.md @@ -6,7 +6,7 @@ menu: components # Compactor -The compactor component of Thanos applies the compaction procedure of the Prometheus 2.0 storage engine to block data stored in object storage. +The `thanos compact` command applies the compaction procedure of the Prometheus 2.0 storage engine to block data stored in object storage. It is generally not semantically concurrency safe and must be deployed as a singleton against a bucket. It is also responsible for downsampling of data: @@ -17,7 +17,7 @@ It is also responsible for downsampling of data: Example: ```bash -$ thanos compact --data-dir /tmp/thanos-compact --objstore.config-file=bucket.yml +thanos compact --data-dir /tmp/thanos-compact --objstore.config-file=bucket.yml ``` The content of `bucket.yml`: diff --git a/docs/components/query.md b/docs/components/query.md index 563fd5ce4b..e7c2a185f9 100644 --- a/docs/components/query.md +++ b/docs/components/query.md @@ -6,7 +6,7 @@ menu: components # Querier/Query -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. +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. 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. @@ -15,7 +15,7 @@ Querier is fully stateless and horizontally scalable. Example command to run Querier: ```bash -$ thanos query \ +thanos query \ --http-address "0.0.0.0:9090" \ --store ":" \ --store ":" @@ -81,7 +81,7 @@ This also hides gaps in collection of a single data source. If we configure Querier like this: ``` -$ thanos query \ +thanos query \ --http-address "0.0.0.0:9090" \ --query.replica-label "replica" \ --store ":" \ @@ -106,7 +106,7 @@ WITHOUT this replica flag (deduplication turned off), we will get 3 results: * Prometheus + sidecar "A" in different cluster: `cluster=2,env=2,replica=A,replicaX=A` ``` -$ thanos query \ +thanos query \ --http-address "0.0.0.0:9090" \ --query.replica-label "replica" \ --query.replica-label "replicaX" \ diff --git a/docs/components/rule.md b/docs/components/rule.md index 85c7ed5b0b..e85c2d45ab 100644 --- a/docs/components/rule.md +++ b/docs/components/rule.md @@ -10,7 +10,7 @@ _**NOTE:** It is recommended to keep deploying rules inside the relevant Prometh _The rule component should in particular not be used to circumvent solving rule deployment properly at the configuration management level._ -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. +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. 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. @@ -20,7 +20,7 @@ The data of each Rule node can be labeled to satisfy the clusters labeling schem Read more about Ruler in HA [here](rule.md#ruler-ha) ```bash -$ thanos rule \ +thanos rule \ --data-dir "/path/to/data" \ --eval-interval "30s" \ --rule-file "/path/to/rules/*.rules.yaml" \ diff --git a/docs/components/sidecar.md b/docs/components/sidecar.md index 723dab0775..1eb2a0eb2f 100644 --- a/docs/components/sidecar.md +++ b/docs/components/sidecar.md @@ -6,7 +6,7 @@ menu: components # Sidecar -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. +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. In details: @@ -49,14 +49,14 @@ Thanos sidecar can watch `--reloader.config-file=CONFIG_FILE` configuration file ## Example basic deployment ```bash -$ prometheus \ +prometheus \ --storage.tsdb.max-block-duration=2h \ --storage.tsdb.min-block-duration=2h \ --web.enable-lifecycle ``` ```bash -$ thanos sidecar \ +thanos sidecar \ --tsdb.path "/path/to/prometheus/data/dir" \ --prometheus.url "http://localhost:9090" \ --objstore.config-file "bucket.yml" diff --git a/docs/components/store.md b/docs/components/store.md index f519522980..bfeb1eb749 100644 --- a/docs/components/store.md +++ b/docs/components/store.md @@ -6,11 +6,11 @@ menu: components # Store -The store component of Thanos implements the Store API on top of historical data in an object storage bucket. It acts primarily as an API gateway and therefore does not need significant amounts of local disk space. It joins a Thanos cluster on startup and advertises the data it can access. +The `thanost store` command (also known as Store Gateway) implements the Store API on top of historical data in an object storage bucket. It acts primarily as an API gateway and therefore does not need significant amounts of local disk space. It joins a Thanos cluster on startup and advertises the data it can access. It keeps a small amount of information about all remote blocks on local disk and keeps it in sync with the bucket. This data is generally safe to delete across restarts at the cost of increased startup times. ```bash -$ thanos store \ +thanos store \ --data-dir "/local/state/data/dir" \ --objstore.config-file "bucket.yml" ``` @@ -28,7 +28,6 @@ In general about 1MB of local disk space is required per TSDB block stored in th ## Flags [embedmd]: # "flags/store.txt $" - ```$ usage: thanos store [] diff --git a/docs/components/bucket.md b/docs/components/tools.md similarity index 73% rename from docs/components/bucket.md rename to docs/components/tools.md index 4922b740d5..feb5ace116 100644 --- a/docs/components/bucket.md +++ b/docs/components/tools.md @@ -1,18 +1,75 @@ --- -title: Bucket +title: Tools type: docs menu: components --- -# Bucket +# Tools -The bucket component of Thanos is a set of commands to inspect data in object storage buckets. -It is normally run as a stand alone command to aid with troubleshooting. +The `thanos tools` subcommand of Thanos is a set of additional CLI, short-living tools that +are meant to be ran for development or debugging purposes. + +All commands added as tools should land in `tools.go` or file with `tools_` prefix. + +## Flags + +[embedmd]:# (flags/tools.txt $) +```$ +usage: thanos tools [ ...] + +Tools utility commands + +Flags: + -h, --help Show context-sensitive help (also try --help-long and + --help-man). + --version Show application version. + --log.level=info Log filtering level. + --log.format=logfmt Log format to use. Possible options: logfmt or json. + --tracing.config-file= + Path to YAML file with tracing configuration. See + format details: + https://thanos.io/tracing.md/#configuration + --tracing.config= + Alternative to 'tracing.config-file' flag (lower + priority). Content of YAML file with tracing + configuration. See format details: + https://thanos.io/tracing.md/#configuration + +Subcommands: + tools bucket verify [] + Verify all blocks in the bucket against specified issues + + tools bucket ls [] + List all blocks in the bucket + + tools bucket inspect [] + Inspect all blocks in the bucket in detailed, table-like way + + tools bucket web [] + Web interface for remote storage bucket + + tools bucket replicate [] + Replicate data from one object storage to another. NOTE: Currently it works + only with Thanos blocks (meta.json has to have Thanos metadata). + + tools bucket downsample [] + continuously downsamples blocks in an object store bucket + + tools rules-check --rules=RULES + Check if the rule files are valid or not. + + +``` + +## Bucket + +The `thanos tools bucket` subcommand of Thanos is a set of commands to inspect data in object storage buckets. +It is normally run as a standalone command to aid with troubleshooting. Example: ```bash -$ thanos bucket verify --objstore.config-file=bucket.yml +thanos tools bucket verify --objstore.config-file=bucket.yml ``` The content of `bucket.yml`: @@ -24,16 +81,11 @@ config: ``` Bucket can be extended to add more subcommands that will be helpful when working with object storage buckets -by adding a new command within `/cmd/thanos/bucket.go`. - -## Deployment - -## Flags - -[embedmd]: # "flags/bucket.txt $" +by adding a new command within [`/cmd/thanos/tools_bucket.go`](/cmd/thanos/tools_bucket.go) . +[embedmd]:# (flags/tools_bucket.txt $) ```$ -usage: thanos bucket [] [ ...] +usage: thanos tools bucket [] [ ...] Bucket utility commands @@ -63,31 +115,31 @@ Flags: https://thanos.io/storage.md/#configuration Subcommands: - bucket verify [] + tools bucket verify [] Verify all blocks in the bucket against specified issues - bucket ls [] + tools bucket ls [] List all blocks in the bucket - bucket inspect [] + tools bucket inspect [] Inspect all blocks in the bucket in detailed, table-like way - bucket web [] + tools bucket web [] Web interface for remote storage bucket - bucket replicate [] + tools bucket replicate [] Replicate data from one object storage to another. NOTE: Currently it works only with Thanos blocks (meta.json has to have Thanos metadata). - bucket downsample [] + tools bucket downsample [] continuously downsamples blocks in an object store bucket ``` -### Web +### Bucket Web -`bucket web` is used to inspect bucket blocks in form of interactive web UI. +`tools bucket web` is used to inspect bucket blocks in form of interactive web UI. This will start local webserver that will periodically update the view with given refresh. @@ -96,13 +148,12 @@ This will start local webserver that will periodically update the view with give Example: ``` -$ thanos bucket web --objstore.config-file="..." +thanos tools bucket web --objstore.config-file="..." ``` -[embedmd]: # "flags/bucket_web.txt" - -```txt -usage: thanos bucket web [] +[embedmd]:# (flags/tools_bucket_web.txt $) +```$ +usage: thanos tools bucket web [] Web interface for remote storage bucket @@ -162,22 +213,21 @@ Flags: ``` -### Verify +### Bucket Verify -`bucket verify` is used to verify and optionally repair blocks within the specified bucket. +`tools bucket verify` is used to verify and optionally repair blocks within the specified bucket. Example: ``` -$ thanos bucket verify --objstore.config-file="..." +thanos tools bucket verify --objstore.config-file="..." ``` When using the `--repair` option, make sure that the compactor job is disabled first. -[embedmd]: # "flags/bucket_verify.txt" - -```txt -usage: thanos bucket verify [] +[embedmd]:# (flags/tools_bucket_verify.txt $) +```$ +usage: thanos tools bucket verify [] Verify all blocks in the bucket against specified issues @@ -227,27 +277,34 @@ Flags: Block IDs to verify (and optionally repair) only. If none is specified, all blocks will be verified. Repeated field - --delete-delay=0s Duration after which blocks marked for deletion would be deleted permanently from source bucket by compactor component. - If delete-delay is non zero, blocks will be marked for deletion and compactor component is required to delete blocks from source bucket. - If delete-delay is 0, blocks will be deleted straight away. Use this if you want to get rid of or move the block immediately. - Note that deleting blocks immediately can cause query failures, if store gateway still has the block - loaded, or compactor is ignoring the deletion because it's compacting the block at the same time. + --delete-delay=0s Duration after which blocks marked for deletion would + be deleted permanently from source bucket by + compactor component. If delete-delay is non zero, + blocks will be marked for deletion and compactor + component is required to delete blocks from source + bucket. If delete-delay is 0, blocks will be deleted + straight away. Use this if you want to get rid of or + move the block immediately. Note that deleting blocks + immediately can cause query failures, if store + gateway still has the block loaded, or compactor is + ignoring the deletion because it's compacting the + block at the same time. + ``` -### ls +### Bucket ls -`bucket ls` is used to list all blocks in the specified bucket. +`tools bucket ls` is used to list all blocks in the specified bucket. Example: ``` -$ thanos bucket ls -o json --objstore.config-file="..." +thanos tools bucket ls -o json --objstore.config-file="..." ``` -[embedmd]: # "flags/bucket_ls.txt" - -```txt -usage: thanos bucket ls [] +[embedmd]:# (flags/tools_bucket_ls.txt $) +```$ +usage: thanos tools bucket ls [] List all blocks in the bucket @@ -281,20 +338,19 @@ Flags: ``` -### inspect +### Bucket inspect -`bucket inspect` is used to inspect buckets in a detailed way using stdout in ASCII table format. +`tools bucket inspect` is used to inspect buckets in a detailed way using stdout in ASCII table format. Example: ``` -$ thanos bucket inspect -l environment=\"prod\" --objstore.config-file="..." +thanos tools bucket inspect -l environment=\"prod\" --objstore.config-file="..." ``` -[embedmd]: # "flags/bucket_inspect.txt" - -```txt -usage: thanos bucket inspect [] +[embedmd]:# (flags/tools_bucket_inspect.txt $) +```$ +usage: thanos tools bucket inspect [] Inspect all blocks in the bucket in detailed, table-like way @@ -335,20 +391,20 @@ Flags: ``` -### replicate +### Bucket replicate -`bucket replicate` is used to replicate buckets from one object storage to another. +`bucket tools replicate` is used to replicate buckets from one object storage to another. NOTE: Currently it works only with Thanos blocks (meta.json has to have Thanos metadata). Example: ``` -$ thanos bucket replicate --objstore.config-file="..." --objstore-to.config="..." +thanos tools bucket replicate --objstore.config-file="..." --objstore-to.config="..." ``` -[embedmd]:# (flags/bucket_replicate.txt) -```txt -usage: thanos bucket replicate [] +[embedmd]:# (flags/tools_bucket_replicate.txt $) +```$ +usage: thanos tools bucket replicate [] Replicate data from one object storage to another. NOTE: Currently it works only with Thanos blocks (meta.json has to have Thanos metadata). @@ -405,13 +461,13 @@ Flags: ``` -### downsample +### Bucket downsample -`bucket downsample` is used to continuously downsample blocks in an object store bucket as a service. +`tools bucket downsample` is used to continuously downsample blocks in an object store bucket as a service. It implements the downsample API on top of historical data in an object storage bucket. ```bash -$ thanos bucket downsample \ +thanos tools bucket downsample \ --data-dir "/local/state/data/dir" \ --objstore.config-file "bucket.yml" ``` @@ -424,9 +480,9 @@ config: bucket: example-bucket ``` -[embedmd]:# (flags/bucket_downsample.txt $) +[embedmd]:# (flags/tools_bucket_downsample.txt $) ```$ -usage: thanos bucket downsample [] +usage: thanos tools bucket downsample [] continuously downsamples blocks in an object store bucket @@ -462,6 +518,47 @@ Flags: --data-dir="./data" Data directory in which to cache blocks and process downsamplings. +``` +## Rules-check + +The `tools rules-check` subcommand contains tools for validation of Prometheus rules. + +This is allowing to check the rules with the same validation as is used by the Thanos rule node. + +NOTE: The check is equivalent to the `promtool check rules` with addition of Thanos rule extended rules file syntax, +which includes `partial_response_strategy` field which `promtool` does not allow. + +If the check fails the command fails with exit code `1`, otherwise `0`. + +Example: + +``` +./thanos tools rules-check --rules cmd/thanos/testdata/rules-files/*.yaml +``` + +[embedmd]:# (flags/tools_rules-check.txt $) +```$ +usage: thanos tools rules-check --rules=RULES + +Check if the rule files are valid or not. + +Flags: + -h, --help Show context-sensitive help (also try --help-long and + --help-man). + --version Show application version. + --log.level=info Log filtering level. + --log.format=logfmt Log format to use. Possible options: logfmt or json. + --tracing.config-file= + Path to YAML file with tracing configuration. See + format details: + https://thanos.io/tracing.md/#configuration + --tracing.config= + Alternative to 'tracing.config-file' flag (lower + priority). Content of YAML file with tracing + configuration. See format details: + https://thanos.io/tracing.md/#configuration + --rules=RULES ... The rule files glob to check (repeated). + ``` #### Probes diff --git a/scripts/genflagdocs.sh b/scripts/genflagdocs.sh index cfd09bbbb6..5e4543ce51 100755 --- a/scripts/genflagdocs.sh +++ b/scripts/genflagdocs.sh @@ -8,7 +8,7 @@ EMBEDMD_BIN=${EMBEDMD_BIN:-embedmd} SED_BIN=${SED_BIN:-sed} function docs { -# if check arg was passed, instead of the docs generation verifies if docs coincide with the codebase +# If check arg was passed, instead of the docs generation verifies if docs coincide with the codebase. if [[ "${CHECK}" == "check" ]]; then set +e DIFF=$(${EMBEDMD_BIN} -d *.md) @@ -34,25 +34,27 @@ fi CHECK=${1:-} -commands=("compact" "query" "rule" "sidecar" "store" "bucket" "check") +# Auto update flags. +commands=("compact" "query" "rule" "sidecar" "store" "tools") for x in "${commands[@]}"; do ./thanos "${x}" --help &> "docs/components/flags/${x}.txt" done -bucketCommands=("verify" "ls" "inspect" "web" "replicate" "downsample") -for x in "${bucketCommands[@]}"; do - ./thanos bucket "${x}" --help &> "docs/components/flags/bucket_${x}.txt" +toolsCommands=("bucket" "rules-check") +for x in "${toolsCommands[@]}"; do + ./thanos tools "${x}" --help &> "docs/components/flags/tools_${x}.txt" done -checkCommands=("rules") -for x in "${checkCommands[@]}"; do - ./thanos check "${x}" --help &> "docs/components/flags/check_${x}.txt" +toolsBucketCommands=("verify" "ls" "inspect" "web" "replicate" "downsample") +for x in "${toolsBucketCommands[@]}"; do + ./thanos tools bucket "${x}" --help &> "docs/components/flags/tools_bucket_${x}.txt" done -# remove white noise +# Remove white noise. ${SED_BIN} -i -e 's/[ \t]*$//' docs/components/flags/*.txt +# Auto update configuration. go run scripts/cfggen/main.go --output-dir=docs/flags # Change dir so embedmd understand the local references made in our markdown doc.