@@ -77,28 +77,20 @@ func NewTopologyQuery(cfg *Config, start, end, limit, rateInterval, step string,
7777 }, nil
7878}
7979
80- func getLabels (aggregate , groups string ) string {
81- var fields []string
82- switch aggregate {
83- case "app" :
84- fields = []string {"app" }
85- case "droppedState" :
86- fields = []string {"PktDropLatestState" }
87- case "droppedCause" :
88- fields = []string {"PktDropLatestDropCause" }
89- case "dnsRCode" :
90- fields = []string {"DnsFlagsResponseCode" }
91- case "host" :
92- fields = []string {"SrcK8S_HostName" , "DstK8S_HostName" }
93- case "namespace" :
94- fields = []string {"SrcK8S_Namespace" , "DstK8S_Namespace" }
95- case "owner" :
96- fields = []string {"SrcK8S_OwnerName" , "SrcK8S_OwnerType" , "DstK8S_OwnerName" , "DstK8S_OwnerType" , "SrcK8S_Namespace" , "DstK8S_Namespace" }
97- default :
98- fields = []string {"SrcK8S_Name" , "SrcK8S_Type" , "SrcK8S_OwnerName" , "SrcK8S_OwnerType" , "SrcK8S_Namespace" , "SrcAddr" , "SrcK8S_HostName" , "DstK8S_Name" , "DstK8S_Type" , "DstK8S_OwnerName" , "DstK8S_OwnerType" , "DstK8S_Namespace" , "DstAddr" , "DstK8S_HostName" }
99- }
100-
80+ func manageGroupLabels (fields []string , groups string ) []string {
10181 if len (groups ) > 0 {
82+ if strings .Contains (groups , "clusters" ) {
83+ if ! utils .Contains (fields , "K8S_ClusterName" ) {
84+ fields = append (fields , "K8S_ClusterName" )
85+ }
86+ }
87+
88+ if strings .Contains (groups , "zones" ) {
89+ if ! utils .Contains (fields , "SrcK8S_Zone" ) {
90+ fields = append (fields , "SrcK8S_Zone" , "DstK8S_Zone" )
91+ }
92+ }
93+
10294 if strings .Contains (groups , "hosts" ) {
10395 if ! utils .Contains (fields , "SrcK8S_HostName" ) {
10496 fields = append (fields , "SrcK8S_HostName" , "DstK8S_HostName" )
@@ -117,7 +109,34 @@ func getLabels(aggregate, groups string) string {
117109 }
118110 }
119111 }
112+ return fields
113+ }
120114
115+ func getLabels (aggregate , groups string ) string {
116+ var fields []string
117+ switch aggregate {
118+ case "app" :
119+ fields = []string {"app" }
120+ case "droppedState" :
121+ fields = []string {"PktDropLatestState" }
122+ case "droppedCause" :
123+ fields = []string {"PktDropLatestDropCause" }
124+ case "dnsRCode" :
125+ fields = []string {"DnsFlagsResponseCode" }
126+ case "cluster" :
127+ fields = []string {"K8S_ClusterName" }
128+ case "zone" :
129+ fields = []string {"SrcK8S_Zone" , "DstK8S_Zone" }
130+ case "host" :
131+ fields = []string {"SrcK8S_HostName" , "DstK8S_HostName" }
132+ case "namespace" :
133+ fields = []string {"SrcK8S_Namespace" , "DstK8S_Namespace" }
134+ case "owner" :
135+ fields = []string {"SrcK8S_OwnerName" , "SrcK8S_OwnerType" , "DstK8S_OwnerName" , "DstK8S_OwnerType" , "SrcK8S_Namespace" , "DstK8S_Namespace" }
136+ default :
137+ fields = []string {"SrcK8S_Name" , "SrcK8S_Type" , "SrcK8S_OwnerName" , "SrcK8S_OwnerType" , "SrcK8S_Namespace" , "SrcAddr" , "SrcK8S_HostName" , "DstK8S_Name" , "DstK8S_Type" , "DstK8S_OwnerName" , "DstK8S_OwnerType" , "DstK8S_Namespace" , "DstAddr" , "DstK8S_HostName" }
138+ }
139+ fields = manageGroupLabels (fields , groups )
121140 return strings .Join (fields [:], "," )
122141}
123142
0 commit comments