Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc-site/docs/reference/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ title: Configuration Reference
|Key|Description|Type|Default Value|
|---|-----------|----|-------------|
|address|The IP address on which the metrics HTTP API should listen|`int`|`127.0.0.1`
|enabled|Enables the metrics API|`boolean`|`true`
|enabled|Enables the metrics API|`boolean`|`false`
|metricsPath|The path from which to serve the Prometheus metrics|`string`|`/metrics`
|port|The port on which the metrics HTTP API should listen|`int`|`6000`
|publicURL|The fully qualified public URL for the metrics API. This is used for building URLs in HTTP responses and in OpenAPI Spec generation|URL `string`|`<nil>`
Expand Down
2 changes: 1 addition & 1 deletion internal/apiserver/metrics_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ func initDeprecatedMetricsConfig(config config.Section) {
}

func initMonitoringConfig(config config.Section) {
config.AddKnownKey(Enabled, true)
config.AddKnownKey(Enabled, false)
config.AddKnownKey(MetricsPath, "/metrics")
}
21 changes: 11 additions & 10 deletions internal/apiserver/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,17 +115,18 @@ func (as *apiServer) Serve(ctx context.Context, mgr namespace.Manager) (err erro
} else if config.GetBool(coreconfig.LegacyAdminEnabled) {
log.L(ctx).Warnf("Your config includes an 'admin' section, which should be renamed to 'spi' - SPI server will not be enabled until this is corrected")
}
serverName := "metrics"
mConfig := deprecatedMetricsConfig
if as.monitoringEnabled {
serverName = "monitoring"
mConfig = monitoringConfig
}

if as.deprecatedMetricsEnabled || as.monitoringEnabled {
monitoringServer, err := httpserver.NewHTTPServer(ctx, serverName, as.createMonitoringMuxRouter(), metricsErrChan, mConfig, corsConfig, &httpserver.ServerOptions{
MaximumRequestTimeout: as.apiMaxTimeout,
})
var monitoringServer httpserver.HTTPServer
var err error
if as.monitoringEnabled {
monitoringServer, err = httpserver.NewHTTPServer(ctx, "monitoring", as.createMonitoringMuxRouter(), metricsErrChan, monitoringConfig, corsConfig, &httpserver.ServerOptions{
MaximumRequestTimeout: as.apiMaxTimeout,
})
} else {
monitoringServer, err = httpserver.NewHTTPServer(ctx, "metrics", as.createMonitoringMuxRouter(), metricsErrChan, deprecatedMetricsConfig, corsConfig, &httpserver.ServerOptions{
MaximumRequestTimeout: as.apiMaxTimeout,
})
}
if err != nil {
return err
}
Expand Down