|
| 1 | +// Module included in the following assemblies: |
| 2 | +// |
| 3 | +// network_observability/metrics-alerts-dashboards.adoc |
| 4 | + |
| 5 | +:_mod-docs-content-type: PROCEDURE |
| 6 | +[id="network-observability-tcp-flag-syn-flood_{context}"] |
| 7 | += Detecting SYN flooding using the FlowMetric API and TCP flags |
| 8 | +You can create an `AlertingRule` resouce to alert for SYN flooding. |
| 9 | + |
| 10 | +.Procedure |
| 11 | +. In the web console, navigate to *Operators* -> *Installed Operators*. |
| 12 | +. In the *Provided APIs* heading for the *NetObserv Operator*, select *FlowMetric*. |
| 13 | +. In the *Project* dropdown list, select the project of the Network Observability Operator instance. |
| 14 | +. Click *Create FlowMetric*. |
| 15 | +. Create `FlowMetric` resources to add the following configurations: |
| 16 | ++ |
| 17 | +.Configuration counting flows per destination host and resource, with TCP flags |
| 18 | +[source,yaml] |
| 19 | +---- |
| 20 | +apiVersion: flows.netobserv.io/v1alpha1 |
| 21 | +kind: FlowMetric |
| 22 | +metadata: |
| 23 | + name: flows-with-flags-per-destination |
| 24 | +spec: |
| 25 | + metricName: flows_with_flags_per_destination_total |
| 26 | + type: Counter |
| 27 | + labels: [SrcSubnetLabel,DstSubnetLabel,DstK8S_Name,DstK8S_Type,DstK8S_HostName,DstK8S_Namespace,Flags] |
| 28 | +---- |
| 29 | ++ |
| 30 | +.Configuration counting flows per source host and resource, with TCP flags |
| 31 | +[source,yaml] |
| 32 | +---- |
| 33 | +apiVersion: flows.netobserv.io/v1alpha1 |
| 34 | +kind: FlowMetric |
| 35 | +metadata: |
| 36 | + name: flows-with-flags-per-source |
| 37 | +spec: |
| 38 | + metricName: flows_with_flags_per_source_total |
| 39 | + type: Counter |
| 40 | + labels: [DstSubnetLabel,SrcSubnetLabel,SrcK8S_Name,SrcK8S_Type,SrcK8S_HostName,SrcK8S_Namespace,Flags] |
| 41 | +---- |
| 42 | +. Deploy the following `AlertingRule` resource to alert for SYN flooding: |
| 43 | ++ |
| 44 | +.`AlertingRule` for SYN flooding |
| 45 | +[source,yaml] |
| 46 | +---- |
| 47 | +apiVersion: monitoring.openshift.io/v1 |
| 48 | +kind: AlertingRule |
| 49 | +metadata: |
| 50 | + name: netobserv-syn-alerts |
| 51 | + namespace: openshift-monitoring |
| 52 | +# ... |
| 53 | + spec: |
| 54 | + groups: |
| 55 | + - name: NetObservSYNAlerts |
| 56 | + rules: |
| 57 | + - alert: NetObserv-SYNFlood-in |
| 58 | + annotations: |
| 59 | + message: |- |
| 60 | + {{ $labels.job }}: incoming SYN-flood attack suspected to Host={{ $labels.DstK8S_HostName}}, Namespace={{ $labels.DstK8S_Namespace }}, Resource={{ $labels.DstK8S_Name }}. This is characterized by a high volume of SYN-only flows with different source IPs and/or ports. |
| 61 | + summary: "Incoming SYN-flood" |
| 62 | + expr: sum(rate(netobserv_flows_with_flags_per_destination_total{Flags="2"}[1m])) by (job, DstK8S_HostName, DstK8S_Namespace, DstK8S_Name) > 300 <1> |
| 63 | + for: 15s |
| 64 | + labels: |
| 65 | + severity: warning |
| 66 | + app: netobserv |
| 67 | + - alert: NetObserv-SYNFlood-out |
| 68 | + annotations: |
| 69 | + message: |- |
| 70 | + {{ $labels.job }}: outgoing SYN-flood attack suspected from Host={{ $labels.SrcK8S_HostName}}, Namespace={{ $labels.SrcK8S_Namespace }}, Resource={{ $labels.SrcK8S_Name }}. This is characterized by a high volume of SYN-only flows with different source IPs and/or ports. |
| 71 | + summary: "Outgoing SYN-flood" |
| 72 | + expr: sum(rate(netobserv_flows_with_flags_per_source_total{Flags="2"}[1m])) by (job, SrcK8S_HostName, SrcK8S_Namespace, SrcK8S_Name) > 300 <1> |
| 73 | + for: 15s |
| 74 | + labels: |
| 75 | + severity: warning |
| 76 | + app: netobserv |
| 77 | +# ... |
| 78 | +---- |
| 79 | +<1> In this example, the threshold for the alert is `300`; however, you can adapt this value empirically. A threshold that is too low might produce false-positives, and if it's too high it might miss actual attacks. |
| 80 | + |
| 81 | +.Verification |
| 82 | +. In the web console, click *Manage Columns* in the *Network Traffic* table view and click *TCP flags*. |
| 83 | +. In the *Network Traffic* table view, filter on *TCP protocol SYN TCPFlag*. A large number of flows with the same *byteSize* indicates a SYN flood. |
| 84 | +. Go to *Observe* -> *Alerting* and select the *Alerting Rules* tab. |
| 85 | +. Filter on *netobserv-synflood-in alert*. The alert should fire when SYN flooding occurs. |
0 commit comments