# Apache & Nginx Log Parser (`automation-lab/apache-log-parser`) Actor

Parse Apache, Nginx, and IIS access logs into structured JSON. Extracts IPs, timestamps, HTTP methods, paths, status codes, bytes, user agents, and referrers. Includes traffic analytics.

- **URL**: https://apify.com/automation-lab/apache-log-parser.md
- **Developed by:** [Stas Persiianenko](https://apify.com/automation-lab) (community)
- **Categories:** Developer tools, Other
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, NaN bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per event

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

Learn more: https://docs.apify.com/platform/actors/running/actors-in-store#pay-per-event

## What's an Apify Actor?

Actors are a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp.md).

If your project is in a different language, use the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).


# README

## 🪵 Apache & Nginx Log Parser

**Parse Apache access logs, Nginx logs, and IIS W3C logs in seconds.** Extract structured data — IP addresses, timestamps, HTTP methods, paths, status codes, user agents — and get instant traffic analytics without installing any tools.

No proxy required. No web scraping. Pure computation.

---

### 🔍 What does it do?

Apache & Nginx Log Parser reads raw access log files and converts them into clean, structured records you can filter, sort, and export. It works with:

- **Apache Combined Log Format** (the default for most Apache 2.x installs)
- **Nginx access logs** (same format by default)
- **Common Log Format (CLF)** — legacy Apache without referrer/user-agent
- **IIS W3C Extended Log Format** — Microsoft IIS server logs

Give it a log file URL or paste raw log content, and it returns:

1. **One structured record per log line** — IP, timestamp (ISO 8601), method, path, status code, response bytes, referrer, user agent
2. **A summary record** — top pages, top IPs, status code distribution, hourly traffic breakdown, top user agents, HTTP method breakdown

---

### 👤 Who is it for?

#### 🔧 SEO Auditors
Identify your top crawled pages, detect Googlebot activity, find 404s and redirect chains — all from raw access logs without Google Analytics or Search Console.

#### 🖥️ DevOps & SysAdmins
Quickly diagnose traffic spikes, identify bad bots hammering your server, find which endpoints are slowest, and spot error patterns — without SSH access or log aggregation tools.

#### 📊 Data Analysts
Load access logs into your data pipeline, spreadsheet, or BI tool. Get structured JSON out of messy log text in one step.

#### 🛡️ Security Analysts
Find brute force attempts, unusual IP patterns, and suspicious user agents from raw access logs with no special software.

---

### 💡 Why use Apache & Nginx Log Parser?

Traditional log analysis requires command-line tools (`awk`, `grep`, `GoAccess`, `AWStats`) or a full ELK stack. This actor:

- ✅ Works in your browser — no SSH, no terminal
- ✅ Outputs clean JSON you can download, query via API, or pipe into n8n/Make
- ✅ Auto-detects log format — no configuration needed
- ✅ Handles large log files (millions of lines) efficiently
- ✅ Integrates with Apify's dataset storage — keep your analysis history
- ✅ Zero proxy cost — pure computation, no web requests to target sites

---

### 📋 What data is extracted?

Each parsed log line produces a structured record:

| Field | Type | Description |
|-------|------|-------------|
| `ip` | string | Client IP address |
| `timestamp` | string | Raw timestamp from log (e.g. `10/Oct/2000:13:55:36 -0700`) |
| `timestampIso` | string | ISO 8601 timestamp (e.g. `2000-10-10T13:55:36-07:00`) |
| `method` | string | HTTP method (`GET`, `POST`, `PUT`, `DELETE`, etc.) |
| `path` | string | Request path (may include query string) |
| `protocol` | string | HTTP protocol (`HTTP/1.0`, `HTTP/1.1`, `HTTP/2`) |
| `statusCode` | number | HTTP status code (200, 301, 404, 500, etc.) |
| `responseBytes` | number | Response size in bytes |
| `referrer` | string | HTTP Referer header value |
| `userAgent` | string | User-Agent header value |
| `logFormat` | string | Detected format (`apache_combined`, `common`, `iis_w3c`) |
| `parseError` | string | Error message if the line couldn't be parsed |
| `rawLine` | string | Original raw log line |

Plus a **summary record** (when `includeStats: true`):

| Field | Description |
|-------|-------------|
| `topPages` | Top N most-requested paths |
| `topIPs` | Top N most-active IP addresses |
| `statusCodes` | Count per HTTP status code |
| `hourlyTraffic` | Request count per hour |
| `topUserAgents` | Top N user agent strings |
| `topMethods` | HTTP method distribution |

---

### 💰 How much does it cost to parse Apache logs?

This actor uses **Pay-Per-Event (PPE) pricing** — you only pay for what you use:

| Event | FREE tier | DIAMOND tier |
|-------|-----------|--------------|
| **Run start** | $0.005 | $0.0025 |
| **Per 1,000 log lines** | $0.008 | $0.004 |

#### Example costs

| File size | Lines | Estimated cost (FREE) |
|-----------|-------|-----------------------|
| Small log | 1,000 lines | ~$0.013 |
| Medium log | 10,000 lines | ~$0.085 |
| Large log | 100,000 lines | ~$0.805 |
| Huge log (1M lines) | 1,000,000 | ~$8.005 |

Parsing is pure computation with zero proxy cost — the only expense is the nominal per-batch charge.

Use `maxLines` to cap processing and control costs on very large files.

---

### 🚀 How to use it

#### Step 1 — Provide your log data

**Option A: Paste log content**
Set `logText` to your raw log lines. Ideal for small snippets or when testing.

**Option B: Fetch from URL**
Set `logUrl` to any publicly accessible log file URL. The actor fetches it over HTTP — no auth or proxy needed.

#### Step 2 — Choose format (optional)

Leave `logFormat` as `auto` to detect automatically. Set it explicitly if auto-detection fails:
- `apache_combined` — Apache Combined Log Format
- `nginx` — Nginx access log (same as Apache Combined by default)
- `common` — Common Log Format (CLF), no referrer/user-agent
- `iis_w3c` — IIS W3C Extended Log Format

#### Step 3 — Run and download results

Results are saved to the actor's dataset. Download as JSON, CSV, or JSONL — or query them via the Apify API.

---

### ⚙️ Input parameters

| Parameter | Type | Default | Description |
|-----------|------|---------|-------------|
| `logText` | string | — | Paste raw log lines directly |
| `logUrl` | string | — | URL of a log file to fetch |
| `logFormat` | string | `auto` | Log format: `auto`, `apache_combined`, `nginx`, `common`, `iis_w3c` |
| `maxLines` | integer | `0` (unlimited) | Max lines to parse (0 = parse all) |
| `includeStats` | boolean | `true` | Include summary statistics record |
| `topN` | integer | `10` | How many entries in top-N summaries |

Either `logText` or `logUrl` is required.

---

### 📤 Output format

Results are stored in two dataset views:

#### `log-entries` view
One record per parsed log line. Use this to filter, sort, or search individual requests.

#### `summary` view
A single record with aggregated statistics. Use this for the big-picture traffic breakdown.

---

### 🔧 Tips & best practices

#### Handling large log files
- Use `maxLines` to process only the most recent N lines (log files grow from the bottom up)
- For very large files (> 1GB), consider splitting them before uploading
- Use `includeStats: false` if you only need raw entries and want to compute stats yourself

#### Format auto-detection
Auto-detection samples the first 20 non-comment lines. If your log file has a long header or preamble, auto-detection may fail — set `logFormat` explicitly in that case.

#### IIS logs
IIS W3C logs have a `#Fields:` header that defines column order. The actor reads this header automatically and adjusts field mapping accordingly. Multiple `#Fields:` headers in a single file (rare but valid) are handled correctly.

#### Filtering by status code
After parsing, filter the dataset by `statusCode` in the Apify console or via API:
````

GET https://api.apify.com/v2/datasets/{DATASET\_ID}/items?fields=ip,path,statusCode\&limit=1000

````

#### Nginx default format
Nginx's default `access_log` format is identical to Apache Combined Log Format. The actor parses it without any special configuration.

---

### 🔌 Integrations

#### With n8n
Use the **Apify n8n node** to trigger the parser, then pass the dataset URL to a **HTTP Request** node to fetch results. Feed into **Spreadsheet File** or **Google Sheets** nodes for pivot tables.

#### With Make (Integromat)
Trigger the actor via **Apify > Run Actor** module, then use **Apify > Get Dataset Items** to fetch structured records into any downstream module (Google Sheets, Airtable, Slack).

#### With Zapier
Use **Apify > Run Actor** trigger, connect to **Google Sheets > Create Spreadsheet Row** — each parsed log line becomes a row.

#### With your data pipeline
Use the dataset API to stream results:
```bash
curl "https://api.apify.com/v2/datasets/{DATASET_ID}/items?format=json" \
  -H "Authorization: Bearer YOUR_TOKEN" | jq '.[] | select(.statusCode == 404)'
````

***

### 🤖 API usage

#### Node.js

```javascript
import { ApifyClient } from 'apify-client';

const client = new ApifyClient({ token: 'YOUR_TOKEN' });

const run = await client.actor('automation-lab/apache-log-parser').call({
    logUrl: 'https://example.com/access.log',
    logFormat: 'auto',
    includeStats: true,
    topN: 10,
});

const { items } = await client.dataset(run.defaultDatasetId).listItems();
console.log(items.filter(i => i.statusCode === 404));
```

#### Python

```python
from apify_client import ApifyClient

client = ApifyClient(token='YOUR_TOKEN')

run = client.actor('automation-lab/apache-log-parser').call(run_input={
    'logUrl': 'https://example.com/access.log',
    'logFormat': 'auto',
    'includeStats': True,
    'topN': 10,
})

items = client.dataset(run['defaultDatasetId']).list_items().items
errors = [i for i in items if i.get('statusCode', 0) >= 500]
print(f"Found {len(errors)} server errors")
```

#### cURL

```bash
TOKEN="YOUR_TOKEN"

## Start the run
RUN=$(curl -s -X POST "https://api.apify.com/v2/acts/automation-lab~apache-log-parser/runs?token=$TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"logUrl":"https://example.com/access.log","includeStats":true}')

DATASET_ID=$(echo $RUN | python3 -c "import sys,json; print(json.load(sys.stdin)['data']['defaultDatasetId'])")

## Fetch results
curl "https://api.apify.com/v2/datasets/$DATASET_ID/items?token=$TOKEN" | python3 -m json.tool
```

***

### 🧠 Use with Claude (MCP)

You can use this actor directly from Claude via the **Apify MCP server**:

**Claude Desktop** — Add to `claude_desktop_config.json`:

```json
{
  "mcpServers": {
    "apify": {
      "command": "npx",
      "args": ["-y", "@apify/mcp-server?tools=automation-lab/apache-log-parser"],
      "env": { "APIFY_TOKEN": "YOUR_TOKEN" }
    }
  }
}
```

**Claude Code** — Run in terminal:

```bash
claude mcp add --transport http apify "https://mcp.apify.com?tools=automation-lab/apache-log-parser"
```

**Example prompts:**

- *"Parse this Apache log and show me the top 10 pages with 404 errors"*
- *"Fetch my Nginx log from https://example.com/access.log and give me hourly traffic for yesterday"*
- *"Analyze this IIS log: \[paste log content] — which IPs are hitting us hardest?"*

***

### ⚖️ Legality & privacy

This actor processes log data you provide — it does not scrape any website. Log files typically contain IP addresses and user agent strings, which may be considered personal data under GDPR and similar regulations.

Ensure you:

- Have the right to process the log data you provide
- Comply with your organization's data retention policies
- Anonymize or pseudonymize IP addresses if required by your jurisdiction

***

### ❓ FAQ

**Q: My log lines aren't being parsed — what format should I use?**
A: Copy one line from your log and check if it matches Apache Combined Format:
`IP - user [timestamp] "METHOD /path HTTP/1.1" STATUS BYTES "referrer" "user-agent"`
If so, use `apache_combined`. If it's missing the referrer/user-agent at the end, use `common`. If it has a `#Fields:` header, use `iis_w3c`.

**Q: How many lines can it process?**
A: There is no hard limit — the actor processes all lines in memory. For very large files (millions of lines), Apify's 256 MB memory limit applies. Use `maxLines` to cap processing if you get out-of-memory errors.

**Q: Can it parse custom Nginx log formats?**
A: Currently supports the Nginx default format (which matches Apache Combined). Custom `log_format` directives produce non-standard output that may not parse correctly. Support for custom format strings is planned for a future version.

**Q: The URL fetch fails — what can I do?**
A: The log URL must be publicly accessible without authentication. If your log is behind auth or a firewall, download it locally and paste the content using `logText` instead.

**Q: Why are some lines showing parseError?**
A: Lines that don't match the expected format (e.g., blank lines, comment lines in Apache config files accidentally included, or log rotation markers) produce a parseError. The actor continues processing remaining lines — one bad line doesn't stop the run.

**Q: Does it support compressed (.gz) log files?**
A: Not currently. Decompress the file first (`gunzip access.log.gz`) and then provide the plain text content via `logText` or host it at a URL.

***

### 🔗 Related actors from automation-lab

- [JSON Schema Generator](https://apify.com/automation-lab/json-schema-generator) — Generate JSON Schema from sample JSON documents
- [Color Contrast Checker](https://apify.com/automation-lab/color-contrast-checker) — WCAG 2.1 AA/AAA color contrast validator
- [JSON CSV Converter](https://apify.com/automation-lab/json-csv-converter) — Convert between JSON and CSV formats

# Actor input Schema

## `logText` (type: `string`):

Paste raw log lines directly here. Supports Apache Combined Log Format, Nginx access logs, and IIS W3C format.

## `logUrl` (type: `string`):

URL of a publicly accessible log file to fetch and parse (e.g. https://example.com/access.log). Fetched over HTTP — no proxy needed.

## `logFormat` (type: `string`):

Format of the log file. Use <strong>auto</strong> to detect automatically.

## `maxLines` (type: `integer`):

Maximum number of log lines to parse. Set to 0 for unlimited. Useful to limit costs on very large log files.

## `includeStats` (type: `boolean`):

When enabled, saves a summary record with top pages, top IPs, status code counts, and hourly traffic breakdown to the dataset.

## `topN` (type: `integer`):

How many top entries to include in summary statistics (top pages, top IPs, top user agents).

## Actor input object example

```json
{
  "logText": "83.149.9.216 - - [17/May/2015:10:05:03 +0000] \"GET /presentations/logstash-monitorama-2013/images/kibana-search.png HTTP/1.1\" 200 203023 \"http://semicomplete.com/presentations/logstash-monitorama-2013/\" \"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.77 Safari/537.36\"\n83.149.9.216 - - [17/May/2015:10:05:07 +0000] \"GET /presentations/logstash-monitorama-2013/plugin/highlight/highlight.js HTTP/1.1\" 200 26185 \"http://semicomplete.com/presentations/logstash-monitorama-2013/\" \"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.77 Safari/537.36\"\n83.149.9.216 - - [17/May/2015:10:05:12 +0000] \"GET /presentations/logstash-monitorama-2013/plugin/zoom-js/zoom.js HTTP/1.1\" 200 7697 \"http://semicomplete.com/presentations/logstash-monitorama-2013/\" \"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.77 Safari/537.36\"\n10.0.0.5 - admin [17/May/2015:10:05:15 +0000] \"POST /api/login HTTP/1.1\" 401 120 \"-\" \"curl/7.88.1\"\n192.168.1.1 - - [17/May/2015:10:05:20 +0000] \"GET /favicon.ico HTTP/1.1\" 404 209 \"-\" \"Googlebot/2.1 (+http://www.google.com/bot.html)\"",
  "logFormat": "auto",
  "maxLines": 0,
  "includeStats": true,
  "topN": 10
}
```

# Actor output Schema

## `logEntries` (type: `string`):

No description

## `summary` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "logText": `83.149.9.216 - - [17/May/2015:10:05:03 +0000] "GET /presentations/logstash-monitorama-2013/images/kibana-search.png HTTP/1.1" 200 203023 "http://semicomplete.com/presentations/logstash-monitorama-2013/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.77 Safari/537.36"
83.149.9.216 - - [17/May/2015:10:05:07 +0000] "GET /presentations/logstash-monitorama-2013/plugin/highlight/highlight.js HTTP/1.1" 200 26185 "http://semicomplete.com/presentations/logstash-monitorama-2013/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.77 Safari/537.36"
83.149.9.216 - - [17/May/2015:10:05:12 +0000] "GET /presentations/logstash-monitorama-2013/plugin/zoom-js/zoom.js HTTP/1.1" 200 7697 "http://semicomplete.com/presentations/logstash-monitorama-2013/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.77 Safari/537.36"
10.0.0.5 - admin [17/May/2015:10:05:15 +0000] "POST /api/login HTTP/1.1" 401 120 "-" "curl/7.88.1"
192.168.1.1 - - [17/May/2015:10:05:20 +0000] "GET /favicon.ico HTTP/1.1" 404 209 "-" "Googlebot/2.1 (+http://www.google.com/bot.html)"`,
    "logFormat": "auto"
};

// Run the Actor and wait for it to finish
const run = await client.actor("automation-lab/apache-log-parser").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "logText": """83.149.9.216 - - [17/May/2015:10:05:03 +0000] \"GET /presentations/logstash-monitorama-2013/images/kibana-search.png HTTP/1.1\" 200 203023 \"http://semicomplete.com/presentations/logstash-monitorama-2013/\" \"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.77 Safari/537.36\"
83.149.9.216 - - [17/May/2015:10:05:07 +0000] \"GET /presentations/logstash-monitorama-2013/plugin/highlight/highlight.js HTTP/1.1\" 200 26185 \"http://semicomplete.com/presentations/logstash-monitorama-2013/\" \"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.77 Safari/537.36\"
83.149.9.216 - - [17/May/2015:10:05:12 +0000] \"GET /presentations/logstash-monitorama-2013/plugin/zoom-js/zoom.js HTTP/1.1\" 200 7697 \"http://semicomplete.com/presentations/logstash-monitorama-2013/\" \"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.77 Safari/537.36\"
10.0.0.5 - admin [17/May/2015:10:05:15 +0000] \"POST /api/login HTTP/1.1\" 401 120 \"-\" \"curl/7.88.1\"
192.168.1.1 - - [17/May/2015:10:05:20 +0000] \"GET /favicon.ico HTTP/1.1\" 404 209 \"-\" \"Googlebot/2.1 (+http://www.google.com/bot.html)\"""",
    "logFormat": "auto",
}

# Run the Actor and wait for it to finish
run = client.actor("automation-lab/apache-log-parser").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "logText": "83.149.9.216 - - [17/May/2015:10:05:03 +0000] \\"GET /presentations/logstash-monitorama-2013/images/kibana-search.png HTTP/1.1\\" 200 203023 \\"http://semicomplete.com/presentations/logstash-monitorama-2013/\\" \\"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.77 Safari/537.36\\"\\n83.149.9.216 - - [17/May/2015:10:05:07 +0000] \\"GET /presentations/logstash-monitorama-2013/plugin/highlight/highlight.js HTTP/1.1\\" 200 26185 \\"http://semicomplete.com/presentations/logstash-monitorama-2013/\\" \\"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.77 Safari/537.36\\"\\n83.149.9.216 - - [17/May/2015:10:05:12 +0000] \\"GET /presentations/logstash-monitorama-2013/plugin/zoom-js/zoom.js HTTP/1.1\\" 200 7697 \\"http://semicomplete.com/presentations/logstash-monitorama-2013/\\" \\"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.77 Safari/537.36\\"\\n10.0.0.5 - admin [17/May/2015:10:05:15 +0000] \\"POST /api/login HTTP/1.1\\" 401 120 \\"-\\" \\"curl/7.88.1\\"\\n192.168.1.1 - - [17/May/2015:10:05:20 +0000] \\"GET /favicon.ico HTTP/1.1\\" 404 209 \\"-\\" \\"Googlebot/2.1 (+http://www.google.com/bot.html)\\"",
  "logFormat": "auto"
}' |
apify call automation-lab/apache-log-parser --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=automation-lab/apache-log-parser",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "Apache & Nginx Log Parser",
        "description": "Parse Apache, Nginx, and IIS access logs into structured JSON. Extracts IPs, timestamps, HTTP methods, paths, status codes, bytes, user agents, and referrers. Includes traffic analytics.",
        "version": "0.1",
        "x-build-id": "flYOYGg0wHgtMPufD"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/automation-lab~apache-log-parser/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-automation-lab-apache-log-parser",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/automation-lab~apache-log-parser/runs": {
            "post": {
                "operationId": "runs-sync-automation-lab-apache-log-parser",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/automation-lab~apache-log-parser/run-sync": {
            "post": {
                "operationId": "run-sync-automation-lab-apache-log-parser",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "properties": {
                    "logText": {
                        "title": "📋 Log content (paste)",
                        "type": "string",
                        "description": "Paste raw log lines directly here. Supports Apache Combined Log Format, Nginx access logs, and IIS W3C format."
                    },
                    "logUrl": {
                        "title": "🔗 Log file URL",
                        "type": "string",
                        "description": "URL of a publicly accessible log file to fetch and parse (e.g. https://example.com/access.log). Fetched over HTTP — no proxy needed."
                    },
                    "logFormat": {
                        "title": "📁 Log format",
                        "enum": [
                            "auto",
                            "apache_combined",
                            "nginx",
                            "iis_w3c",
                            "common"
                        ],
                        "type": "string",
                        "description": "Format of the log file. Use <strong>auto</strong> to detect automatically.",
                        "default": "auto"
                    },
                    "maxLines": {
                        "title": "🔢 Max lines to parse",
                        "minimum": 0,
                        "type": "integer",
                        "description": "Maximum number of log lines to parse. Set to 0 for unlimited. Useful to limit costs on very large log files.",
                        "default": 0
                    },
                    "includeStats": {
                        "title": "📊 Include summary statistics",
                        "type": "boolean",
                        "description": "When enabled, saves a summary record with top pages, top IPs, status code counts, and hourly traffic breakdown to the dataset.",
                        "default": true
                    },
                    "topN": {
                        "title": "🏆 Top N for summaries",
                        "minimum": 1,
                        "maximum": 100,
                        "type": "integer",
                        "description": "How many top entries to include in summary statistics (top pages, top IPs, top user agents).",
                        "default": 10
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
