Expressions: Add option to disable feature (#30541) (#30558)

* Expressions: Add option to disable feature

* Apply suggestions from code review

Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com>
(cherry picked from commit 9ada4b6052)

Co-authored-by: Sofia Papagiannaki <papagian@users.noreply.github.com>
This commit is contained in:
Grot (@grafanabot)
2021-01-25 15:58:52 +02:00
committed by GitHub
co-authored by Sofia Papagiannaki
parent 7592031b36
commit fcfb12d0b3
15 changed files with 99 additions and 28 deletions
+9
View File
@@ -339,6 +339,9 @@ type Cfg struct {
AutoAssignOrg bool
AutoAssignOrgId int
AutoAssignOrgRole string
// ExpressionsEnabled specifies whether expressions are enabled.
ExpressionsEnabled bool
}
// IsLiveEnabled returns if grafana live should be enabled
@@ -482,6 +485,11 @@ func (cfg *Cfg) readAnnotationSettings() {
cfg.APIAnnotationCleanupSettings = newAnnotationCleanupSettings(apiIAnnotation, "max_age")
}
func (cfg *Cfg) readExpressionsSettings() {
expressions := cfg.Raw.Section("expressions")
cfg.ExpressionsEnabled = expressions.Key("enabled").MustBool(true)
}
type AnnotationCleanupSettings struct {
MaxAge time.Duration
MaxCount int64
@@ -850,6 +858,7 @@ func (cfg *Cfg) Load(args *CommandLineArgs) error {
cfg.readSmtpSettings()
cfg.readQuotaSettings()
cfg.readAnnotationSettings()
cfg.readExpressionsSettings()
if err := cfg.readGrafanaEnvironmentMetrics(); err != nil {
return err
}