Skip to content

Commit

Permalink
Add logs for allowed traffic in L7 NetworkPolicy
Browse files Browse the repository at this point in the history
The solution adds logs with event type http for allowed
traffic in L7 NetworkPolicy. It also adds log support for
DNS, TLS as later supported by L7NP.

Signed-off-by: Qiyue Yao <yaoq@vmware.com>
  • Loading branch information
qiyueyao committed Feb 22, 2024
1 parent cb52631 commit 14056d1
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 3 deletions.
37 changes: 34 additions & 3 deletions docs/antrea-l7-network-policy.md
Original file line number Diff line number Diff line change
Expand Up @@ -292,9 +292,38 @@ spec:

Layer 7 traffic that matches the NetworkPolicy will be logged in an event
triggered log file (`/var/log/antrea/networkpolicy/l7engine/eve-YEAR-MONTH-DAY.json`).
The event type for this log is `alert`. If `enableLogging` is set for the rule,
packets that match the rule will also be logged in addition to the event with
event type `packet`. Below is an example of the two event types.
Logs are categorized by **event_type**. The event type for allowed traffic is `http`,
for dropped traffic is `alert`. If `enableLogging` is set for the rule, dropped packets
that match the rule will also be logged in addition to the event with
event type `packet`. Below are examples for allow, drop, packet scenarios.

Allow ingress from client (10.10.1.8) to web (10.10.1.7/public/*)

```json
{
"timestamp": "2024-02-22T21:26:07.074791+0000",
"flow_id": 757085628206447,
"in_iface": "antrea-l7-tap0",
"event_type": "http",
"vlan": [1],
"src_ip": "10.10.1.8",
"src_port": 44132,
"dest_ip": "10.10.1.7",
"dest_port": 80,
"proto": "TCP",
"tx_id": 0,
"http": {
"hostname": "10.10.1.7",
"url": "/public/main.html",
"http_user_agent": "Wget/1.21.1",
"http_content_type": "text/html",
"http_method": "GET",
"protocol": "HTTP/1.1",
"status": 404,
"length": 153
}
}
```

Deny ingress from client (10.10.1.5) to web (10.10.1.4/admin)

Expand Down Expand Up @@ -341,6 +370,8 @@ Deny ingress from client (10.10.1.5) to web (10.10.1.4/admin)
}
```

Additional packet log when `enableLogging` is set

```json
{
"timestamp": "2023-03-09T20:00:28.225016+0000",
Expand Down
6 changes: 6 additions & 0 deletions pkg/agent/controller/networkpolicy/l7engine/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ outputs:
types:
- alert:
tagged-packets: yes
- http:
extended: yes
- dns:
version: 2
- tls:
extended: yes
- eve-log:
enabled: yes
filetype: unix_stream
Expand Down

0 comments on commit 14056d1

Please sign in to comment.