From affec5bdd188556e94e38385e7c309773a8ed586 Mon Sep 17 00:00:00 2001 From: DylanGuedes Date: Mon, 22 Apr 2024 10:28:39 -0300 Subject: [PATCH 01/16] Split gRPC client into two. --- pkg/querier/worker/frontend_processor.go | 2 +- pkg/querier/worker/scheduler_processor.go | 4 +- pkg/querier/worker/worker.go | 48 +++++++++++++++-------- pkg/querier/worker/worker_test.go | 2 +- 4 files changed, 35 insertions(+), 21 deletions(-) diff --git a/pkg/querier/worker/frontend_processor.go b/pkg/querier/worker/frontend_processor.go index a0e3569359bfa..2cf25202dcbb4 100644 --- a/pkg/querier/worker/frontend_processor.go +++ b/pkg/querier/worker/frontend_processor.go @@ -30,7 +30,7 @@ func newFrontendProcessor(cfg Config, handler RequestHandler, log log.Logger, co log: log, handler: handler, codec: codec, - maxMessageSize: cfg.GRPCClientConfig.MaxSendMsgSize, + maxMessageSize: cfg.QueryFrontendGRPCClientConfig.MaxSendMsgSize, querierID: cfg.QuerierID, } } diff --git a/pkg/querier/worker/scheduler_processor.go b/pkg/querier/worker/scheduler_processor.go index 00b08219e5dbe..c8f6d4effa91d 100644 --- a/pkg/querier/worker/scheduler_processor.go +++ b/pkg/querier/worker/scheduler_processor.go @@ -38,9 +38,9 @@ func newSchedulerProcessor(cfg Config, handler RequestHandler, log log.Logger, m log: log, handler: handler, codec: codec, - maxMessageSize: cfg.GRPCClientConfig.MaxSendMsgSize, + maxMessageSize: cfg.QuerySchedulerGRPCClientConfig.MaxSendMsgSize, querierID: cfg.QuerierID, - grpcConfig: cfg.GRPCClientConfig, + grpcConfig: cfg.QuerySchedulerGRPCClientConfig, schedulerClientFactory: func(conn *grpc.ClientConn) schedulerpb.SchedulerForQuerierClient { return schedulerpb.NewSchedulerForQuerierClient(conn) }, diff --git a/pkg/querier/worker/worker.go b/pkg/querier/worker/worker.go index bc41a49d9075d..ad7d597273730 100644 --- a/pkg/querier/worker/worker.go +++ b/pkg/querier/worker/worker.go @@ -30,7 +30,9 @@ type Config struct { QuerierID string `yaml:"id"` - GRPCClientConfig grpcclient.Config `yaml:"grpc_client_config"` + QueryFrontendGRPCClientConfig grpcclient.Config `yaml:"grpc_client_config"` + + QuerySchedulerGRPCClientConfig grpcclient.Config `yaml:"query_scheduler_grpc_client_config"` } func (cfg *Config) RegisterFlags(f *flag.FlagSet) { @@ -39,14 +41,19 @@ func (cfg *Config) RegisterFlags(f *flag.FlagSet) { f.DurationVar(&cfg.DNSLookupPeriod, "querier.dns-lookup-period", 3*time.Second, "How often to query DNS for query-frontend or query-scheduler address. Also used to determine how often to poll the scheduler-ring for addresses if the scheduler-ring is configured.") f.StringVar(&cfg.QuerierID, "querier.id", "", "Querier ID, sent to frontend service to identify requests from the same querier. Defaults to hostname.") - cfg.GRPCClientConfig.RegisterFlagsWithPrefix("querier.frontend-client", f) + cfg.QueryFrontendGRPCClientConfig.RegisterFlagsWithPrefix("querier.frontend-client", f) + cfg.QuerySchedulerGRPCClientConfig.RegisterFlagsWithPrefix("querier.scheduler-client", f) } func (cfg *Config) Validate() error { if cfg.FrontendAddress != "" && cfg.SchedulerAddress != "" { return errors.New("frontend address and scheduler address are mutually exclusive, please use only one") } - return cfg.GRPCClientConfig.Validate() + if err := cfg.QueryFrontendGRPCClientConfig.Validate(); err != nil { + return err + } + + return cfg.QuerySchedulerGRPCClientConfig.Validate() } // Handler for HTTP requests wrapped in protobuf messages. @@ -80,7 +87,7 @@ type processor interface { type querierWorker struct { *services.BasicService - cfg Config + // cfg Config logger log.Logger processor processor @@ -92,6 +99,9 @@ type querierWorker struct { managers map[string]*processorManager metrics *Metrics + + grpcClientConfig grpcclient.Config + maxConcurrentRequests int } func NewQuerierWorker(cfg Config, rng ring.ReadRing, handler RequestHandler, logger log.Logger, reg prometheus.Registerer, codec RequestCodec) (services.Service, error) { @@ -105,12 +115,14 @@ func NewQuerierWorker(cfg Config, rng ring.ReadRing, handler RequestHandler, log metrics := NewMetrics(cfg, reg) var processor processor + var grpcCfg grpcclient.Config var servs []services.Service var address string switch { case rng != nil: level.Info(logger).Log("msg", "Starting querier worker using query-scheduler and scheduler ring for addresses") + grpcCfg = cfg.QuerySchedulerGRPCClientConfig processor, servs = newSchedulerProcessor(cfg, handler, logger, metrics, codec) case cfg.SchedulerAddress != "": level.Info(logger).Log("msg", "Starting querier worker connected to query-scheduler", "scheduler", cfg.SchedulerAddress) @@ -122,26 +134,28 @@ func NewQuerierWorker(cfg Config, rng ring.ReadRing, handler RequestHandler, log level.Info(logger).Log("msg", "Starting querier worker connected to query-frontend", "frontend", cfg.FrontendAddress) address = cfg.FrontendAddress + grpcCfg = cfg.QueryFrontendGRPCClientConfig processor = newFrontendProcessor(cfg, handler, logger, codec) default: return nil, errors.New("unable to start the querier worker, need to configure one of frontend_address, scheduler_address, or a ring config in the query_scheduler config block") } - return newQuerierWorkerWithProcessor(cfg, metrics, logger, processor, address, rng, servs) + return newQuerierWorkerWithProcessor(grpcCfg, cfg.MaxConcurrent, cfg.DNSLookupPeriod, metrics, logger, processor, address, rng, servs) } -func newQuerierWorkerWithProcessor(cfg Config, metrics *Metrics, logger log.Logger, processor processor, address string, ring ring.ReadRing, servs []services.Service) (*querierWorker, error) { +func newQuerierWorkerWithProcessor(grpcCfg grpcclient.Config, maxConcReq int, dnsLookupPeriod time.Duration, metrics *Metrics, logger log.Logger, processor processor, address string, ring ring.ReadRing, servs []services.Service) (*querierWorker, error) { f := &querierWorker{ - cfg: cfg, - logger: logger, - managers: map[string]*processorManager{}, - processor: processor, - metrics: metrics, + maxConcurrentRequests: maxConcReq, + grpcClientConfig: grpcCfg, + logger: logger, + managers: map[string]*processorManager{}, + processor: processor, + metrics: metrics, } // Empty address is only used in tests, where individual targets are added manually. if address != "" { - w, err := util.NewDNSWatcher(address, cfg.DNSLookupPeriod, f) + w, err := util.NewDNSWatcher(address, dnsLookupPeriod, f) if err != nil { return nil, err } @@ -150,7 +164,7 @@ func newQuerierWorkerWithProcessor(cfg Config, metrics *Metrics, logger log.Logg } if ring != nil { - w, err := util.NewRingWatcher(log.With(logger, "component", "querier-scheduler-worker"), ring, cfg.DNSLookupPeriod, f) + w, err := util.NewRingWatcher(log.With(logger, "component", "querier-scheduler-worker"), ring, dnsLookupPeriod, f) if err != nil { return nil, err } @@ -245,17 +259,17 @@ func (w *querierWorker) resetConcurrency() { }() for _, m := range w.managers { - concurrency := w.cfg.MaxConcurrent / len(w.managers) + concurrency := w.maxConcurrentRequests / len(w.managers) // If max concurrency does not evenly divide into our frontends a subset will be chosen // to receive an extra connection. Frontend addresses were shuffled above so this will be a // random selection of frontends. - if index < w.cfg.MaxConcurrent%len(w.managers) { + if index < w.maxConcurrentRequests%len(w.managers) { level.Warn(w.logger).Log("msg", "max concurrency is not evenly divisible across targets, adding an extra connection", "addr", m.address) concurrency++ } - // If concurrency is 0 then MaxConcurrentRequests is less than the total number of + // If concurrency is 0 then maxConcurrentRequests is less than the total number of // frontends/schedulers. In order to prevent accidentally starving a frontend or scheduler we are just going to // always connect once to every target. This is dangerous b/c we may start exceeding LogQL // max concurrency. @@ -271,7 +285,7 @@ func (w *querierWorker) resetConcurrency() { func (w *querierWorker) connect(ctx context.Context, address string) (*grpc.ClientConn, error) { // Because we only use single long-running method, it doesn't make sense to inject user ID, send over tracing or add metrics. - opts, err := w.cfg.GRPCClientConfig.DialOption(nil, nil) + opts, err := w.grpcClientConfig.DialOption(nil, nil) if err != nil { return nil, err } diff --git a/pkg/querier/worker/worker_test.go b/pkg/querier/worker/worker_test.go index fb311925fb207..43c6d74262f54 100644 --- a/pkg/querier/worker/worker_test.go +++ b/pkg/querier/worker/worker_test.go @@ -54,7 +54,7 @@ func TestResetConcurrency(t *testing.T) { MaxConcurrent: tt.maxConcurrent, } - w, err := newQuerierWorkerWithProcessor(cfg, NewMetrics(cfg, nil), log.NewNopLogger(), &mockProcessor{}, "", nil, nil) + w, err := newQuerierWorkerWithProcessor(cfg.QuerySchedulerGRPCClientConfig, cfg.MaxConcurrent, cfg.DNSLookupPeriod, NewMetrics(cfg, nil), log.NewNopLogger(), &mockProcessor{}, "", nil, nil) require.NoError(t, err) require.NoError(t, services.StartAndAwaitRunning(context.Background(), w)) From dd7c5d6ad779f0a4c1d506877f0fabda29bada3a Mon Sep 17 00:00:00 2001 From: DylanGuedes Date: Mon, 22 Apr 2024 10:32:10 -0300 Subject: [PATCH 02/16] Remove dead code. --- pkg/querier/worker/worker.go | 1 - 1 file changed, 1 deletion(-) diff --git a/pkg/querier/worker/worker.go b/pkg/querier/worker/worker.go index ad7d597273730..c4c654bc51c6a 100644 --- a/pkg/querier/worker/worker.go +++ b/pkg/querier/worker/worker.go @@ -87,7 +87,6 @@ type processor interface { type querierWorker struct { *services.BasicService - // cfg Config logger log.Logger processor processor From 4e9aef0e7a13e41514e7c47fd6892fe5648c0a88 Mon Sep 17 00:00:00 2001 From: DylanGuedes Date: Mon, 22 Apr 2024 10:37:27 -0300 Subject: [PATCH 03/16] Update docs. --- docs/sources/shared/configuration.md | 12 ++++++++++++ pkg/querier/worker/worker.go | 10 ++++++++++ 2 files changed, 22 insertions(+) diff --git a/docs/sources/shared/configuration.md b/docs/sources/shared/configuration.md index 8c2413e26250b..a815c69780dce 100644 --- a/docs/sources/shared/configuration.md +++ b/docs/sources/shared/configuration.md @@ -3561,6 +3561,17 @@ The `frontend_worker` configures the worker - running within the Loki querier - # client and server component in Loki. # The CLI flags prefix for this block configuration is: querier.frontend-client [grpc_client_config: ] + +# The grpc_client block configures the gRPC client used to communicate between a +# client and server component in Loki. +# The CLI flags prefix for this block configuration is: querier.scheduler-client +[query_scheduler_grpc_client_config: ] + +# Wether to use separated clients for frontend and scheduler. If set to true, +# querier will use separated clients for frontend and scheduler. If set to +# false, querier will use the same client for both frontend and scheduler. +# CLI flag: -querier.use-separated-clients +[uses_separated_clients: | default = false] ``` ### table_manager @@ -4543,6 +4554,7 @@ The `grpc_client` block configures the gRPC client used to communicate between a - `ingester.client` - `pattern-ingester.client` - `querier.frontend-client` +- `querier.scheduler-client` - `query-scheduler.grpc-client-config` - `ruler.client` - `tsdb.shipper.index-gateway-client.grpc` diff --git a/pkg/querier/worker/worker.go b/pkg/querier/worker/worker.go index c4c654bc51c6a..1f3ca53e774d4 100644 --- a/pkg/querier/worker/worker.go +++ b/pkg/querier/worker/worker.go @@ -33,6 +33,8 @@ type Config struct { QueryFrontendGRPCClientConfig grpcclient.Config `yaml:"grpc_client_config"` QuerySchedulerGRPCClientConfig grpcclient.Config `yaml:"query_scheduler_grpc_client_config"` + + UseSeparatedClients bool `yaml:"uses_separated_clients"` } func (cfg *Config) RegisterFlags(f *flag.FlagSet) { @@ -40,6 +42,7 @@ func (cfg *Config) RegisterFlags(f *flag.FlagSet) { f.StringVar(&cfg.FrontendAddress, "querier.frontend-address", "", "Address of query frontend service, in host:port format. If -querier.scheduler-address is set as well, querier will use scheduler instead. Only one of -querier.frontend-address or -querier.scheduler-address can be set. If neither is set, queries are only received via HTTP endpoint.") f.DurationVar(&cfg.DNSLookupPeriod, "querier.dns-lookup-period", 3*time.Second, "How often to query DNS for query-frontend or query-scheduler address. Also used to determine how often to poll the scheduler-ring for addresses if the scheduler-ring is configured.") f.StringVar(&cfg.QuerierID, "querier.id", "", "Querier ID, sent to frontend service to identify requests from the same querier. Defaults to hostname.") + f.BoolVar(&cfg.UseSeparatedClients, "querier.use-separated-clients", false, "Wether to use separated clients for frontend and scheduler. If set to true, querier will use separated clients for frontend and scheduler. If set to false, querier will use the same client for both frontend and scheduler.") cfg.QueryFrontendGRPCClientConfig.RegisterFlagsWithPrefix("querier.frontend-client", f) cfg.QuerySchedulerGRPCClientConfig.RegisterFlagsWithPrefix("querier.scheduler-client", f) @@ -104,6 +107,13 @@ type querierWorker struct { } func NewQuerierWorker(cfg Config, rng ring.ReadRing, handler RequestHandler, logger log.Logger, reg prometheus.Registerer, codec RequestCodec) (services.Service, error) { + if !cfg.UseSeparatedClients { + level.Warn(logger).Log("msg", "Using the same client for frontend and scheduler. This is deprecated and will be removed in the future. Please use separated clients for frontend and scheduler.") + // The frontend client config is the older config and it points to "grpc_client_config" so we + // reuse it for the scheduler client config. + cfg.QuerySchedulerGRPCClientConfig = cfg.QueryFrontendGRPCClientConfig + } + if cfg.QuerierID == "" { hostname, err := os.Hostname() if err != nil { From 66ab50efcfb8f535b67b01b185378f79d70ae11f Mon Sep 17 00:00:00 2001 From: DylanGuedes Date: Mon, 22 Apr 2024 10:42:06 -0300 Subject: [PATCH 04/16] Add docs description. --- pkg/querier/worker/worker.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/querier/worker/worker.go b/pkg/querier/worker/worker.go index 1f3ca53e774d4..e312de1a14b3c 100644 --- a/pkg/querier/worker/worker.go +++ b/pkg/querier/worker/worker.go @@ -30,11 +30,11 @@ type Config struct { QuerierID string `yaml:"id"` - QueryFrontendGRPCClientConfig grpcclient.Config `yaml:"grpc_client_config"` + QueryFrontendGRPCClientConfig grpcclient.Config `yaml:"grpc_client_config" doc:"description=Configures the gRPC client used to communicate between the querier and the query-frontend. If 'use_separated_clients' is false, this config is used for communicating with both frontend and scheduler."` - QuerySchedulerGRPCClientConfig grpcclient.Config `yaml:"query_scheduler_grpc_client_config"` + QuerySchedulerGRPCClientConfig grpcclient.Config `yaml:"query_scheduler_grpc_client_config" doc:"description=Configures the gRPC client used to communicate between the querier and the query-scheduler. If 'use_separated_clients' is false, this config is ignored."` - UseSeparatedClients bool `yaml:"uses_separated_clients"` + UseSeparatedClients bool `yaml:"uses_separated_clients" doc:"description=If set to true, querier will use 'query_scheduler_grpc_client_config' to communicate with the scheduler. Otherwise, 'query_scheduler_grpc_client_config' is ignored and 'grpc_client_config' is used instead."` } func (cfg *Config) RegisterFlags(f *flag.FlagSet) { @@ -42,7 +42,7 @@ func (cfg *Config) RegisterFlags(f *flag.FlagSet) { f.StringVar(&cfg.FrontendAddress, "querier.frontend-address", "", "Address of query frontend service, in host:port format. If -querier.scheduler-address is set as well, querier will use scheduler instead. Only one of -querier.frontend-address or -querier.scheduler-address can be set. If neither is set, queries are only received via HTTP endpoint.") f.DurationVar(&cfg.DNSLookupPeriod, "querier.dns-lookup-period", 3*time.Second, "How often to query DNS for query-frontend or query-scheduler address. Also used to determine how often to poll the scheduler-ring for addresses if the scheduler-ring is configured.") f.StringVar(&cfg.QuerierID, "querier.id", "", "Querier ID, sent to frontend service to identify requests from the same querier. Defaults to hostname.") - f.BoolVar(&cfg.UseSeparatedClients, "querier.use-separated-clients", false, "Wether to use separated clients for frontend and scheduler. If set to true, querier will use separated clients for frontend and scheduler. If set to false, querier will use the same client for both frontend and scheduler.") + f.BoolVar(&cfg.UseSeparatedClients, "querier.use-separated-clients", false, "Whether to use separated clients for frontend and scheduler. If set to true, querier will use separated clients for frontend and scheduler. If set to false, querier will use the same client for both frontend and scheduler.") cfg.QueryFrontendGRPCClientConfig.RegisterFlagsWithPrefix("querier.frontend-client", f) cfg.QuerySchedulerGRPCClientConfig.RegisterFlagsWithPrefix("querier.scheduler-client", f) From d62d434dd741029f45f59b32938a236a7c973727 Mon Sep 17 00:00:00 2001 From: DylanGuedes Date: Mon, 22 Apr 2024 10:43:36 -0300 Subject: [PATCH 05/16] regenerate docs --- docs/sources/shared/configuration.md | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/docs/sources/shared/configuration.md b/docs/sources/shared/configuration.md index a815c69780dce..9bcc1f72a278e 100644 --- a/docs/sources/shared/configuration.md +++ b/docs/sources/shared/configuration.md @@ -3557,19 +3557,21 @@ The `frontend_worker` configures the worker - running within the Loki querier - # CLI flag: -querier.id [id: | default = ""] -# The grpc_client block configures the gRPC client used to communicate between a -# client and server component in Loki. +# Configures the gRPC client used to communicate between the querier and the +# query-frontend. If 'use_separated_clients' is false, this config is used for +# communicating with both frontend and scheduler. # The CLI flags prefix for this block configuration is: querier.frontend-client [grpc_client_config: ] -# The grpc_client block configures the gRPC client used to communicate between a -# client and server component in Loki. +# Configures the gRPC client used to communicate between the querier and the +# query-scheduler. If 'use_separated_clients' is false, this config is ignored. # The CLI flags prefix for this block configuration is: querier.scheduler-client [query_scheduler_grpc_client_config: ] -# Wether to use separated clients for frontend and scheduler. If set to true, -# querier will use separated clients for frontend and scheduler. If set to -# false, querier will use the same client for both frontend and scheduler. +# If set to true, querier will use 'query_scheduler_grpc_client_config' to +# communicate with the scheduler. Otherwise, +# 'query_scheduler_grpc_client_config' is ignored and 'grpc_client_config' is +# used instead. # CLI flag: -querier.use-separated-clients [uses_separated_clients: | default = false] ``` From a1676b6ec9c8f0f14b53f2ed5a694695a5ab5c70 Mon Sep 17 00:00:00 2001 From: DylanGuedes Date: Mon, 22 Apr 2024 11:50:06 -0300 Subject: [PATCH 06/16] set grpc config here too --- pkg/querier/worker/worker.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/querier/worker/worker.go b/pkg/querier/worker/worker.go index e312de1a14b3c..a02b3b4593bcd 100644 --- a/pkg/querier/worker/worker.go +++ b/pkg/querier/worker/worker.go @@ -136,6 +136,7 @@ func NewQuerierWorker(cfg Config, rng ring.ReadRing, handler RequestHandler, log case cfg.SchedulerAddress != "": level.Info(logger).Log("msg", "Starting querier worker connected to query-scheduler", "scheduler", cfg.SchedulerAddress) + grpcCfg = cfg.QuerySchedulerGRPCClientConfig address = cfg.SchedulerAddress processor, servs = newSchedulerProcessor(cfg, handler, logger, metrics, codec) From ccc58283699ce27f2d2aec0b334444db7050da6b Mon Sep 17 00:00:00 2001 From: DylanGuedes Date: Mon, 22 Apr 2024 11:57:00 -0300 Subject: [PATCH 07/16] renmae config --- docs/sources/shared/configuration.md | 2 +- pkg/querier/worker/worker.go | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/sources/shared/configuration.md b/docs/sources/shared/configuration.md index 9bcc1f72a278e..6ee3fef67f11b 100644 --- a/docs/sources/shared/configuration.md +++ b/docs/sources/shared/configuration.md @@ -3572,7 +3572,7 @@ The `frontend_worker` configures the worker - running within the Loki querier - # communicate with the scheduler. Otherwise, # 'query_scheduler_grpc_client_config' is ignored and 'grpc_client_config' is # used instead. -# CLI flag: -querier.use-separated-clients +# CLI flag: -querier.use-separated-grpc-clients [uses_separated_clients: | default = false] ``` diff --git a/pkg/querier/worker/worker.go b/pkg/querier/worker/worker.go index a02b3b4593bcd..107f07a93eff1 100644 --- a/pkg/querier/worker/worker.go +++ b/pkg/querier/worker/worker.go @@ -34,7 +34,7 @@ type Config struct { QuerySchedulerGRPCClientConfig grpcclient.Config `yaml:"query_scheduler_grpc_client_config" doc:"description=Configures the gRPC client used to communicate between the querier and the query-scheduler. If 'use_separated_clients' is false, this config is ignored."` - UseSeparatedClients bool `yaml:"uses_separated_clients" doc:"description=If set to true, querier will use 'query_scheduler_grpc_client_config' to communicate with the scheduler. Otherwise, 'query_scheduler_grpc_client_config' is ignored and 'grpc_client_config' is used instead."` + UseSeparatedGRPCClients bool `yaml:"uses_separated_clients" doc:"description=If set to true, querier will use 'query_scheduler_grpc_client_config' to communicate with the scheduler. Otherwise, 'query_scheduler_grpc_client_config' is ignored and 'grpc_client_config' is used instead."` } func (cfg *Config) RegisterFlags(f *flag.FlagSet) { @@ -42,7 +42,7 @@ func (cfg *Config) RegisterFlags(f *flag.FlagSet) { f.StringVar(&cfg.FrontendAddress, "querier.frontend-address", "", "Address of query frontend service, in host:port format. If -querier.scheduler-address is set as well, querier will use scheduler instead. Only one of -querier.frontend-address or -querier.scheduler-address can be set. If neither is set, queries are only received via HTTP endpoint.") f.DurationVar(&cfg.DNSLookupPeriod, "querier.dns-lookup-period", 3*time.Second, "How often to query DNS for query-frontend or query-scheduler address. Also used to determine how often to poll the scheduler-ring for addresses if the scheduler-ring is configured.") f.StringVar(&cfg.QuerierID, "querier.id", "", "Querier ID, sent to frontend service to identify requests from the same querier. Defaults to hostname.") - f.BoolVar(&cfg.UseSeparatedClients, "querier.use-separated-clients", false, "Whether to use separated clients for frontend and scheduler. If set to true, querier will use separated clients for frontend and scheduler. If set to false, querier will use the same client for both frontend and scheduler.") + f.BoolVar(&cfg.UseSeparatedGRPCClients, "querier.use-separated-grpc-clients", false, "Whether to use separated clients for frontend and scheduler. If set to true, querier will use separated clients for frontend and scheduler. If set to false, querier will use the same client for both frontend and scheduler.") cfg.QueryFrontendGRPCClientConfig.RegisterFlagsWithPrefix("querier.frontend-client", f) cfg.QuerySchedulerGRPCClientConfig.RegisterFlagsWithPrefix("querier.scheduler-client", f) @@ -107,7 +107,7 @@ type querierWorker struct { } func NewQuerierWorker(cfg Config, rng ring.ReadRing, handler RequestHandler, logger log.Logger, reg prometheus.Registerer, codec RequestCodec) (services.Service, error) { - if !cfg.UseSeparatedClients { + if !cfg.UseSeparatedGRPCClients { level.Warn(logger).Log("msg", "Using the same client for frontend and scheduler. This is deprecated and will be removed in the future. Please use separated clients for frontend and scheduler.") // The frontend client config is the older config and it points to "grpc_client_config" so we // reuse it for the scheduler client config. From 35820954f379ea91a62b369a88615125b9d20ed9 Mon Sep 17 00:00:00 2001 From: DylanGuedes Date: Fri, 26 Apr 2024 09:29:05 -0300 Subject: [PATCH 08/16] Don't say using same client is deprecated. --- pkg/querier/worker/worker.go | 1 - 1 file changed, 1 deletion(-) diff --git a/pkg/querier/worker/worker.go b/pkg/querier/worker/worker.go index 107f07a93eff1..c74ce949fb137 100644 --- a/pkg/querier/worker/worker.go +++ b/pkg/querier/worker/worker.go @@ -108,7 +108,6 @@ type querierWorker struct { func NewQuerierWorker(cfg Config, rng ring.ReadRing, handler RequestHandler, logger log.Logger, reg prometheus.Registerer, codec RequestCodec) (services.Service, error) { if !cfg.UseSeparatedGRPCClients { - level.Warn(logger).Log("msg", "Using the same client for frontend and scheduler. This is deprecated and will be removed in the future. Please use separated clients for frontend and scheduler.") // The frontend client config is the older config and it points to "grpc_client_config" so we // reuse it for the scheduler client config. cfg.QuerySchedulerGRPCClientConfig = cfg.QueryFrontendGRPCClientConfig From 9ba6f8718717139c3bf24a1c34dd57d7e52fd9ab Mon Sep 17 00:00:00 2001 From: DylanGuedes Date: Fri, 26 Apr 2024 09:32:35 -0300 Subject: [PATCH 09/16] address suggestion of wording order --- docs/sources/shared/configuration.md | 6 ++++-- pkg/querier/worker/worker.go | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/sources/shared/configuration.md b/docs/sources/shared/configuration.md index 6ee3fef67f11b..87f3f425813aa 100644 --- a/docs/sources/shared/configuration.md +++ b/docs/sources/shared/configuration.md @@ -3558,8 +3558,10 @@ The `frontend_worker` configures the worker - running within the Loki querier - [id: | default = ""] # Configures the gRPC client used to communicate between the querier and the -# query-frontend. If 'use_separated_clients' is false, this config is used for -# communicating with both frontend and scheduler. +# query-frontend, and the querier and the query-scheduler. If +# 'use_separated_clients' is true, this config is only used for communicating +# with frontend and 'query_scheduler_grpc_client_config' should be used to +# configuring querier <-> scheduler communication. # The CLI flags prefix for this block configuration is: querier.frontend-client [grpc_client_config: ] diff --git a/pkg/querier/worker/worker.go b/pkg/querier/worker/worker.go index c74ce949fb137..ae992a1ce636e 100644 --- a/pkg/querier/worker/worker.go +++ b/pkg/querier/worker/worker.go @@ -30,7 +30,7 @@ type Config struct { QuerierID string `yaml:"id"` - QueryFrontendGRPCClientConfig grpcclient.Config `yaml:"grpc_client_config" doc:"description=Configures the gRPC client used to communicate between the querier and the query-frontend. If 'use_separated_clients' is false, this config is used for communicating with both frontend and scheduler."` + QueryFrontendGRPCClientConfig grpcclient.Config `yaml:"grpc_client_config" doc:"description=Configures the gRPC client used to communicate between the querier and the query-frontend, and the querier and the query-scheduler. If 'use_separated_clients' is true, this config is only used for communicating with frontend and 'query_scheduler_grpc_client_config' should be used to configuring querier <-> scheduler communication."` QuerySchedulerGRPCClientConfig grpcclient.Config `yaml:"query_scheduler_grpc_client_config" doc:"description=Configures the gRPC client used to communicate between the querier and the query-scheduler. If 'use_separated_clients' is false, this config is ignored."` From 0fb7fe7a89f137060d52485931ae322d892ae35f Mon Sep 17 00:00:00 2001 From: DylanGuedes Date: Fri, 26 Apr 2024 09:35:58 -0300 Subject: [PATCH 10/16] regenerate markdown --- docs/sources/shared/configuration.md | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/docs/sources/shared/configuration.md b/docs/sources/shared/configuration.md index 9a04d6fac7854..a4ef9a5405088 100644 --- a/docs/sources/shared/configuration.md +++ b/docs/sources/shared/configuration.md @@ -2236,10 +2236,25 @@ The `frontend_worker` configures the worker - running within the Loki querier - # CLI flag: -querier.id [id: | default = ""] -# The grpc_client block configures the gRPC client used to communicate between a -# client and server component in Loki. +# Configures the gRPC client used to communicate between the querier and the +# query-frontend, and the querier and the query-scheduler. If +# 'use_separated_clients' is true, this config is only used for communicating +# with frontend and 'query_scheduler_grpc_client_config' should be used to +# configuring querier <-> scheduler communication. # The CLI flags prefix for this block configuration is: querier.frontend-client [grpc_client_config: ] + +# Configures the gRPC client used to communicate between the querier and the +# query-scheduler. If 'use_separated_clients' is false, this config is ignored. +# The CLI flags prefix for this block configuration is: querier.scheduler-client +[query_scheduler_grpc_client_config: ] + +# If set to true, querier will use 'query_scheduler_grpc_client_config' to +# communicate with the scheduler. Otherwise, +# 'query_scheduler_grpc_client_config' is ignored and 'grpc_client_config' is +# used instead. +# CLI flag: -querier.use-separated-grpc-clients +[uses_separated_clients: | default = false] ``` ### gcs_storage_config @@ -2297,6 +2312,7 @@ The `grpc_client` block configures the gRPC client used to communicate between a - `ingester.client` - `pattern-ingester.client` - `querier.frontend-client` +- `querier.scheduler-client` - `query-scheduler.grpc-client-config` - `ruler.client` - `tsdb.shipper.index-gateway-client.grpc` From 01b1e748c80d048c0a008b314cb46db77985f878 Mon Sep 17 00:00:00 2001 From: DylanGuedes Date: Tue, 30 Apr 2024 12:14:47 -0300 Subject: [PATCH 11/16] Use the correct config --- pkg/querier/worker/scheduler_processor.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/querier/worker/scheduler_processor.go b/pkg/querier/worker/scheduler_processor.go index c8f6d4effa91d..68842c5cde3f2 100644 --- a/pkg/querier/worker/scheduler_processor.go +++ b/pkg/querier/worker/scheduler_processor.go @@ -38,9 +38,9 @@ func newSchedulerProcessor(cfg Config, handler RequestHandler, log log.Logger, m log: log, handler: handler, codec: codec, - maxMessageSize: cfg.QuerySchedulerGRPCClientConfig.MaxSendMsgSize, + maxMessageSize: cfg.QueryFrontendGRPCClientConfig.MaxRecvMsgSize, querierID: cfg.QuerierID, - grpcConfig: cfg.QuerySchedulerGRPCClientConfig, + grpcConfig: cfg.QueryFrontendGRPCClientConfig, schedulerClientFactory: func(conn *grpc.ClientConn) schedulerpb.SchedulerForQuerierClient { return schedulerpb.NewSchedulerForQuerierClient(conn) }, From 9cb6360f4294be77a9bec494dcf50cd4a3769a57 Mon Sep 17 00:00:00 2001 From: DylanGuedes Date: Thu, 2 May 2024 14:08:49 -0300 Subject: [PATCH 12/16] Get rid of boolean flag, add new client config sections. --- docs/sources/shared/configuration.md | 103 +++++++++++----------- pkg/loki/config_wrapper.go | 23 +++++ pkg/loki/config_wrapper_test.go | 103 ++++++++++++++++++++++ pkg/querier/worker/frontend_processor.go | 2 +- pkg/querier/worker/scheduler_processor.go | 4 +- pkg/querier/worker/worker.go | 28 +++--- pkg/querier/worker/worker_test.go | 34 +++++++ 7 files changed, 228 insertions(+), 69 deletions(-) diff --git a/docs/sources/shared/configuration.md b/docs/sources/shared/configuration.md index a4ef9a5405088..d397d224c1424 100644 --- a/docs/sources/shared/configuration.md +++ b/docs/sources/shared/configuration.md @@ -789,92 +789,92 @@ The `azure_storage_config` block configures the connection to Azure object stora ```yaml # Azure Cloud environment. Supported values are: AzureGlobal, AzureChinaCloud, # AzureGermanCloud, AzureUSGovernment. -# CLI flag: -.azure.environment +# CLI flag: -azure.environment [environment: | default = "AzureGlobal"] # Azure storage account name. -# CLI flag: -.azure.account-name +# CLI flag: -azure.account-name [account_name: | default = ""] # Azure storage account key. -# CLI flag: -.azure.account-key +# CLI flag: -azure.account-key [account_key: | default = ""] # If `connection-string` is set, the values of `account-name` and # `endpoint-suffix` values will not be used. Use this method over `account-key` # if you need to authenticate via a SAS token. Or if you use the Azurite # emulator. -# CLI flag: -.azure.connection-string +# CLI flag: -azure.connection-string [connection_string: | default = ""] # Name of the storage account blob container used to store chunks. This # container must be created before running cortex. -# CLI flag: -.azure.container-name +# CLI flag: -azure.container-name [container_name: | default = "loki"] # Azure storage endpoint suffix without schema. The storage account name will be # prefixed to this value to create the FQDN. -# CLI flag: -.azure.endpoint-suffix +# CLI flag: -azure.endpoint-suffix [endpoint_suffix: | default = ""] # Use Managed Identity to authenticate to the Azure storage account. -# CLI flag: -.azure.use-managed-identity +# CLI flag: -azure.use-managed-identity [use_managed_identity: | default = false] # Use Federated Token to authenticate to the Azure storage account. -# CLI flag: -.azure.use-federated-token +# CLI flag: -azure.use-federated-token [use_federated_token: | default = false] # User assigned identity ID to authenticate to the Azure storage account. -# CLI flag: -.azure.user-assigned-id +# CLI flag: -azure.user-assigned-id [user_assigned_id: | default = ""] # Use Service Principal to authenticate through Azure OAuth. -# CLI flag: -.azure.use-service-principal +# CLI flag: -azure.use-service-principal [use_service_principal: | default = false] # Azure Service Principal ID(GUID). -# CLI flag: -.azure.client-id +# CLI flag: -azure.client-id [client_id: | default = ""] # Azure Service Principal secret key. -# CLI flag: -.azure.client-secret +# CLI flag: -azure.client-secret [client_secret: | default = ""] # Azure Tenant ID is used to authenticate through Azure OAuth. -# CLI flag: -.azure.tenant-id +# CLI flag: -azure.tenant-id [tenant_id: | default = ""] # Chunk delimiter for blob ID to be used -# CLI flag: -.azure.chunk-delimiter +# CLI flag: -azure.chunk-delimiter [chunk_delimiter: | default = "-"] # Preallocated buffer size for downloads. -# CLI flag: -.azure.download-buffer-size +# CLI flag: -azure.download-buffer-size [download_buffer_size: | default = 512000] # Preallocated buffer size for uploads. -# CLI flag: -.azure.upload-buffer-size +# CLI flag: -azure.upload-buffer-size [upload_buffer_size: | default = 256000] # Number of buffers used to used to upload a chunk. -# CLI flag: -.azure.download-buffer-count +# CLI flag: -azure.download-buffer-count [upload_buffer_count: | default = 1] # Timeout for requests made against azure blob storage. -# CLI flag: -.azure.request-timeout +# CLI flag: -azure.request-timeout [request_timeout: | default = 30s] # Number of retries for a request which times out. -# CLI flag: -.azure.max-retries +# CLI flag: -azure.max-retries [max_retries: | default = 5] # Minimum time to wait before retrying a request. -# CLI flag: -.azure.min-retry-delay +# CLI flag: -azure.min-retry-delay [min_retry_delay: | default = 10ms] # Maximum time to wait before retrying a request. -# CLI flag: -.azure.max-retry-delay +# CLI flag: -azure.max-retry-delay [max_retry_delay: | default = 500ms] ``` @@ -2236,6 +2236,12 @@ The `frontend_worker` configures the worker - running within the Loki querier - # CLI flag: -querier.id [id: | default = ""] +# The grpc_client block configures the gRPC client used to communicate between a +# client and server component in Loki. +# The CLI flags prefix for this block configuration is: +# querier.frontend-grpc-client +[query_frontend_grpc_client: ] + # Configures the gRPC client used to communicate between the querier and the # query-frontend, and the querier and the query-scheduler. If # 'use_separated_clients' is true, this config is only used for communicating @@ -2246,15 +2252,9 @@ The `frontend_worker` configures the worker - running within the Loki querier - # Configures the gRPC client used to communicate between the querier and the # query-scheduler. If 'use_separated_clients' is false, this config is ignored. -# The CLI flags prefix for this block configuration is: querier.scheduler-client -[query_scheduler_grpc_client_config: ] - -# If set to true, querier will use 'query_scheduler_grpc_client_config' to -# communicate with the scheduler. Otherwise, -# 'query_scheduler_grpc_client_config' is ignored and 'grpc_client_config' is -# used instead. -# CLI flag: -querier.use-separated-grpc-clients -[uses_separated_clients: | default = false] +# The CLI flags prefix for this block configuration is: +# querier.scheduler-grpc-client +[query_scheduler_grpc_client: ] ``` ### gcs_storage_config @@ -2312,7 +2312,8 @@ The `grpc_client` block configures the gRPC client used to communicate between a - `ingester.client` - `pattern-ingester.client` - `querier.frontend-client` -- `querier.scheduler-client` +- `querier.frontend-grpc-client` +- `querier.scheduler-grpc-client` - `query-scheduler.grpc-client-config` - `ruler.client` - `tsdb.shipper.index-gateway-client.grpc` @@ -2374,7 +2375,7 @@ backoff_config: # TLS flag is set. If set to false, insecure connection to gRPC server will be # used. # CLI flag: -.tls-enabled -[tls_enabled: | default = false] +[tls_enabled: | default = true] # Path to the client certificate, which will be used for authenticating with the # server. Also requires the key path to be configured. @@ -5297,83 +5298,83 @@ The `swift_storage_config` block configures the connection to OpenStack Object S ```yaml # OpenStack Swift authentication API version. 0 to autodetect. -# CLI flag: -.swift.auth-version +# CLI flag: -swift.auth-version [auth_version: | default = 0] # OpenStack Swift authentication URL -# CLI flag: -.swift.auth-url +# CLI flag: -swift.auth-url [auth_url: | default = ""] # Set this to true to use the internal OpenStack Swift endpoint URL -# CLI flag: -.swift.internal +# CLI flag: -swift.internal [internal: | default = false] # OpenStack Swift username. -# CLI flag: -.swift.username +# CLI flag: -swift.username [username: | default = ""] # OpenStack Swift user's domain name. -# CLI flag: -.swift.user-domain-name +# CLI flag: -swift.user-domain-name [user_domain_name: | default = ""] # OpenStack Swift user's domain ID. -# CLI flag: -.swift.user-domain-id +# CLI flag: -swift.user-domain-id [user_domain_id: | default = ""] # OpenStack Swift user ID. -# CLI flag: -.swift.user-id +# CLI flag: -swift.user-id [user_id: | default = ""] # OpenStack Swift API key. -# CLI flag: -.swift.password +# CLI flag: -swift.password [password: | default = ""] # OpenStack Swift user's domain ID. -# CLI flag: -.swift.domain-id +# CLI flag: -swift.domain-id [domain_id: | default = ""] # OpenStack Swift user's domain name. -# CLI flag: -.swift.domain-name +# CLI flag: -swift.domain-name [domain_name: | default = ""] # OpenStack Swift project ID (v2,v3 auth only). -# CLI flag: -.swift.project-id +# CLI flag: -swift.project-id [project_id: | default = ""] # OpenStack Swift project name (v2,v3 auth only). -# CLI flag: -.swift.project-name +# CLI flag: -swift.project-name [project_name: | default = ""] # ID of the OpenStack Swift project's domain (v3 auth only), only needed if it # differs the from user domain. -# CLI flag: -.swift.project-domain-id +# CLI flag: -swift.project-domain-id [project_domain_id: | default = ""] # Name of the OpenStack Swift project's domain (v3 auth only), only needed if it # differs from the user domain. -# CLI flag: -.swift.project-domain-name +# CLI flag: -swift.project-domain-name [project_domain_name: | default = ""] # OpenStack Swift Region to use (v2,v3 auth only). -# CLI flag: -.swift.region-name +# CLI flag: -swift.region-name [region_name: | default = ""] # Name of the OpenStack Swift container to put chunks in. -# CLI flag: -.swift.container-name +# CLI flag: -swift.container-name [container_name: | default = ""] # Max retries on requests error. -# CLI flag: -.swift.max-retries +# CLI flag: -swift.max-retries [max_retries: | default = 3] # Time after which a connection attempt is aborted. -# CLI flag: -.swift.connect-timeout +# CLI flag: -swift.connect-timeout [connect_timeout: | default = 10s] # Time after which an idle request is aborted. The timeout watchdog is reset # each time some data is received, so the timeout triggers after X time no data # is received on a request. -# CLI flag: -.swift.request-timeout +# CLI flag: -swift.request-timeout [request_timeout: | default = 5s] ``` diff --git a/pkg/loki/config_wrapper.go b/pkg/loki/config_wrapper.go index a0e5fa5043d55..0c52c6963d9de 100644 --- a/pkg/loki/config_wrapper.go +++ b/pkg/loki/config_wrapper.go @@ -125,6 +125,9 @@ func (c *ConfigWrapper) ApplyDynamicConfig() cfg.Source { applyIngesterFinalSleep(r) applyIngesterReplicationFactor(r) applyChunkRetain(r, &defaults) + if err := applyCommonQuerierWorkerGRPCConfig(r, &defaults); err != nil { + return err + } return nil } @@ -684,3 +687,23 @@ func applyChunkRetain(cfg, defaults *ConfigWrapper) { } } } + +func applyCommonQuerierWorkerGRPCConfig(cfg, defaults *ConfigWrapper) error { + if !reflect.DeepEqual(cfg.Worker.OldQueryFrontendGRPCClientConfig, defaults.Worker.OldQueryFrontendGRPCClientConfig) { + // User is using the old grpc configuration. + + if reflect.DeepEqual(cfg.Worker.NewQueryFrontendGRPCClientConfig, defaults.Worker.NewQueryFrontendGRPCClientConfig) { + // User is using the old grpc configuration only, we can just copy it to the new grpc client struct. + cfg.Worker.NewQueryFrontendGRPCClientConfig = cfg.Worker.OldQueryFrontendGRPCClientConfig + } else { + // User is using both, old and new way of configuring the grpc client, so we throw an error. + return fmt.Errorf("both `grpc_client_config` and `query_frontend_grpc_client` are set at the same time. Please use only one of them.") + } + + if reflect.DeepEqual(cfg.Worker.QuerySchedulerGRPCClientConfig, defaults.Worker.QuerySchedulerGRPCClientConfig) { + // Since the scheduler grpc client is not set, we can just copy the old query frontend grpc client to the scheduler grpc client. + cfg.Worker.QuerySchedulerGRPCClientConfig = cfg.Worker.OldQueryFrontendGRPCClientConfig + } + } + return nil +} diff --git a/pkg/loki/config_wrapper_test.go b/pkg/loki/config_wrapper_test.go index bda2b8fa2596f..d010419770936 100644 --- a/pkg/loki/config_wrapper_test.go +++ b/pkg/loki/config_wrapper_test.go @@ -799,6 +799,109 @@ query_range: config, _ := testContext(configFileString, nil) assert.True(t, config.QueryRange.ResultsCacheConfig.CacheConfig.EmbeddedCache.Enabled) }) + + t.Run("querier worker grpc client behavior", func(t *testing.T) { + newConfigBothClientsSet := `--- +frontend_worker: + query_frontend_grpc_client: + tls_server_name: query-frontend + query_scheduler_grpc_client: + tls_server_name: query-scheduler +` + + oldConfig := `--- +frontend_worker: + grpc_client_config: + tls_server_name: query-frontend +` + + mixedConfig := `--- +frontend_worker: + grpc_client_config: + tls_server_name: query-frontend-old + query_frontend_grpc_client: + tls_server_name: query-frontend-new + query_scheduler_grpc_client: + tls_server_name: query-scheduler +` + t.Run("new configs are used", func(t *testing.T) { + asserts := func(config ConfigWrapper) { + require.EqualValues(t, "query-frontend", config.Worker.NewQueryFrontendGRPCClientConfig.TLS.ServerName) + require.EqualValues(t, "query-scheduler", config.Worker.QuerySchedulerGRPCClientConfig.TLS.ServerName) + // we never want to use zero values by default. + require.NotEqualValues(t, 0, config.Worker.NewQueryFrontendGRPCClientConfig.MaxRecvMsgSize) + require.NotEqualValues(t, 0, config.Worker.QuerySchedulerGRPCClientConfig.MaxRecvMsgSize) + } + + yamlConfig, _, err := configWrapperFromYAML(t, newConfigBothClientsSet, nil) + require.NoError(t, err) + asserts(yamlConfig) + + // repeat the test using only cli flags. + cliFlags := []string{ + "-querier.frontend-grpc-client.tls-server-name=query-frontend", + "-querier.scheduler-grpc-client.tls-server-name=query-scheduler", + } + cliConfig, _, err := configWrapperFromYAML(t, emptyConfigString, cliFlags) + require.NoError(t, err) + asserts(cliConfig) + }) + + t.Run("old config works the same way", func(t *testing.T) { + asserts := func(config ConfigWrapper) { + require.EqualValues(t, "query-frontend", config.Worker.NewQueryFrontendGRPCClientConfig.TLS.ServerName) + require.EqualValues(t, "query-frontend", config.Worker.QuerySchedulerGRPCClientConfig.TLS.ServerName) + + // we never want to use zero values by default. + require.NotEqualValues(t, 0, config.Worker.NewQueryFrontendGRPCClientConfig.MaxRecvMsgSize) + require.NotEqualValues(t, 0, config.Worker.QuerySchedulerGRPCClientConfig.MaxRecvMsgSize) + } + + yamlConfig, _, err := configWrapperFromYAML(t, oldConfig, nil) + require.NoError(t, err) + asserts(yamlConfig) + + // repeat the test using only cli flags. + cliFlags := []string{ + "-querier.frontend-client.tls-server-name=query-frontend", + } + cliConfig, _, err := configWrapperFromYAML(t, emptyConfigString, cliFlags) + require.NoError(t, err) + asserts(cliConfig) + }) + + t.Run("mixed frontend clients throws an error", func(t *testing.T) { + _, _, err := configWrapperFromYAML(t, mixedConfig, nil) + require.Error(t, err) + + // repeat the test using only cli flags. + _, _, err = configWrapperFromYAML(t, emptyConfigString, []string{ + "-querier.frontend-client.tls-server-name=query-frontend", + "-querier.frontend-grpc-client.tls-server-name=query-frontend", + }) + require.Error(t, err) + + // repeat the test mixing the YAML with cli flags. + _, _, err = configWrapperFromYAML(t, newConfigBothClientsSet, []string{ + "-querier.frontend-client.tls-server-name=query-frontend", + }) + require.Error(t, err) + }) + + t.Run("mix correct cli flags with YAML configs", func(t *testing.T) { + config, _, err := configWrapperFromYAML(t, newConfigBothClientsSet, []string{ + "-querier.scheduler-grpc-client.tls-enabled=true", + }) + require.NoError(t, err) + + require.EqualValues(t, "query-frontend", config.Worker.NewQueryFrontendGRPCClientConfig.TLS.ServerName) + require.EqualValues(t, "query-scheduler", config.Worker.QuerySchedulerGRPCClientConfig.TLS.ServerName) + // we never want to use zero values by default. + require.NotEqualValues(t, 0, config.Worker.NewQueryFrontendGRPCClientConfig.MaxRecvMsgSize) + require.NotEqualValues(t, 0, config.Worker.QuerySchedulerGRPCClientConfig.MaxRecvMsgSize) + require.True(t, config.Worker.QuerySchedulerGRPCClientConfig.TLSEnabled) + }) + }) } const defaultResulsCacheString = `--- diff --git a/pkg/querier/worker/frontend_processor.go b/pkg/querier/worker/frontend_processor.go index 2cf25202dcbb4..1327a30ae3190 100644 --- a/pkg/querier/worker/frontend_processor.go +++ b/pkg/querier/worker/frontend_processor.go @@ -30,7 +30,7 @@ func newFrontendProcessor(cfg Config, handler RequestHandler, log log.Logger, co log: log, handler: handler, codec: codec, - maxMessageSize: cfg.QueryFrontendGRPCClientConfig.MaxSendMsgSize, + maxMessageSize: cfg.NewQueryFrontendGRPCClientConfig.MaxSendMsgSize, querierID: cfg.QuerierID, } } diff --git a/pkg/querier/worker/scheduler_processor.go b/pkg/querier/worker/scheduler_processor.go index 68842c5cde3f2..97f6d8f4d1df9 100644 --- a/pkg/querier/worker/scheduler_processor.go +++ b/pkg/querier/worker/scheduler_processor.go @@ -38,9 +38,9 @@ func newSchedulerProcessor(cfg Config, handler RequestHandler, log log.Logger, m log: log, handler: handler, codec: codec, - maxMessageSize: cfg.QueryFrontendGRPCClientConfig.MaxRecvMsgSize, + maxMessageSize: cfg.NewQueryFrontendGRPCClientConfig.MaxRecvMsgSize, querierID: cfg.QuerierID, - grpcConfig: cfg.QueryFrontendGRPCClientConfig, + grpcConfig: cfg.NewQueryFrontendGRPCClientConfig, schedulerClientFactory: func(conn *grpc.ClientConn) schedulerpb.SchedulerForQuerierClient { return schedulerpb.NewSchedulerForQuerierClient(conn) }, diff --git a/pkg/querier/worker/worker.go b/pkg/querier/worker/worker.go index ae992a1ce636e..fcd7fc899e1ce 100644 --- a/pkg/querier/worker/worker.go +++ b/pkg/querier/worker/worker.go @@ -30,11 +30,10 @@ type Config struct { QuerierID string `yaml:"id"` - QueryFrontendGRPCClientConfig grpcclient.Config `yaml:"grpc_client_config" doc:"description=Configures the gRPC client used to communicate between the querier and the query-frontend, and the querier and the query-scheduler. If 'use_separated_clients' is true, this config is only used for communicating with frontend and 'query_scheduler_grpc_client_config' should be used to configuring querier <-> scheduler communication."` + NewQueryFrontendGRPCClientConfig grpcclient.Config `yaml:"query_frontend_grpc_client"` + OldQueryFrontendGRPCClientConfig grpcclient.Config `yaml:"grpc_client_config" doc:"description=Configures the gRPC client used to communicate between the querier and the query-frontend, and the querier and the query-scheduler. If 'use_separated_clients' is true, this config is only used for communicating with frontend and 'query_scheduler_grpc_client_config' should be used to configuring querier <-> scheduler communication."` - QuerySchedulerGRPCClientConfig grpcclient.Config `yaml:"query_scheduler_grpc_client_config" doc:"description=Configures the gRPC client used to communicate between the querier and the query-scheduler. If 'use_separated_clients' is false, this config is ignored."` - - UseSeparatedGRPCClients bool `yaml:"uses_separated_clients" doc:"description=If set to true, querier will use 'query_scheduler_grpc_client_config' to communicate with the scheduler. Otherwise, 'query_scheduler_grpc_client_config' is ignored and 'grpc_client_config' is used instead."` + QuerySchedulerGRPCClientConfig grpcclient.Config `yaml:"query_scheduler_grpc_client" doc:"description=Configures the gRPC client used to communicate between the querier and the query-scheduler. If 'use_separated_clients' is false, this config is ignored."` } func (cfg *Config) RegisterFlags(f *flag.FlagSet) { @@ -42,17 +41,22 @@ func (cfg *Config) RegisterFlags(f *flag.FlagSet) { f.StringVar(&cfg.FrontendAddress, "querier.frontend-address", "", "Address of query frontend service, in host:port format. If -querier.scheduler-address is set as well, querier will use scheduler instead. Only one of -querier.frontend-address or -querier.scheduler-address can be set. If neither is set, queries are only received via HTTP endpoint.") f.DurationVar(&cfg.DNSLookupPeriod, "querier.dns-lookup-period", 3*time.Second, "How often to query DNS for query-frontend or query-scheduler address. Also used to determine how often to poll the scheduler-ring for addresses if the scheduler-ring is configured.") f.StringVar(&cfg.QuerierID, "querier.id", "", "Querier ID, sent to frontend service to identify requests from the same querier. Defaults to hostname.") - f.BoolVar(&cfg.UseSeparatedGRPCClients, "querier.use-separated-grpc-clients", false, "Whether to use separated clients for frontend and scheduler. If set to true, querier will use separated clients for frontend and scheduler. If set to false, querier will use the same client for both frontend and scheduler.") - cfg.QueryFrontendGRPCClientConfig.RegisterFlagsWithPrefix("querier.frontend-client", f) - cfg.QuerySchedulerGRPCClientConfig.RegisterFlagsWithPrefix("querier.scheduler-client", f) + // Register old client as the frontend-client flag for retro-compatibility. + cfg.OldQueryFrontendGRPCClientConfig.RegisterFlagsWithPrefix("querier.frontend-client", f) + + cfg.NewQueryFrontendGRPCClientConfig.RegisterFlagsWithPrefix("querier.frontend-grpc-client", f) + cfg.QuerySchedulerGRPCClientConfig.RegisterFlagsWithPrefix("querier.scheduler-grpc-client", f) } func (cfg *Config) Validate() error { if cfg.FrontendAddress != "" && cfg.SchedulerAddress != "" { return errors.New("frontend address and scheduler address are mutually exclusive, please use only one") } - if err := cfg.QueryFrontendGRPCClientConfig.Validate(); err != nil { + if err := cfg.NewQueryFrontendGRPCClientConfig.Validate(); err != nil { + return err + } + if err := cfg.OldQueryFrontendGRPCClientConfig.Validate(); err != nil { return err } @@ -107,12 +111,6 @@ type querierWorker struct { } func NewQuerierWorker(cfg Config, rng ring.ReadRing, handler RequestHandler, logger log.Logger, reg prometheus.Registerer, codec RequestCodec) (services.Service, error) { - if !cfg.UseSeparatedGRPCClients { - // The frontend client config is the older config and it points to "grpc_client_config" so we - // reuse it for the scheduler client config. - cfg.QuerySchedulerGRPCClientConfig = cfg.QueryFrontendGRPCClientConfig - } - if cfg.QuerierID == "" { hostname, err := os.Hostname() if err != nil { @@ -143,7 +141,7 @@ func NewQuerierWorker(cfg Config, rng ring.ReadRing, handler RequestHandler, log level.Info(logger).Log("msg", "Starting querier worker connected to query-frontend", "frontend", cfg.FrontendAddress) address = cfg.FrontendAddress - grpcCfg = cfg.QueryFrontendGRPCClientConfig + grpcCfg = cfg.NewQueryFrontendGRPCClientConfig processor = newFrontendProcessor(cfg, handler, logger, codec) default: return nil, errors.New("unable to start the querier worker, need to configure one of frontend_address, scheduler_address, or a ring config in the query_scheduler config block") diff --git a/pkg/querier/worker/worker_test.go b/pkg/querier/worker/worker_test.go index 43c6d74262f54..1633554b7a136 100644 --- a/pkg/querier/worker/worker_test.go +++ b/pkg/querier/worker/worker_test.go @@ -7,6 +7,8 @@ import ( "time" "github.com/go-kit/log" + "github.com/grafana/dskit/crypto/tls" + "github.com/grafana/dskit/grpcclient" "github.com/grafana/dskit/services" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -93,3 +95,35 @@ func (m mockProcessor) processQueriesOnSingleStream(ctx context.Context, _ *grpc } func (m mockProcessor) notifyShutdown(_ context.Context, _ *grpc.ClientConn, _ string) {} + +func TestGRPCConfigBehavior(t *testing.T) { + logger := log.NewNopLogger() + + t.Run("uses separated GRPC TLS server names", func(t *testing.T) { + cfg := Config{ + SchedulerAddress: "scheduler:9095", + QuerySchedulerGRPCClientConfig: grpcclient.Config{ + TLS: tls.ClientConfig{ + ServerName: "query-scheduler", + }, + }, + NewQueryFrontendGRPCClientConfig: grpcclient.Config{ + TLS: tls.ClientConfig{ + ServerName: "query-frontend", + }, + }, + } + + qw, err := NewQuerierWorker(cfg, nil, nil, logger, nil, nil) + require.NoError(t, err) + require.NoError(t, services.StopAndAwaitTerminated(context.Background(), qw)) + + // grpc client the querier uses to talk to the scheduler, so the expected server name is "query-scheduler". + castedQw := qw.(*querierWorker) + require.Equal(t, "query-scheduler", castedQw.grpcClientConfig.TLS.ServerName) + + // grpc client the querier uses to return results to the frontend, so the expected server name is "query-frontend". + sp := castedQw.processor.(*schedulerProcessor) + require.Equal(t, "query-frontend", sp.grpcConfig.TLS.ServerName) + }) +} From 601d3ae79c5e2dd876c2b3a4ff0f1a1c867e07ad Mon Sep 17 00:00:00 2001 From: DylanGuedes Date: Thu, 2 May 2024 16:10:24 -0300 Subject: [PATCH 13/16] Update docs. --- docs/sources/shared/configuration.md | 16 +++++++--------- pkg/querier/worker/worker.go | 6 +++--- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/docs/sources/shared/configuration.md b/docs/sources/shared/configuration.md index 643452d4763f5..a5b939e2f0780 100644 --- a/docs/sources/shared/configuration.md +++ b/docs/sources/shared/configuration.md @@ -2236,22 +2236,20 @@ The `frontend_worker` configures the worker - running within the Loki querier - # CLI flag: -querier.id [id: | default = ""] -# The grpc_client block configures the gRPC client used to communicate between a -# client and server component in Loki. +# Configures the querier gRPC client used to communicate with the +# query-frontend. Shouldn't be used in conjunction with 'grpc_client_config'. # The CLI flags prefix for this block configuration is: # querier.frontend-grpc-client [query_frontend_grpc_client: ] -# Configures the gRPC client used to communicate between the querier and the -# query-frontend, and the querier and the query-scheduler. If -# 'use_separated_clients' is true, this config is only used for communicating -# with frontend and 'query_scheduler_grpc_client_config' should be used to -# configuring querier <-> scheduler communication. +# Configures the querier gRPC client used to communicate with the query-frontend +# and with the query-scheduler if 'query_scheduler_grpc_client' isn't defined. +# This shouldn't be used if 'query_frontend_grpc_client' is defined. # The CLI flags prefix for this block configuration is: querier.frontend-client [grpc_client_config: ] -# Configures the gRPC client used to communicate between the querier and the -# query-scheduler. If 'use_separated_clients' is false, this config is ignored. +# Configures the querier gRPC client used to communicate with the +# query-scheduler. If not defined, 'grpc_client_config' is used instead. # The CLI flags prefix for this block configuration is: # querier.scheduler-grpc-client [query_scheduler_grpc_client: ] diff --git a/pkg/querier/worker/worker.go b/pkg/querier/worker/worker.go index fcd7fc899e1ce..7d7b46dc814f5 100644 --- a/pkg/querier/worker/worker.go +++ b/pkg/querier/worker/worker.go @@ -30,10 +30,10 @@ type Config struct { QuerierID string `yaml:"id"` - NewQueryFrontendGRPCClientConfig grpcclient.Config `yaml:"query_frontend_grpc_client"` - OldQueryFrontendGRPCClientConfig grpcclient.Config `yaml:"grpc_client_config" doc:"description=Configures the gRPC client used to communicate between the querier and the query-frontend, and the querier and the query-scheduler. If 'use_separated_clients' is true, this config is only used for communicating with frontend and 'query_scheduler_grpc_client_config' should be used to configuring querier <-> scheduler communication."` + NewQueryFrontendGRPCClientConfig grpcclient.Config `yaml:"query_frontend_grpc_client" doc:"description=Configures the querier gRPC client used to communicate with the query-frontend. Shouldn't be used in conjunction with 'grpc_client_config'."` + OldQueryFrontendGRPCClientConfig grpcclient.Config `yaml:"grpc_client_config" doc:"description=Configures the querier gRPC client used to communicate with the query-frontend and with the query-scheduler if 'query_scheduler_grpc_client' isn't defined. This shouldn't be used if 'query_frontend_grpc_client' is defined."` - QuerySchedulerGRPCClientConfig grpcclient.Config `yaml:"query_scheduler_grpc_client" doc:"description=Configures the gRPC client used to communicate between the querier and the query-scheduler. If 'use_separated_clients' is false, this config is ignored."` + QuerySchedulerGRPCClientConfig grpcclient.Config `yaml:"query_scheduler_grpc_client" doc:"description=Configures the querier gRPC client used to communicate with the query-scheduler. If not defined, 'grpc_client_config' is used instead."` } func (cfg *Config) RegisterFlags(f *flag.FlagSet) { From b799bb7f26c0da26d67f522f32668a8f9bdded60 Mon Sep 17 00:00:00 2001 From: DylanGuedes Date: Thu, 2 May 2024 18:55:58 -0300 Subject: [PATCH 14/16] fix lint --- pkg/loki/config_wrapper.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/loki/config_wrapper.go b/pkg/loki/config_wrapper.go index 0c52c6963d9de..2a4789fb9e60f 100644 --- a/pkg/loki/config_wrapper.go +++ b/pkg/loki/config_wrapper.go @@ -697,7 +697,7 @@ func applyCommonQuerierWorkerGRPCConfig(cfg, defaults *ConfigWrapper) error { cfg.Worker.NewQueryFrontendGRPCClientConfig = cfg.Worker.OldQueryFrontendGRPCClientConfig } else { // User is using both, old and new way of configuring the grpc client, so we throw an error. - return fmt.Errorf("both `grpc_client_config` and `query_frontend_grpc_client` are set at the same time. Please use only one of them.") + return fmt.Errorf("both `grpc_client_config` and `query_frontend_grpc_client` are set at the same time. Please use only one of them") } if reflect.DeepEqual(cfg.Worker.QuerySchedulerGRPCClientConfig, defaults.Worker.QuerySchedulerGRPCClientConfig) { From 5d714a3964dd745e4a701833fd5bbfa364ab3dda Mon Sep 17 00:00:00 2001 From: DylanGuedes Date: Fri, 3 May 2024 07:37:25 -0300 Subject: [PATCH 15/16] undo docs change --- docs/sources/shared/configuration.md | 101 ++++++++++++--------------- 1 file changed, 43 insertions(+), 58 deletions(-) diff --git a/docs/sources/shared/configuration.md b/docs/sources/shared/configuration.md index a5b939e2f0780..208def0cdd521 100644 --- a/docs/sources/shared/configuration.md +++ b/docs/sources/shared/configuration.md @@ -789,92 +789,92 @@ The `azure_storage_config` block configures the connection to Azure object stora ```yaml # Azure Cloud environment. Supported values are: AzureGlobal, AzureChinaCloud, # AzureGermanCloud, AzureUSGovernment. -# CLI flag: -azure.environment +# CLI flag: -.azure.environment [environment: | default = "AzureGlobal"] # Azure storage account name. -# CLI flag: -azure.account-name +# CLI flag: -.azure.account-name [account_name: | default = ""] # Azure storage account key. -# CLI flag: -azure.account-key +# CLI flag: -.azure.account-key [account_key: | default = ""] # If `connection-string` is set, the values of `account-name` and # `endpoint-suffix` values will not be used. Use this method over `account-key` # if you need to authenticate via a SAS token. Or if you use the Azurite # emulator. -# CLI flag: -azure.connection-string +# CLI flag: -.azure.connection-string [connection_string: | default = ""] # Name of the storage account blob container used to store chunks. This # container must be created before running cortex. -# CLI flag: -azure.container-name +# CLI flag: -.azure.container-name [container_name: | default = "loki"] # Azure storage endpoint suffix without schema. The storage account name will be # prefixed to this value to create the FQDN. -# CLI flag: -azure.endpoint-suffix +# CLI flag: -.azure.endpoint-suffix [endpoint_suffix: | default = ""] # Use Managed Identity to authenticate to the Azure storage account. -# CLI flag: -azure.use-managed-identity +# CLI flag: -.azure.use-managed-identity [use_managed_identity: | default = false] # Use Federated Token to authenticate to the Azure storage account. -# CLI flag: -azure.use-federated-token +# CLI flag: -.azure.use-federated-token [use_federated_token: | default = false] # User assigned identity ID to authenticate to the Azure storage account. -# CLI flag: -azure.user-assigned-id +# CLI flag: -.azure.user-assigned-id [user_assigned_id: | default = ""] # Use Service Principal to authenticate through Azure OAuth. -# CLI flag: -azure.use-service-principal +# CLI flag: -.azure.use-service-principal [use_service_principal: | default = false] # Azure Service Principal ID(GUID). -# CLI flag: -azure.client-id +# CLI flag: -.azure.client-id [client_id: | default = ""] # Azure Service Principal secret key. -# CLI flag: -azure.client-secret +# CLI flag: -.azure.client-secret [client_secret: | default = ""] # Azure Tenant ID is used to authenticate through Azure OAuth. -# CLI flag: -azure.tenant-id +# CLI flag: -.azure.tenant-id [tenant_id: | default = ""] # Chunk delimiter for blob ID to be used -# CLI flag: -azure.chunk-delimiter +# CLI flag: -.azure.chunk-delimiter [chunk_delimiter: | default = "-"] # Preallocated buffer size for downloads. -# CLI flag: -azure.download-buffer-size +# CLI flag: -.azure.download-buffer-size [download_buffer_size: | default = 512000] # Preallocated buffer size for uploads. -# CLI flag: -azure.upload-buffer-size +# CLI flag: -.azure.upload-buffer-size [upload_buffer_size: | default = 256000] # Number of buffers used to used to upload a chunk. -# CLI flag: -azure.download-buffer-count +# CLI flag: -.azure.download-buffer-count [upload_buffer_count: | default = 1] # Timeout for requests made against azure blob storage. -# CLI flag: -azure.request-timeout +# CLI flag: -.azure.request-timeout [request_timeout: | default = 30s] # Number of retries for a request which times out. -# CLI flag: -azure.max-retries +# CLI flag: -.azure.max-retries [max_retries: | default = 5] # Minimum time to wait before retrying a request. -# CLI flag: -azure.min-retry-delay +# CLI flag: -.azure.min-retry-delay [min_retry_delay: | default = 10ms] # Maximum time to wait before retrying a request. -# CLI flag: -azure.max-retry-delay +# CLI flag: -.azure.max-retry-delay [max_retry_delay: | default = 500ms] ``` @@ -2236,23 +2236,10 @@ The `frontend_worker` configures the worker - running within the Loki querier - # CLI flag: -querier.id [id: | default = ""] -# Configures the querier gRPC client used to communicate with the -# query-frontend. Shouldn't be used in conjunction with 'grpc_client_config'. -# The CLI flags prefix for this block configuration is: -# querier.frontend-grpc-client -[query_frontend_grpc_client: ] - -# Configures the querier gRPC client used to communicate with the query-frontend -# and with the query-scheduler if 'query_scheduler_grpc_client' isn't defined. -# This shouldn't be used if 'query_frontend_grpc_client' is defined. +# The grpc_client block configures the gRPC client used to communicate between a +# client and server component in Loki. # The CLI flags prefix for this block configuration is: querier.frontend-client [grpc_client_config: ] - -# Configures the querier gRPC client used to communicate with the -# query-scheduler. If not defined, 'grpc_client_config' is used instead. -# The CLI flags prefix for this block configuration is: -# querier.scheduler-grpc-client -[query_scheduler_grpc_client: ] ``` ### gcs_storage_config @@ -2310,8 +2297,6 @@ The `grpc_client` block configures the gRPC client used to communicate between a - `ingester.client` - `pattern-ingester.client` - `querier.frontend-client` -- `querier.frontend-grpc-client` -- `querier.scheduler-grpc-client` - `query-scheduler.grpc-client-config` - `ruler.client` - `tsdb.shipper.index-gateway-client.grpc` @@ -2373,7 +2358,7 @@ backoff_config: # TLS flag is set. If set to false, insecure connection to gRPC server will be # used. # CLI flag: -.tls-enabled -[tls_enabled: | default = true] +[tls_enabled: | default = false] # Path to the client certificate, which will be used for authenticating with the # server. Also requires the key path to be configured. @@ -5328,83 +5313,83 @@ The `swift_storage_config` block configures the connection to OpenStack Object S ```yaml # OpenStack Swift authentication API version. 0 to autodetect. -# CLI flag: -swift.auth-version +# CLI flag: -.swift.auth-version [auth_version: | default = 0] # OpenStack Swift authentication URL -# CLI flag: -swift.auth-url +# CLI flag: -.swift.auth-url [auth_url: | default = ""] # Set this to true to use the internal OpenStack Swift endpoint URL -# CLI flag: -swift.internal +# CLI flag: -.swift.internal [internal: | default = false] # OpenStack Swift username. -# CLI flag: -swift.username +# CLI flag: -.swift.username [username: | default = ""] # OpenStack Swift user's domain name. -# CLI flag: -swift.user-domain-name +# CLI flag: -.swift.user-domain-name [user_domain_name: | default = ""] # OpenStack Swift user's domain ID. -# CLI flag: -swift.user-domain-id +# CLI flag: -.swift.user-domain-id [user_domain_id: | default = ""] # OpenStack Swift user ID. -# CLI flag: -swift.user-id +# CLI flag: -.swift.user-id [user_id: | default = ""] # OpenStack Swift API key. -# CLI flag: -swift.password +# CLI flag: -.swift.password [password: | default = ""] # OpenStack Swift user's domain ID. -# CLI flag: -swift.domain-id +# CLI flag: -.swift.domain-id [domain_id: | default = ""] # OpenStack Swift user's domain name. -# CLI flag: -swift.domain-name +# CLI flag: -.swift.domain-name [domain_name: | default = ""] # OpenStack Swift project ID (v2,v3 auth only). -# CLI flag: -swift.project-id +# CLI flag: -.swift.project-id [project_id: | default = ""] # OpenStack Swift project name (v2,v3 auth only). -# CLI flag: -swift.project-name +# CLI flag: -.swift.project-name [project_name: | default = ""] # ID of the OpenStack Swift project's domain (v3 auth only), only needed if it # differs the from user domain. -# CLI flag: -swift.project-domain-id +# CLI flag: -.swift.project-domain-id [project_domain_id: | default = ""] # Name of the OpenStack Swift project's domain (v3 auth only), only needed if it # differs from the user domain. -# CLI flag: -swift.project-domain-name +# CLI flag: -.swift.project-domain-name [project_domain_name: | default = ""] # OpenStack Swift Region to use (v2,v3 auth only). -# CLI flag: -swift.region-name +# CLI flag: -.swift.region-name [region_name: | default = ""] # Name of the OpenStack Swift container to put chunks in. -# CLI flag: -swift.container-name +# CLI flag: -.swift.container-name [container_name: | default = ""] # Max retries on requests error. -# CLI flag: -swift.max-retries +# CLI flag: -.swift.max-retries [max_retries: | default = 3] # Time after which a connection attempt is aborted. -# CLI flag: -swift.connect-timeout +# CLI flag: -.swift.connect-timeout [connect_timeout: | default = 10s] # Time after which an idle request is aborted. The timeout watchdog is reset # each time some data is received, so the timeout triggers after X time no data # is received on a request. -# CLI flag: -swift.request-timeout +# CLI flag: -.swift.request-timeout [request_timeout: | default = 5s] ``` From 2da59b041d284fc94ae20efa1a7ce1080f92ba70 Mon Sep 17 00:00:00 2001 From: DylanGuedes Date: Sun, 5 May 2024 20:02:03 -0300 Subject: [PATCH 16/16] fix docs generation --- docs/sources/shared/configuration.md | 27 +++++++++++++++++++++------ tools/doc-generator/main.go | 6 ++++++ 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/docs/sources/shared/configuration.md b/docs/sources/shared/configuration.md index 208def0cdd521..86aa8b0589b3a 100644 --- a/docs/sources/shared/configuration.md +++ b/docs/sources/shared/configuration.md @@ -543,19 +543,19 @@ The `alibabacloud_storage_config` block configures the connection to Alibaba Clo ```yaml # Name of OSS bucket. -# CLI flag: -common.storage.oss.bucketname +# CLI flag: -.storage.oss.bucketname [bucket: | default = ""] # oss Endpoint to connect to. -# CLI flag: -common.storage.oss.endpoint +# CLI flag: -.storage.oss.endpoint [endpoint: | default = ""] # alibabacloud Access Key ID -# CLI flag: -common.storage.oss.access-key-id +# CLI flag: -.storage.oss.access-key-id [access_key_id: | default = ""] # alibabacloud Secret Access Key -# CLI flag: -common.storage.oss.secret-access-key +# CLI flag: -.storage.oss.secret-access-key [secret_access_key: | default = ""] ``` @@ -2236,10 +2236,23 @@ The `frontend_worker` configures the worker - running within the Loki querier - # CLI flag: -querier.id [id: | default = ""] -# The grpc_client block configures the gRPC client used to communicate between a -# client and server component in Loki. +# Configures the querier gRPC client used to communicate with the +# query-frontend. Shouldn't be used in conjunction with 'grpc_client_config'. +# The CLI flags prefix for this block configuration is: +# querier.frontend-grpc-client +[query_frontend_grpc_client: ] + +# Configures the querier gRPC client used to communicate with the query-frontend +# and with the query-scheduler if 'query_scheduler_grpc_client' isn't defined. +# This shouldn't be used if 'query_frontend_grpc_client' is defined. # The CLI flags prefix for this block configuration is: querier.frontend-client [grpc_client_config: ] + +# Configures the querier gRPC client used to communicate with the +# query-scheduler. If not defined, 'grpc_client_config' is used instead. +# The CLI flags prefix for this block configuration is: +# querier.scheduler-grpc-client +[query_scheduler_grpc_client: ] ``` ### gcs_storage_config @@ -2297,6 +2310,8 @@ The `grpc_client` block configures the gRPC client used to communicate between a - `ingester.client` - `pattern-ingester.client` - `querier.frontend-client` +- `querier.frontend-grpc-client` +- `querier.scheduler-grpc-client` - `query-scheduler.grpc-client-config` - `ruler.client` - `tsdb.shipper.index-gateway-client.grpc` diff --git a/tools/doc-generator/main.go b/tools/doc-generator/main.go index 24f6c82ef0cff..7648bb407f6fc 100644 --- a/tools/doc-generator/main.go +++ b/tools/doc-generator/main.go @@ -104,6 +104,12 @@ func generateBlocksMarkdown(blocks []*parse.ConfigBlock) string { return 1 } + if a.FlagsPrefix < b.FlagsPrefix { + return -1 + } + if a.FlagsPrefix < b.FlagsPrefix { + return 1 + } return 0 })