From 7c1bb93e3544d1082e360959248f71c0c8f84267 Mon Sep 17 00:00:00 2001 From: wanjunlei Date: Wed, 28 Sep 2022 10:21:26 +0800 Subject: [PATCH] Store: Support disable block viewer UI. Signed-off-by: wanjunlei --- CHANGELOG.md | 1 + cmd/thanos/store.go | 24 +++++++++++++++--------- docs/components/store.md | 1 + 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 74f559818a9..5365c20508a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ We use *breaking :warning:* to mark changes that are not backward compatible (re - [#5658](https://github.com/thanos-io/thanos/pull/5658) Query Frontend: Introduce new optional parameters (`query-range.min-split-interval`, `query-range.max-split-interval`, `query-range.horizontal-shards`) to implement more dynamic horizontal query splitting. - [#5721](https://github.com/thanos-io/thanos/pull/5721) Store: Add metric `thanos_bucket_store_empty_postings_total` for number of empty postings when fetching series. - [#5723](https://github.com/thanos-io/thanos/pull/5723) Compactor: Support disable block viewer UI. +- [#5734](https://github.com/thanos-io/thanos/pull/5734) Store: Support disable block viewer UI. ### Changed diff --git a/cmd/thanos/store.go b/cmd/thanos/store.go index c55d1450a66..ca24a9a1984 100644 --- a/cmd/thanos/store.go +++ b/cmd/thanos/store.go @@ -69,6 +69,7 @@ type storeConfig struct { advertiseCompatibilityLabel bool consistencyDelay commonmodel.Duration ignoreDeletionMarksDelay commonmodel.Duration + disableWeb bool webConfig webConfig postingOffsetsInMemSampling int cachingBucketConfig extflag.PathOrContent @@ -157,6 +158,8 @@ func (sc *storeConfig) registerFlag(cmd extkingpin.FlagClause) { cmd.Flag("store.index-header-lazy-reader-idle-timeout", "If index-header lazy reader is enabled and this idle timeout setting is > 0, memory map-ed index-headers will be automatically released after 'idle timeout' inactivity."). Hidden().Default("5m").DurationVar(&sc.lazyIndexReaderIdleTimeout) + cmd.Flag("web.disable", "Disable Block Viewer UI and block APIS.").Default("false").BoolVar(&sc.disableWeb) + cmd.Flag("web.external-prefix", "Static prefix for all HTML links and redirect URLs in the bucket web UI interface. Actual endpoints are still served on / or the web.route-prefix. This allows thanos bucket web UI to be served behind a reverse proxy that strips a URL sub-path."). Default("").StringVar(&sc.webConfig.externalPrefix) @@ -431,17 +434,20 @@ func runStore( { ins := extpromhttp.NewInstrumentationMiddleware(reg, nil) - compactorView := ui.NewBucketUI(logger, conf.webConfig.externalPrefix, conf.webConfig.prefixHeaderName, conf.component) - compactorView.Register(r, ins) + if !conf.disableWeb { + compactorView := ui.NewBucketUI(logger, conf.webConfig.externalPrefix, conf.webConfig.prefixHeaderName, conf.component) + compactorView.Register(r, ins) - // Configure Request Logging for HTTP calls. - logMiddleware := logging.NewHTTPServerMiddleware(logger, httpLogOpts...) - api := blocksAPI.NewBlocksAPI(logger, conf.webConfig.disableCORS, "", flagsMap, bkt) - api.Register(r.WithPrefix("/api/v1"), tracer, logger, ins, logMiddleware) + // Configure Request Logging for HTTP calls. + logMiddleware := logging.NewHTTPServerMiddleware(logger, httpLogOpts...) + api := blocksAPI.NewBlocksAPI(logger, conf.webConfig.disableCORS, "", flagsMap, bkt) + api.Register(r.WithPrefix("/api/v1"), tracer, logger, ins, logMiddleware) + + metaFetcher.UpdateOnChange(func(blocks []metadata.Meta, err error) { + api.SetLoaded(blocks, err) + }) + } - metaFetcher.UpdateOnChange(func(blocks []metadata.Meta, err error) { - api.SetLoaded(blocks, err) - }) srv.Handle("/", r) } diff --git a/docs/components/store.md b/docs/components/store.md index 3071e7b928b..9eb2afbbec4 100644 --- a/docs/components/store.md +++ b/docs/components/store.md @@ -190,6 +190,7 @@ Flags: See format details: https://thanos.io/tip/thanos/tracing.md/#configuration --version Show application version. + --web.disable Disable Block Viewer UI and block APIS. --web.disable-cors Whether to disable CORS headers to be set by Thanos. By default Thanos sets CORS headers to be allowed by all.