Files
grafana/pkg/setting/setting_unified_storage.go
owensmallwood 995128d1db Search PoC: Improves initial indexing speed. Makes params configurable. (#95439)
* Improves initial indexing speed. Makes params configurable.

* fix linter errors

* removes kind param

* updates index test

* remove println from test

* removes error check in test

* adds log for high index latency ands updates max goroutine var with workers config var

* fix test timing out - set worker limit

* set the batch size

---------

Co-authored-by: Scott Lepper <scott.lepper@gmail.com>
2024-10-29 12:24:31 -06:00

46 lines
1.5 KiB
Go

package setting
import (
"strings"
"github.com/grafana/grafana/pkg/apiserver/rest"
)
// read storage configs from ini file. They look like:
// [unified_storage.<group>.<resource>]
// <field> = <value>
// e.g.
// [unified_storage.playlists.playlist.grafana.app]
// dualWriterMode = 2
func (cfg *Cfg) setUnifiedStorageConfig() {
storageConfig := make(map[string]UnifiedStorageConfig)
sections := cfg.Raw.Sections()
for _, section := range sections {
sectionName := section.Name()
if !strings.HasPrefix(sectionName, "unified_storage.") {
continue
}
// the resource name is the part after the first dot
resourceName := strings.SplitAfterN(sectionName, ".", 2)[1]
// parse dualWriter modes from the section
dualWriterMode := section.Key("dualWriterMode").MustInt(0)
// parse dualWriter periodic data syncer config
dualWriterPeriodicDataSyncJobEnabled := section.Key("dualWriterPeriodicDataSyncJobEnabled").MustBool(false)
storageConfig[resourceName] = UnifiedStorageConfig{
DualWriterMode: rest.DualWriterMode(dualWriterMode),
DualWriterPeriodicDataSyncJobEnabled: dualWriterPeriodicDataSyncJobEnabled,
}
}
cfg.UnifiedStorage = storageConfig
// Set indexer config for unified storaae
section := cfg.Raw.Section("unified_storage")
cfg.IndexPath = section.Key("index_path").String()
cfg.IndexWorkers = section.Key("index_workers").MustInt(10)
cfg.IndexMaxBatchSize = section.Key("index_max_batch_size").MustInt(100)
cfg.IndexListLimit = section.Key("index_list_limit").MustInt(1000)
}