Selaa lähdekoodia

feat(alerting): adds fearture toogle for alerting

bergquist 9 vuotta sitten
vanhempi
commit
6d66d9f42d

+ 5 - 0
conf/defaults.ini

@@ -332,3 +332,8 @@ global_api_key = -1
 
 # global limit on number of logged in users.
 global_session = -1
+
+
+#################################### Alerting ######################################
+[alerting]
+enabled = true

+ 1 - 0
pkg/api/frontendsettings.go

@@ -143,6 +143,7 @@ func getFrontendSettingsMap(c *middleware.Context) (map[string]interface{}, erro
 			"latestVersion": plugins.GrafanaLatestVersion,
 			"hasUpdate":     plugins.GrafanaHasUpdate,
 		},
+		"alertingEnabled": setting.AlertingEnabled,
 	}
 
 	return jsonObj, nil

+ 6 - 0
pkg/setting/setting.go

@@ -137,6 +137,9 @@ var (
 
 	// QUOTA
 	Quota QuotaSettings
+
+	// Alerting
+	AlertingEnabled bool
 )
 
 type CommandLineArgs struct {
@@ -484,6 +487,9 @@ func NewConfigContext(args *CommandLineArgs) error {
 	LdapEnabled = ldapSec.Key("enabled").MustBool(false)
 	LdapConfigFile = ldapSec.Key("config_file").String()
 
+	alerting := Cfg.Section("alerting")
+	AlertingEnabled = alerting.Key("enabled").MustBool(false)
+
 	readSessionConfig()
 	readSmtpSettings()
 	readQuotaSettings()

+ 4 - 1
public/app/plugins/panel/graph/module.ts

@@ -10,6 +10,7 @@ import moment from 'moment';
 import kbn from 'app/core/utils/kbn';
 import _ from 'lodash';
 import TimeSeries from 'app/core/time_series2';
+import config from 'app/core/config';
 import * as fileExport from 'app/core/utils/file_export';
 import {MetricsPanelCtrl} from 'app/plugins/sdk';
 import {graphAlertEditor} from './alert_tab_ctrl';
@@ -130,7 +131,9 @@ class GraphCtrl extends MetricsPanelCtrl {
     this.addEditorTab('Axes', 'public/app/plugins/panel/graph/tab_axes.html', 2);
     this.addEditorTab('Legend', 'public/app/plugins/panel/graph/tab_legend.html', 3);
     this.addEditorTab('Display', 'public/app/plugins/panel/graph/tab_display.html', 4);
-    this.addEditorTab('Alerting', graphAlertEditor, 5);
+    if (config.alertingEnabled) {
+      this.addEditorTab('Alerting', graphAlertEditor, 5);
+    }
 
     this.logScales = {
       'linear': 1,