Configure alerts for failed workflow invocations

This documents shows you how to configure log-based alerts for failed Dataform workflow invocations by using the Logs Explorer.

You can use Cloud Monitoring to observe trends in Cloud Logging logs for Dataform workflow invocations and to notify you when conditions you describe occur.

Each Dataform workflow invocation is logged using Cloud Logging. Logging is automatically enabled for Dataform workflow invocations, which can incur Cloud Logging billing charges. For more information, see Dataform pricing.

To receive alerts when a Dataform workflow invocation fails, you can create log-based alerts.

You can create log-based alerts from the Logs Explorer page in the Google Cloud console or by using the Monitoring API. This guide describes how to create log-based alerts for Dataform workflow invocation failure by using Logs Explorer.

Before you begin

To create and manage log-based alerts, ensure that your Identity and Access Management role includes the permissions described in Permissions for log-based alerts.

Configure log-based alerts for failed Dataform workflow invocations

To configure log-based alerts for failed Dataform workflow invocations, follow these steps:

  1. In the Google Cloud console, select Logging, and then select Logs Explorer:

    Go to the Logs Explorer

  2. In the Query pane, select Show query and enter the following query:

        resource.type="dataform.googleapis.com/Repository"
        jsonPayload.@type="type.googleapis.com/google.cloud.dataform.logging.v1.WorkflowInvocationCompletionLogEntry"
        jsonPayload.terminalState="FAILED"
     

    This query alerts you of all failed Dataform workflow invocations.

    1. Optional: To filter failed workflow invocations by a release configuration, append the following to the query:

      jsonPayload.releaseConfigId="RELEASE_CONFIGURATION_ID"
      
    2. Optional: To filter failed workflow invocations by a workflow configuration, append the following to the query:

      jsonPayload.workflowConfigId="WORKFLOW_CONFIGURATION_ID"
      

    The following query alerts when a Dataform workflow invocation related both to the daily release configuration and the production workflow configuration fails:

     resource.type="dataform.googleapis.com/Repository"
     jsonPayload.@type="type.googleapis.com/google.cloud.dataform.logging.v1.WorkflowInvocationCompletionLogEntry"
     jsonPayload.terminalState="FAILED"
     jsonPayload.releaseConfigId="daily"
     jsonPayload.workflowConfigId="production"
    
  3. Optional: Use Run query in the Query results pane to validate the query.

  4. In the header of the Query results pane, click Create alert. When your window is narrow, the Create alert option might appear on the Actions menu instead.

  5. In the Alert details pane, give the alert a name and description:

    1. Enter a name for your alert in the Alert Name field. For example: "Dataform: workflow failure".

    2. Enter a description of this alert. You can also include information that might help the recipient of a notification diagnose the problem. The following string summarizes the reason for the alert:

      Log-based alert in project ${project} detected a failed Dataform workflow.
      

      For information about how you can format and tailor the content of this field, see Using Markdown and variables in documentation templates.

  6. To advance to the next step, click Next.

  7. In the Choose logs to include in the alert pane, check the query and results by clicking Preview logs.

    We recommend building the query in the Logs Explorer Query pane. The query you built in the Query pane is also displayed on this pane.

    You can edit the query in this pane, if necessary. If you edit the query, then check the results by clicking Preview logs.

  8. Click Next.

  9. Select the minimum time between notifications. This value lets you control the number of notifications you get from this alert if it is triggered multiple times. For this example, select 5 min from the options.

  10. Optional: Select the incident autoclose duration. By default, the incident autoclose duration is set to 7 days.

  11. Click Next.

  12. Select one or more notification channels for your alert. For this example, select an email notification channel.

    If you already have an email notification channel configured, then you can select it from the list. If not, click Manage notification channels and add an email channel. For information about creating notification channels, see Managing notification channels.

  13. Click Save.

Your log-based alert is now ready to test. For instructions to test the alert, see Test the example log-based alert.

What's next