mabead
mabead

Reputation: 2381

Does AWS Step Functions log in CloudWatch

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.

Upvotes: 2

Views: 12931

Answers (3)

Ibrahim_kamal
Ibrahim_kamal

Reputation: 23

You can definitely log to the assigned log group but this will only log the input data in each state and the lambda when it gets scheduled and executed. In my opinion the graph inspector is much better in this. Unfortunately you cannot see all logs from all lambdas in a single execution in one place

Upvotes: 0

Ben T
Ben T

Reputation: 4946

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 _.

Upvotes: 6

Joe
Joe

Reputation: 1181

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

Upvotes: 2

Related Questions