Skip to main content

Spark Sentinel

PyPI Python CI License

Find performance problems in Apache Spark jobs from their event logs, and learn how to fix them. Skew, spill, small files, missed broadcast joins, row-by-row Python UDFs, idle cores and more, each traced to the stage and SQL query that caused it, with a concrete fix and a link to the Spark documentation behind it.

Spark Sentinel analysing a skewed job in the terminal

  • No code changes. It reads the event log Spark already writes (the same file the History Server uses).
  • No cluster needed. Runs on your laptop, on logs from anywhere: local runs, Databricks, EMR, Kubernetes, Spark 3.5 and 4.x.
  • Made for CI. --fail-on high turns a performance regression into a failed build.

Install

pipx install spark-sentinel        # or: pip install spark-sentinel
uvx spark-sentinel analyze ...     # or run it without installing

Python 3.11+. You don't need Spark or Java to run Sentinel, only an event log.

Quick start

  1. Turn on event logging for your Spark job:

    spark = (
        SparkSession.builder.config("spark.eventLog.enabled", "true")
        .config("spark.eventLog.dir", "file:///tmp/spark-events")
        .getOrCreate()
    )
    

    On a cluster, logs are usually already on: look where spark.eventLog.dir points and copy the log to your machine.

  2. Analyze it:

    sentinel analyze /tmp/spark-events                    # every log in the folder
    sentinel analyze /tmp/spark-events -f html -o report.html
    
  3. Small local runs finish in seconds, so their problems are small too. Use the laptop profile to see them: sentinel analyze /tmp/spark-events --profile laptop.

The HTML report is one self-contained file that works offline, in light and dark mode:

The HTML report: verdict, app index and a skew finding with evidence bars

What it finds

Rule Problem Based on (Spark docs)
SKEW001 One task takes far longer than its siblings; tells data skew from compute skew Optimizing Skew Join
SPILL001 Tasks spill to disk for lack of execution memory Memory Usage of Reduce Tasks
GC001 Tasks spend a large share of their time in garbage collection Garbage Collection Tuning
FILES001 A write produces many small files Coalesce Hints
PART001 Too many shuffle partitions for the data Coalescing Post Shuffle Partitions
PART002 Too few shuffle partitions: huge tasks Tuning Partitions
PAR001 A long stage with fewer tasks than cores Level of Parallelism
PLAN001 A Python UDF in a filter blocks pushdown into the file scan Arrow Python UDFs
PLAN002 A join without an equality key: cartesian or nested-loop join Join Strategy Hints
PLAN003 All of a query's data goes through one task (e.g. a window without partitionBy) Avoid computation on single partition
PLAN004 A sort-merge join where one side was small enough to broadcast Automatically Broadcasting Joins
PLAN005 A Python UDF runs row by row instead of in Arrow batches Arrow Python UDFs
CONF001 Settings that switch off Spark's automatic optimizations (info) Adaptive Query Execution

The rule catalog maps every section of Spark's tuning guides to the symptom Sentinel looks for, including what's planned next and what an event log can't show. sentinel rules lists the rules with their thresholds.

Every rule is tested against a gallery of deliberately bad Spark jobs, run on Spark 3.5 and 4.3: each job must trigger its rule, and a clean job must trigger none.

Use it in CI

sentinel analyze path/to/eventlogs --fail-on high -f md -o sentinel.md
Exit code Meaning
0 Analysis ran; nothing at or above --fail-on (default: never fail on findings)
1 A finding at or above --fail-on
2 Bad options or config
3 An event log couldn't be read, or a rule crashed

Settings can live in a sentinel.toml next to your code (command-line options override it):

profile = "default"          # or "laptop" for small test jobs
fail_on = "high"
format  = "md"
ignore  = ["CONF001"]

[thresholds.SKEW001]
min_time_lost_ms = 60000

Commands

Command What it does
sentinel analyze PATH... Read logs (if given) and report problems: --format text|md|html|json, --profile, --select, --ignore, --threshold RULE.name=value, --fail-on
sentinel ingest PATH Parse logs once into a local Parquet warehouse (.sentinel/)
sentinel sql "SELECT ..." Query the stored tables (tasks, stages, jobs, sql, executors, config, ...) with DuckDB
sentinel apps List ingested apps
sentinel rules List rules and their thresholds
sentinel inspect PATH Show how a log is stored and count its events

How it works

event log ─▶ reader ─▶ parser ─▶ Parquet tables ─▶ DuckDB SQL ─▶ rules ─▶ report
 (plain,      (streams   (tasks, stages,   (parse once,      (one SQL query    (text, md,
  zstd, gzip,  lines)     jobs, sql plans,  query many        + diagnosis       html, json)
  rolled)                 executors, ...)   times)            per rule)

Every slow task can be traced through its stage and job to the SQL query and physical plan that produced it, which is how findings name the join key, the UDF or the repartition(500) behind a problem.

Limitations (v0.1)

  • Reads local files. Copy logs from S3, HDFS or DBFS first.
  • Logs compressed with Spark's lz4, lzf or snappy codecs aren't supported yet (zstd, Spark's default, and gzip are).
  • Per-operator SQL metrics (rows per plan node, files read) aren't parsed yet; the rules that need them are planned.
  • Thresholds default to production-sized jobs; use --profile laptop for small runs.

Contributing

New rules are welcome. CONTRIBUTING.md walks through adding one, from the gallery job that reproduces the problem to the tests that keep it free of false alarms.

License

Apache License 2.0

Metadata

Release files for spark-sentinel 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for spark-sentinel 0.1.0
File Size Uploaded Provenance Actions
spark_sentinel-0.1.0.tar.gz 1.5 MB With provenance Details for spark_sentinel-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for spark-sentinel 0.1.0
File Interpreter ABI Platform Actions
spark_sentinel-0.1.0-py3-none-any.whl Python 3 none any Details for spark_sentinel-0.1.0-py3-none-any.whl

Total release size: 1.6 MB

Release files / spark_sentinel-0.1.0.tar.gz

Download URL spark_sentinel-0.1.0.tar.gz
Size 1.5 MB
Tags Source
SHA-256 checksum
How to use checksums
8f22e0f05c0449610c669f48dc4121704490a93acd5ea8dd6dc3786a13f8d3b9
BLAKE2b-256 checksum
How to use checksums
9b0bfc2c084bad2d61cff89ab4f147c53df32bddda5f641c4f100f1f7e4eabaf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.

Transparency log

Release files / spark_sentinel-0.1.0-py3-none-any.whl

Download URL spark_sentinel-0.1.0-py3-none-any.whl
Size 80.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3a86f7b54eb662de04b80847ec454314d299b2ce78516b8250b3dac526c03505
BLAKE2b-256 checksum
How to use checksums
bad208e7ce6540a51b22a1203859279280344da3e330f34700237e73d68ed181
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.

Transparency log

Security for spark-sentinel 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for spark_sentinel-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page