当AWS Step-function失败时,输出消息为null,并且输出消息传递到cloudwatch事件日志,但异常错误消息不会传递到cloudwatch事件日志。如何将异常消息发送到cloudwatch事件日志,以便可以在下游进行处理。
答案 0 :(得分:0)
CloudWatch Events和CloudWatch Logs是两种不同的服务。如果在ERROR
,FATAL
或ALL
日志级别启用日志记录,您将在CloudWatch Logs中看到错误。参见https://docs.aws.amazon.com/step-functions/latest/dg/cw-logs.html
我假设您在这里指的是CloudWatch Events / EventBridge。 The events Step Functions emits to CloudWatch Events包含DescribeExecution API的结果。它不包括错误,仅包括执行的输入和输出。导致执行失败的错误和原因位于执行历史记录中的最后一个事件的executionFailedEventDetails
字段中。您可以通过使用"reverseOrder": true
和"maxResults": 1
调用GetExecutionHistory来检索上一个事件。
答案 1 :(得分:0)
我最终使用下面的 boto3.client(‘stepfunctions’) 然后使用 get_execution_history() 方法来检索原因和错误。