|
| 1 | +// Module included in the following assemblies: |
| 2 | +// |
| 3 | +// * observability/network_observability/mertics-alerts-dashboards.adoc |
| 4 | + |
| 5 | +:_mod-docs-content-type: PROCEDURE |
| 6 | +[id="network-observability-creating-metrics-network-events_{context}"] |
| 7 | += Creating metrics from nested or array fields in the Traffic flows table |
| 8 | + |
| 9 | +:FeatureName: OVN Observability / Viewing `NetworkEvents` |
| 10 | +include::snippets/technology-preview.adoc[] |
| 11 | +[IMPORTANT] |
| 12 | +==== |
| 13 | +OVN Observability and the ability to view and track network events is available only in {product-title} 4.17 and 4.18. |
| 14 | +==== |
| 15 | +You can create a `FlowMetric` resource to generate metrics for nested or array fields in the *Traffic flows* table, such as *Network events* or *Interfaces*. The following example shows how to generate metrics from the *Network events* field for network policy events. |
| 16 | + |
| 17 | +.Prerequsities |
| 18 | +* Enable `NetworkEvents feature`. See the Additional resources for how to do this. |
| 19 | +* A network policy specified. |
| 20 | + |
| 21 | +.Procedure |
| 22 | +. In the web console, navigate to *Operators* -> *Installed Operators*. |
| 23 | +. In the *Provided APIs* heading for the *NetObserv Operator*, select *FlowMetric*. |
| 24 | +. In the *Project* dropdown list, select the project of the Network Observability Operator instance. |
| 25 | +. Click *Create FlowMetric*. |
| 26 | +. Create `FlowMetric` resources to add the following configurations: |
| 27 | ++ |
| 28 | +.Configuration counting network policy events per policy name and namespace |
| 29 | +[source,yaml] |
| 30 | +---- |
| 31 | +apiVersion: flows.netobserv.io/v1alpha1 |
| 32 | +kind: FlowMetric |
| 33 | +metadata: |
| 34 | + name: network-policy-events |
| 35 | + namespace: netobserv |
| 36 | +spec: |
| 37 | + metricName: network_policy_events_total |
| 38 | + type: Counter |
| 39 | + labels: [NetworkEvents>Type, NetworkEvents>Namespace, NetworkEvents>Name, NetworkEvents>Action, NetworkEvents>Direction] <1> |
| 40 | + filters: |
| 41 | + - field: NetworkEvents>Feature |
| 42 | + value: acl |
| 43 | + flatten: [NetworkEvents] <2> |
| 44 | + remap: <3> |
| 45 | + "NetworkEvents>Type": type |
| 46 | + "NetworkEvents>Namespace": namespace |
| 47 | + "NetworkEvents>Name": name |
| 48 | + "NetworkEvents>Direction": direction |
| 49 | +---- |
| 50 | +<1> These labels represent the nested fields for *Network Events* from the *Traffic flows* table. Each network event has a specific type, namespace, name, action, and direction. You can alternatively specify the `Interfaces` if `NetworkEvents` is unavailable in your {product-title} version. |
| 51 | +<2> Optional: You can choose to represent a field that contains a list of items as distinct items. |
| 52 | +<3> Optional: You can rename the fields in Prometheus. |
| 53 | + |
| 54 | +.Verification |
| 55 | +. In the web console, navigate to *Observe* -> *Dashboards* and scroll down to see the *Network Policy* tab. |
| 56 | +. You should begin seeing metrics filter in based on the metric you created along with the network policy specifications. |
0 commit comments