@@ -88,6 +88,7 @@ type Command struct {
88
88
disableMetrics bool
89
89
telemetryProject string
90
90
telemetryPrefix string
91
+ prometheus bool
91
92
prometheusNamespace string
92
93
healthCheck bool
93
94
httpPort string
@@ -184,8 +185,10 @@ the maximum time has passed. Defaults to 0s.`)
184
185
"Disable Cloud Monitoring integration (used with telemetry-project)" )
185
186
cmd .PersistentFlags ().StringVar (& c .telemetryPrefix , "telemetry-prefix" , "" ,
186
187
"Prefix to use for Cloud Monitoring metrics." )
188
+ cmd .PersistentFlags ().BoolVar (& c .prometheus , "prometheus" , false ,
189
+ "Enable Prometheus HTTP endpoint /metrics" )
187
190
cmd .PersistentFlags ().StringVar (& c .prometheusNamespace , "prometheus-namespace" , "" ,
188
- "Enable Prometheus for metric collection using the provided namespace" )
191
+ "Use the provided Prometheus namespace for metrics " )
189
192
cmd .PersistentFlags ().StringVar (& c .httpPort , "http-port" , "9090" ,
190
193
"Port for the Prometheus server to use" )
191
194
cmd .PersistentFlags ().BoolVar (& c .healthCheck , "health-check" , false ,
@@ -247,8 +250,8 @@ func parseConfig(cmd *Command, conf *proxy.Config, args []string) error {
247
250
cmd .logger .Infof ("Using API Endpoint %v" , conf .APIEndpointURL )
248
251
}
249
252
250
- if userHasSet ("http-port" ) && ! userHasSet ("prometheus-namespace " ) && ! userHasSet ("health-check" ) {
251
- cmd .logger .Infof ("Ignoring --http-port because --prometheus-namespace or --health-check was not set" )
253
+ if userHasSet ("http-port" ) && ! userHasSet ("prometheus" ) && ! userHasSet ("health-check" ) {
254
+ cmd .logger .Infof ("Ignoring --http-port because --prometheus or --health-check was not set" )
252
255
}
253
256
254
257
if ! userHasSet ("telemetry-project" ) && userHasSet ("telemetry-prefix" ) {
@@ -367,7 +370,7 @@ func runSignalWrapper(cmd *Command) error {
367
370
needsHTTPServer bool
368
371
mux = http .NewServeMux ()
369
372
)
370
- if cmd .prometheusNamespace != "" {
373
+ if cmd .prometheus {
371
374
needsHTTPServer = true
372
375
e , err := prometheus .NewExporter (prometheus.Options {
373
376
Namespace : cmd .prometheusNamespace ,
0 commit comments