
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
Set up resources in the first project
/ 20
Configure the export to BigQuery
/ 40
Create a logging metric
/ 40
In this lab, you will learn common configurations and uses of both Cloud Logging and Cloud Monitoring.
You will learn how to view logs with filtering mechanisms, export logs to BigQuery syncs, and create logging metrics. You will also learn how to use Cloud Monitoring to view consumption metrics and create dashboards..
In this lab, you will learn how to perform the following tasks:
For each lab, you get a new Google Cloud project and set of resources for a fixed time at no cost.
Sign in to Qwiklabs using an incognito window.
Note the lab's access time (for example, 1:15:00
), and make sure you can finish within that time.
There is no pause feature. You can restart if needed, but you have to start at the beginning.
When ready, click Start lab.
Note your lab credentials (Username and Password). You will use them to sign in to the Google Cloud Console.
Click Open Google Console.
Click Use another account and copy/paste credentials for this lab into the prompts.
If you use other credentials, you'll receive errors or incur charges.
Accept the terms and skip the recovery resource page.
Google 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.
Google Cloud Shell provides command-line access to your Google Cloud resources.
In Cloud console, on the top right toolbar, click the Open Cloud Shell button.
Click Continue.
It takes a few moments to provision and connect to the environment. When you are connected, you are already authenticated, and the project is set to your PROJECT_ID. For example:
gcloud is the command-line tool for Google Cloud. It comes pre-installed on Cloud Shell and supports tab-completion.
Output:
Example output:
Output:
Example output:
In this task, you create the Google Cloud resources for the first project.
In the Qwiklabs Connection Details section, you will see two projects listed. The first project will contain active Google Cloud resources, which will generate logs and monitoring metric data.
The second project will contain your Monitoring account configuration data.
If you have not activated cloud shell yet then, activate the Cloud Shell by clicking on Activate cloud shell. If prompted, click Continue.
In the Cloud Shell, download and unpack an archive that contains setup code:
Click on the Open Editor icon in the top-right corner of your Cloud Shell session.
Click Open in a new window if prompted.
Open the stackdriver-lab folder and select the linux_startup.sh file.
Replace the # install Ops Agent
section with the following:
After pasting, make sure that your lines of code are properly indented.
Save your file.
Now open the setup.sh
file.
Update the image version in # create vms
section for windows-server (row 17) after --image
with the following:
After pasting, make sure that your lines of code are properly indented.
Save your file.
In the Cloud Console, click Open Terminal in the top-right corner.
The created resources will include:
You can safely ignore errors about service accounts and firewalls already existing.
Ensure you receive a similar output that states that both the Linux and Windows VMs are created:
Click Check my progress to verify the objective.
In this task, you view VM instance logs with simple filtering.
Ensure that you are on the Google Cloud Console homepage.
Verify you are still working in project 1; the project ID in the Console's info panel should match Project ID 1 in your lab's connection details panel.
View Cloud Logging by opening Navigation menu > Logging > Logs Explorer. If prompted, close the notification.
On the left-hand panel, Log fields will be visible. Under Resource Type, you will see several Google Cloud services that are creating logs.
All of these services are writing log entries. Entries from all these logs appear on the right, in the Query results pane. You can also query for results from specific logs, or that match specific criteria.
After you click this:
INSTANCE ID
. It shows all the instance IDs of the VM instances that are writing log entries.resource.type="gce_instance"
. This means that only entries from VM instances will be logged and displayed.In the Instance Id field, select one of the instance IDs. Logs for the associated VM instance appear in the Query results pane.
Click inside the Query box. This now becomes editable.
In the Query box, remove everything after line 1. You should see only line 1, which contains resource.type="gce_instance"
.
Click Run query (located in the top-right corner). In the Query results, you should see entries from all VM instance logs.
Note that the logs panel reverts to its previous state.
Turn on streaming logs by clicking Stream logs (top-right corner, above the "Run query" button).
You should see new log entries showing up every 1-2 seconds as the background activity is generating unauthorized requests against your Web servers.
You will now view overall web activity on any Linux Apache server.
Stop log streaming by clicking on Stop stream in the top-right corner.
Now click on the All Log Names dropdown, and select syslog, and then click Apply.
Entries from syslog appear in the Query results pane.
In this task, you configure and test log exports to BigQuery.
Cloud Logging retains log entries for 30 days. In most circumstances, you'll want to retain some log entries for an extended time (and possibly perform sophisticated reporting on the archived logs).
Google Cloud provides a mechanism to have all log entries ingested into Cloud Monitoring also written to one or more archival sinks
.
Go to Cloud Logging Exports (Navigation menu > Logging > Log Router).
Click Create Sink.
For the Sink name, type vm_logs
and then click Next.
For Select sink service, select BigQuery dataset.
For Select BigQuery dataset, select Create new BigQuery dataset.
For the Dataset ID, type project_logs
, and click Create Dataset.
Click Next.
In the Build inclusion filter list box, copy and paste resource.type="gce_instance"
.
Click Create Sink. You will now return to a Log Router Create log sink next steps page (a message at the top may appear that says "Your log sink was successfully created. Data should be available soon.")
Monitoring > Pub/Sub > Dataflow > BigQuery/Bigtable
).
Exporting to Cloud Storage will batch up entries and write them into Cloud Storage objects approximately every hour.You will now create an export for the HTTP load balancing logs to BigQuery.
From the left-hand navigation menu, select Log Router to return to the service homepage.
Click Create Sink.
For the Sink name, type load_bal_logs
and then click Next.
For Select sink service, select BigQuery dataset.
For Select BigQuery dataset, select project_logs. (You created this BigQuery dataset in the previous set of steps.)
Click Next.
In the Build inclusion filter list box, copy and paste resource.type="http_load_balancer"
.
Click Create Sink.
You will now be on the Create log sink next steps page for the log sink.
From the left-hand navigation menu, select Log Router to return to the service homepage.
The Log Router page appears, displaying a list of sinks (including the one you just created—load_bal_logs
).
Open BigQuery (Navigation menu > BigQuery).
The "Welcome to BigQuery in the Cloud Console" message box opens. This message box provides a link to the quickstart guide and lists UI updates.
Click Done.
In the left pane in the Explorer section, click the arrow next to your project (this starts with qwiklabs-gcp-xxx
) and you should see a project_logs
dataset revealed under it.
You will now verify that the BigQuery dataset has appropriate permissions to allow the export writer to store log entries.
Click on the three dotted menu item ("View actions") next to the project_logs
dataset and click Open.
Then from the top-right hand corner of the Console, click the Sharing dropdown and select Permissions.
On the Dataset permission page, you will see that your service accounts have the "BigQuery Data Editor" role.
Close the dataset permissions panel.
Expand the project_logs
dataset to see the tables with your exported logs—you should see multiple tables (one for each type of log that's receiving entries).
Click on the syslog_(1) table, then click Details to see the number of rows and other metadata. If the syslog_(1) table is not visible, try refreshing the browser.
In Details tab, under the table info you will see the full table name in the Table ID, copy this table name.
qwiklabs-gcp-xx.project_logs.syslog_xxxxx
with the table name you copied in the previous step).Feel free to experiment with some other queries that might provide interesting insights.
Note: Cloud Logging exports incoming log entries before any decision is made about ingesting the entry into logging storage. As a result, only new log entries will be exported to the sink. As a result, you may not see a syslog_(1)
table as all the syslog entries were generated prior to the export.
gcloud logging read "resource.type=gce_instance AND logName=projects/[PROJECT_ID]/logs/syslog AND textPayload:SyncAddress" --limit 10 --format json
.
Click Check my progress to verify the objective.
In this task, you create a metric that you can use to generate alerts if too many web requests generate access denied log entries.
Cloud Monitoring allows you to create custom metrics based on the arrival of specific log entries.
Select Create Metric from Actions dropdown (right-hand side of the Console) to create a logging metric based on this filter.
In the Log-based metric Editor, set Metric Type as Counter.
Under the Details section, set the Log-based metric name to 403s.
Under the Filter selection for Build filter, enter the following and replace PROJECT_ID
with Project ID 1:
Leave all the other fields at their default.
Click Create Metric.
You will make use of this metric in the dashboarding portion of the lab.
Click Check my progress to verify the objective.
In this task, you switch to the second project created by Qwiklabs and setup a Monitoring workspace.
Click the second project you want to switch to. Verify it is the Project ID 2 from the Qwiklabs Connection Details.
Click Open.
You will now setup a Monitoring workspace that's tied to your Google Cloud Project. The following steps create a new account that has a free trial of Monitoring.
In the Cloud Console, click on Navigation menu > Monitoring.
Wait for your workspace to be provisioned.
When the Monitoring dashboard opens, your workspace is ready.
Now add the first project to your Cloud Monitoring workspace.
In the left menu, click Settings, then click Metric Scope and click + Add Projects.
Click Select Projects
Select the checkmark next to your first project ID and click Select.
Click Add Projects.
In the left pane, click Dashboards.
Click + Create Dashboard.
Replace the generic dashboard name at the top with Example Dashboard
.
Click Add Widget > Line.
For Widget Title, enter in CPU Usage.
Click the Metric dropdown.
Click Active to deselect it. The tick should disappear.
For Metric, select VM Instance > Instance > CPU usage. Make sure it's the one that follows the format: compute.googleapis.com/instance/cpu/usage_time
.
Click Apply.
Now click Apply in the top-right corner.
Click Add Widget > Line.
For Widget Title, enter in Memory Utilization.
Click the Metric dropdown.
Click Active to deselect it. The tick should disappear.
For Metric, select VM Instance > Memory > Memory Utilization. Make sure it's the one that follows the format: agent.googleapis.com/memory/percent_used
.
Click Apply.
Now click Apply in the top-right corner.
You should now see your two graphs—one for CPU usage and the other for memory utilization—populated.
You can now explore some other options by editing the charts such as Filter, Group By, and Aggregation.
In this lab, you learned how to do the following:
View logs using a variety of filtering mechanisms.
Exclude log entries and disable log ingestion.
Export logs and run reports against exported logs.
Create and report on logging metrics.
Use Cloud Monitoring to monitor different Google Cloud projects.
Create a metrics dashboard.
When you have completed your lab, click End Lab. Google Cloud Skills Boost removes the resources you’ve used and cleans the account for you.
You will be given an opportunity to rate the lab experience. Select the applicable number of stars, type a comment, and then click Submit.
The number of stars indicates the following:
You can close the dialog box if you don't want to provide feedback.
For feedback, suggestions, or corrections, please use the Support tab.
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