cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
cancel
Showing results for 
Search instead for 
Did you mean: 

I am unable to attach a streaming listener to a spark streaming job. Error: no streaming listener attached to the spark application is the error we are observing post accessing streaming statistics API. Please help us with this issue ASAP. Thanks.

swetha
New Contributor III

Issue:

After adding the listener jar file in the cluster init script, the listener is working (From what I see in the stdout/log4j logs)

But when I try to hit the

'Content-Type: application/json' http://host:port/api/v1/applications/app-id/streaming/statistics end point

It is showing no streaming listener attached to spark application

Details:

I have created a jar file with the class file containing below code and have made it available to cluster using below shell script

cluster init script:

#!/bin/bash

cp /dbfs/FileStore/jars/my_jar.jar /databricks/jars

mySparkListener class:

import org.apache.spark.sql.streaming.StreamingQueryListener

import org.apache.spark.sql.streaming.StreamingQueryListener._

import org.apache.spark.sql.streaming.StreamingQueryProgress

import org.apache.log4j.Logger

import org.joda.time.DateTime

import scala.collection.JavaConverters._

class mySparkListener extends StreamingQueryListener {

 override def onQueryStarted(queryStarted: QueryStartedEvent): Unit = {

   println("Query started: " + queryStarted.id)

 }

 override def onQueryTerminated(queryTerminated: QueryTerminatedEvent): Unit = {

   println("Query terminated: " + queryTerminated.id)

 }

 override def onQueryProgress(queryProgress: QueryProgressEvent): Unit = {

   println("Query made progress: " + queryProgress.progress)

  

 }

}

val listener = new mySparkListener()

spark.streams.addListener(listener)

 Note: I have already added following configs to the cluster

  1. spark.sql.streaming.metricsEnabled true

ReplyForward

2 REPLIES 2

Vidula
Honored Contributor

Hi @swetha kadiyala​ 

Hope all is well! Just wanted to check in if you were able to resolve your issue and would you be happy to share the solution or mark an answer as best? Else please let us know if you need more help. 

We'd love to hear from you.

Thanks!

Welcome to Databricks Community: Lets learn, network and celebrate together

Join our fast-growing data practitioner and expert community of 80K+ members, ready to discover, help and collaborate together while making meaningful connections. 

Click here to register and join today! 

Engage in exciting technical discussions, join a group with your peers and meet our Featured Members.