From 18d03d99d360e6c362bf22dd17790674d14c1a7b Mon Sep 17 00:00:00 2001 From: zoues Date: Wed, 22 Mar 2017 22:34:44 +0800 Subject: [PATCH] change buildDS param --- controllers/nginx/pkg/metric/collector/nginx.go | 8 ++++++-- controllers/nginx/pkg/metric/collector/vts.go | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/controllers/nginx/pkg/metric/collector/nginx.go b/controllers/nginx/pkg/metric/collector/nginx.go index 944eb920d..a51b7de39 100644 --- a/controllers/nginx/pkg/metric/collector/nginx.go +++ b/controllers/nginx/pkg/metric/collector/nginx.go @@ -18,6 +18,7 @@ package collector import ( "fmt" + "strings" "github.com/golang/glog" "github.com/prometheus/client_golang/prometheus" @@ -42,13 +43,16 @@ type ( } ) -func buildNS(namespace, class string) string { +func buildNS(system, namespace, class string) string { if namespace == "" { namespace = "all" } if class == "" { class = "all" } + if strings.Compare(system, namespace) == 1 { + namespace = "" + } return fmt.Sprintf("%v_%v", namespace, class) } @@ -61,7 +65,7 @@ func NewNginxStatus(namespace, class string, ngxHealthPort int, ngxVtsPath strin ngxVtsPath: ngxVtsPath, } - ns := buildNS(namespace, class) + ns := buildNS(system, namespace, class) p.data = &nginxStatusData{ active: prometheus.NewDesc( diff --git a/controllers/nginx/pkg/metric/collector/vts.go b/controllers/nginx/pkg/metric/collector/vts.go index 4d80d66c4..9ec488cb9 100644 --- a/controllers/nginx/pkg/metric/collector/vts.go +++ b/controllers/nginx/pkg/metric/collector/vts.go @@ -62,7 +62,7 @@ func NewNGINXVTSCollector(namespace, class string, ngxHealthPort int, ngxVtsPath ngxVtsPath: ngxVtsPath, } - ns := buildNS(namespace, class) + ns := buildNS(system, namespace, class) p.data = &vtsData{ bytes: prometheus.NewDesc(