diff --git a/CHANGELOG.md b/CHANGELOG.md index 841b99a0549..e6bf457b976 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ * [CHANGE] Querier: the CLI flag `-querier.minimize-ingester-requests` has been moved from "experimental" to "advanced". #7638 * [CHANGE] Ingester: `/ingester/flush` endpoint is now only allowed to execute only while the ingester is in `Running` state. The 503 status code is returned if the endpoint is called while the ingester is not in `Running` state. #7486 * [CHANGE] Distributor: Include label name in `err-mimir-label-value-too-long` error message: #7740 +* [FEATURE] Continuous-test: now runable as a module with `mimir -target=continuous-test`. #7747 * [FEATURE] Store-gateway: Allow specific tenants to be enabled or disabled via `-store-gateway.enabled-tenants` or `-store-gateway.disabled-tenants` CLI flags or their corresponding YAML settings. #7653 * [FEATURE] New `-.s3.bucket-lookup-type` flag configures lookup style type, used to access bucket in s3 compatible providers. #7684 * [ENHANCEMENT] Store-gateway: merge series from different blocks concurrently. #7456 diff --git a/cmd/mimir-continuous-test/main.go b/cmd/mimir-continuous-test/main.go index fb1642c4df6..4cf5a7d26c5 100644 --- a/cmd/mimir-continuous-test/main.go +++ b/cmd/mimir-continuous-test/main.go @@ -22,33 +22,23 @@ import ( "github.com/grafana/mimir/pkg/util/version" ) -type Config struct { - ServerMetricsPort int - LogLevel log.Level - Client continuoustest.ClientConfig - Manager continuoustest.ManagerConfig - WriteReadSeriesTest continuoustest.WriteReadSeriesTestConfig -} - -func (cfg *Config) RegisterFlags(f *flag.FlagSet) { - f.IntVar(&cfg.ServerMetricsPort, "server.metrics-port", 9900, "The port where metrics are exposed.") - cfg.LogLevel.RegisterFlags(f) - cfg.Client.RegisterFlags(f) - cfg.Manager.RegisterFlags(f) - cfg.WriteReadSeriesTest.RegisterFlags(f) -} - func main() { // Parse CLI arguments. - cfg := &Config{} + cfg := &continuoustest.Config{} + var ( + serverMetricsPort int + logLevel log.Level + ) + flag.CommandLine.IntVar(&serverMetricsPort, "server.metrics-port", 9900, "The port where metrics are exposed.") cfg.RegisterFlags(flag.CommandLine) + logLevel.RegisterFlags(flag.CommandLine) if err := flagext.ParseFlagsWithoutArguments(flag.CommandLine); err != nil { fmt.Fprintln(os.Stderr, err.Error()) os.Exit(1) } - util_log.InitLogger(log.LogfmtFormat, cfg.LogLevel, false, util_log.RateLimitedLoggerCfg{}) + util_log.InitLogger(log.LogfmtFormat, logLevel, false, util_log.RateLimitedLoggerCfg{}) // Setting the environment variable JAEGER_AGENT_HOST enables tracing. if trace, err := tracing.NewFromEnv("mimir-continuous-test", jaegercfg.MaxTagValueLength(16e3)); err != nil { @@ -64,7 +54,7 @@ func main() { registry.MustRegister(version.NewCollector("mimir_continuous_test")) registry.MustRegister(collectors.NewGoCollector()) - i := instrumentation.NewMetricsServer(cfg.ServerMetricsPort, registry) + i := instrumentation.NewMetricsServer(serverMetricsPort, registry) if err := i.Start(); err != nil { level.Error(logger).Log("msg", "Unable to start instrumentation server", "err", err.Error()) util_log.Flush() diff --git a/cmd/mimir/help-all.txt.tmpl b/cmd/mimir/help-all.txt.tmpl index 7e0a9676c73..1621740de95 100644 --- a/cmd/mimir/help-all.txt.tmpl +++ b/cmd/mimir/help-all.txt.tmpl @@ -2765,6 +2765,38 @@ Usage of ./cmd/mimir/mimir: [experimental] The number of workers used for each tenant federated query. This setting limits the maximum number of per-tenant queries executed at a time for a tenant federated query. (default 16) -tenant-federation.max-tenants int [experimental] The max number of tenant IDs that may be supplied for a federated query if enabled. 0 to disable the limit. + -tests.basic-auth-password string + The password to use for HTTP bearer authentication. (mutually exclusive with tenant-id or bearer-token flags) + -tests.basic-auth-user string + The username to use for HTTP bearer authentication. (mutually exclusive with tenant-id or bearer-token flags) + -tests.bearer-token string + The bearer token to use for HTTP bearer authentication. (mutually exclusive with tenant-id flag or basic-auth flags) + -tests.read-endpoint string + The base endpoint on the read path. The URL should have no trailing slash. The specific API path is appended by the tool to the URL, for example /api/v1/query_range for range query API, so the configured URL must not include it. + -tests.read-timeout duration + The timeout for a single read request. (default 1m0s) + -tests.run-interval duration + How frequently tests should run. (default 5m0s) + -tests.smoke-test + Run a smoke test, i.e. run all tests once and exit. + -tests.tenant-id string + The tenant ID to use to write and read metrics in tests. (mutually exclusive with basic-auth or bearer-token flags) (default "anonymous") + -tests.write-batch-size int + The maximum number of series to write in a single request. (default 1000) + -tests.write-endpoint string + The base endpoint on the write path. The URL should have no trailing slash. The specific API path is appended by the tool to the URL, for example /api/v1/push for the remote write API endpoint, so the configured URL must not include it. + -tests.write-protocol string + The protocol to use to write series data. Supported values are: prometheus, otlp-http (default "prometheus") + -tests.write-read-series-test.float-samples-enabled + Set to true to use float samples (default true) + -tests.write-read-series-test.histogram-samples-enabled + Set to true to use native histogram samples + -tests.write-read-series-test.max-query-age duration + How back in the past metrics can be queried at most. (default 168h0m0s) + -tests.write-read-series-test.num-series int + Number of series used for the test. (default 10000) + -tests.write-timeout duration + The timeout for a single write request. (default 5s) -timeseries-unmarshal-caching-optimization-enabled [experimental] Enables optimized marshaling of timeseries. (default true) -usage-stats.enabled diff --git a/cmd/mimir/help.txt.tmpl b/cmd/mimir/help.txt.tmpl index 93c78089569..7dd666432df 100644 --- a/cmd/mimir/help.txt.tmpl +++ b/cmd/mimir/help.txt.tmpl @@ -719,6 +719,38 @@ Usage of ./cmd/mimir/mimir: Comma-separated list of components to include in the instantiated process. The default value 'all' includes all components that are required to form a functional Grafana Mimir instance in single-binary mode. Use the '-modules' command line flag to get a list of available components, and to see which components are included with 'all'. (default all) -tenant-federation.enabled If enabled on all services, queries can be federated across multiple tenants. The tenant IDs involved need to be specified separated by a '|' character in the 'X-Scope-OrgID' header. + -tests.basic-auth-password string + The password to use for HTTP bearer authentication. (mutually exclusive with tenant-id or bearer-token flags) + -tests.basic-auth-user string + The username to use for HTTP bearer authentication. (mutually exclusive with tenant-id or bearer-token flags) + -tests.bearer-token string + The bearer token to use for HTTP bearer authentication. (mutually exclusive with tenant-id flag or basic-auth flags) + -tests.read-endpoint string + The base endpoint on the read path. The URL should have no trailing slash. The specific API path is appended by the tool to the URL, for example /api/v1/query_range for range query API, so the configured URL must not include it. + -tests.read-timeout duration + The timeout for a single read request. (default 1m0s) + -tests.run-interval duration + How frequently tests should run. (default 5m0s) + -tests.smoke-test + Run a smoke test, i.e. run all tests once and exit. + -tests.tenant-id string + The tenant ID to use to write and read metrics in tests. (mutually exclusive with basic-auth or bearer-token flags) (default "anonymous") + -tests.write-batch-size int + The maximum number of series to write in a single request. (default 1000) + -tests.write-endpoint string + The base endpoint on the write path. The URL should have no trailing slash. The specific API path is appended by the tool to the URL, for example /api/v1/push for the remote write API endpoint, so the configured URL must not include it. + -tests.write-protocol string + The protocol to use to write series data. Supported values are: prometheus, otlp-http (default "prometheus") + -tests.write-read-series-test.float-samples-enabled + Set to true to use float samples (default true) + -tests.write-read-series-test.histogram-samples-enabled + Set to true to use native histogram samples + -tests.write-read-series-test.max-query-age duration + How back in the past metrics can be queried at most. (default 168h0m0s) + -tests.write-read-series-test.num-series int + Number of series used for the test. (default 10000) + -tests.write-timeout duration + The timeout for a single write request. (default 5s) -usage-stats.enabled Enable anonymous usage reporting. (default true) -usage-stats.installation-mode string diff --git a/pkg/continuoustest/config.go b/pkg/continuoustest/config.go new file mode 100644 index 00000000000..8232cc99695 --- /dev/null +++ b/pkg/continuoustest/config.go @@ -0,0 +1,19 @@ +// SPDX-License-Identifier: AGPL-3.0-only + +package continuoustest + +import ( + "flag" +) + +type Config struct { + Client ClientConfig `yaml:"-"` + Manager ManagerConfig `yaml:"-"` + WriteReadSeriesTest WriteReadSeriesTestConfig `yaml:"-"` +} + +func (cfg *Config) RegisterFlags(f *flag.FlagSet) { + cfg.Client.RegisterFlags(f) + cfg.Manager.RegisterFlags(f) + cfg.WriteReadSeriesTest.RegisterFlags(f) +} diff --git a/pkg/mimir/mimir.go b/pkg/mimir/mimir.go index bb7bd6965b4..6252f031183 100644 --- a/pkg/mimir/mimir.go +++ b/pkg/mimir/mimir.go @@ -48,6 +48,7 @@ import ( alertstorelocal "github.com/grafana/mimir/pkg/alertmanager/alertstore/local" "github.com/grafana/mimir/pkg/api" "github.com/grafana/mimir/pkg/compactor" + "github.com/grafana/mimir/pkg/continuoustest" "github.com/grafana/mimir/pkg/distributor" "github.com/grafana/mimir/pkg/flusher" "github.com/grafana/mimir/pkg/frontend" @@ -135,6 +136,7 @@ type Config struct { MemberlistKV memberlist.KVConfig `yaml:"memberlist"` QueryScheduler scheduler.Config `yaml:"query_scheduler"` UsageStats usagestats.Config `yaml:"usage_stats"` + ContinuousTest continuoustest.Config `yaml:"-"` OverridesExporter exporter.Config `yaml:"overrides_exporter"` Common CommonConfig `yaml:"common"` @@ -192,6 +194,7 @@ func (c *Config) RegisterFlags(f *flag.FlagSet, logger log.Logger) { c.ActivityTracker.RegisterFlags(f) c.QueryScheduler.RegisterFlags(f, logger) c.UsageStats.RegisterFlags(f) + c.ContinuousTest.RegisterFlags(f) c.OverridesExporter.RegisterFlags(f, logger) c.Common.RegisterFlags(f) @@ -720,6 +723,7 @@ type Mimir struct { ActivityTracker *activitytracker.ActivityTracker Vault *vault.Vault UsageStatsReporter *usagestats.Reporter + ContinuousTestManager *continuoustest.Manager BuildInfoHandler http.Handler } diff --git a/pkg/mimir/modules.go b/pkg/mimir/modules.go index dcec7a68f5f..5985688589e 100644 --- a/pkg/mimir/modules.go +++ b/pkg/mimir/modules.go @@ -40,6 +40,7 @@ import ( "github.com/grafana/mimir/pkg/alertmanager/alertstore" "github.com/grafana/mimir/pkg/api" "github.com/grafana/mimir/pkg/compactor" + "github.com/grafana/mimir/pkg/continuoustest" "github.com/grafana/mimir/pkg/distributor" "github.com/grafana/mimir/pkg/flusher" "github.com/grafana/mimir/pkg/frontend" @@ -97,6 +98,7 @@ const ( Vault string = "vault" TenantFederation string = "tenant-federation" UsageStats string = "usage-stats" + ContinuousTest string = "continuous-test" All string = "all" // Write Read and Backend are the targets used when using the read-write deployment mode. @@ -1034,6 +1036,20 @@ func (t *Mimir) initUsageStats() (services.Service, error) { return t.UsageStatsReporter, nil } +func (t *Mimir) initContinuousTest() (services.Service, error) { + client, err := continuoustest.NewClient(t.Cfg.ContinuousTest.Client, util_log.Logger) + if err != nil { + return nil, errors.Wrap(err, "Failed to initialize continuous-test client") + } + + t.ContinuousTestManager = continuoustest.NewManager(t.Cfg.ContinuousTest.Manager, util_log.Logger) + t.ContinuousTestManager.AddTest(continuoustest.NewWriteReadSeriesTest(t.Cfg.ContinuousTest.WriteReadSeriesTest, client, util_log.Logger, t.Registerer)) + + return services.NewBasicService(nil, func(ctx context.Context) error { + return t.ContinuousTestManager.Run(ctx) + }, nil), nil +} + func (t *Mimir) setupModuleManager() error { mm := modules.NewManager(util_log.Logger) @@ -1069,6 +1085,7 @@ func (t *Mimir) setupModuleManager() error { mm.RegisterModule(QueryScheduler, t.initQueryScheduler) mm.RegisterModule(TenantFederation, t.initTenantFederation, modules.UserInvisibleModule) mm.RegisterModule(UsageStats, t.initUsageStats, modules.UserInvisibleModule) + mm.RegisterModule(ContinuousTest, t.initContinuousTest) mm.RegisterModule(Vault, t.initVault, modules.UserInvisibleModule) mm.RegisterModule(Write, nil) mm.RegisterModule(Read, nil) @@ -1102,6 +1119,7 @@ func (t *Mimir) setupModuleManager() error { Compactor: {API, MemberlistKV, Overrides, Vault}, StoreGateway: {API, Overrides, MemberlistKV, Vault}, TenantFederation: {Queryable}, + ContinuousTest: {API}, Write: {Distributor, Ingester}, Read: {QueryFrontend, Querier}, Backend: {QueryScheduler, Ruler, StoreGateway, Compactor, AlertManager, OverridesExporter},