
Before you begin
- Labs create a Google Cloud project and resources for a fixed time
- Labs have a time limit and no pause feature. If you end the lab, you'll have to restart from the beginning.
- On the top left of your screen, click Start lab to begin
Deploy application
/ 50
Create a Log bucket
/ 25
create the log sink
/ 25
In this lab you will learn about the features and tools provided by Cloud Logging to gain insight of your applications.
To use a concrete example, you will work through a scenario based on this microservices demo sample app deployed to a GKE cluster. In this demo app, there are many microservices and dependencies among them.
Read these instructions. Labs are timed and you cannot pause them. The timer, which starts when you click Start Lab, shows how long Google Cloud resources are made available to you.
This hands-on lab lets you do the lab activities in a real cloud environment, not in a simulation or demo environment. It does so by giving you new, temporary credentials you use to sign in and access Google Cloud for the duration of the lab.
To complete this lab, you need:
Click the Start Lab button. If you need to pay for the lab, a dialog opens for you to select your payment method. On the left is the Lab Details pane with the following:
Click Open Google Cloud console (or right-click and select Open Link in Incognito Window if you are running the Chrome browser).
The lab spins up resources, and then opens another tab that shows the Sign in page.
Tip: Arrange the tabs in separate windows, side-by-side.
If necessary, copy the Username below and paste it into the Sign in dialog.
You can also find the Username in the Lab Details pane.
Click Next.
Copy the Password below and paste it into the Welcome dialog.
You can also find the Password in the Lab Details pane.
Click Next.
Click through the subsequent pages:
After a few moments, the Google Cloud console opens in this tab.
Cloud Shell is a virtual machine that is loaded with development tools. It offers a persistent 5GB home directory and runs on the Google Cloud. Cloud Shell provides command-line access to your Google Cloud resources.
Click Activate Cloud Shell at the top of the Google Cloud console.
Click through the following windows:
When you are connected, you are already authenticated, and the project is set to your Project_ID,
gcloud
is the command-line tool for Google Cloud. It comes pre-installed on Cloud Shell and supports tab-completion.
Output:
Output:
gcloud
, in Google Cloud, refer to the gcloud CLI overview guide.
Connect to a Google Kubernetes Engine cluster and validate that it's been created correctly.
1.In Cloud Shell, set the zone in gcloud
:
You should see a similar status:
The cluster status will say RUNNING. If it's still PROVISIONING, wait a moment and run the command above again. Repeat until the status is RUNNING.
You can also check the progress in the Cloud Console - Navigation menu > Kubernetes Engine > Clusters.
(Output)
Your output should look like this:
Next, you will deploy a microservices application called Online Boutique to your cluster to create an actual workload you can monitor.
microservices-demo
directory:kubectl
:The output should look similar to the output below. Re-run the command until all pods are reporting a Running status before moving to the next step.
(Example output)
Your confirmation will look like this:
After the application is deployed, you can also go to the Cloud Console and view the status.
Under Gateways, Services & Ingress, click the Endpoint IP of the service frontend-external:
It should open the application and you will have a page like the following:
Click Check my progress to verify the objective.
There are two ways you can enable Log Analytics. One way is to upgrade an existing bucket. The other is to create a new log bucket with Log Analytics enabled.
You can use the following steps to upgrade an existing log bucket.
On the Navigation menu, click Logging, then click Logs Storage.
Click UPGRADE for an existing bucket, for example, the _Default
bucket.
Click UPGRADE in the popup window.
Wait for the upgrade to complete. Initially the status changes to Not eligible for upgrade before you see the Upgraded status.
Click the OPEN dropdown button.
Select the view _AllLogs
, the Log Analytics page will open for you.
Alternatively, you can configure Cloud Logging to create a new log bucket with Log Analytics enabled.
On the left-hand menu open Logging, then click Logs Storage.
Click CREATE LOG BUCKET at top.
Provide a name such as day2ops-log to the bucket.
Check both Upgrade to use Log Analytics and Create a new BigQuery dataset that links to this bucket.
Type in a dataset name such as: day2ops_log
Selecting Create a linked dataset in BigQuery will create a dataset for you in BigQuery if it does not exist. This way you can run queries in BigQuery if you want to.
Click Check my progress to verify the objective.
You can create a log sink to use the new log bucket. You can do it from the Logs Router directly. Another easy way to do this is from Logs Explorer. You can run log queries to select and filter the logs you are interested in and create a sink. Once nice thing from that approach is the log query will be automatically copied to the sing configuration as the filter.
On the Navigation menu, click Logging, then click Logs Explorer.
In the top-right of Logs Explorer, enable Show query and run the following query in the query field:
Provide a name such as day2ops-sink as the sink name.
Click NEXT.
Select Logging bucket in the sink service dropdown list.
Select the new log bucket you just created.
Click NEXT.
You should see the resource type query already in the filter.
Wait a little bit and your sink should be created.
Click Check my progress to verify the objective.
Go back to the Logs Explorer. Notice that there are many different resource types for the logs as highlighted in the screenshot below.
To view the logs in the new log bucket, click REFINE SCOPE at the top of the page.
Select Log view and the new log bucket you just created.
Click APPLY.
You will see Kubernetes Containers is now the only resource type and there are much less log entries now. That's because only filtered logs will be sent to the bucket.
If your query field is empty or you forget which table you want to use, you can click the Query button to get the sample query back.
Now you can run your own queries in the query field. The following are some examples.
Important: The log view name in the FROM
clause is different for the log buckets. You need to make sure you use the correct view name. You can use the previous step to verify.
You want to find the most recent errors for from the containers:
After run the query, you should see the output like the following:
You can view the min, max, and average latencies in a timeframe for the frontend service:
After run the query, you should see the output like the following:
You want to know how many times users visit a certain product page in the past hour:
After run the query, you should see the output like the following:
You can run the following query to view how many sessions end up with checkout (POST call to the /cart/checkout service):
After run the query, you should see the output like the following:
You now have experience using Cloud Logging to get insight about applications running on GKE, and you built and ran queries using log analytics.
...helps you make the most of Google Cloud technologies. Our classes include technical skills and best practices to help you get up to speed quickly and continue your learning journey. We offer fundamental to advanced level training, with on-demand, live, and virtual options to suit your busy schedule. Certifications help you validate and prove your skill and expertise in Google Cloud technologies.
Manual Last Updated November 01, 2024
Lab Last Tested November 01, 2024
Copyright 2025 Google LLC All rights reserved. Google and the Google logo are trademarks of Google LLC. All other company and product names may be trademarks of the respective companies with which they are associated.
此内容目前不可用
一旦可用,我们会通过电子邮件告知您
太好了!
一旦可用,我们会通过电子邮件告知您
One lab at a time
Confirm to end all existing labs and start this one