Explore: Add setting for default time offset (#90401)

* Add setting for explore for a different time offset

* fix linter

* Add validation for duration value
This commit is contained in:
Kristina
2024-07-17 11:47:49 -05:00
committed by GitHub
parent 1fc57d8fd5
commit 6eb695b258
8 changed files with 24 additions and 3 deletions
+10 -1
View File
@@ -513,7 +513,8 @@ type Cfg struct {
AlertingMinInterval int64
// Explore UI
ExploreEnabled bool
ExploreEnabled bool
ExploreDefaultTimeOffset string
// Help UI
HelpEnabled bool
@@ -1173,6 +1174,14 @@ func (cfg *Cfg) parseINIFile(iniFile *ini.File) error {
explore := iniFile.Section("explore")
cfg.ExploreEnabled = explore.Key("enabled").MustBool(true)
exploreDefaultTimeOffset := valueAsString(explore, "defaultTimeOffset", "1h")
// we want to ensure the value parses as a duration, but we send it forward as a string to the frontend
if _, err := gtime.ParseDuration(exploreDefaultTimeOffset); err != nil {
return err
} else {
cfg.ExploreDefaultTimeOffset = exploreDefaultTimeOffset
}
help := iniFile.Section("help")
cfg.HelpEnabled = help.Key("enabled").MustBool(true)