Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spark accumulator not displayed in spark WebUI

Tags:

apache-spark

I'm using spark streaming. According to the Spark Programming Guide (see http://spark.apache.org/docs/latest/programming-guide.html#accumulators), named accumulators will be displayed in the WebUI as below: Accumulators in Spark WebUI Unfortunately, I cannot find this anywhere. I am registering the accumulators like this (Java):

LongAccumulator accumulator = new LongAccumulator();    
ssc.sparkContext.sc().register(accumulator, "my accumulator");

I am using Spark 2.0.0.

like image 692
Jack Avatar asked Apr 23 '15 18:04

Jack


People also ask

Where is accumulator Spark UI?

When you create a named accumulator, you can see them on Spark web UI under the “Accumulator” tab. On this tab, you will see two tables; the first table “accumulable” – consists of all named accumulator variables and their values. And on the second table “Tasks” – value for each accumulator modified by a task.

How do you read an accumulator on Spark?

An accumulator is created from an initial value v by calling SparkContext. accumulator(v). Tasks running on the cluster can then add to it using the add method or the += operator (in Scala and Python). However, they cannot read its value.

What are the some of the things you can monitor in the Spark Web UI?

Apache Spark provides a suite of Web UI/User Interfaces (Jobs, Stages, Tasks, Storage, Environment, Executors, and SQL) to monitor the status of your Spark/PySpark application, resource consumption of Spark cluster, and Spark configurations.

Can we modify accumulator in Spark?

Spark natively supports programmers for new types and accumulators of numeric types. We can also create named or unnamed accumulators, as a user. As similar in below image, In the web UI, it displays a named accumulator. For each accumulator modified by a task in the “Tasks” table Spark displays the value.


2 Answers

I do not have a working streaming example but in non streaming example this UI could be found at the stages tab when choosing a specific stage. Also, I generally create the accumulator like this:

val accum = sc.longAccumulator("My Accumulator")

The equivalent in for spark streaming would probably be to replace sc with ssc.SparkContext

like image 74
Assaf Mendelson Avatar answered Sep 28 '22 15:09

Assaf Mendelson


It worked for me. Below is my sample code

Accumulator<Integer> spansWritten = jsc.sparkContext().intAccumulator(0,"Spans_Written");
JavaDStream<Span> dStream = SourceFactory.getSource().createStream(jsc)
    .map( s -> {
      spansWritten.add(1);
      return s;
    });

However, when I tried to use them inside a Decoder while creating stream for kafka, it didn't show up in the UI.

Here is how it looks in the UI (select stages tab from the top, and click on one of the stage) screen shot

like image 24
NAbbas Avatar answered Sep 28 '22 16:09

NAbbas