Home > front end >  How do I show only the failed steps in a large StepFunction call?
How do I show only the failed steps in a large StepFunction call?

Time:10-29

When you have run a long-running call of Step Functions that includes many steps (sometimes 1000s of events in the history), you may get a failure that is several pages down in the console. I have to keep clicking "Load more" to be able to see the actual error.

There has to be a better way, how do you solve this?

CodePudding user response:

To make this easier, we need to use the AWS CLI.

First, make sure we can list the specific execution by copying the execution ARN from the web console and using that to show the execution details using the CLI:

aws stepfunctions describe-execution --execution-arn <EXECUTION ARN>

The reply should look something like this:

{
    "executionArn": "arn:aws:states:us-east-1:123456789012:execution:my-execution-id",
    "stateMachineArn": "arn:aws:states:us-east-1:123456789012:stateMachine:my-state-machine-name",
    "status": "FAILED",
    "startDate": "2021-10-28T08:31:04.138000 02:00",
    "stopDate": "2021-10-28T08:33:37.471000 02:00",
    "name": "my-execution-name",
    "input": "{\"foo\":\"bar\"}"
}

To show the steps in the execution, we can use the CLI to list the execution history. As we're dealing with an execution that has many steps, it's smart to reverse the list and limiting the number of results to something less, like 5.

aws stepfunctions get-execution-history --reverse-order --max-items 5 --execution-arn <EXECUTION ARN>

This will very likely show you the failing step, since it's normally in the end of the execution steps.

CodePudding user response:

You can enable logging on the step function, then load the step function logs into Log Insights, and write a query like:

fields @timestamp, @message
| filter type like "TaskFailed"

which will return all the failed type tasks in the time period of your search.

  • Related