AWS Security ChangesHomeSearch

AWS emr: Rewrite Spark agents page: add IAM identity, guardrails, and tools docs

Service: emr · 2026-11-18 · Documentation medium

File: emr/latest/ReleaseGuide/spark-troubleshoot.md · Type: iam

Summary

Restructures the Apache Spark Troubleshooting Agent page into a combined 'Spark Troubleshooting and Optimization Agents' page. Adds new sections on how the agents use the caller's IAM identity (SigV4-signed requests via MCP Proxy for AWS, short-lived credentials, no server-side access or credential storage), the aws:ViaAWSMCPService and aws:CalledViaAWSMCP condition keys for scoping agent permissions, read-only behavior, guardrails (Amazon Comprehend PII masking, Amazon Bedrock content guardrail blocking harmful content and prompt attacks), per-agent workflows, MCP tools table, feature comparison, and pricing. Also updates the topics list and nav labels.

Security assessment

The added content documents security-relevant behavior of the Spark agents: requests are signed with SigV4 using the caller's AWS CLI profile credentials, the remote MCP server uses short-lived credentials scoped to the caller's identity and stores no credentials, and requests carry aws:ViaAWSMCPService / aws:CalledViaAWSMCP condition keys that customers can use to scope what the agents can do. It also documents PII masking via Amazon Comprehend and a Bedrock guardrail that blocks harmful content and prompt attacks, plus the read-only nature of the agents. This is security best-practice/hardening guidance rather than a fix for a specific vulnerability, so it is medium severity and not security_issue_related.

Evidence

+Both agents act as the IAM identity that your MCP client is configured with. That identity is either your own identity or a dedicated role that your AWS CLI profile assumes. The identity's permissions define what the agents can read. You don't need any separate MCP-specific permissions.

Diff

diff --git a/emr/latest/ReleaseGuide/spark-troubleshoot.md b/emr/latest/ReleaseGuide/spark-troubleshoot.md
index ff4bb5c..dafa25d 100644
--- a//emr/latest/ReleaseGuide/spark-troubleshoot.md
+++ b//emr/latest/ReleaseGuide/spark-troubleshoot.md
@@ -7 +7 @@
-IntroductionArchitecture Overview
+ArchitectureToolsFeature list for each agentPricing
@@ -9 +9 @@ IntroductionArchitecture Overview
-# What is Apache Spark Troubleshooting Agent for Amazon EMR and AWS Glue
+# Spark Troubleshooting and Optimization Agents
@@ -11 +11 @@ IntroductionArchitecture Overview
-## Introduction
+The Apache Spark agents analyze your Apache Spark workloads on Amazon EMR and AWS Glue. You can use the agents from an MCP client with natural language prompts, or directly from the console. In either case, the `analyze_spark_workload` tool on the Amazon SageMaker Unified Studio remote MCP server is invoked and picks the analysis based on how the run ended:
@@ -13 +13 @@ IntroductionArchitecture Overview
-The Apache Spark Troubleshooting Agent for Amazon EMR is a conversational AI capability that simplifies the troubleshooting of Apache Spark applications on Amazon EMR (EMR on EC2, EMR Serverless, and EMR on EKS), AWS Glue and Amazon SageMaker Notebooks. Traditional Spark troubleshooting requires extensive manual analysis of logs, performance metrics, and error patterns to identify root causes and code fixes. The agent simplifies this process through natural language prompts, automated workload analysis, and intelligent code recommendations.
+  * For a failed run, the Apache Spark Troubleshooting Agent finds the root cause and recommends fixes.
@@ -15 +15 @@ The Apache Spark Troubleshooting Agent for Amazon EMR is a conversational AI cap
-You can use the agent to troubleshoot PySpark and Scala applications failures. The agent analyzes your failed jobs, identifies performance bottlenecks, and provides actionable recommendations and code fixes while giving you full control over implementation decisions.
+  * For a successful run, the Apache Spark Optimization Agent recommends configuration and data changes that improve performance.
@@ -17 +16,0 @@ You can use the agent to troubleshoot PySpark and Scala applications failures. T
-Note
@@ -19 +17,0 @@ Note
-The Apache Spark Troubleshooting Agent is available at no additional cost as part of Amazon EMR. The agent provides analysis and recommendations only. You only pay for the Amazon EMR resources that you use when you run your applications to validate any recommended fixes.
@@ -21 +18,0 @@ The Apache Spark Troubleshooting Agent is available at no additional cost as par
-## Architecture Overview
@@ -23 +20 @@ The Apache Spark Troubleshooting Agent is available at no additional cost as par
-The troubleshooting agent has three main components: an MCP-compatible AI Assistant in your development environment for interaction, the [MCP Proxy for AWS](https://github.com/aws/mcp-proxy-for-aws) that handles secure communication and authentication between your client and AWS services, and the Amazon SageMaker Unified Studio Remote MCP Server that provides specialized Spark troubleshooting tools for Amazon EMR (EMR on EC2, EMR Serverless, and EMR on EKS), AWS Glue and Amazon SageMaker Notebooks. This diagram illustrates how you interact with the Amazon SageMaker Unified Studio Remote MCP Server through your AI Assistant.
+## Architecture
@@ -25 +22 @@ The troubleshooting agent has three main components: an MCP-compatible AI Assist
-![Spark Troubleshooting Agent Architecture.](/images/emr/latest/ReleaseGuide/images/spark-troubleshooting-agent-architecture.png)
+The following diagram shows how the Apache Spark agents work. The numbers show the order of the steps.
@@ -27 +24 @@ The troubleshooting agent has three main components: an MCP-compatible AI Assist
-The AI assistant will orchestrate the troubleshooting using specialized tools provided by the MCP server following these steps:
+![Architecture of the Apache Spark Troubleshooting and Optimization Agents.](/images/emr/latest/ReleaseGuide/images/spark-agents-architecture.png)
@@ -29 +26 @@ The AI assistant will orchestrate the troubleshooting using specialized tools pr
-  * **Feature Extraction and Context Building:** The agent automatically collects and analyzes telemetry data from your Spark application including Spark History Server logs, configuration settings, and error traces. It extracts key performance metrics, resource utilization patterns, and failure signatures to build a comprehensive context profile for intelligent troubleshooting.
+You start by asking about your job run in natural language (1) from an MCP client in your development environment, or by choosing the **Analyze with AI** button in the console (2). An MCP client connects through the [MCP Proxy for AWS](https://github.com/aws/mcp-proxy-for-aws). The proxy runs on your machine, signs each request with SigV4 using the credentials from your AWS CLI profile, and forwards it to the Amazon SageMaker Unified Studio remote MCP server. The remote MCP server reads your job run data (3), analyzes it (4), and returns recommendations with explanations (6).
@@ -31 +28 @@ The AI assistant will orchestrate the troubleshooting using specialized tools pr
-  * **GenAI Root Cause analyzer and Recommendation Engine:** The agent leverages AI models and Spark knowledge base to correlate extracted features and identify root causes of performance issues or failures. It provides diagnostic insights and analysis of what went wrong in your Spark application execution.
+### How the agents use your identity
@@ -33 +30 @@ The AI assistant will orchestrate the troubleshooting using specialized tools pr
-  * **GenAI Spark Code Recommendation:** Based on the root cause analysis from the previous step, the agent analyzes your existing code patterns and identifies inefficient operations that need code fixes for application failures. It provides actionable recommendations including specific code modifications, configuration adjustments and architectural improvements with concrete examples.
+Both agents act as the IAM identity that your MCP client is configured with. That identity is either your own identity or a dedicated role that your AWS CLI profile assumes. The identity's permissions define what the agents can read. You don't need any separate MCP-specific permissions.
@@ -34,0 +32 @@ The AI assistant will orchestrate the troubleshooting using specialized tools pr
+For each request, the remote MCP server uses short-lived credentials for your identity to call Amazon EMR, AWS Glue, Amazon S3, and Amazon CloudWatch Logs, and to read Spark History Server or Spark UI data. The server doesn't use access of its own to read your resources, and it doesn't store your credentials.
@@ -35,0 +34 @@ The AI assistant will orchestrate the troubleshooting using specialized tools pr
+Requests made through the server carry the condition keys `aws:ViaAWSMCPService` and `aws:CalledViaAWSMCP`. You can use these keys to scope what the agents can do. For more information, see [Condition keys for MCP server requests](./spark-troubleshooting-agent-iam-setup.html#spark-troubleshooting-agent-mcp-permissions-change).
@@ -36,0 +36,63 @@ The AI assistant will orchestrate the troubleshooting using specialized tools pr
+The agents only read data. They don't modify, start, or stop your jobs. For the policies that each platform needs, see [IAM permissions for the Apache Spark agents](./spark-troubleshooting-agent-iam-setup.html).
+
+### Guardrails
+
+Both agents apply the following guardrails:
+
+  * **PII masking** – Before any data reaches the model, Amazon Comprehend detects PII and masks it. The model's response is also masked. Masked values aren't restored in the analysis output.
+
+  * **Content guardrail** – Every model call goes through an Amazon Bedrock guardrail that blocks harmful content and prompt attacks.
+
+
+
+
+Each agent adds its own checks, some of which are described in the following sections.
+
+### Troubleshooting Agent
+
+The Troubleshooting Agent runs on failed runs on EMR on EC2, EMR Serverless, EMR on EKS, and AWS Glue.
+
+**Extracts features and builds context (3)**
+
+The agent reads evidence about the failed run from your platform:
+
+  * **EMR on EC2** – Step and container logs from Amazon S3, and the EMR persistent UI.
+
+  * **EMR Serverless** – Driver and executor logs from Amazon S3, and the Spark History Server.
+
+  * **EMR on EKS** – Logs from Amazon S3 or Amazon CloudWatch Logs, and the persistent UI.
+
+  * **AWS Glue** – Amazon CloudWatch Logs, and the Glue Studio Spark UI, built from the event logs.
+
+
+
+
+On every platform, the agent also reads the run's Spark configuration and extracts the stack traces.
+
+**Analyzes the failure and recommends fixes (4)**
+
+A fast classification pass first identifies the type of error. For well-understood error types, deterministic rules drive the analysis directly. Otherwise, the agent retrieves matching guidance from its curated Spark troubleshooting knowledge base and generates the root cause and recommended fixes.
+
+You get back the root cause and recommendations, plus which artifacts the agent could and couldn't analyze (`artifacts_analyzed`). If no code change is needed, the analysis ends here. When code recommendations apply, the response tells your MCP client to call `spark_code_recommendation`.
+
+**Recommends code changes (5)**
+
+Code recommendations apply to code-related errors in PySpark jobs.
+
+The tool maps the parts of your script that are relevant to the error, applies fix guidance specific to the error type, and proposes code changes, along with `spark-submit` argument changes when they're needed. These are proposals only. The tool doesn't apply them.
+
+Code recommendations add their own guardrails. For example, sensitive data in your script and stack trace is masked before it reaches the model, and then restored in the proposed changes so that they're usable. A content guardrail also runs on code generation.
+
+For more information, see [Apache Spark Troubleshooting Agent for Amazon EMR and AWS Glue](./spark-troubleshooting-agent.html).
+
+### Optimization Agent
+
+The Optimization Agent runs only on successful runs on EMR Serverless and AWS Glue.
+
+**Extracts features and builds context (3)**
+
+The agent primarily reads the following from your run:
+
+  * **Spark event data** – Stages, tasks, executors, shuffle, and SQL plans. On EMR Serverless, this data comes from the Spark History Server. On AWS Glue, it comes from the Glue Studio Spark UI, built from the run's event logs in Amazon S3.
+
+  * **Configuration** – The run's submitted and effective configuration, at the application level and the job run level.
@@ -38 +99,0 @@ The AI assistant will orchestrate the troubleshooting using specialized tools pr
-## Topics
@@ -40 +100,0 @@ The AI assistant will orchestrate the troubleshooting using specialized tools pr
-  * [Setup for Troubleshooting Agent](./spark-troubleshooting-agent-setup.html)
@@ -42 +101,0 @@ The AI assistant will orchestrate the troubleshooting using specialized tools pr
-  * [Using the Troubleshooting Agent](./spark-troubleshooting-using-troubleshooting-agent.html)
@@ -44 +103,72 @@ The AI assistant will orchestrate the troubleshooting using specialized tools pr
-  * [Features and Capabilities](./spark-troubleshooting-features.html)
+**Generates recommendations (4)**
+
+The agent combines the following to produce recommendations:
+
+  * **Rule-based investigations** – Deterministic checks look for issues in four categories:
+
+    * **Memory** – GC pressure, spill, out-of-memory, and disk full.
+
+    * **Data** – Skew, stragglers, too few partitions, oversized tasks, and slow reads.
+
+    * **Capacity** – Idle or underused capacity, right-sizing, backlog against the capacity ceiling, and contention for shared capacity.
+
+    * **Execution** – Fetch failures, killed containers, oversized execution plans, and adaptive query execution settings.
+
+  * **Intent** – Your goal, cost or performance, comes from your prompt. A cost goal means lowering what the run costs to execute, and a performance goal means speeding up runtime. If you don't state a goal, the agent optimizes for performance. With a baseline and no stated goal, the agent uses whichever metric regressed. Intent-based models use your goal to decide which recommendations are allowed and how capacity is sized.
+
+  * **Knowledge base** – Spark tuning guidance curated by AWS engineers from their experience running Spark at scale, matched to your platform, version, and the issues found.
+
+  * **Baseline comparison** – A baseline comparison happens only when you name a baseline by its run ID. The baseline must be an earlier run of the same job (AWS Glue) or the same application (EMR Serverless). The agent compares configuration, metrics, stages, and capacity, and determines how to mitigate the regression. If the baseline can't be used, the agent analyzes the current run on its own.
+
+
+
+
+**Validates recommendations**
+
+Before the agent returns results, deterministic rules drop or adjust recommendations that the evidence doesn't support:
+
+  * They drop settings that can't take effect.
+
+  * They block changes that work against your goal, such as changes that raise cost under a cost goal, or capacity cuts that could slow the job under a performance goal.
+
+  * They withhold capacity changes when nothing shows that capacity is the problem.
+
+  * They ensure that each recommendation is valid for the platform that it's for.
+
+
+
+
+You get back a summary, prioritized recommendations tagged `[config]`, `[infra]`, or `[data]`, recommended Spark properties with their current and recommended values, and the baseline comparison when one was used.
+
+The Optimization Agent doesn't support code recommendations through the `spark_code_recommendation` tool.
+
+For more information, see [Apache Spark Optimization Agent for Amazon EMR and AWS Glue](./spark-optimization-agent.html).
+
+## Tools
+
+The Amazon SageMaker Unified Studio remote MCP server provides the following tools for the Apache Spark agents.
+
+Tool| MCP server| Used by  
+---|---|---  
+`analyze_spark_workload`| `sagemaker-unified-studio-mcp-troubleshooting`| Both agents  
+`spark_code_recommendation`| `sagemaker-unified-studio-mcp-code-rec`| Troubleshooting Agent only  
+  
+Your MCP client calls these tools based on your prompt.
+
+## Feature list for each agent
+
+The following table lists the features that each agent supports.
+
+Aspect| Apache Spark Troubleshooting Agent| Apache Spark Optimization Agent  
+---|---|---  
+Run state analyzed| Failed runs| Successful runs  
+Supported platforms| EMR on EC2, EMR Serverless, EMR on EKS, AWS Glue, and Amazon SageMaker notebooks| EMR Serverless and AWS Glue  
+Output| Root cause analysis and code fixes| Performance and cost analysis, and configuration and data recommendations  
+Code recommendations| Yes| No  
+Entry points| MCP clients, the **Troubleshoot with AI** button (EMR on EC2 and EMR on EKS consoles), the **Analyze with AI** button (EMR Serverless and AWS Glue consoles), and the notebook **Fix with AI** button| MCP clients and the **Analyze with AI** button (EMR Serverless and AWS Glue consoles)  
+  
+## Pricing
+
+The Apache Spark agents are available at no additional cost as part of Amazon EMR and AWS Glue. The agents provide analysis and recommendations. You pay only for the Amazon EMR or AWS Glue resources that you use, including any runs that you start to validate a recommended change.
+
+## Topics
@@ -46 +176 @@ The AI assistant will orchestrate the troubleshooting using specialized tools pr
-  * [Troubleshooting and Q&A](./spark-troubleshooting-agent-troubleshooting.html)
+  * [Set up the Apache Spark agents](./spark-troubleshooting-agent-setup.html)
@@ -48 +178 @@ The AI assistant will orchestrate the troubleshooting using specialized tools pr
-  * [Spark Troubleshooting Agent Workflow in Details](./spark-troubleshooting-agent-workflow.html)
+  * [IAM permissions for the Apache Spark agents](./spark-troubleshooting-agent-iam-setup.html)
@@ -50 +180 @@ The AI assistant will orchestrate the troubleshooting using specialized tools pr
-  * [Prompt Examples](./spark-troubleshooting-agent-prompt-examples.html)
+  * [Apache Spark Troubleshooting Agent for Amazon EMR and AWS Glue](./spark-troubleshooting-agent.html)