Fix nginx stats

This commit is contained in:
Manuel de Brito Fontes 2017-08-31 14:19:32 -03:00
parent abc53ccfc5
commit 57a18d11bd
5 changed files with 22 additions and 32 deletions

View file

@ -24,7 +24,7 @@ import (
)
const (
ngxStatusPath = "/internal_nginx_status"
ngxStatusPath = "/nginx_status"
ngxVtsPath = "/nginx_status/format/json"
)
@ -46,7 +46,7 @@ type statsCollector struct {
namespace string
watchClass string
healthPort int
port int
}
func (s *statsCollector) stop(sm statusModule) {
@ -63,18 +63,19 @@ func (s *statsCollector) stop(sm statusModule) {
func (s *statsCollector) start(sm statusModule) {
switch sm {
case defaultStatusModule:
s.basic = collector.NewNginxStatus(s.namespace, s.watchClass, s.healthPort, ngxStatusPath)
s.basic = collector.NewNginxStatus(s.namespace, s.watchClass, s.port, ngxStatusPath)
prometheus.Register(s.basic)
break
case vtsStatusModule:
s.vts = collector.NewNGINXVTSCollector(s.namespace, s.watchClass, s.healthPort, ngxVtsPath)
s.vts = collector.NewNGINXVTSCollector(s.namespace, s.watchClass, s.port, ngxVtsPath)
prometheus.Register(s.vts)
break
}
}
func newStatsCollector(ns, class, binary string, hz int) *statsCollector {
func newStatsCollector(ns, class, binary string, port int) *statsCollector {
glog.Infof("starting new nginx stats collector for Ingress controller running in namespace %v (class %v)", ns, class)
glog.Infof("collector extracting information from port %v", port)
pc, err := collector.NewNamedProcess(true, collector.BinaryNameMatcher{
Name: "nginx",
Binary: binary,
@ -91,6 +92,6 @@ func newStatsCollector(ns, class, binary string, hz int) *statsCollector {
namespace: ns,
watchClass: class,
process: pc,
healthPort: hz,
port: port,
}
}

View file

@ -372,7 +372,11 @@ func (n *NGINXController) OverrideFlags(flags *pflag.FlagSet) {
}
flags.Set("ingress-class", ic)
n.stats = newStatsCollector(wc, ic, n.binary, n.ports.Health)
h, _ := flags.GetInt("healthz-port")
n.ports.Health = h
n.stats = newStatsCollector(wc, ic, n.binary, n.ports.Status)
if n.isSSLPassthroughEnabled {
if !isPortAvailable(n.ports.SSLProxy) {