|
43 | 43 | "namespace_drop_packets_total", |
44 | 44 | "namespace_rtt_seconds", |
45 | 45 | "namespace_dns_latency_seconds", |
| 46 | + "namespace_network_policy_events_total", |
46 | 47 | } |
47 | 48 | // More metrics enabled when Loki is disabled, to avoid loss of information |
48 | 49 | DefaultIncludeListLokiDisabled = []string{ |
|
57 | 58 | "workload_drop_packets_total", |
58 | 59 | "workload_rtt_seconds", |
59 | 60 | "workload_dns_latency_seconds", |
| 61 | + "namespace_network_policy_events_total", |
60 | 62 | } |
61 | 63 | // Pre-deprecation default IgnoreTags list (1.4) - used before switching to whitelist approach, |
62 | 64 | // to make sure there is no unintended new metrics being collected |
@@ -163,6 +165,28 @@ func init() { |
163 | 165 | }, |
164 | 166 | tags: []string{group, "dns"}, |
165 | 167 | }) |
| 168 | + |
| 169 | + // Netpol metrics |
| 170 | + netpolLabels := labels |
| 171 | + netpolLabels = append(netpolLabels, "NetworkEvents>Type", "NetworkEvents>Namespace", "NetworkEvents>Name", "NetworkEvents>Action", "NetworkEvents>Direction") |
| 172 | + predefinedMetrics = append(predefinedMetrics, taggedMetricDefinition{ |
| 173 | + FlowMetricSpec: metricslatest.FlowMetricSpec{ |
| 174 | + MetricName: fmt.Sprintf("%s_network_policy_events_total", groupTrimmed), |
| 175 | + Type: "counter", |
| 176 | + Labels: netpolLabels, |
| 177 | + Filters: []metricslatest.MetricFilter{{Field: "NetworkEvents>Feature", Value: "acl"}}, |
| 178 | + Flatten: []string{"NetworkEvents"}, |
| 179 | + Remap: map[string]string{ |
| 180 | + "NetworkEvents>Type": "type", |
| 181 | + "NetworkEvents>Namespace": "namespace", |
| 182 | + "NetworkEvents>Name": "name", |
| 183 | + "NetworkEvents>Action": "action", |
| 184 | + "NetworkEvents>Direction": "direction", |
| 185 | + }, |
| 186 | + Charts: netpolCharts(group), |
| 187 | + }, |
| 188 | + tags: []string{group, "network-policy"}, |
| 189 | + }) |
166 | 190 | } |
167 | 191 | } |
168 | 192 |
|
@@ -253,6 +277,9 @@ func GetIncludeList(spec *flowslatest.FlowCollectorSpec) []string { |
253 | 277 | if !helper.IsDNSTrackingEnabled(&spec.Agent.EBPF) { |
254 | 278 | list = removeMetricsByPattern(list, "_dns_") |
255 | 279 | } |
| 280 | + if !helper.IsNetworkEventsEnabled(&spec.Agent.EBPF) { |
| 281 | + list = removeMetricsByPattern(list, "_network_policy_") |
| 282 | + } |
256 | 283 | return list |
257 | 284 | } |
258 | 285 |
|
|
0 commit comments