This page shows you how to read Ray Operator logs on Google Kubernetes Engine (GKE) using Cloud Logging when you use the Ray Operator on GKE.

## Before you begin


Before you start, make sure that you have performed the following tasks:

- Enable the Google Kubernetes Engine API.
[Enable Google Kubernetes Engine API](https://console.cloud.google.com/apis/enableflow?apiid=container.googleapis.com)
- To use the Google Cloud CLI for this task, [install](https://docs.cloud.google.com/sdk/docs/install) and then [initialize](https://docs.cloud.google.com/sdk/docs/initialize.md.txt) the gcloud CLI. If you previously installed the gcloud CLI, get the latest version by running the `gcloud components update` command. Earlier gcloud CLI versions might not support running the commands in this document.

  > [!NOTE]
  > **Note:** For existing gcloud CLI installations, make sure to set the `compute/region` [property](https://docs.cloud.google.com/sdk/docs/properties.md.txt#setting_properties). If you use primarily zonal clusters, set the `compute/zone` instead. By setting a default location, you can avoid errors in the gcloud CLI like the following: `One of [--zone, --region] must be supplied: Please specify location`. You might need to specify the location in certain commands if the location of your cluster differs from the default that you set.

<!-- -->

- [Enable the Ray Operator for Google Kubernetes Engine (GKE)](https://docs.cloud.google.com/kubernetes-engine/docs/add-on/ray-on-gke/how-to/enable-ray-on-gke.md.txt).

### Requirements and limitations

Ray Operator logs are available on GKE cluster versions 1.33.1-gke.1231000 or later.

## View Ray operator logs

When enabling the Ray Operator on GKE, the operator logs are automatically available in Cloud Logging.

To view the logs, follow these steps:

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

   [**Open the Logs Explorer**](https://console.cloud.google.com/logs)
2. Open the query editor. In the query editor, enter your expression and click **Run query**.

   You can use the following example query in the Logs Explorer:

   ```text
      resource.type="k8s_control_plane_component"
      resource.labels.cluster_name="CLUSTER_NAME"
      resource.labels.location="CLUSTER_LOCATION"
      logName="projects/"PROJECT_NAME"/logs/container.googleapis.com%2Fray-operator"
   ```

   Replace the following values:
   - <var translate="no">CLUSTER_NAME</var>: the name of your GKE cluster.
   - <var translate="no">CLUSTER_LOCATION</var>: the Compute Engine [location](https://docs.cloud.google.com/compute/docs/regions-zones.md.txt#available) of the control plane of your cluster. Provide a region for regional clusters, or a zone for zonal clusters.
   - <var translate="no">PROJECT_NAME</var>: your Google Cloud [project ID](https://docs.cloud.google.com/resource-manager/docs/creating-managing-projects.md.txt#identifying_projects).

   The query returns logs related to the Ray Operator addon, such as the status of the Ray cluster, the creation of the Ray resources, and the reconciliation of the Ray resources.