Skip to content

Commit 8976c66

Browse files
docs: add awf logs command documentation (#551)
1 parent ac4e638 commit 8976c66

2 files changed

Lines changed: 99 additions & 41 deletions

File tree

docs/logging_quickref.md

Lines changed: 83 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,86 @@
11
# Logging Quick Reference
22

3-
## View Logs
3+
## Using the AWF CLI
4+
5+
The firewall includes a built-in `awf logs` command for viewing and analyzing Squid proxy logs:
6+
7+
### View Logs in Real-Time
8+
9+
```bash
10+
# Follow logs in real-time (like tail -f)
11+
awf logs -f
12+
13+
# Follow with PID tracking to identify which process made each request
14+
awf logs -f --with-pid
15+
16+
# Follow with JSON output
17+
awf logs -f --format json
18+
```
19+
20+
### View Historical Logs
21+
22+
```bash
23+
# View logs from last run (pretty format, default)
24+
awf logs
25+
26+
# View logs from specific directory
27+
awf logs --source /tmp/squid-logs-1234567890
28+
29+
# Raw format (no colorization)
30+
awf logs --format raw
31+
32+
# JSON format for scripting
33+
awf logs --format json
34+
```
35+
36+
### List Available Log Sources
37+
38+
```bash
39+
# Find all preserved log directories
40+
awf logs --list
41+
```
42+
43+
### Generate Statistics
44+
45+
```bash
46+
# Show aggregated stats (pretty terminal output)
47+
awf logs stats
48+
49+
# JSON format for scripting
50+
awf logs stats --format json
51+
52+
# Markdown format
53+
awf logs stats --format markdown
54+
```
55+
56+
### Generate Summary for GitHub Actions
57+
58+
```bash
59+
# Add summary to GitHub Actions step summary
60+
awf logs summary >> $GITHUB_STEP_SUMMARY
61+
62+
# Also available in JSON and pretty formats
63+
awf logs summary --format json
64+
```
65+
66+
**CLI Options:**
67+
| Flag | Description |
68+
|------|-------------|
69+
| `-f, --follow` | Follow log output in real-time (like `tail -f`) |
70+
| `--format <format>` | Output format: `raw`, `pretty`, `json` |
71+
| `--source <path>` | Path to log directory or `"running"` for live container |
72+
| `--list` | List available log sources |
73+
| `--with-pid` | Enrich logs with PID/process info (requires `-f`) |
74+
75+
**Statistics Commands:**
76+
| Command | Description |
77+
|---------|-------------|
78+
| `awf logs stats` | Show aggregated statistics (total requests, allowed/denied counts, per-domain breakdown) |
79+
| `awf logs summary` | Generate markdown summary (optimized for GitHub Actions) |
80+
81+
## Manual Docker Commands
82+
83+
For advanced use cases or when the CLI is not available, you can access logs directly via Docker:
484

585
### HTTP/HTTPS Traffic (Squid)
686
```bash
@@ -121,23 +201,9 @@ docker exec awf-squid grep "TCP_DENIED" /var/log/squid/access.log | \
121201

122202
## PID/Process Tracking
123203

124-
Correlate network requests with specific processes using `awf logs -f --with-pid`:
125-
126-
```bash
127-
# Follow logs with PID tracking (real-time only)
128-
awf logs -f --with-pid
129-
130-
# Example output:
131-
# [2024-01-01 12:00:00.123] CONNECT api.github.com → 200 (ALLOWED) [curl/7.88.1] <PID:12345 curl>
132-
```
204+
The `awf logs` command supports real-time PID tracking using the `--with-pid` flag (see "Using the AWF CLI" section above for examples).
133205

134-
### JSON Output with PID
135-
136-
```bash
137-
awf logs -f --with-pid --format json
138-
```
139-
140-
**Additional fields when `--with-pid` is enabled:**
206+
When enabled, logs include:
141207
| Field | Description |
142208
|-------|-------------|
143209
| `pid` | Process ID that made the request |
@@ -226,30 +292,6 @@ docker exec awf-squid grep "curl" /var/log/squid/access.log
226292

227293
## Statistics
228294

229-
### Using `awf logs stats`
230-
231-
Get aggregated statistics including total requests, allowed/denied counts, and per-domain breakdown:
232-
233-
```bash
234-
# Pretty terminal output (default)
235-
awf logs stats
236-
237-
# JSON format for scripting
238-
awf logs stats --format json
239-
240-
# Markdown format
241-
awf logs stats --format markdown
242-
```
243-
244-
### Using `awf logs summary` for GitHub Actions
245-
246-
Generate a markdown summary optimized for GitHub Actions step summaries:
247-
248-
```bash
249-
# Add summary to GitHub Actions step summary
250-
awf logs summary >> $GITHUB_STEP_SUMMARY
251-
```
252-
253295
### Manual Statistics Queries
254296

255297
#### Total Requests

docs/usage.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,22 @@ Options:
4444
4545
Arguments:
4646
command Command to execute (wrap in quotes, use -- separator)
47+
48+
Commands:
49+
logs [options] View and analyze Squid proxy logs
50+
-f, --follow Follow log output in real-time (like tail -f)
51+
--format <format> Output format: raw, pretty (colorized), json
52+
--source <path> Path to log directory or "running" for live container
53+
--list List available log sources
54+
--with-pid Enrich logs with PID/process info (requires -f)
55+
56+
logs stats [options] Show aggregated statistics from firewall logs
57+
--format <format> Output format: json, markdown, pretty
58+
--source <path> Path to log directory or "running" for live container
59+
60+
logs summary [options] Generate summary report (markdown by default)
61+
--format <format> Output format: json, markdown, pretty
62+
--source <path> Path to log directory or "running" for live container
4763
```
4864

4965
## Basic Examples

0 commit comments

Comments
 (0)