diff --git a/pkg/api/http_server.go b/pkg/api/http_server.go index 0de63ce5e08..432d6a18369 100644 --- a/pkg/api/http_server.go +++ b/pkg/api/http_server.go @@ -233,6 +233,10 @@ func (hs *HTTPServer) addMiddlewaresAndStaticRoutes() { } func (hs *HTTPServer) metricsEndpoint(ctx *macaron.Context) { + if !hs.Cfg.MetricsEndpointEnabled { + return + } + if ctx.Req.Method != "GET" || ctx.Req.URL.Path != "/metrics" { return } diff --git a/pkg/metrics/service.go b/pkg/metrics/service.go index ec38e0acfec..3d7fa6a1269 100644 --- a/pkg/metrics/service.go +++ b/pkg/metrics/service.go @@ -28,7 +28,6 @@ func init() { type InternalMetricsService struct { Cfg *setting.Cfg `inject:""` - enabled bool intervalSeconds int64 graphiteCfg *graphitebridge.Config } diff --git a/pkg/metrics/settings.go b/pkg/metrics/settings.go index 58b84a7192f..048e4134690 100644 --- a/pkg/metrics/settings.go +++ b/pkg/metrics/settings.go @@ -16,13 +16,8 @@ func (im *InternalMetricsService) readSettings() error { return fmt.Errorf("Unable to find metrics config section %v", err) } - im.enabled = section.Key("enabled").MustBool(false) im.intervalSeconds = section.Key("interval_seconds").MustInt64(10) - if !im.enabled { - return nil - } - if err := im.parseGraphiteSettings(); err != nil { return fmt.Errorf("Unable to parse metrics graphite section, %v", err) } diff --git a/pkg/setting/setting.go b/pkg/setting/setting.go index fb23a192a85..1a253b9b238 100644 --- a/pkg/setting/setting.go +++ b/pkg/setting/setting.go @@ -203,6 +203,8 @@ type Cfg struct { DisableBruteForceLoginProtection bool TempDataLifetime time.Duration + + MetricsEndpointEnabled bool } type CommandLineArgs struct { @@ -659,6 +661,7 @@ func (cfg *Cfg) Load(args *CommandLineArgs) error { cfg.ImagesDir = filepath.Join(DataPath, "png") cfg.PhantomDir = filepath.Join(HomePath, "tools/phantomjs") cfg.TempDataLifetime = iniFile.Section("paths").Key("temp_data_lifetime").MustDuration(time.Second * 3600 * 24) + cfg.MetricsEndpointEnabled = iniFile.Section("metrics").Key("enabled").MustBool(true) analytics := iniFile.Section("analytics") ReportingEnabled = analytics.Key("reporting_enabled").MustBool(true)