Allow to disable NGINX metrics

This commit is contained in:
Manuel Alejandro de Brito Fontes 2018-12-04 16:59:54 -03:00
parent c4ba23832a
commit 06d33c16b5
No known key found for this signature in database
GPG key ID: 786136016A8BA02A
9 changed files with 42 additions and 9 deletions

View file

@ -147,6 +147,9 @@ Requires the update-status parameter.`)
`Dynamically update SSL certificates instead of reloading NGINX.
Feature backed by OpenResty Lua libraries. Requires that OCSP stapling is not enabled`)
enableMetrics = flags.Bool("enable-metrics", true,
`Enables the collection of NGINX metrics`)
httpPort = flags.Int("http-port", 80, `Port to use for servicing HTTP traffic.`)
httpsPort = flags.Int("https-port", 443, `Port to use for servicing HTTPS traffic.`)
statusPort = flags.Int("status-port", 18080, `Port to use for exposing NGINX status pages.`)
@ -223,6 +226,7 @@ Feature backed by OpenResty Lua libraries. Requires that OCSP stapling is not en
UpdateStatus: *updateStatus,
ElectionID: *electionID,
EnableProfiling: *profiling,
EnableMetrics: *enableMetrics,
EnableSSLPassthrough: *enableSSLPassthrough,
EnableSSLChainCompletion: *enableSSLChainCompletion,
ResyncPeriod: *resyncPeriod,

View file

@ -128,9 +128,12 @@ func main() {
ReportErrors: true,
}))
mc, err := metric.NewCollector(conf.ListenPorts.Status, reg)
if err != nil {
glog.Fatalf("Error creating prometheus collector: %v", err)
mc := metric.NewDummyCollector()
if conf.EnableMetrics {
mc, err = metric.NewCollector(conf.ListenPorts.Status, reg)
if err != nil {
glog.Fatalf("Error creating prometheus collector: %v", err)
}
}
mc.Start()