HTTP Traffic Logging
HTTP traffic logging allows you to capture and analyze HTTP requests and responses passing through your port forwards.
Currently available in KFtray GUI. Coming soon to KFtui.
Enabling HTTP Logging
- Start Port Forward
- Enable your port forward configuration
- Verify it's running properly
- Enable Logging
- Click the hamburger menu next to your configuration
- Select "Enable HTTP Logging"
- Logs are saved in
$HOME/.kftray/http_logs/{config_id}_{local_port}
Log Format
Example HTTP log entry:
----------------------------------------
Trace ID: 5525d312-5582-46ad-85d1-0fd3710f824e
Request at: 2024-06-13T15:34:09.756706+00:00
Method: GET
Path: /api/users
Version: 1
Headers:
Host: localhost:8080
Connection: keep-alive
Accept: application/json
Body:
<empty>
----------------------------------------
Trace ID: 5525d312-5582-46ad-85d1-0fd3710f824e
Response at: 2024-06-13T15:34:09.901304+00:00
Took: 144 ms
Status: 200
Headers:
Content-Type: application/json
Content-Length: 42
Body:
{
"users": [
{"id": 1, "name": "John"}
]
}
Features
- Request/response correlation with Trace IDs
- Timing information
- Headers and body capture
- Response status tracking
- Human-readable format
Managing Logs
Viewing Logs
- Click the log icon next to your configuration
- Logs open in your default text editor
- Each configuration has its own log file
Cleaning Logs
- Open the main menu
- Click "Prune Logs"
- Confirm to delete all HTTP logs
Use Cases
API Debugging
- Track request/response cycles
- Verify headers
- Validate payload formats
Performance Monitoring
- Check response times
- Identify slow endpoints
- Monitor request patterns
Security Auditing
- Review authentication headers
- Check for sensitive data
- Monitor access patterns
Best Practices
- Regular log cleanup
- Monitor disk usage
- Document logging purposes
- Review sensitive information
Configuration Examples
Basic HTTP Service
{
"service": "api-service",
"namespace": "default",
"local_port": 8080,
"remote_port": 80,
"protocol": "tcp",
"alias": "api",
"http_logging": true
}
Multiple Endpoints
{
"service": "gateway",
"namespace": "default",
"local_port": 3000,
"remote_port": 3000,
"protocol": "tcp",
"alias": "gateway",
"http_logging": true
}
Troubleshooting
Common issues and solutions:
- No Logs Generated
- Verify HTTP logging is enabled
- Check port forward is active
- Confirm traffic is flowing
- Missing Information
- Check content-type headers
- Verify request/response format
- Review logging permissions
- Large Log Files
- Regular cleanup
- Monitor disk space
- Archive important logs