diff --git a/CHANGELOG.md b/CHANGELOG.md index cb9986e5907..00c9f3562a0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## master / unreleased +* [CHANGE] Removed support for flags to configure schema. Further, the flag for specifying the config file (`-config-yaml`) has been deprecated. Please use `schema-config-file`. See https://cortexmetrics.io/docs/configuration/schema-configuration/ for more details on how to configure the schema using the YAML file. #2221 * [CHANGE] The frontend http server will now send 502 in case of deadline exceeded and 499 if the user requested cancellation. #2156 * [CHANGE] Config file changed to remove top level `config_store` field in favor of a nested `configdb` field. #2125 * [CHANGE] We now enforce queries to be up to `-querier.max-query-into-future` into the future (defaults to 10m). #1929 diff --git a/docs/configuration/schema-config-reference.md b/docs/configuration/schema-config-reference.md new file mode 100644 index 00000000000..3b212f176a0 --- /dev/null +++ b/docs/configuration/schema-config-reference.md @@ -0,0 +1,127 @@ +--- +title: "Schema Configuration" +linkTitle: "Schema Configuration" +weight: 1 +slug: schema-configuration +--- + +Cortex uses a NoSQL Store to store its index and optionally an Object store to store its chunks. Cortex has overtime evolved its schema to be more optimal and better fit the use cases and query patterns that arose. + +Currently there are 9 schemas that are used in production but we recommend running with `v9` schema when possible. You can move from one schema to another if a new schema fits your purpose better, but you still need to configure Cortex to make sure it can read the old data in the old schemas. + +You can configure the schemas using a YAML config file, that you can point to using the `-schema-config-file` flag. It has the following YAML spec: + +```yaml +configs: [] +``` + +Where `period_config` is +``` +# In YYYY-MM-DD format, for example: 2020-03-01. +from: +# The index client to use, valid options: aws-dynamo, bigtable, bigtable-hashed, cassandra, boltdb. +store: +# The object client to use. If none is specified, `store` is used for storing chunks as well. Valid options: s3, aws-dynamo, bigtable, bigtable-hashed, gcs, cassandra, filesystem. +object_store: +# The schema version to use. Valid ones are v1, v2, v3,... v6, v9, v10, v11. Recommended for production: v9. +schema: +index: +chunks: +``` + +Where `periodic_table_config` is +``` +# The prefix to use for the tables. +prefix: +# We typically run Cortex with new tables every week to keep the index size low and to make retention easier. This sets the period at which new tables are created and used. Typically 168h (1week). +period: +# The tags that can be set on the dynamo table. +tags: +``` + +Now an example of this file (also something recommended when starting out) is: +``` +configs: + - from: "2020-03-01" # Or typically a week before the Cortex cluster was created. + schema: v9 + index: + period: 168h + prefix: cortex_index_ + # Chunks section is optional and required only if you're not using a + # separate object store. + chunks: + period: 168h + prefix: cortex_chunks + store: aws-dynamo/bigtable-hashed/cassandra/boltdb + object_store: /s3/gcs/azure/filesystem +``` + +An example of an advanced schema file with a lot of changes: +``` +configs: + # Starting from 2018-08-23 Cortex should store chunks and indexes + # on Google BigTable using weekly periodic tables. The chunks table + # names will be prefixed with "dev_chunks_", while index tables will be + # prefixed with "dev_index_". + - from: "2018-08-23" + schema: v9 + chunks: + period: 168h0m0s + prefix: dev_chunks_ + index: + period: 168h0m0s + prefix: dev_index_ + store: gcp-columnkey + + # Starting 2018-02-13 we moved from BigTable to GCS for storing the chunks. + - from: "2019-02-13" + schema: v9 + chunks: + period: 168h + prefix: dev_chunks_ + index: + period: 168h + prefix: dev_index_ + object_store: gcs + store: gcp-columnkey + + # Starting 2019-02-24 we moved our index from bigtable-columnkey to bigtable-hashed + # which improves the distribution of keys. + - from: "2019-02-24" + schema: v9 + chunks: + period: 168h + prefix: dev_chunks_ + index: + period: 168h + prefix: dev_index_ + object_store: gcs + store: bigtable-hashed + + # Starting 2019-03-05 we moved from v9 schema to v10 schema. + - from: "2019-03-05" + schema: v10 + chunks: + period: 168h + prefix: dev_chunks_ + index: + period: 168h + prefix: dev_index_ + object_store: gcs + store: bigtable-hashed +``` + +Note how we started out with v9 and just Bigtable, but later migrated to GCS as the object store, finally moving to v10. This is a complex schema file showing several changes changes over the time, while a typical schema config file usually has just one or two schema versions. + +### Migrating from flags to schema file + +Legacy versions of Cortex did support the ability to configure schema via flags. If you are still using flags, you need to migrate your configuration from flags to the config file. + +If you're using: + +* `chunk.storage-client`: then set the corresponding `object_store` field correctly in the schema file. +* `dynamodb.daily-buckets-from`: then set the corresponding `from` date with `v2` schema. +* `dynamodb.base64-buckets-from`: then set the corresponding `from` date with `v3` schema. +* `dynamodb.v{4,5,6,9}-schema-from`: then set the corresponding `from` date with schema `v{4,5,6,9}` +* `bigtable.column-key-from`: then set the corresponding `from` date and use the `store` as `bigtable-columnkey`. +* `dynamodb.use-periodic-tables`: then set the right `index` and `chunk` fields with corresponding values from `dynamodb.periodic-table.{prefix, period, tag}` and `dynamodb.chunk-table.{prefix, period, tag}` flags. Note that the default period is 7 days, so please set the `period` as `168h` in the config file if none is set in the flags. diff --git a/docs/guides/aws-specific.md b/docs/guides/aws-specific.md index 215a3ac570d..88750b2c5ec 100644 --- a/docs/guides/aws-specific.md +++ b/docs/guides/aws-specific.md @@ -51,10 +51,8 @@ example set of command-line parameters from a fairly modest install: -metrics.url=http://prometheus.monitoring.svc.cluster.local./api/prom/ -metrics.target-queue-length=100000 -dynamodb.url=dynamodb://us-east-1/ - -dynamodb.use-periodic-tables=true + -schema-config-file=/etc/schema.yaml - -dynamodb.periodic-table.prefix=cortex_index_ - -dynamodb.periodic-table.from=2019-05-02 -dynamodb.periodic-table.write-throughput=1000 -dynamodb.periodic-table.write-throughput.scale.enabled=true -dynamodb.periodic-table.write-throughput.scale.min-capacity=200 @@ -64,8 +62,6 @@ example set of command-line parameters from a fairly modest install: -dynamodb.periodic-table.read-throughput=300 -dynamodb.periodic-table.tag=product_area=cortex - -dynamodb.chunk-table.from=2019-05-02 - -dynamodb.chunk-table.prefix=cortex_data_ -dynamodb.chunk-table.write-throughput=800 -dynamodb.chunk-table.write-throughput.scale.enabled=true -dynamodb.chunk-table.write-throughput.scale.min-capacity=200 diff --git a/docs/guides/running.md b/docs/guides/running.md index 62a4e48284c..d29d8c9e5e8 100644 --- a/docs/guides/running.md +++ b/docs/guides/running.md @@ -55,22 +55,7 @@ redundancy or less, depending on your risk appetite. ### Schema -#### Schema periodic table - -The periodic table from argument (`-dynamodb.periodic-table.from=` if -using command line flags, the `from` field for the first schema entry if using -YAML) should be set to the date the oldest metrics you will be sending to -Cortex. Generally that means set it to the date you are first deploying this -instance. If you use an example date from years ago table-manager will create -hundreds of tables. You can also avoid creating too many tables by setting a -reasonable retention in the table-manager -(`-table-manager.retention-period=`). - -#### Schema version - -Choose schema version 9 in most cases; version 10 if you expect -hundreds of thousands of timeseries under a single name. Anything -older than v9 is much less efficient. +See [schema config file docs](../configuration/schema-config-reference.md). ### Chunk encoding diff --git a/integration/backward_compatibility_test.go b/integration/backward_compatibility_test.go index 3642875afe5..d30ed2ace34 100644 --- a/integration/backward_compatibility_test.go +++ b/integration/backward_compatibility_test.go @@ -31,13 +31,18 @@ func TestBackwardCompatibilityWithChunksStorage(t *testing.T) { consul := e2edb.NewConsul() require.NoError(t, s.StartAndWaitReady(dynamo, consul)) + flagsForOldImage := mergeFlags(ChunksStorageFlags, map[string]string{ + "-schema-config-file": "", + "-config-yaml": ChunksStorageFlags["-schema-config-file"], + }) + // Start Cortex components (ingester running on previous version). require.NoError(t, writeFileToSharedDir(s, cortexSchemaConfigFile, []byte(cortexSchemaConfigYaml))) - tableManager := e2ecortex.NewTableManager("table-manager", ChunksStorageFlags, previousVersionImage) + tableManager := e2ecortex.NewTableManager("table-manager", flagsForOldImage, previousVersionImage) // Old table-manager doesn't expose a readiness probe, so we just check if the / returns 404 tableManager.SetReadinessProbe(e2e.NewReadinessProbe(tableManager.HTTPPort(), "/", 404)) - ingester1 := e2ecortex.NewIngester("ingester-1", consul.NetworkHTTPEndpoint(), ChunksStorageFlags, "") - distributor := e2ecortex.NewDistributor("distributor", consul.NetworkHTTPEndpoint(), ChunksStorageFlags, "") + ingester1 := e2ecortex.NewIngester("ingester-1", consul.NetworkHTTPEndpoint(), flagsForOldImage, "") + distributor := e2ecortex.NewDistributor("distributor", consul.NetworkHTTPEndpoint(), flagsForOldImage, "") // Old ring didn't have /ready probe, use /ring instead. distributor.SetReadinessProbe(e2e.NewReadinessProbe(distributor.HTTPPort(), "/ring", 200)) require.NoError(t, s.StartAndWaitReady(distributor, ingester1, tableManager)) @@ -72,7 +77,11 @@ func TestBackwardCompatibilityWithChunksStorage(t *testing.T) { // Query the new ingester both with the old and the new querier. for _, image := range []string{previousVersionImage, ""} { - querier := e2ecortex.NewQuerier("querier", consul.NetworkHTTPEndpoint(), ChunksStorageFlags, image) + flags := ChunksStorageFlags + if image == previousVersionImage { + flags = flagsForOldImage + } + querier := e2ecortex.NewQuerier("querier", consul.NetworkHTTPEndpoint(), flags, image) require.NoError(t, s.StartAndWaitReady(querier)) // Wait until the querier has updated the ring. diff --git a/integration/configs.go b/integration/configs.go index 5265a9a6043..5c228e03ce2 100644 --- a/integration/configs.go +++ b/integration/configs.go @@ -90,7 +90,7 @@ tsdb: ChunksStorageFlags = map[string]string{ "-dynamodb.url": fmt.Sprintf("dynamodb://u:p@%s-dynamodb.:8000", networkName), "-dynamodb.poll-interval": "1m", - "-config-yaml": filepath.Join(e2e.ContainerSharedDir, cortexSchemaConfigFile), + "-schema-config-file": filepath.Join(e2e.ContainerSharedDir, cortexSchemaConfigFile), "-table-manager.retention-period": "168h", } diff --git a/integration/e2e/util.go b/integration/e2e/util.go index e0efff31916..23116216ef9 100644 --- a/integration/e2e/util.go +++ b/integration/e2e/util.go @@ -30,6 +30,12 @@ func MergeFlags(inputs ...map[string]string) map[string]string { } } + for k, v := range output { + if v == "" { + delete(output, k) + } + } + return output } diff --git a/k8s/ingester-dep.yaml b/k8s/ingester-dep.yaml index 41f5e7dab50..854c3095998 100644 --- a/k8s/ingester-dep.yaml +++ b/k8s/ingester-dep.yaml @@ -45,16 +45,8 @@ spec: - -ingester.claim-on-rollout=true - -consul.hostname=consul.default.svc.cluster.local:8500 - -s3.url=s3://abc:123@s3.default.svc.cluster.local:4569 - - -dynamodb.original-table-name=cortex - -dynamodb.url=dynamodb://user:pass@dynamodb.default.svc.cluster.local:8000 - - -dynamodb.periodic-table.prefix=cortex_weekly_ - - -dynamodb.periodic-table.from=2017-01-06 - - -dynamodb.daily-buckets-from=2017-01-10 - - -dynamodb.base64-buckets-from=2017-01-17 - - -dynamodb.v4-schema-from=2017-02-05 - - -dynamodb.v5-schema-from=2017-02-22 - - -dynamodb.v6-schema-from=2017-03-19 - - -dynamodb.chunk-table.from=2017-04-17 + - -schema-config-file=/etc/cortex/schema.yaml - -memcached.hostname=memcached.default.svc.cluster.local - -memcached.timeout=100ms - -memcached.service=memcached @@ -66,3 +58,10 @@ spec: port: 80 initialDelaySeconds: 15 timeoutSeconds: 1 + volumeMounts: + - name: config-volume + mountPath: /etc/cortex + volumes: + - name: config-volume + configMap: + name: schema-config diff --git a/k8s/querier-dep.yaml b/k8s/querier-dep.yaml index e416369371d..1f697b47460 100644 --- a/k8s/querier-dep.yaml +++ b/k8s/querier-dep.yaml @@ -22,20 +22,19 @@ spec: - -server.http-listen-port=80 - -consul.hostname=consul.default.svc.cluster.local:8500 - -s3.url=s3://abc:123@s3.default.svc.cluster.local:4569 - - -querier.frontend-address=query-frontend.default.svc.cluster.local:9095 - - -dynamodb.original-table-name=cortex - -dynamodb.url=dynamodb://user:pass@dynamodb.default.svc.cluster.local:8000 - - -dynamodb.periodic-table.prefix=cortex_weekly_ - - -dynamodb.periodic-table.from=2017-01-06 - - -dynamodb.daily-buckets-from=2017-01-10 - - -dynamodb.base64-buckets-from=2017-01-17 - - -dynamodb.v4-schema-from=2017-02-05 - - -dynamodb.v5-schema-from=2017-02-22 - - -dynamodb.v6-schema-from=2017-03-19 - - -dynamodb.chunk-table.from=2017-04-17 + - -schema-config-file=/etc/cortex/schema.yaml + - -querier.frontend-address=query-frontend.default.svc.cluster.local:9095 - -memcached.hostname=memcached.default.svc.cluster.local - -memcached.timeout=100ms - -memcached.service=memcached - -distributor.replication-factor=1 ports: - containerPort: 80 + volumeMounts: + - name: config-volume + mountPath: /etc/cortex + volumes: + - name: config-volume + configMap: + name: schema-config diff --git a/k8s/ruler-dep.yaml b/k8s/ruler-dep.yaml index 3c102a6fe0d..2d9a83e6890 100644 --- a/k8s/ruler-dep.yaml +++ b/k8s/ruler-dep.yaml @@ -25,19 +25,18 @@ spec: - -ruler.alertmanager-url=http://alertmanager.default.svc.cluster.local/api/prom/alertmanager/ - -consul.hostname=consul.default.svc.cluster.local:8500 - -s3.url=s3://abc:123@default.svc.cluster.local:4569/s3 - - -dynamodb.original-table-name=cortex - -dynamodb.url=dynamodb://user:pass@dynamodb.default.svc.cluster.local:8000 - - -dynamodb.periodic-table.prefix=cortex_weekly_ - - -dynamodb.periodic-table.from=2017-01-06 - - -dynamodb.daily-buckets-from=2017-01-10 - - -dynamodb.base64-buckets-from=2017-01-17 - - -dynamodb.v4-schema-from=2017-02-05 - - -dynamodb.v5-schema-from=2017-02-22 - - -dynamodb.v6-schema-from=2017-03-19 - - -dynamodb.chunk-table.from=2017-04-17 + - -schema-config-file=/etc/cortex/schema.yaml - -memcached.hostname=memcached.default.svc.cluster.local - -memcached.timeout=100ms - -memcached.service=memcached - -distributor.replication-factor=1 ports: - containerPort: 80 + volumeMounts: + - name: config-volume + mountPath: /etc/cortex + volumes: + - name: config-volume + configMap: + name: schema-config diff --git a/k8s/schema-config.yaml b/k8s/schema-config.yaml new file mode 100644 index 00000000000..11c2915c9ac --- /dev/null +++ b/k8s/schema-config.yaml @@ -0,0 +1,15 @@ +--- +kind: ConfigMap +apiVersion: v1 +metadata: + name: schema-config +data: + schema.yaml: | + configs: + - from: "2020-01-01" + schema: v9 + index: + period: 168h0m0s + prefix: cortex_weekly_ + store: aws-dynamo + object_store: s3 diff --git a/k8s/table-manager-dep.yaml b/k8s/table-manager-dep.yaml index f222a10172f..a6afb3b9c4e 100644 --- a/k8s/table-manager-dep.yaml +++ b/k8s/table-manager-dep.yaml @@ -20,10 +20,14 @@ spec: args: - -target=table-manager - -server.http-listen-port=80 - - -dynamodb.original-table-name=cortex - -dynamodb.url=dynamodb://user:pass@dynamodb.default.svc.cluster.local:8000 - - -dynamodb.periodic-table.prefix=cortex_weekly_ - - -dynamodb.periodic-table.from=2017-01-06 - - -dynamodb.chunk-table.from=2017-04-17 + - -schema-config-file=/etc/cortex/schema.yaml ports: - containerPort: 80 + volumeMounts: + - name: config-volume + mountPath: /etc/cortex + volumes: + - name: config-volume + configMap: + name: schema-config diff --git a/pkg/chunk/schema_config.go b/pkg/chunk/schema_config.go index 0141fe3d9aa..ab4cd4247ab 100644 --- a/pkg/chunk/schema_config.go +++ b/pkg/chunk/schema_config.go @@ -14,7 +14,6 @@ import ( yaml "gopkg.in/yaml.v2" "github.com/cortexproject/cortex/pkg/util" - "github.com/cortexproject/cortex/pkg/util/flagext" ) const ( @@ -27,6 +26,7 @@ const ( var ( errInvalidSchemaVersion = errors.New("invalid schema version") errInvalidTablePeriod = errors.New("the table period must be a multiple of 24h (1h for schema v1)") + errConfigFileNotSet = errors.New("schema config file needs to be set") ) // PeriodConfig defines the schema and tables to use for a period of time @@ -69,116 +69,31 @@ func (d *DayTime) UnmarshalYAML(unmarshal func(interface{}) error) error { type SchemaConfig struct { Configs []PeriodConfig `yaml:"configs"` - fileName string - legacy LegacySchemaConfig // if fileName is set then legacy config is ignored -} - -// LegacySchemaConfig lets you configure schema via command-line flags -type LegacySchemaConfig struct { - StorageClient string // aws, gcp, etc. - - // After midnight on this day, we start bucketing indexes by day instead of by - // hour. Only the day matters, not the time within the day. - DailyBucketsFrom flagext.DayValue - Base64ValuesFrom flagext.DayValue - V4SchemaFrom flagext.DayValue - V5SchemaFrom flagext.DayValue - V6SchemaFrom flagext.DayValue - V9SchemaFrom flagext.DayValue - BigtableColumnKeyFrom flagext.DayValue - - // Config for the index & chunk tables. - OriginalTableName string - UsePeriodicTables bool - IndexTablesFrom flagext.DayValue - IndexTables PeriodicTableConfig - ChunkTablesFrom flagext.DayValue - ChunkTables PeriodicTableConfig + fileName string + legacyFileName string } // RegisterFlags adds the flags required to config this to the given FlagSet. func (cfg *SchemaConfig) RegisterFlags(f *flag.FlagSet) { - flag.StringVar(&cfg.fileName, "config-yaml", "", "Schema config yaml") - cfg.legacy.RegisterFlags(f) -} - -// RegisterFlags adds the flags required to config this to the given FlagSet. -func (cfg *LegacySchemaConfig) RegisterFlags(f *flag.FlagSet) { - flag.StringVar(&cfg.StorageClient, "chunk.storage-client", "aws", "Which storage client to use (aws, gcp, cassandra, inmemory).") - f.Var(&cfg.DailyBucketsFrom, "dynamodb.daily-buckets-from", "The date (in the format YYYY-MM-DD) of the first day for which DynamoDB index buckets should be day-sized vs. hour-sized.") - f.Var(&cfg.Base64ValuesFrom, "dynamodb.base64-buckets-from", "The date (in the format YYYY-MM-DD) after which we will stop querying to non-base64 encoded values.") - f.Var(&cfg.V4SchemaFrom, "dynamodb.v4-schema-from", "The date (in the format YYYY-MM-DD) after which we enable v4 schema.") - f.Var(&cfg.V5SchemaFrom, "dynamodb.v5-schema-from", "The date (in the format YYYY-MM-DD) after which we enable v5 schema.") - f.Var(&cfg.V6SchemaFrom, "dynamodb.v6-schema-from", "The date (in the format YYYY-MM-DD) after which we enable v6 schema.") - f.Var(&cfg.V9SchemaFrom, "dynamodb.v9-schema-from", "The date (in the format YYYY-MM-DD) after which we enable v9 schema (Series indexing).") - f.Var(&cfg.BigtableColumnKeyFrom, "bigtable.column-key-from", "The date (in the format YYYY-MM-DD) after which we use bigtable column keys.") - - f.StringVar(&cfg.OriginalTableName, "dynamodb.original-table-name", "cortex", "The name of the DynamoDB table used before versioned schemas were introduced.") - f.BoolVar(&cfg.UsePeriodicTables, "dynamodb.use-periodic-tables", false, "Should we use periodic tables.") - - f.Var(&cfg.IndexTablesFrom, "dynamodb.periodic-table.from", "Date after which to use periodic tables.") - cfg.IndexTables.RegisterFlags("dynamodb.periodic-table", "cortex_", f) - f.Var(&cfg.ChunkTablesFrom, "dynamodb.chunk-table.from", "Date after which to write chunks to DynamoDB.") - cfg.ChunkTables.RegisterFlags("dynamodb.chunk-table", "cortex_chunks_", f) + flag.StringVar(&cfg.fileName, "schema-config-file", "", "The path to the schema config file.") + // TODO(gouthamve): Add a metric for this. + flag.StringVar(&cfg.legacyFileName, "config-yaml", "", "DEPRECATED(use -schema-config-file) The path to the schema config file.") } -func (cfg *SchemaConfig) loadFromFlags() error { - cfg.Configs = []PeriodConfig{} - - add := func(t string, f model.Time) { - cfg.Configs = append(cfg.Configs, PeriodConfig{ - From: DayTime{f}, - Schema: t, - IndexType: cfg.legacy.StorageClient, - IndexTables: PeriodicTableConfig{ - Prefix: cfg.legacy.OriginalTableName, - Tags: cfg.legacy.IndexTables.Tags, - }, - }) - } - - add("v1", 0) +// loadFromFile loads the schema config from a yaml file +func (cfg *SchemaConfig) loadFromFile() error { + if cfg.fileName == "" { + cfg.fileName = cfg.legacyFileName - if cfg.legacy.DailyBucketsFrom.IsSet() { - add("v2", cfg.legacy.DailyBucketsFrom.Time) - } - if cfg.legacy.Base64ValuesFrom.IsSet() { - add("v3", cfg.legacy.Base64ValuesFrom.Time) - } - if cfg.legacy.V4SchemaFrom.IsSet() { - add("v4", cfg.legacy.V4SchemaFrom.Time) - } - if cfg.legacy.V5SchemaFrom.IsSet() { - add("v5", cfg.legacy.V5SchemaFrom.Time) - } - if cfg.legacy.V6SchemaFrom.IsSet() { - add("v6", cfg.legacy.V6SchemaFrom.Time) - } - if cfg.legacy.V9SchemaFrom.IsSet() { - add("v9", cfg.legacy.V9SchemaFrom.Time) + if cfg.legacyFileName != "" { + level.Warn(util.Logger).Log("msg", "running with DEPRECATED flag -config-yaml, use -schema-config-file instead") + } } - cfg.ForEachAfter(cfg.legacy.IndexTablesFrom.Time, func(config *PeriodConfig) { - config.IndexTables = cfg.legacy.IndexTables - }) - if cfg.legacy.ChunkTablesFrom.IsSet() { - cfg.ForEachAfter(cfg.legacy.ChunkTablesFrom.Time, func(config *PeriodConfig) { - if config.IndexType == "aws" { - config.IndexType = "aws-dynamo" - } - config.ChunkTables = cfg.legacy.ChunkTables - }) - } - if cfg.legacy.BigtableColumnKeyFrom.IsSet() { - cfg.ForEachAfter(cfg.legacy.BigtableColumnKeyFrom.Time, func(config *PeriodConfig) { - config.IndexType = "gcp-columnkey" - }) + if cfg.fileName == "" { + return errConfigFileNotSet } - return nil -} -// loadFromFile loads the schema config from a yaml file -func (cfg *SchemaConfig) loadFromFile() error { f, err := os.Open(cfg.fileName) if err != nil { return err @@ -304,16 +219,8 @@ func (cfg *SchemaConfig) Load() error { return nil } - // Load config from file (if provided), falling back to CLI flags - var err error - - if cfg.fileName == "" { - err = cfg.loadFromFlags() - } else { - err = cfg.loadFromFile() - } - - if err != nil { + // Load config from file. + if err := cfg.loadFromFile(); err != nil { return err } @@ -388,13 +295,6 @@ type PeriodicTableConfig struct { Tags Tags `yaml:"tags,omitempty"` } -// RegisterFlags adds the flags required to config this to the given FlagSet. -func (cfg *PeriodicTableConfig) RegisterFlags(argPrefix, tablePrefix string, f *flag.FlagSet) { - f.StringVar(&cfg.Prefix, argPrefix+".prefix", tablePrefix, "DynamoDB table prefix for period tables.") - f.DurationVar(&cfg.Period, argPrefix+".period", 7*24*time.Hour, "DynamoDB table period.") - f.Var(&cfg.Tags, argPrefix+".tag", "Tag (of the form key=value) to be added to all tables under management.") -} - // AutoScalingConfig for DynamoDB tables. type AutoScalingConfig struct { Enabled bool `yaml:"enabled,omitempty"` diff --git a/pkg/cortex/modules.go b/pkg/cortex/modules.go index e60246f4d39..ec991a73b98 100644 --- a/pkg/cortex/modules.go +++ b/pkg/cortex/modules.go @@ -378,9 +378,12 @@ func (t *Cortex) initStore(cfg *Config) (serv services.Service, err error) { } func (t *Cortex) initQueryFrontend(cfg *Config) (serv services.Service, err error) { - err = cfg.Schema.Load() - if err != nil { - return + // Load the schema only if sharded queries is set. + if cfg.QueryRange.ShardedQueries { + err = cfg.Schema.Load() + if err != nil { + return + } } t.frontend, err = frontend.New(cfg.Frontend, util.Logger, prometheus.DefaultRegisterer)