diff --git a/docs/sources/configuration/_index.md b/docs/sources/configuration/_index.md index d51e347de5..3fff69e4fb 100644 --- a/docs/sources/configuration/_index.md +++ b/docs/sources/configuration/_index.md @@ -3610,6 +3610,55 @@ fifocache: [async_cache_write_back_buffer_size: | default = 500] ``` +### period_config + +The `period_config` block configures what index schemas should be used for from specific time periods. + +```yaml +# The date of the first day that index buckets should be created. Use a date in +# the past if this is your only period_config, otherwise use a date when you +# want the schema to switch over. In YYYY-MM-DD format, for example: 2018-04-15. +[from: ] + +# store and object_store below affect which key is used. +# Which store to use for the index. Either aws, aws-dynamo, gcp, bigtable, +# bigtable-hashed, cassandra, boltdb or boltdb-shipper. +[store: | default = ""] + +# Which store to use for the chunks. Either aws, azure, gcp, bigtable, gcs, +# cassandra, swift or filesystem. If omitted, defaults to the same value as +# store. +[object_store: | default = ""] + +# The schema version to use, current recommended schema is v11. +[schema: | default = ""] + +# Configures how the index is updated and stored. +index: + # Table prefix for all period tables. + [prefix: | default = ""] + + # Table period. + [period: ] + + # A map to be added to all managed tables. + [tags: ] + +# Configured how the chunks are updated and stored. +chunks: + # Table prefix for all period tables. + [prefix: | default = ""] + + # Table period. + [period: ] + + # A map to be added to all managed tables. + [tags: ] + +# How many shards will be created. Only used if schema is v10 or greater. +[row_shards: ] +``` + ### azure_storage_config The `azure_storage_config` block configures the connection to Azure object storage backend. The supported CLI flags `` used to reference this configuration block are: diff --git a/pkg/storage/config/schema_config.go b/pkg/storage/config/schema_config.go index 3e95804e28..8e152b8239 100644 --- a/pkg/storage/config/schema_config.go +++ b/pkg/storage/config/schema_config.go @@ -91,13 +91,13 @@ type PeriodConfig struct { // used when working with config From DayTime `yaml:"from" doc:"description=The date of the first day that index buckets should be created. Use a date in the past if this is your only period_config, otherwise use a date when you want the schema to switch over. In YYYY-MM-DD format, for example: 2018-04-15."` // type of index client to use. - IndexType string `yaml:"store"` + IndexType string `yaml:"store" doc:"description=store and object_store below affect which key is used.\nWhich store to use for the index. Either aws, aws-dynamo, gcp, bigtable, bigtable-hashed, cassandra, boltdb or boltdb-shipper. "` // type of object client to use; if omitted, defaults to store. - ObjectType string `yaml:"object_store"` - Schema string `yaml:"schema"` - IndexTables PeriodicTableConfig `yaml:"index"` - ChunkTables PeriodicTableConfig `yaml:"chunks"` - RowShards uint32 `yaml:"row_shards"` + ObjectType string `yaml:"object_store" doc:"description=Which store to use for the chunks. Either aws, azure, gcp, bigtable, gcs, cassandra, swift or filesystem. If omitted, defaults to the same value as store."` + Schema string `yaml:"schema" doc:"description=The schema version to use, current recommended schema is v11."` + IndexTables PeriodicTableConfig `yaml:"index" doc:"description=Configures how the index is updated and stored."` + ChunkTables PeriodicTableConfig `yaml:"chunks" doc:"description=Configured how the chunks are updated and stored."` + RowShards uint32 `yaml:"row_shards" doc:"description=How many shards will be created. Only used if schema is v10 or greater."` // Integer representation of schema used for hot path calculation. Populated on unmarshaling. schemaInt *int `yaml:"-"` @@ -369,9 +369,9 @@ func (cfg *PeriodConfig) VersionAsInt() (int, error) { // PeriodicTableConfig is configuration for a set of time-sharded tables. type PeriodicTableConfig struct { - Prefix string - Period time.Duration - Tags Tags + Prefix string `yaml:"prefix" doc:"description=Table prefix for all period tables."` + Period time.Duration `yaml:"period" doc:"description=Table period."` + Tags Tags `yaml:"tags" doc:"description=A map to be added to all managed tables."` } // UnmarshalYAML implements the yaml.Unmarshaler interface. diff --git a/tools/doc-generator/parse/parser.go b/tools/doc-generator/parse/parser.go index 37562a0413..0ddf1cdd5a 100644 --- a/tools/doc-generator/parse/parser.go +++ b/tools/doc-generator/parse/parser.go @@ -256,16 +256,30 @@ func config(block *ConfigBlock, cfg interface{}, flags map[uintptr]*flag.Flag, r _, isCustomType := getFieldCustomType(field.Type) isSliceOfStructs := field.Type.Kind() == reflect.Slice && (field.Type.Elem().Kind() == reflect.Struct || field.Type.Elem().Kind() == reflect.Ptr) if !isCustomType && isSliceOfStructs { + // Check if slice element type is a root block + // and add it to the blocks structure + rootName, rootDesc, isRoot := isRootBlock(field.Type.Elem(), rootBlocks) + if isRoot { + sliceElementBlock, err := config(nil, reflect.New(field.Type.Elem()).Interface(), flags, rootBlocks) + if err != nil { + return nil, errors.Wrapf(err, "couldn't inspect slice, element_type=%s", field.Type.Elem()) + } + if len(sliceElementBlock) == 1 { + element = &ConfigBlock{ + Name: rootName, + Desc: rootDesc, + Entries: sliceElementBlock[0].Entries, + } + blocks = append(blocks, element) + } + } + + // Add slice element to current block element = &ConfigBlock{ Name: fieldName, Desc: getFieldDescription(cfg, field, ""), } kind = KindSlice - - _, err = config(element, reflect.New(field.Type.Elem()).Interface(), flags, rootBlocks) - if err != nil { - return nil, errors.Wrapf(err, "couldn't inspect slice, element_type=%s", field.Type.Elem()) - } } } @@ -338,6 +352,8 @@ func getFieldCustomType(t reflect.Type) (string, bool) { return "url", true case reflect.TypeOf(time.Duration(0)).String(): return "duration", true + case reflect.TypeOf(storage_config.DayTime{}).String(): + return "daytime", true case reflect.TypeOf(flagext.StringSliceCSV{}).String(): return fieldString, true case reflect.TypeOf(flagext.CIDRSliceCSV{}).String(): @@ -421,6 +437,8 @@ func getCustomFieldType(t reflect.Type) (string, bool) { return "url", true case reflect.TypeOf(time.Duration(0)).String(): return "duration", true + case reflect.TypeOf(storage_config.DayTime{}).String(): + return "daytime", true case reflect.TypeOf(flagext.StringSliceCSV{}).String(): return fieldString, true case reflect.TypeOf(flagext.CIDRSliceCSV{}).String():