How to retrieve Metrics like Output Size and Records Written from Spark UI?
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Monitoring and analyzing metrics during the execution of Spark applications is crucial for optimizing performance and managing resources effectively. Metrics such as output size and records written are of particular importance, providing insights into the data processing details. Thankfully, Spark UI offers a comprehensive interface for accessing these valuable metrics. This article details how to retrieve such metrics from Spark UI, providing technical explanations and real-world examples where applicable.
Understanding Spark UI's Structure
Apache Spark UI is structured into several tabs that provide various insights into the application:
- Jobs Tab: Displays the list of all Spark jobs in the application.
- Stages Tab: Offers detailed insights into individual stages of a Spark job.
- Storage Tab: Shows information about RDDs and DataFrames being cached.
- Environment Tab: Details Spark runtime environment including properties and class paths.
- Executors Tab: Displays information about active and dead executors, along with related metrics.
Retrieving Metrics: Output Size and Records Written
Accessing the Stages Tab
The Stages tab in Spark UI is your go-to location for gathering detailed metrics about output size and records written. Here's how you can navigate and interpret the relevant information:
- Navigate to Spark UI:
- When running your Spark application, note the web UI hyperlink provided in the console (by default on port 4040). Open this in your web browser.
- Select the Stages Tab:
- Click on the "Stages" tab. This displays all stages related to your Spark jobs along with their metrics.
- Identify Target Stage:
- Locate the stage you are interested in, focusing on either its ID or description for ease of navigation.
- Explore Task Details:
- Click on the link corresponding to the stage ID. This will take you to a page that provides detailed task-level information within the stage.
Reviewing Output Size and Records Written
Once inside the stage details:
- Look for the "Tasks" Table:
- The tasks table will illuminate aspects of each individual task executed as part of the stage.
- Examine Key Metrics Columns:
- Output Size: Look for a column labeled "Output Size" which reflects the size of data output from each task.
- Shuffle Write (or Records Written): Depending on the operation, metrics related to data shuffle such as "Shuffle Write Metrics" can offer insights into records written by tasks.
- After execution, navigate to Spark UI.
- Within the Stages tab, observe the stage corresponding to the writing task.
- Explore the details to find output size and number of records written by viewing shuffle write statistics.
Additional Considerations
Event Logs
For post-analysis, Spark also writes event logs containing similar metrics. These logs can be parsed using the spark.eventLog.enabled parameter set to true. This setup allows offline metric analysis using a script or a separate tool.
Utilizing Spark Listeners
Custom metrics collection can be achieved using Spark Listeners in your Spark application:
Summary Table: Key Points
| Topic | Details |
| Spark UI Access | Through URL visible in application logs, defaults to http://localhost:4040. |
| Main Tabs for Metrics | "Jobs", "Stages", "Storage", "Environment", "Executors". |
| Retrieving Metrics | Go to "Stages" Tab → Click Stage ID → Review "Tasks" Table. |
| Additional Tooling | Log analysis via event logs or custom Spark Listeners. |
By leveraging the capabilities of the Spark UI and employing auxiliary methods like event logs and Spark Listeners, you can successfully retrieve and analyze performance metrics including output size and records written, thus allowing for optimized data processing workflows.

