将异常消息从 Step-functions 发送到 aws cloudwatch 事件日志

Sending exception message from Step-functions to aws cloudwatch event logs

当AWS Step-function失败时,输出消息为null,并传递给cloudwatch events logs,但exception中的错误消息不会传递给cloudwatch events log。我如何将该异常消息发送到 cloudwatch 事件日志,以便我可以在下游处理它。

CloudWatch Events and CloudWatch Logs are two different services. If you enable logging at ERROR, FATAL, or ALL log level, you'll see the errors in CloudWatch Logs. See https://docs.aws.amazon.com/step-functions/latest/dg/cw-logs.html

我假设您在这里指的是 CloudWatch Events/EventBridge。 The events Step Functions emits to CloudWatch Events contain the result of the DescribeExecution API. It doesn't include errors, just the input and output of the execution. The error and cause that caused the execution to fail is in the executionFailedEventDetails field of last event in the execution history. You can retrieve the last event by calling GetExecutionHistory"reverseOrder": true"maxResults": 1

我最终使用下面的 boto3.client('stepfunctions') 然后使用 get_execution_history() 方法检索原因和错误。