将异常消息从步进功能发送到AWS CloudWatch事件日志

时间:2020-05-11 10:07:21

标签: amazon-cloudwatch aws-step-functions amazon-cloudwatchlogs

当AWS Step-function失败时,输出消息为null,并且输出消息传递到cloudwatch事件日志,但异常错误消息不会传递到cloudwatch事件日志。如何将异常消息发送到cloudwatch事件日志,以便可以在下游进行处理。

2 个答案:

答案 0 :(得分:0)

CloudWatch EventsCloudWatch Logs是两种不同的服务。如果在ERRORFATALALL日志级别启用日志记录,您将在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() 方法来检索原因和错误。