How Do I Check Google Cloud Build Logs Using Logs Explorer

Author

Reads 1.3K

Young man intensely focused on computer work in a tech office setting with a whiteboard in the background.
Credit: pexels.com, Young man intensely focused on computer work in a tech office setting with a whiteboard in the background.

To check Google Cloud Build logs using Logs Explorer, you'll need to have the Logs Explorer feature enabled in your project. This feature allows you to view and analyze your build logs in a centralized location.

Navigate to the Logs Explorer in the Google Cloud Console by clicking on the three horizontal lines in the top left corner, then clicking on "Logging" and finally selecting "Logs Explorer".

Once you're in the Logs Explorer, you can select the specific build logs you want to view by using the query bar at the top. You can filter by build name, timestamp, or other criteria to narrow down your results.

You can also use the "Logs" tab in the Cloud Console to view build logs, but Logs Explorer offers more advanced filtering and analysis capabilities.

Using Logs Explorer

To access your Google Cloud build logs, you'll want to check out Logs Explorer. This interface in the Google Cloud console allows you to query and view logs in a more user-friendly way than the command line.

Credit: youtube.com, 30. Using Logs Explorer | Google Quick Tutorials

Logs Explorer is a great option if you're not comfortable with the command line. You can download logs in JSON or CSV format, although be aware that there's an export limit of 10,000 events. To view logs via Logs Explorer, you'll need an IAM role with the relevant permissions, such as the Private Logs Viewer role mentioned earlier.

To use Logs Explorer, follow these steps:

  1. Log into Logs Explorer at https://console.cloud.google.com/logs/query
  2. Ensure the right project is being viewed
  3. If necessary, use “Refine Scope” on the top left to narrow down the search to a specific bucket/folder.
  4. Build queries to filter the logs
  5. Select “Run query” to execute the search

View Build Results

To view your build results, you'll need to grant the right IAM roles to your principals. Principals require one of the following IAM roles in addition to the Cloud Build IAM permissions.

If your build logs are in the default Cloud Storage bucket, grant the Project > Viewer role. This will give them the necessary access to view the build logs.

If your build logs are in a user-specified Cloud Storage bucket, grant the Storage Object Viewer role. This role is specifically designed for viewing storage objects, making it the perfect choice for this scenario.

House Surrounded by Green Grass Below Clouds and Sky
Credit: pexels.com, House Surrounded by Green Grass Below Clouds and Sky

To summarize, you have two options for granting IAM roles to view build results: Project > Viewer for default Cloud Storage buckets and Storage Object Viewer for user-specified buckets.

Here's a quick reference table to help you keep track of the necessary IAM roles:

Logs Explorer

Logs Explorer is an interface in the Google Cloud console that allows you to query and view logs. It's perfect for those who prefer navigating a UI over using the command line.

You can download logs from Logs Explorer in either JSON or CSV format, but be aware that there's an export limit of 10,000 events. If you download in JSON, you can import them into SOF-ELK and they'll be processed by the Google Cloud logstash parser.

To view logs via Logs Explorer, you'll need an IAM role assigned with the relevant permissions. The Private Logs Viewer role mentioned earlier will provide the necessary permissions.

Credit: youtube.com, 30. Using Logs Explorer | Google Quick Tutorials

Here are the steps to search and download logs using Logs Explorer:

  1. Log into Logs Explorer at https://console.cloud.google.com/logs/query.
  2. Ensure the right project is being viewed.
  3. If necessary, use “Refine Scope” on the top left to narrow down the search to a specific bucket/folder.
  4. Build queries to filter the logs.
  5. Select “Run query” to execute the search.

After you've downloaded the logs, you can import them into the application or tool of your choice for analysis.

Margaret Schoen

Writer

Margaret Schoen is a skilled writer with a passion for exploring the intersection of technology and everyday life. Her articles have been featured in various publications, covering topics such as cloud storage issues and their impact on modern productivity. With a keen eye for detail and a knack for breaking down complex concepts, Margaret's writing has resonated with readers seeking practical advice and insight.

Love What You Read? Stay Updated!

Join our community for insights, tips, and more.