2 weeks ago
Hi Everyone,
I'm trying to capture Spark Event Logs for a Databricks cost optimization solution.
I configured my job cluster as follows:
The job completed successfully over an hour ago, but the file remains in the .inprogress state and no actual event log files are generated.
A few additional details:
Has anyone successfully configured Spark Event Logging on DBR 17.3 and observed only a 0-byte .inprogress file without any actual event log output? Are there any additional configurations required to persist Spark event logs in DBFS?
Thanks in advance for any guidance.
2 weeks ago
Hi @Vamsi3757 - yes, the eventlog/ folder holds the full Spark listener event log, the same JSON-lines stream the Spark UI / History Server is built from: job, stage and task start/end events with task metrics, executor added/removed, SQL execution events and so on. Driver stdout/stderr/log4j go to the separate driver/ folder.
Layout: <path>/<cluster_id>/eventlog/<cluster_id>_<driver_ip>/<id>/ with the current eventlog file plus rotated eventlog-<date>.gz files.
Quick check once a run has finished:
df = spark.read.json("/Volumes/<catalog>/<schema>/<volume>/cluster-logs/<cluster_id>/eventlog/*/*/eventlog*")
df.groupBy("Event").count().orderBy("count", ascending=False).show(truncate=False)
You should see SparkListenerTaskEnd, SparkListenerStageCompleted, SparkListenerJobEnd, SparkListenerExecutorAdded etc. (spark.read.json reads the .gz files directly). Task-level metrics such as Executor Run Time, Executor CPU Time, shuffle and spill bytes are in the Task Metrics struct on SparkListenerTaskEnd.
One tip for cost analysis: add spark.eventLog.logStageExecutorMetrics true to the cluster's Spark config. It's off by default and adds per-stage peak executor memory, which is what you need to judge whether executors are over-provisioned.
Hope this answer your doubts, if yes kindly mark this as answer so it is useful for other community members as well ๐
2 weeks ago - last edited 2 weeks ago
Hi @Vamsi3757
The 0-byte appstatus_...inprogress file is expected - in Spark's rolling event log layout (eventlog_v2_...) it's only a status marker. The actual events go to events_N_<appId> files, and on DBFS those only become visible once the writer closes them, which happens at a 128 MB roll or a clean SparkContext stop; on a job cluster the driver is torn down at termination, so neither happens. Instead of spark.eventLog.dir, use compute log delivery, which ships the Spark event log to a UC volume for you.
Setup:
- Remove spark.eventLog.enabled / spark.eventLog.dir from the Spark config.
- Job compute > Advanced > Logging tab: destination Volumes, path e.g. /Volumes/<catalog>/<schema>/<volume>/cluster-logs. In a bundle/job JSON: "cluster_log_conf": {"volumes": {"destination": "/Volumes/<catalog>/<schema>/<volume>/cluster-logs"}}
- Grant the job's run-as service principal READ VOLUME and WRITE VOLUME on that volume. Dedicated access mode assigned to a user/SP is supported; dedicated assigned to a group is not.
Logs are delivered every 5 minutes until the compute terminates, under <path>/<cluster_id>/ with driver/, executor/ and eventlog/ folders. The event logs there are the standard JSON-lines format, so the Spark History Server or your own parser can read them.
Why /Volumes failed directly: Spark's event log writer keeps a file open and appends to it, which the volume path doesn't allow - hence Operation not permitted. Log delivery copies the files instead.
For cost optimization specifically, check whether system tables already cover you before parsing event logs: system.billing.usage, system.compute.node_timeline (per-node CPU/memory utilization) and system.lakeflow.job_run_timeline.
Docs: https://docs.databricks.com/aws/en/compute/configure#compute-log-delivery
2 weeks ago
Thanks for the explanation. Just to confirm, if I configure Compute Log Delivery to a Unity Catalog Volume, will the event log/ folder contain the actual Spark Event Logs (jobs, stages, tasks, executor metrics, etc.) that can be parsed and analyzed, or does it only deliver driver/executor logs?
My goal is to analyze Spark Event Logs for a cost optimization use case, so I want to confirm that the logs delivered to the volume contain the full Spark event data and not just driver logs.
2 weeks ago
Hi @Vamsi3757 - yes, the eventlog/ folder holds the full Spark listener event log, the same JSON-lines stream the Spark UI / History Server is built from: job, stage and task start/end events with task metrics, executor added/removed, SQL execution events and so on. Driver stdout/stderr/log4j go to the separate driver/ folder.
Layout: <path>/<cluster_id>/eventlog/<cluster_id>_<driver_ip>/<id>/ with the current eventlog file plus rotated eventlog-<date>.gz files.
Quick check once a run has finished:
df = spark.read.json("/Volumes/<catalog>/<schema>/<volume>/cluster-logs/<cluster_id>/eventlog/*/*/eventlog*")
df.groupBy("Event").count().orderBy("count", ascending=False).show(truncate=False)
You should see SparkListenerTaskEnd, SparkListenerStageCompleted, SparkListenerJobEnd, SparkListenerExecutorAdded etc. (spark.read.json reads the .gz files directly). Task-level metrics such as Executor Run Time, Executor CPU Time, shuffle and spill bytes are in the Task Metrics struct on SparkListenerTaskEnd.
One tip for cost analysis: add spark.eventLog.logStageExecutorMetrics true to the cluster's Spark config. It's off by default and adds per-stage peak executor memory, which is what you need to judge whether executors are over-provisioned.
Hope this answer your doubts, if yes kindly mark this as answer so it is useful for other community members as well ๐