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:
+10
-1
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user