Server Log Analysis
Analyzes local server log files for crawl budget breakdown. No MCP or external calls required.
Inputs
file: Absolute path to server log file (Apache Combined, Apache Common, or Nginx access log).
If user provides relative path, resolve with Bash: realpath <path>.
Execution
Step 1: Format Detection
Read the first 10 lines of the log file to detect format:
- Apache Combined:
%h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-agent}i" — 9+ fields, has referer and UA in quotes
- Apache Common:
%h %l %u %t "%r" %>s %b — 7 fields, no referer/UA
- Nginx: similar to Apache Combined with slight field order differences
- Check for compressed files (.gz) — if detected, inform user to decompress first
Step 2: Parse Log Lines
Use Bash awk to extract fields. For Apache Combined/Nginx format (9 fields):
awk '{
ip=$1; method_url=$7; status=$9; ua=$0
match($0, /"([^"]+)"$/, arr) # Extract UA from last quoted field
print ip, $7, $9, arr[1]
}' logfile
For Apache Common (7 fields): ip=$1, request=$7, status=$9, ua="unknown"
Step 3: Classify User-Agents
Group each request into categories:
- Googlebot:
Googlebot, Googlebot-Image, Googlebot-News, AdsBot-Google
- Bingbot:
bingbot, BingPreview, MicrosoftPreview
- Other search bots:
Slurp (Yahoo), DuckDuckBot, Baiduspider, YandexBot, Sogou
- AI crawlers:
GPTBot, ClaudeBot, PerplexityBot, Bytespider, CCBot, anthropic-ai
- Monitoring tools:
Pingdom, UptimeRobot, StatusCake, NewRelic, Datadog
- Real users: everything else (browsers:
Mozilla, Chrome, Safari, Firefox, Edge)
- Unknown: no UA or unrecognized
Step 4: Calculate Metrics
Using awk/grep on the log file:
- Total request count
- Requests by bot category (count per category, % of total)
- Requests by HTTP status code (200, 301, 302, 404, 500, etc.)
- Top 20 crawled URLs by frequency — sort by count descending
- Top 10 crawled path prefixes (first 2 URL segments, e.g.,
/blog/, /products/) — aggregate by prefix
- Requests by hour-of-day (extract hour from timestamp field
[DD/Mon/YYYY:HH:MM:SS])
Step 5: Identify Crawl Budget Concerns
Flag these patterns:
- 4xx error rate >5%: crawlers wasting budget on broken URLs
- 5xx error rate >1%: server errors burning crawl budget
- Duplicate crawl patterns: same URL crawled >10x without apparent content change
- Low-value paths: bots crawling
/wp-admin, /search?, ?sort=, ?page=, session URLs
- 302 redirect overuse: temporary redirects don't pass full crawl equity
- Non-canonical crawls:
?utm_ or tracking parameters in crawled URLs
Output Format
## Server Log Analysis: [filename]
**File:** [path] | **Format:** [Apache Combined/Common/Nginx] | **Total Requests:** [N]
### Crawl Budget Summary
| Metric | Value |
|--------|-------|
| Total requests | N |
| Bot traffic | N (X%) |
| Human traffic | N (X%) |
| Crawl error rate | X% (4xx+5xx) |
| Date range | [first log entry] to [last log entry] |
### Bot Traffic Breakdown
| Bot Category | Requests | % of Total | Top URL |
|---|---|---|---|
| Googlebot | N | X% | /path |
| Bingbot | N | X% | /path |
| AI Crawlers | N | X% | /path |
| Monitoring | N | X% | /path |
| Real Users | N | X% | — |
| Other/Unknown | N | X% | — |
### Top 20 Crawled URLs
| Rank | URL | Requests | Status Codes |
|------|-----|----------|--------------|
| 1 | /path | N | 200: N, 404: N |
### Crawl Frequency by Path
| Path Prefix | Requests | % of Bot Traffic |
|---|---|---|
| /blog/ | N | X% |
### Status Code Distribution
| Status | Count | % | Interpretation |
|--------|-------|---|----------------|
| 200 | N | X% | OK |
| 301 | N | X% | Permanent redirect |
| 404 | N | X% | Not found (crawl waste) |
### Crawl Budget Recommendations
[Prioritized list of issues found — Critical/High/Medium/Low]
## Data Sources
- Source: Local server log file (no external calls)
1---2name: seo-log-analysis3description: Analyze server log files for crawl budget insights. Reads Apache Combined/Common or Nginx access logs locally (no external calls). Classifies bot vs user traffic, identifies top crawled URLs, crawl frequency by path, and crawl budget concerns. Use when user says "log analysis", "crawl budget", "server logs", "bot traffic", "crawl frequency", "access log", "analyze logs".4---56# Server Log Analysis78Analyzes local server log files for crawl budget breakdown. No MCP or external calls required.910## Inputs1112- `file`: Absolute path to server log file (Apache Combined, Apache Common, or Nginx access log).13 If user provides relative path, resolve with `Bash: realpath <path>`.1415## Execution1617**Step 1: Format Detection**1819Read the first 10 lines of the log file to detect format:20- Apache Combined: `%h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-agent}i"` — 9+ fields, has referer and UA in quotes21- Apache Common: `%h %l %u %t "%r" %>s %b` — 7 fields, no referer/UA22- Nginx: similar to Apache Combined with slight field order differences23- Check for compressed files (.gz) — if detected, inform user to decompress first2425**Step 2: Parse Log Lines**2627Use Bash awk to extract fields. For Apache Combined/Nginx format (9 fields):28```bash29awk '{30 ip=$1; method_url=$7; status=$9; ua=$031 match($0, /"([^"]+)"$/, arr) # Extract UA from last quoted field32 print ip, $7, $9, arr[1]33}' logfile34```35For Apache Common (7 fields): ip=$1, request=$7, status=$9, ua="unknown"3637**Step 3: Classify User-Agents**3839Group each request into categories:40- **Googlebot**: `Googlebot`, `Googlebot-Image`, `Googlebot-News`, `AdsBot-Google`41- **Bingbot**: `bingbot`, `BingPreview`, `MicrosoftPreview`42- **Other search bots**: `Slurp` (Yahoo), `DuckDuckBot`, `Baiduspider`, `YandexBot`, `Sogou`43- **AI crawlers**: `GPTBot`, `ClaudeBot`, `PerplexityBot`, `Bytespider`, `CCBot`, `anthropic-ai`44- **Monitoring tools**: `Pingdom`, `UptimeRobot`, `StatusCake`, `NewRelic`, `Datadog`45- **Real users**: everything else (browsers: `Mozilla`, `Chrome`, `Safari`, `Firefox`, `Edge`)46- **Unknown**: no UA or unrecognized4748**Step 4: Calculate Metrics**4950Using awk/grep on the log file:511. Total request count522. Requests by bot category (count per category, % of total)533. Requests by HTTP status code (200, 301, 302, 404, 500, etc.)544. Top 20 crawled URLs by frequency — sort by count descending555. Top 10 crawled path prefixes (first 2 URL segments, e.g., `/blog/`, `/products/`) — aggregate by prefix566. Requests by hour-of-day (extract hour from timestamp field `[DD/Mon/YYYY:HH:MM:SS]`)5758**Step 5: Identify Crawl Budget Concerns**5960Flag these patterns:61- **4xx error rate >5%**: crawlers wasting budget on broken URLs62- **5xx error rate >1%**: server errors burning crawl budget63- **Duplicate crawl patterns**: same URL crawled >10x without apparent content change64- **Low-value paths**: bots crawling `/wp-admin`, `/search?`, `?sort=`, `?page=`, session URLs65- **302 redirect overuse**: temporary redirects don't pass full crawl equity66- **Non-canonical crawls**: `?utm_` or tracking parameters in crawled URLs6768## Output Format6970```71## Server Log Analysis: [filename]7273**File:** [path] | **Format:** [Apache Combined/Common/Nginx] | **Total Requests:** [N]7475### Crawl Budget Summary7677| Metric | Value |78|--------|-------|79| Total requests | N |80| Bot traffic | N (X%) |81| Human traffic | N (X%) |82| Crawl error rate | X% (4xx+5xx) |83| Date range | [first log entry] to [last log entry] |8485### Bot Traffic Breakdown8687| Bot Category | Requests | % of Total | Top URL |88|---|---|---|---|89| Googlebot | N | X% | /path |90| Bingbot | N | X% | /path |91| AI Crawlers | N | X% | /path |92| Monitoring | N | X% | /path |93| Real Users | N | X% | — |94| Other/Unknown | N | X% | — |9596### Top 20 Crawled URLs9798| Rank | URL | Requests | Status Codes |99|------|-----|----------|--------------|100| 1 | /path | N | 200: N, 404: N |101102### Crawl Frequency by Path103104| Path Prefix | Requests | % of Bot Traffic |105|---|---|---|106| /blog/ | N | X% |107108### Status Code Distribution109110| Status | Count | % | Interpretation |111|--------|-------|---|----------------|112| 200 | N | X% | OK |113| 301 | N | X% | Permanent redirect |114| 404 | N | X% | Not found (crawl waste) |115116### Crawl Budget Recommendations117118[Prioritized list of issues found — Critical/High/Medium/Low]119120## Data Sources121122- Source: Local server log file (no external calls)123```