apiVersion: flows.netobserv.io/v1alpha1
kind: FlowMetric
metadata:
name: flowmetric-cluster-external-ingress-traffic
namespace: netobserv (1)
spec:
metricName: cluster_external_ingress_bytes_total (2)
type: Counter (3)
valueField: Bytes
direction: Ingress (4)
labels: [DstK8S_HostName,DstK8S_Namespace,DstK8S_OwnerName,DstK8S_OwnerType] (5)
filters: (6)
- field: SrcSubnetLabel
matchType: Absence
1 | The FlowMetric resources need to be created in the namespace defined in the FlowCollector spec.namespace , which is netobserv by default. |
2 | The name of the Prometheus metric, which in the web console appears with the prefix netobserv-<metricName> . |
3 | The type specifies the type of metric. The Counter type is useful for counting bytes or packets. |
4 | The direction of traffic to capture. If not specified, both ingress and egress are captured, which can lead to duplicated counts. |
5 | Labels define what the metrics look like and the relationship between the different entities and also define the metrics cardinality. For example, SrcK8S_Name is a high cardinality metric. |
6 | Refines results based on the listed criteria. In this example, selecting only the cluster external traffic is done by matching only flows where SrcSubnetLabel is absent. This assumes the subnet labels feature is enabled (via spec.processor.subnetLabels ), which is done by default. |
-
Once the pods refresh, navigate to Observe → Metrics.
-
In the Expression field, type the metric name to view the corresponding result. You can also enter an expression, such as
topk(5, sum(rate(netobserv_cluster_external_ingress_bytes_total{DstK8S_Namespace="my-namespace"}[2m])) by (DstK8S_HostName, DstK8S_OwnerName, DstK8S_OwnerType))