> [!WARNING]
>
> **Preview**
>
>
> This product or feature is
>
> subject to the "Pre-GA Offerings Terms" in the General Service Terms section
> of the [Service Specific
> Terms](https://docs.cloud.google.com/terms/service-terms#1).
>
> Pre-GA products and features are available "as is" and might have limited support.
>
> For more information, see the
> [launch stage descriptions](https://cloud.google.com/products/#product-launch-stages).

This page describes how to view platform logs generated by App Lifecycle Manager.
Platform logs in Google Cloud are service-specific logs, which you
can use to debug and troubleshoot issues, and better understand the Google Cloud
services you're using.

For details about supported App Lifecycle Manager platform logs, see
[Google Cloud platform logs](https://docs.cloud.google.com/logging/docs/api/platform-logs#saas_runtime). For
more information about understanding the data in the platform log tables, see
[Log entry structure](https://docs.cloud.google.com/logging/docs/api/platform-logs#structure).

## Before you begin

1. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
2. Ensure that billing is enabled for your Google Cloud project.
3. Enable the App Lifecycle Manager API.
4. To get the permissions that you need to view logs and create alerts, ask your administrator to grant you the following Identity and Access Management (IAM) roles on your project:
   - Logs Viewer (`roles/logging.viewer`)
   - Monitoring Editor (`roles/monitoring.editor`)

## Create log-based alerts

To create a log-based alert, you build a query in the Logs Explorer that returns
the log entries for which you want to be alerted, and then you configure the
alert policy.

1. In the Google Cloud console, go to the **Logs Explorer** page.

   [Go to Logs Explorer](https://console.cloud.google.com/logs/query)
2. In the query editor, enter a query to filter for the chosen log entries.
   See the following sections for example queries.

3. Click **Create alert**.

4. Enter a name and description for the alert policy.

5. Configure the alert details, including notification channels.

6. Click **Save alert**.

For detailed instructions, see [Create a log-based alert](https://docs.cloud.google.com/logging/docs/alerting/log-based-alerts).

### Example queries for platform logs

This section provides example queries for common alert scenarios based on
App Lifecycle Manager platform logs.

#### SaaS operations alerts

To create an alert for when a unit provisioning operation fails, use the query:

    protoPayload.methodName="google.cloud.saasplatform.saasservicemgmt.v1beta1.SaasDeployments.CreateUnitOperation"
    protoPayload.response.state="UNIT_OPERATION_STATE_FAILED"

To create an alert for when a unit provisioning operation reaches a terminal
state (succeeded, failed, or cancelled), use the query:

    jsonPayload.@type="type.googleapis.com/google.cloud.saasservicemgmt.logging.v1.UnitOperationLog"
    AND (jsonPayload.unit_operation_state="UNIT_OPERATION_STATE_SUCCEEDED" OR jsonPayload.unit_operation_state="UNIT_OPERATION_STATE_FAILED" OR jsonPayload.unit_operation_state="UNIT_OPERATION_STATE_CANCELLED")
    AND jsonPayload.unit_operation_type="PROVISION"

#### Rollout alerts

To create a log alert for when a rollout enters a `PAUSED` state (because
App Lifecycle Manager has identified the rollout as unhealthy), or a `FAILED`
state, use the query:

    resource.type = "saasservicemgmt.googleapis.com/Rollout"
    (jsonPayload.currentState = "PAUSED" AND jsonPayload.reason = "SYSTEM_PAUSE")
      OR
    jsonPayload.currentState = "FAILED"

To create a metric alert for rollout state metrics when a rollout enters a `PAUSED`
state (because App Lifecycle Manager has identified the rollout as unhealthy),
or a `FAILED` state, use the query:

    saasservicemgmt_googleapis_com:rollout_state
    {state_name="PAUSED", reason="SYSTEM_PAUSE"}
    OR
    saasservicemgmt_googleapis_com:rollout_state{state_name="FAILED"}

## What's next

- For more information about supported App Lifecycle Manager platform logs, see [Google Cloud platform logs](https://docs.cloud.google.com/logging/docs/api/platform-logs#saas_runtime).
- To understand the data in platform log tables, see [Log entry structure](https://docs.cloud.google.com/logging/docs/api/platform-logs#structure).
- Learn more about [App Lifecycle Manager audit logs](https://docs.cloud.google.com/saas-runtime/docs/audit-logging).