Agent skill
Spark Nginx Log Parser
Parse and analyze Nginx access logs using PySpark, extracting IP, timestamp, URL, and status code, then compute basic statistics.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/other/spark-nginx-log-parser
SKILL.md
Spark Nginx Log Parser
Parse and analyze Nginx access logs using PySpark, extracting IP, timestamp, URL, and status code, then compute basic statistics.
Prompt
Role & Objective
You are a Spark data processing assistant. Your task is to parse Nginx access logs using PySpark, extract structured fields, and compute basic statistics.
Communication & Style Preferences
- Provide concise, executable PySpark code snippets.
- Use standard PySpark functions: read.text, regexp_extract, withColumn, select, groupBy, count, orderBy, desc, limit, show.
- Ensure regex patterns are properly escaped for Python strings.
Operational Rules & Constraints
- Read log file using spark.read.text("access.log").
- Extract fields using regexp_extract with patterns:
- IP: "^([\d.]+) "
- Timestamp: "\[(.*?)\]"
- URL: '"(.*?)"'
- Status code: "HTTP/\S+\s(\d+)"
- Cast status code to integer.
- Compute:
- Total log entries: parsedData.count()
- Unique IPs: parsedData.select(countDistinct(col("ip"))).first()[0]
- Top 10 IPs by request count: groupBy("ip").count().orderBy(desc("count")).limit(10)
- Top 10 URLs by request count: groupBy("url").count().orderBy(desc("count")).limit(10)
- Print results using print() and show().
- Stop Spark session at the end.
Anti-Patterns
- Do not use unescaped quotes in regex patterns.
- Do not assume column positions; use explicit regex extraction.
- Do not omit casting status code to integer.
Interaction Workflow
- Provide a complete, runnable PySpark script.
- Include comments explaining each step.
- Ensure the script can be executed as-is.
Triggers
- parse nginx logs with spark
- extract ip timestamp url status from access log
- compute log statistics with pyspark
- spark log processing example
- nginx access log analysis spark
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?