Apache Spark
v0.1.7Governed Apache Spark operations over the HTTP surfaces a cluster already exposes: the monitoring REST API (/api/v1) on a live driver UI and on the history server — applications, jobs, stages with task-quantile summaries and task lists, executors with memory and GC, SQL executions, cached RDDs, and live executor thread dumps — plus the standalone master's cluster state and the standalone REST submission server. The controls are the ones an operator reaches for during an incident: kill a runaway job or stage on the driver, kill an application or driver from the master, decommission a worker, and kill a REST submission. Reads name their source (driver or history) because only a live driver knows a running application and only the history server keeps a finished one.
curl
jq
bash
Install
emisar pack install
fetches this pack, re-validates it, and verifies its content hash against the
--hash
below — the exact bytes this page was rendered against, so a tampered copy is
rejected — before copying it into the runner's packs dir. The command reloads a
running daemon itself; no manual restart.
sudo emisar pack install spark --hash sha256:d29a4414ace767e96f281639420a455246f07e9ec941220ff3f548ba4ee6ec70
Setup
Every action is one HTTP call to a Spark web endpoint over curl on the runner host. Point each URL at the surface this host can reach; an action only needs the ones it uses.
SPARK_API_TOKEN
, when a reverse proxy in front of the UI requires one, is sent as an Authorization header over curl stdin and never reaches the process arguments.
Environment
Set these on the runner host, then add each name to
execution.inherit_env
so the value reaches the action.
-
SPARK_HISTORY_URLdefault http://127.0.0.1:18080Base URL of the Spark history server. Serves /api/v1 for applications that have finished (and, with status=running, for ones still in flight that have written an event log).
-
SPARK_UI_URLdefault http://127.0.0.1:4040Base URL of a live driver's web UI. Serves /api/v1 for the one application that driver is running, and is the only surface with executor thread dumps and the job and stage kill endpoints.
-
SPARK_MASTER_URLdefault http://127.0.0.1:8080Base URL of the standalone master's web UI, for cluster state and for killing an application, a driver, or a worker.
-
SPARK_REST_URLdefault http://127.0.0.1:6066Base URL of the standalone REST submission server, for submission status and kill. Disabled by default; the cluster must set spark.master.rest.enabled true.
-
SPARK_API_TOKENBearer token for a Spark UI published behind an authenticating proxy. Sent as the Authorization header over curl stdin. Leave unset for a cluster reached directly.
Notes
-
Any SPARK_* variable you set must also be allowlisted in the runner's
execution.inherit_env— the action env is scrubbed to PATH/LANG/LC_ALL/TERM by default, so a variable present on the host but not allowlisted is silently dropped and the action falls back to its local default. - A driver UI serves exactly one application and stops existing when that application ends, so its port is reused by whatever runs next. Confirm the application id from spark.applications with source driver before acting on a job or stage.
- The job and stage kill endpoints need spark.ui.killEnabled (true by default) and, where ACLs are on, a modify-permitted user. The master's kill endpoints need spark.ui.killEnabled on the master; worker decommissioning additionally needs spark.decommission.enabled.
- spark.environment returns the Spark configuration and runtime, with JVM system properties and the classpath dropped on the host. Spark's own spark.redaction.regex masks the property values it recognizes — a credential stored under a key that pattern does not match is still returned, which is why the action is high risk.
-
Spark on YARN or Kubernetes: point
SPARK_UI_URLat the driver's UI (through the YARN proxy or a port-forward) andSPARK_HISTORY_URLat the history server. The master and submission actions are standalone-only.
Verify it works
Runs spark.master_state, a low-risk
read that confirms the pack can reach its target. Run it on the host once the pack
is installed; pack install runs it for
you.
sudo emisar pack verify spark
Install and configure a pack walks through the whole sequence on a host.
Actions 23 total
View on GitHub-
spark.application script low Low — read-only or trivially reversible
GET /api/v1/applications/{app_id}
Show one Spark application — its name, user, and every attempt with start time, end time, duration, and whether it completed. Read it to confirm an application id and see whether the run you care about finished or is still going.
View source on GitHub -
spark.applications script low Low — read-only or trivially reversible
List Spark applications (GET /api/v1/applications)
List Spark applications with their id, name, user, start and end times, and attempts. Against the history server this is the record of what ran; against a live driver it returns the one application that driver is running. Every other action in this pack takes the app_id this returns.
View source on GitHub -
spark.environment script high High — service-affecting
Dump an application's Spark configuration (GET .../environment)
Dump the Spark configuration an application is running with, plus its runtime versions and resource profiles. Answers "what settings did this job actually get" when a tuning change did not take effect. High risk because it is a configuration dump: Spark's own spark.redaction.regex masks the property values it recognizes, and the JVM system properties and classpath are dropped on the runner host, but an object-store key or keystore password stored under a property name that pattern does not match is returned as configured.
View source on GitHub -
spark.executor_threads script medium Medium — changes state, easily reversible
Dump an executor's threads (GET .../executors/{executor_id}/threads)
Dump the stack traces of every thread in one live executor. This is the read for a task that is running but making no progress — the stack says whether it is blocked on a lock, waiting on a shuffle fetch, or spinning in user code. Only a live driver serves it; the history server does not. Heavier than the other reads: collecting the dump briefly pauses the executor's threads.
View source on GitHub -
spark.executors script low Low — read-only or trivially reversible
List an application's executors (GET .../executors)
List an application's executors with cores, active and completed tasks, failed tasks, GC time, storage memory used against total, disk used, and their host and log URLs. Read it when an application is slow or losing work: a single executor with most of the failed tasks names the bad host.
View source on GitHub -
spark.job script low Low — read-only or trivially reversible
GET /api/v1/applications/{app_id}/jobs/{job_id}
Show one Spark job — status, timing, the stage ids it owns, and its task counts including failed and killed. Read it after spark.jobs narrows to the job you care about, then follow its stage ids into spark.stage.
View source on GitHub -
spark.job_kill script high High — service-affecting
Kill a running Spark job (POST /jobs/job/kill on the driver UI)
Kill one running job in the application on the live driver UI. Every task in the job is cancelled and the job is marked failed; whatever the job had already written stays written, so a partially completed output is the normal outcome. The action reads the job back afterwards and returns its state, so a request against an already-finished job is visible rather than assumed. Needs spark.ui.killEnabled, which is on by default.
View source on GitHub -
spark.jobs script low Low — read-only or trivially reversible
List an application's jobs (GET /api/v1/applications/{app_id}/jobs)
List a Spark application's jobs with their status, submission time, duration, and task counts — completed, active, skipped, and failed. Filter by `status: failed` to find the job that broke, or `status: running` to see what a stuck application is still working on.
View source on GitHub -
spark.master_app_kill script high High — service-affecting
Kill an application from the standalone master (POST /app/kill)
Kill one whole application on a Spark standalone master. Its driver and every executor are terminated and its cores and memory return to the cluster — which is the point when one application is starving everything else — but the application's work stops wherever it was, so partial output stays partial. The action reads the master's state back and reports whether the application is still active.
View source on GitHub -
spark.master_driver_kill script high High — service-affecting
Kill a cluster-mode driver from the standalone master (POST /driver/kill)
Kill one cluster-mode driver on a Spark standalone master. The driver process and the application it runs are terminated. Use it for a submitted job whose client is long gone — a driver stuck in a retry loop, or one submitted by mistake. The action reads the master's state back and reports whether the driver is still active.
View source on GitHub -
spark.master_state script low Low — read-only or trivially reversible
Show standalone cluster state (GET /json/ on the master)
Show a Spark standalone master's cluster state — every worker with its state, cores and memory used against total, the running and completed applications with the resources each holds, and any submitted drivers. This is the capacity read: an application stuck in WAITING with no free cores means the cluster is full, not that the application is broken.
View source on GitHub -
spark.master_worker_decommission script high High — service-affecting
Decommission a standalone worker host (POST /workers/kill on the master)
Decommission every standalone worker on one host. Spark stops scheduling new tasks there and migrates shuffle and cached blocks off before the executors go away, which is the graceful way to take a node out for maintenance or a scale-down. Still a capacity change: the cluster loses that host's cores, and running tasks on it are rescheduled elsewhere. Needs spark.decommission.enabled and an allowed value of spark.master.ui.decommission.allow.mode; both are off or restrictive by default.
View source on GitHub -
spark.sql_execution script low Low — read-only or trivially reversible
GET .../sql/{execution_id}
Show one Spark SQL execution with its node-level metrics — rows produced, bytes read, shuffle sizes, and time per operator — and optionally the physical plan. This is where a query's cost is attributed: the node with the row explosion or the full scan is named here.
View source on GitHub -
spark.sql_executions script low Low — read-only or trivially reversible
List SQL executions (GET .../sql)
List an application's Spark SQL executions with their description, submission time, duration, and the jobs each one spawned. For a SQL or DataFrame workload this is the layer that maps a slow query to the jobs and stages underneath it.
View source on GitHub -
spark.stage script low Low — read-only or trivially reversible
GET /api/v1/applications/{app_id}/stages/{stage_id}
Show every attempt of one stage with its status, task counts, timing, shuffle and spill metrics, and — with with_summaries — the task metric quantiles. A stage with more than one attempt has been retried, which usually means lost executors or a fetch failure.
View source on GitHub -
spark.stage_kill script high High — service-affecting
Kill a running Spark stage (POST /stages/stage/kill on the driver UI)
Kill one running stage in the application on the live driver UI. Narrower than killing the job: the stage's tasks are cancelled, and whether the job survives depends on whether Spark can retry the stage. Use it to shed one runaway stage — a skewed shuffle, a stage stuck on a dead host — without losing the whole job. The action reads the stage back and returns its attempts. Needs spark.ui.killEnabled, which is on by default.
View source on GitHub -
spark.stage_task_summary script low Low — read-only or trivially reversible
Get task metric quantiles for a stage attempt (GET .../taskSummary)
Get the task metric quantiles for one stage attempt — duration, GC time, shuffle read and write, input bytes, and memory and disk spill at each quantile. This is the skew read: when the maximum task duration dwarfs the median, the stage is waiting on a few partitions, not on the cluster.
View source on GitHub -
spark.stage_tasks script low Low — read-only or trivially reversible
List tasks in a stage attempt (GET .../taskList)
List individual tasks in one stage attempt with their executor, host, duration, status, and — for a failed task — the error message. Sort by `-runtime` to put the slowest first, or filter `status: failed` to read why the stage broke.
View source on GitHub -
spark.stages script low Low — read-only or trivially reversible
List an application's stages (GET /api/v1/applications/{app_id}/stages)
List a Spark application's stages with status, task counts, duration, shuffle read and write bytes, spill, and input and output sizes. This is where a slow job is diagnosed: the stage with the outsized shuffle read or spill is usually the one to look at.
View source on GitHub -
spark.storage_rdds script low Low — read-only or trivially reversible
List cached RDDs (GET .../storage/rdd)
List the RDDs and DataFrames an application has cached, with their storage level, partition count, and how many bytes sit in memory versus spilled to disk. Read it when executors are short on memory: a large cache that is mostly on disk is paying the cost of caching without the benefit.
View source on GitHub -
spark.submission_kill script high High — service-affecting
Kill a REST submission (POST /v1/submissions/kill/{id})
Kill one cluster-mode submission through the standalone REST submission server. The driver and its application are terminated, and the server answers with whether it found and killed the submission. This is the path for a job submitted with `spark-submit --deploy-mode cluster` when you have the submission id but not the master UI. Needs spark.master.rest.enabled, which is off by default.
View source on GitHub -
spark.submission_status script low Low — read-only or trivially reversible
Get a REST submission's status (GET /v1/submissions/status/{id})
Get the state of one cluster-mode submission from the standalone REST submission server — whether the driver is queued, running, finished, or failed, and the worker it landed on. Use it to follow a `spark-submit --deploy-mode cluster` job whose client already exited. Needs spark.master.rest.enabled, which is off by default.
View source on GitHub -
spark.version script low Low — read-only or trivially reversible
GET /api/v1/version
Show the Spark version a UI is running. Use it to confirm a driver or history server is reachable and which release it is on before reading a version-specific field.
View source on GitHub