AWS emr: Expand Spark agents troubleshooting with IAM, permissions, and data-handling guidance
Summary
Rewrites and greatly expands the Apache Spark agents troubleshooting page: renames sections, adds new error/observation entries (throttling, user/internal errors, AccessDenied on job access, degraded tool response quality, optimization failures), documents required IAM permissions per platform (EMR on EC2, Glue, EMR Serverless, EMR on EKS), adds a CloudFormation template to create a dedicated least-privilege agent role with condition keys, KMS key option for CloudWatch Logs encryption, and FAQs covering trust settings, data transmitted to the LLM, PII masking, and cross-Region inference.
Security assessment
The change is documentation-only but heavily security-focused: it enumerates the exact IAM permissions the agents need (e.g. glue:GetJobRun, emr-serverless:GetDashboardForJobRun, kms:Decrypt), explains how AccessDenied surfaces as degraded analysis, and recommends scoping agent access via a dedicated role or MCP condition keys. It also documents PII masking and cross-Region inference behavior. No specific vulnerability, CVE, or incident is referenced, so it is best-practice/hardening guidance rather than a fix.
Evidence
+For the tightest control, create a dedicated IAM role that's scoped to only the access that you want the agents to have, and point the MCP client at a profile that assumes it.
Diff
diff --git a/emr/latest/ReleaseGuide/spark-troubleshooting-agent-troubleshooting.md b/emr/latest/ReleaseGuide/spark-troubleshooting-agent-troubleshooting.md index 2f3d8fc..35b2360 100644 --- a//emr/latest/ReleaseGuide/spark-troubleshooting-agent-troubleshooting.md +++ b//emr/latest/ReleaseGuide/spark-troubleshooting-agent-troubleshooting.md @@ -7 +7 @@ -TroubleshootingQ&A +Common errorsFAQs @@ -9 +9 @@ TroubleshootingQ&A -# Troubleshooting and Q&A +# Common errors and FAQs for the Apache Spark agents @@ -11 +11 @@ TroubleshootingQ&A -## Troubleshooting +## Common errors @@ -13 +13 @@ TroubleshootingQ&A -The error message from the Spark Troubleshooting Agent is available in different ways for different MCP clients. In this page, we list some general guidance for common issues you may see using Apache Spark troubleshooting agent for Amazon EMR. +The error message from the Apache Spark agents is available in different ways for different MCP clients. This section lists general guidance for common issues that you might see when you use the Apache Spark agents for Amazon EMR and AWS Glue. @@ -15 +15 @@ The error message from the Spark Troubleshooting Agent is available in different -Topics +**General errors** @@ -17 +17 @@ Topics - * Error: MCP Server Failed to Load + * Error: MCP server failed to load @@ -19 +19 @@ Topics - * Observation: Slow Tool Loading + * Observation: Slow tool loading @@ -21 +21 @@ Topics - * Error: Tool Invocation Failed with Throttling Error + * Error: Tool invocation failed with throttling error @@ -23 +23 @@ Topics - * Error: Tool Responds With User Error + * Error: Tool responds with user error @@ -25 +25 @@ Topics - * Error: Tool Responds With Internal Error + * Error: The agent can't access your job @@ -26,0 +27 @@ Topics + * Error: Tool responds with internal error @@ -30 +30,0 @@ Topics -### Error: MCP Server Failed to Load @@ -32 +32,23 @@ Topics - * Verify your MCP configurations are properly configured. +**Troubleshooting Agent errors** + + * Observation: Degraded tool response quality + + + + +**Optimization Agent errors** + + * Error: Optimization fails because Spark event data can't be read + + * Error: Optimization isn't supported for the platform, version, or run state + + * Observation: Optimization recommendations on EMR Serverless miss application-level settings + + * Observation: Baseline comparison falls back to single-run analysis + + + + +### Error: MCP server failed to load + + * Verify that your MCP configurations are properly configured. @@ -36 +58 @@ Topics - * Ensure your JSON is valid with no syntax errors + * Ensure your JSON is valid with no syntax errors. @@ -38 +60 @@ Topics - * Check for missing commas, quotes, or brackets + * Check for missing commas, quotes, or brackets. @@ -40 +62 @@ Topics - * Verify your local AWS credentials and verify the policy for the MCP IAM role is properly configured. + * Verify your local AWS credentials, and verify that the policy for the MCP IAM role is properly configured. @@ -42 +64 @@ Topics - * Run /mcp to verify MCP server availability for `Kiro-CLI` case + * Run `/mcp` to verify MCP server availability for the Kiro CLI case. @@ -47 +69 @@ Topics -### Observation: Slow Tool Loading +### Observation: Slow tool loading @@ -49 +71 @@ Topics - * Tools may take a few seconds to be loaded on first attempt of launching the server. + * Tools might take a few seconds to load on the first attempt to launch the server. @@ -53 +75,206 @@ Topics - * Run `/tools` command to verify tool availability. + * Run the `/tools` command to verify tool availability. + + * Run `/mcp` to verify whether the server launched without error. + + + + +### Error: Tool invocation failed with throttling error + + * If you reach your service limit, wait a few seconds before you issue another tool invocation when you see the throttling exception. + + + + +### Error: Tool responds with user error + + * `AccessDeniedException` – Check the error message and fix the permission issue. + + * `InvalidInputException` – Check the error message and correct the tool input parameters. + + * `ResourceNotFoundException` – Check the error message and fix the input parameter for the resource reference. + + + + +### Error: The agent can't access your job + +If the role that the agent uses doesn't have permission to read your job's basic details, the agent fails and can't start the analysis. You see an error message similar to the following: + + + ... An error occurred (AccessDeniedException) when calling the GetJobRun operation: User: ... is not authorized to perform: glue:GetJobRun ... + +This happens when the role lacks the describe or get permission for your platform. Grant the relevant permission for your platform from the following table, and then run the analysis again. + +Permissions to read basic job details Platform| Permission +---|--- +EMR on EC2| `elasticmapreduce:DescribeCluster`, `elasticmapreduce:DescribeStep` +AWS Glue| `glue:GetJob`, `glue:GetJobRun` +EMR Serverless| `emr-serverless:GetJobRun` +EMR on EKS| `emr-containers:DescribeVirtualCluster`, `emr-containers:DescribeJobRun` + +### Error: Tool responds with internal error + + * If you see `The service is handling high-volume requests`, retry the tool invocation in a few seconds. + + * If you see `INTERNAL SERVICE EXCEPTION`, document the analysis ID, tool name, any error message available from the MCP log or tool response, and optional sanitized conversation history, and contact AWS Support. + + + + +### Observation: Degraded tool response quality + +The Troubleshooting Agent is designed to fail gracefully when certain signals are unavailable. If the agent can't read one of your job's signals (for example, execution logs, Spark event logs, or Spark History Server data), it still returns an analysis based on what it could read. A missing permission therefore usually appears as a less complete or lower-quality analysis rather than a hard error. + +To check whether the agent was able to read everything that you expect it to, look at the `artifacts_analyzed` field in the raw tool response for your analysis. Each artifact that the agent couldn't analyze appears as `{"analyzed": false, "failure_reason": "<reason>"}`. This information isn't shown by default. In Kiro CLI, ask the agent to relay the `artifacts_analyzed` field from the most recent tool response. + +The `failure_reason` often names the missing permission. For example, it might include an `AccessDeniedException`, an "is not authorized to perform" message, or an "Unauthorized access" message. Sometimes the error is more generic. Whenever an artifact shows `analyzed: false`, make sure that the role that the agent uses has the corresponding permission from [IAM permissions for the Apache Spark agents](./spark-troubleshooting-agent-iam-setup.html). The following table shows some common scenarios. + +Artifacts and the permissions required to analyze them Artifact (`artifacts_analyzed` key) | What it provides | If it shows `analyzed: false`, add this permission to the role +---|---|--- +`execution_logs``exception_stack_trace` | Driver and executor log timeline and the parsed error | Logs in Amazon S3 (EMR on EC2, EMR Serverless): `s3:GetObject`, `s3:ListBucket`. Logs in CloudWatch Logs (AWS Glue): `logs:GetLogEvents`, `logs:FilterLogEvents`. Logs in CloudWatch Logs (EMR on EKS): `logs:GetLogEvents`, `logs:DescribeLogGroups`, `logs:DescribeLogStreams`. Encrypted logs: add `kms:Decrypt` and `kms:DescribeKey` for the customer managed key. +`spark_configuration` | Spark environment and configuration | AWS Glue: `glue:GetEnvironment`, plus `iam:PassRole` for your AWS Glue job execution role. +`spark_events` | Jobs, stages, and executor metrics | AWS Glue: `glue:GetStages`, `glue:GetStage`, `glue:GetStageAttempt`, `glue:GetStageAttemptTaskList`, `glue:GetStageAttemptTaskSummary`, `glue:GetExecutors`, `glue:GetExecutorsThreads`, `glue:GetStorage`, `glue:GetStorageUnit`, plus `iam:PassRole` for your AWS Glue job execution role. +`spark_query_plan` | SQL executions and query plans | AWS Glue: `glue:GetQueries`, `glue:GetQuery`, plus `iam:PassRole` for your AWS Glue job execution role. +`spark_history_server` | Connection to your platform's Spark UI. Appears with `analyzed: false` when the agent can't reach the Spark UI, or can't read any Spark UI data. | EMR on EC2 and EMR on EKS: `elasticmapreduce:CreatePersistentAppUI`, `elasticmapreduce:DescribePersistentAppUI`, `elasticmapreduce:GetPersistentAppUIPresignedURL`. EMR Serverless: `emr-serverless:GetDashboardForJobRun`. AWS Glue: the Spark UI permissions in the `spark_events` and `spark_query_plan` rows, plus `iam:PassRole`. Also confirm that the job run has the Spark UI turned on. + +### Error: Optimization fails because Spark event data can't be read + +The Optimization Agent requires the run's Spark event data. If it can't read that data, it stops and returns an error. + +**EMR Serverless** + +The Optimization Agent reads Spark event data from the EMR Serverless Spark History Server, which relies on managed log storage. The analysis fails if managed log storage is turned off for the run, or if the run's logs are past the 30-day retention period. The agent returns a message similar to the following: + + + I encountered the following issue while analyzing your workload: An error occurred (ValidationException) when calling the GetDashboardForJobRun operation: Dashboard for completed job is not available as no logs are present. + +The same message also appears right after a run finishes, before its logs are available. The message doesn't distinguish logs that expired from logs that were never present. The agent retries for about a minute before it returns this error. If you just ran the job, wait and retry. Otherwise, turn on managed log storage and analyze a more recent run whose logs are still within the 30-day window. + +**AWS Glue** + +The Optimization Agent reads the Spark event logs that an AWS Glue run wrote to Amazon S3 through the Glue Studio Spark UI. The run must have the Spark UI turned on: set `--enable-spark-ui` to `true` and set `--spark-event-logs-path`. The maximum supported Spark event log size is 512 MB, and 1 GB for rolling logs. Runs that wrote event logs only to the legacy path (`--enable-spark-ui-legacy-path`) aren't supported. + +If the run didn't have the Spark UI turned on, or didn't write event logs to a supported path, the agent returns a message similar to the following: + + + I encountered the following issue while analyzing your workload: Spark UI (event logs) is required to read Spark event data for this Glue job run. Enable --enable-spark-ui with --spark-event-logs-path and re-run. + +If the run wrote only legacy-format event logs, the agent returns a message similar to the following: + + + I encountered the following issue while analyzing your workload: This Glue job run wrote only legacy-format Spark event logs (--enable-spark-ui-legacy-path=true with --enable-spark-ui=false). The analysis service only supports standard-format Spark event logs. Update the job to write standard logs by setting --enable-spark-ui=true, then re-run the job and analyze the new run. + +To fix either case, run the job again with the Spark UI turned on, and then analyze the new run. + +**Permissions** + +If the role can't read your run's Spark UI data, the `AccessDenied` message is passed through in the error. Grant the permission that your platform needs to read Spark data, and then run the analysis again: + + * EMR Serverless: `emr-serverless:GetDashboardForJobRun` + + * AWS Glue: the AWS Glue Spark UI permissions (`glue:RequestLogParsing`, `glue:GetLogParsingStatus`, `glue:GetEnvironment`, `glue:GetStage`, `glue:GetStages`, `glue:GetStageFiles`, `glue:BatchGetStageFiles`, `glue:GetStageAttempt`, `glue:GetStageAttemptTaskList`, `glue:GetStageAttemptTaskSummary`, `glue:GetExecutors`, `glue:GetExecutorsThreads`, `glue:GetStorage`, `glue:GetStorageUnit`, `glue:GetQueries`, `glue:GetQuery`, `glue:GetDashboardUrl`) and `iam:PassRole` + + + + +For more information, see [IAM permissions for the Apache Spark agents](./spark-troubleshooting-agent-iam-setup.html). + +### Error: Optimization isn't supported for the platform, version, or run state + +The Optimization Agent refuses a run that it can't optimize and returns the reason. + + * **Platform** – Optimization is available for EMR Serverless and AWS Glue only. A run on EMR on EC2 or EMR on EKS returns a message similar to the following: + + Optimization Agent is not yet supported for Amazon EMR on EC2 + + Optimization Agent is not yet supported for Amazon EMR on EKS