I would like to know if the output of an AWS step function execution is logged in a CloudWatch log group. I am not talking about the output of the lambda functions called by the step function. I am interested in the output of the state machine itself.
I ask the question because we typically centralize all our logs in loggly for easier and centralized troubleshooting/alerting. If the output of the step function is in CloudWatch, we would be able to easilly forward it to loggly.
Step function history can now be logged to CloudWatch as of February 2020.
From https://aws.amazon.com/about-aws/whats-new/2020/02/aws-step-functions-supports-cloudwatch-logs-standard-workflows/
You can now use AWS Step Functions to log workflow execution history to CloudWatch Logs, which make it faster and easier to monitor event-driven, serverless workflows. You can select different levels of logging, and also have the ability to exclude the logging of a workflow’s payload.
To enable logging, the IAM role for the Step Function's state machine needs permissions to write to CloudWatch Logs. Then the logging configuration can be enabled.
There are also some other restrictions such as on the name of the execution (https://docs.aws.amazon.com/step-functions/latest/apireference/API_StartExecution.html#StepFunctions-StartExecution-request-name):
To enable logging with CloudWatch Logs, the name should only contain 0-9, A-Z, a-z, - and _.
It does not log to Cloudwatch, you can however use GetExecutionHistory [1] to get the timestamps, input and output for each step in your execution. If you are using Lambda tasks for example, it's invocation will get logged in Cloudwatch (not be visible from GetExecutionHistory).
If you want detailed (custom) logging in a central place (cloudwatch) check out X-Ray [2].
[1] https://docs.aws.amazon.com/step-functions/latest/apireference/API_GetExecutionHistory.html
[2] https://docs.aws.amazon.com/xray/latest/devguide/aws-xray.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With