diff --git a/controllers/nginx/pkg/metric/collector/nginx.go b/controllers/nginx/pkg/metric/collector/nginx.go index 944eb920d..9fc58952d 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" @@ -46,10 +47,15 @@ func buildNS(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) }