The Spark Hive Thrift Server provides comprehensive web-based monitoring through integration with Spark's Web UI, offering real-time visibility into sessions, queries, and server performance.
Main UI tab that integrates with Spark's Web UI to provide Thrift Server monitoring capabilities.
private[thriftserver] class ThriftServerTab(sparkContext: SparkContext)
extends SparkUITab(getSparkUI(sparkContext), "sqlserver") with Logging {
override val name: String = "JDBC/ODBC Server"
val parent: SparkUI
val listener: HiveThriftServer2Listener
def detach(): Unit
}The tab automatically attaches to the Spark Web UI and registers monitoring pages:
Usage Example:
import org.apache.spark.SparkContext
import org.apache.spark.sql.hive.thriftserver.ui.ThriftServerTab
val sparkContext = new SparkContext(conf)
// Tab is automatically created when server starts
val tab = new ThriftServerTab(sparkContext)
// Tab is now available at http://spark-ui:4040/sqlserver/Initialization Process:
The detach method properly removes the tab from the Web UI:
def detach(): Unit = {
getSparkUI(sparkContext).detachTab(this)
}This is typically called during server shutdown to clean up UI resources.
Main monitoring page displaying server overview and active session statistics.
private[thriftserver] class ThriftServerPage(parent: ThriftServerTab) extends WebUIPage("") {
// Renders server overview with session and query statistics
}Page Content:
Detailed session page providing individual session information and query history.
private[thriftserver] class ThriftServerSessionPage(parent: ThriftServerTab) extends WebUIPage("session") {
// Renders detailed session information and query history
}Page Content:
The Web UI integrates with HiveThriftServer2Listener for real-time data:
val listener = HiveThriftServer2.listenerAvailable Data:
Real-time session monitoring data:
// From HiveThriftServer2Listener
def getOnlineSessionNum: Int // Active session count
def getTotalRunning: Int // Running query count
def getSessionList: Seq[SessionInfo] // All session details
def getSession(sessionId: String): Option[SessionInfo] // Specific session info
def getExecutionList: Seq[ExecutionInfo] // All query executionsDetailed query performance tracking:
// ExecutionInfo provides:
val totalTime = execution.totalTime // Query duration
val state = execution.state // STARTED/COMPILED/FAILED/FINISHED
val jobIds = execution.jobId // Associated Spark job IDs
val executePlan = execution.executePlan // SQL execution plan
val errorDetail = execution.detail // Error messages if failedActive Session View:
Session History:
Real-time Query Tracking:
Query Performance Analysis:
SQL Statement History:
System Metrics:
Throughput Metrics:
Spark Integration:
Storage Metrics:
// Enable/disable Web UI tab
spark.ui.enabled=true
// UI retention limits
spark.sql.thriftServer.ui.retainedSessions=200
spark.sql.thriftServer.ui.retainedStatements=1000
// Update intervals
spark.ui.liveUpdate.period=100msThe system automatically manages monitoring data retention:
private val retainedStatements = conf.getConf(SQLConf.THRIFTSERVER_UI_STATEMENT_LIMIT)
private val retainedSessions = conf.getConf(SQLConf.THRIFTSERVER_UI_SESSION_LIMIT)
private def trimExecutionIfNecessary() = {
if (executionList.size > retainedStatements) {
val toRemove = math.max(retainedStatements / 10, 1)
executionList.filter(_._2.finishTimestamp != 0).take(toRemove).foreach { s =>
executionList.remove(s._1)
}
}
}Retention Policy:
UI Security:
Data Privacy:
The Thrift Server tab integrates seamlessly with existing Spark Web UI:
Metrics Export:
Alerting Integration: