Day #13 with Cloud Workflows: Logging with Cloud Logging

Time to come back to our series on Cloud Workflows. Sometimes, for debugging purposes or for auditing, it is useful to be able to log some information via Cloud Logging. As we saw last month, you can call HTTP endpoints from your workflow. We can actually use Cloud Logging’s REST API to log such messages! Let’s see that in action.

- log:
type: OAuth2
- logName: ${"projects/" + sys.get_env("GOOGLE_CLOUD_PROJECT_ID") + "/logs/workflow_logger"}
type: "audited_resource"
labels: {}
textPayload: Hello World from Cloud Workflows!

We call the API endpoint to write new logging entries. We authenticate via OAuth2-as long as the service account used for the workflow execution allows it to use the logging API. Then we pass a JSON structure as the body of the call, indicating the name of the logger to use, which resources it applies to, and also the textPayload containing our text message. You could also use a ${} expression to log more complex values.

Once this workflow definition is done and deployed, you can execute it, and you should see in the logs your message appear:

Voila! You can log messages to Cloud Logging!

Let’s recap in this video:

In the next episode, we’ll take advantage of subworkflows, to create a reusable set of steps that you will be able to call several times throughout your workflow definition, without repeating yourself, by turning this logging example into a subworkflow.

Originally published at



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Guillaume Laforge

Guillaume Laforge

Developer Advocate for Google Cloud Platform, Apache Groovy programming language project VP/Chair