saurabh18cs
Honored Contributor III

Hi @cz0 

 The StreamingQueryListener in Spark is designed to give you metrics at the micro-batch level (not per individual record), which is typical for Spark Structured Streaming

  • onQueryStarted: Called when the streaming job starts.
  • onQueryProgress: Called after each micro-batch is processed. Here, you get metrics like durationMs, inputRowsPerSecond, processedRowsPerSecond, and more.
  • onQueryTerminated: Called when the job ends.
  •  
  • For more granular monitoring, you can add custom logic in your processing code (e.g., use foreachBatch or foreach sink to log or collect metrics per record, but this is not typical and can impact performance).