{"record":{"id":"836507ae3a7986cf","repo":"getredash/redash","slug":"cloudwatch-insights-query-execution-status","errorCode":null,"errorMessage":"CloudWatch Insights Query Execution Status: {}","messagePattern":"CloudWatch Insights Query Execution Status: (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"redash/query_runner/cloudwatch_insights.py","lineNumber":142,"sourceCode":"                    }\n                )\n\n        return log_groups\n\n    def run_query(self, query, user):\n        logs = self._get_client()\n\n        query = parse_query(query)\n        query_id = logs.start_query(**query)[\"queryId\"]\n\n        elapsed = 0\n        while True:\n            result = logs.get_query_results(queryId=query_id)\n            if result[\"status\"] == \"Complete\":\n                data = parse_response(result)\n                break\n            if result[\"status\"] in (\"Failed\", \"Timeout\", \"Unknown\", \"Cancelled\"):\n                raise Exception(\"CloudWatch Insights Query Execution Status: {}\".format(result[\"status\"]))\n            elif elapsed > TIMEOUT:\n                raise Exception(\"Request exceeded timeout.\")\n            else:\n                time.sleep(POLL_INTERVAL)\n                elapsed += POLL_INTERVAL\n\n        return data, None\n\n\nregister(CloudWatchInsights)\n","sourceCodeStart":124,"sourceCodeEnd":153,"githubUrl":"https://github.com/getredash/redash/blob/ca79fe988d81cdac9675b412f3dfcab107bc1fbc/redash/query_runner/cloudwatch_insights.py#L124-L153","documentation":"CloudWatch Insights run_query polls get_query_results; if the status comes back Failed, Timeout, Unknown, or Cancelled it aborts with this message embedding the terminal status. AWS accepted the query but it ended unsuccessfully.","triggerScenarios":"Running a CloudWatch Insights query whose AWS-side execution finishes with status 'Failed' (query invalid for the log group), 'Timeout', 'Cancelled', or 'Unknown'.","commonSituations":"Insights syntax errors that pass StartQuery validation, missing logs:GetQueryResults permissions mid-flight, empty log groups, or region mismatch.","solutions":["Run the same query in the AWS Console Insights editor against the same log group and region to see the error detail","Check IAM permissions (logs:StartQuery, logs:GetQueryResults) and the configured region","Fix the Insights query syntax (fields/filter/stats clauses)","For Timeout: narrow the time range or add filters to reduce scan volume"],"exampleFix":"# before\nfields @timestamp, @message | filter level = \"error\"\n\n# after\nfields @timestamp, @message | filter level = \"error\" | filter @timestamp > now() - 3600s","handlingStrategy":"try-catch","validationCode":"# validate the Insights query is accepted before scheduling\nresp = logs.start_query(logGroupName=LG, queryString=q, startTime=t0, endTime=t1)\nlogs.stop_query(queryId=resp['queryId'])  # immediately cancel","typeGuard":null,"tryCatchPattern":"try:\n    data, err = runner.run_query(q, u)\nexcept Exception as e:\n    if 'Query Execution Status' in str(e):\n        status = str(e).rsplit(' ', 1)[-1]\n        handle(status)  # Failed -> fix syntax, Timeout -> narrow range","preventionTips":["Validate Insights syntax in the AWS console before scheduling","Scope IAM roles to logs:StartQuery/GetQueryResults","Always include time-range filters in Insights queries"],"tags":["redash","aws","cloudwatch-insights","query-status"],"backgroundTag":"query-execution-failed","analyzedSha":"ca79fe988d81cdac9675b412f3dfcab107bc1fbc","analyzedAt":"2026-08-28T18:32:34.637Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}