[SPARK-57776][CORE] Add History Server access logging#56893
Open
qijiale76 wants to merge 3 commits into
Open
Conversation
9362200 to
e5682b5
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
This PR adds optional HTTP access logging for Spark History Server.
It adds two History Server configurations:
spark.history.ui.accessLog.enabled, defaultfalsespark.history.ui.accessLog.excludePaths, default/static,/favicon.icoWhen enabled, Spark logs one access record for each non-excluded History Server UI or REST API request after the request completes. The access log is emitted by the
org.apache.spark.deploy.history.HistoryServerAccessLogFilterlogger atINFOlevel.Each access record includes the request method, URI, redacted query string, status code, duration, remote address, remote user when available, user agent, referer, and exception class if the request chain throws.
Query string values are redacted using Spark's existing
spark.redaction.regexsetting. Static resources and favicon requests are excluded by default to avoid low-value log volume.Why are the changes needed?
Spark History Server exposes application metadata through both web UI pages and REST APIs. Operators may need access records to troubleshoot unexpected clients, detect API polling, investigate failed requests, or satisfy operational audit requirements.
Today this generally requires deploying a reverse proxy or writing a custom
spark.ui.filtersservlet filter. This PR provides a built-in History Server access log while keeping the default behavior unchanged.The feature is disabled by default, does not log request or response bodies, redacts query strings, and avoids logging static-resource noise by default.
Does this PR introduce any user-facing change?
Yes. This PR adds an optional History Server access log.
The default behavior is unchanged because
spark.history.ui.accessLog.enableddefaults tofalse.Users can enable it with:
spark.history.ui.accessLog.enabled=trueThey can customize excluded path prefixes with:
spark.history.ui.accessLog.excludePaths=/static,/favicon.icoRequests rejected by user-installed UI filters before Spark's internal access log filter may not be recorded.
How was this patch tested?
Tested locally with JDK 17 and tested in our cluster.
Was this patch authored or co-authored using generative AI tooling?
Generated-by: OpenAI Codex (GPT-5.5)