File tree Expand file tree Collapse file tree
docs-site/src/content/docs/reference Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -197,6 +197,7 @@ awf logs [options]
197197| ` --format <format> ` | string | ` pretty ` | Output format: ` raw ` , ` pretty ` , ` json ` |
198198| ` --source <path> ` | string | auto | Path to log directory or ` running ` for live container |
199199| ` --list ` | flag | ` false ` | List available log sources |
200+ | ` --with-pid ` | flag | ` false ` | Enrich logs with PID/process info (requires ` -f ` ) |
200201
201202#### Output Formats
202203
@@ -226,7 +227,35 @@ awf logs --source /tmp/squid-logs-1234567890
226227
227228# Stream from running container
228229awf logs --source running -f
230+
231+ # Follow logs with PID/process tracking
232+ awf logs -f --with-pid
233+ ```
234+
235+ #### PID Tracking
236+
237+ The ` --with-pid ` flag enriches log entries with process information, correlating each network request to the specific process that made it.
238+
239+ ** Pretty format with PID:**
229240```
241+ [2024-01-01 12:00:00.123] CONNECT api.github.com → 200 (ALLOWED) [curl/7.88.1] <PID:12345 curl>
242+ ```
243+
244+ ** JSON output includes additional fields:**
245+ ``` json
246+ {
247+ "timestamp" : 1703001234.567 ,
248+ "domain" : " github.com" ,
249+ "pid" : 12345 ,
250+ "cmdline" : " curl https://github.com" ,
251+ "comm" : " curl" ,
252+ "inode" : " 123456"
253+ }
254+ ```
255+
256+ ::: caution
257+ PID tracking only works with ` -f ` (follow mode) and requires Linux. Process information is only available while processes are running.
258+ :::
230259
231260::: note
232261Log sources are auto-discovered in this order: running containers, ` AWF_LOGS_DIR ` environment variable, then preserved log directories in ` /tmp/squid-logs-* ` .
Original file line number Diff line number Diff line change @@ -119,6 +119,44 @@ docker exec awf-squid grep "TCP_DENIED" /var/log/squid/access.log | \
119119 awk ' {print $3}' | sort -u > blocked_domains.txt
120120```
121121
122+ ## PID/Process Tracking
123+
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+ ```
133+
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:**
141+ | Field | Description |
142+ | -------| -------------|
143+ | ` pid ` | Process ID that made the request |
144+ | ` cmdline ` | Full command line of the process |
145+ | ` comm ` | Short command name (from ` /proc/[pid]/comm ` ) |
146+ | ` inode ` | Socket inode for advanced correlation |
147+
148+ ### Limitations
149+
150+ - ** Real-time only** : PID tracking requires ` -f ` (follow mode)
151+ - ** Linux only** : Requires ` /proc ` filesystem access
152+ - ** Ephemeral** : Process must still be running; historical logs cannot be enriched
153+
154+ ### Use Cases
155+
156+ - Identify which MCP server or tool made a specific request
157+ - Trace data exfiltration attempts to specific commands
158+ - Audit agent network behavior for compliance
159+
122160## Decision Codes
123161
124162| Code | Meaning | Action |
Original file line number Diff line number Diff line change @@ -519,6 +519,44 @@ awf logs -f --format json
519519awf logs --source /tmp/squid-logs-1760987995318 --format raw
520520` ` `
521521
522+ # ## PID/Process Tracking
523+
524+ Correlate network requests with the specific processes that made them using the `--with-pid` flag. This enables security auditing and forensic analysis.
525+
526+ ` ` ` bash
527+ # Follow logs with PID tracking (requires -f for real-time mode)
528+ awf logs -f --with-pid
529+ ` ` `
530+
531+ **Pretty format output with PID:**
532+ ```
533+ [ 2024-01-01 12:00:00.123] CONNECT api.github.com → 200 (ALLOWED) [ curl/7.88.1] <PID:12345 curl>
534+ ```
535+
536+ **JSON format includes additional PID fields:**
537+ ```json
538+ {
539+ "timestamp": 1703001234.567,
540+ "domain": "github.com",
541+ "statusCode": 200,
542+ "isAllowed": true,
543+ "pid": 12345,
544+ "cmdline": "curl https://github.com",
545+ "comm": "curl",
546+ "inode": "123456"
547+ }
548+ ```
549+
550+ ** Important limitations:**
551+ - ** Real-time only** : ` --with-pid ` requires ` -f ` (follow mode) because PID tracking reads the live ` /proc ` filesystem
552+ - ** Linux only** : PID tracking requires the ` /proc ` filesystem (standard on Linux)
553+ - ** Process must be running** : By the time historical logs are viewed, processes may have exited
554+
555+ ** Use cases:**
556+ - ** Security auditing** : Identify which command or tool made each request
557+ - ** Incident response** : Trace suspicious network activity to specific processes
558+ - ** Debugging** : Correlate MCP server or tool behavior with network requests
559+
522560### Troubleshooting with Logs
523561
524562** Find blocked requests:**
You can’t perform that action at this time.
0 commit comments