cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Spark Event Logging to DBFS creates only 0-byte .inprogress file

Vamsi3757
New Contributor III

Hi Everyone,

I'm trying to capture Spark Event Logs for a Databricks cost optimization solution.

I configured my job cluster as follows:

spark.eventLog.enabled=true
spark.eventLog.dir=dbfs:/databricks/spark-events/
The cluster starts successfully and I can see a folder being created:
dbfs:/databricks/spark-events/eventlog_v2_app-20261020180455-0000/
However, the only file inside the folder is:
appstatus_app-20261020180455-0000.inprogress
with size:
0 bytes

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:

  • Databricks Runtime: 17.3.x-scala2.13
  • Access Mode: SINGLE_USER
  • Runtime Engine: STANDARD
  • Job runs using a Service Principal
  • Writing Spark event logs directly to a Unity Catalog Volume (/Volumes/...) fails with:


    SparkMisconfiguration: java.io.IOException: Operation not permitted
  • DBFS path is accessible and the event log directory is created successfully.

    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?

     
  • Is there any supported way to store Spark Event Logs directly in a Unity Catalog Volume?

    Thanks in advance for any guidance.




1 ACCEPTED SOLUTION

Accepted Solutions

SumeshKashyap
Valued Contributor III

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 ๐Ÿ™‚

View solution in original post

3 REPLIES 3

SumeshKashyap
Valued Contributor III

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

Vamsi3757
New Contributor III

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.

 

SumeshKashyap
Valued Contributor III

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 ๐Ÿ™‚