
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
Enable the Profiler
/ 25
Deploy an application to App Engine and examine the Cloud logs
/ 25
Create an instance
/ 25
Create uptime checks and alerts
/ 25
In this lab, you will deploy an application to Google Cloud and then use the tools provided by Google Cloud to monitor it. You will use Cloud Logging, Trace, Profiler, and dashboards and create uptime checks and alerting policies.
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.
Click the Start Lab button. If you need to pay for the lab, a pop-up opens for you to select your payment method. On the left is the Lab Details panel 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 panel.
Click Next.
Copy the Password below and paste it into the Welcome dialog.
You can also find the Password in the Lab Details panel.
Click Next.
Click through the subsequent pages:
After a few moments, the Google Cloud console opens in this tab.
Download a sample application from GitHub and preview it in Cloud Shell.
In the Cloud Console, click Activate Cloud Shell ().
If prompted, click Continue. Once connected to Cloud Shell, you should see that you are already authenticated and that the project is already set to your project ID.
Run the following command in Cloud Shell to confirm that you are authenticated. If prompted, click Authorize:
Command output:
Command output
Command output:
gcp-logging
, run the following command:design-process.zip
folderdeploying-apps-to-gcp
folder:In Cloud Shell, click Open Editor ().
Expand the gcp-logging/design-process/deploying-apps-to-gcp folder in the navigation pane, and then click main.py to open it.
Add the following import statement at the top of the file (line 2):
Profiler will continuously report application metrics. Your code should look like this:
requirements.txt
file. Open that file in the code editor and add the following:The file should look like this:
The program should be displayed in a new browser tab.
Click Check my progress to verify the objective.
Now you will deploy the program to App Engine and use Google Cloud tools to monitor it.
Save your changes.
In a project, an App Engine application has to be created. This is done just once using the gcloud app create
command and specifying the region where you want the app to be created. In Cloud Shell, type the following command:
Now deploy your app with the following command:
In the Google Cloud console title bar, type App Engine in the Search field, then click App Engine from the search result.
Click App Engine > Dashboard. The upper-right corner of the dashboard should display a link to your application similar to this:
https://project-id/appspot.com
.
Click on the link to test your program.
Refresh your browser a few times to make some requests.
Return to the Console and click the App Engine > Versions.
In Diagnose column of the table click Logs.
The logs should indicate that Profiler has started and profiles are being generated. If you get to this point too quickly, wait a minute and click Refresh.
Click Check my progress to verify the objective.
(Since it is different from the region of the App Engine app).
Accept all the rest of the defaults and click Create.
Click Check my progress to verify the objective.
When the VM is ready, click SSH to log in to it.
If prompted allow SSH-in-browser to connect to VMs, click Authorize.
You will generate some traffic to your App Engine app using the web testing tool called Apache Bench. Enter the following commands to install it:
<your-project-id>
with your PROJECT_ID from connection details panel and enter the following command to generate some traffic to your App Engine application:The command will make a thousand requests, 10 at a time, to your application.
Now there is a more interesting chart. Each bar represents a function. The width of the bars represents how much CPU time each function consumed.
The Profiler is a way developers can track down parts of a program that are consuming too many resources.
This shows a history of requests and their latency. Again, it's not very exciting because the application hasn't been running for very long. The chart in the upper-left plots requests and how long they took. The table to the right shows a list of requests. If you select a request, more detail will be displayed at the bottom of the screen.
Return to the SSH window where you entered the Apache Bench command previously.
Replace <your-project-id>
with your PROJECT_ID from connection details panel and enter the following ab command:
You can also experiment with different values for the -n and -c parameters.
In the Navigation menu, click Monitoring.
In the left pane, click Dashboards. Cloud Monitoring analyzes the resources used in your projects and generates some default dashboards for you. In this exercise you have used App Engine and Compute Engine virtual machines, so a table similar to the one shown below should be displayed:
Click on the App Engine dashboard, and then select your project name from the dropdown. A dashboard of pertinent information for your App Engine application will appear.
In the left pane, click Dashboards.
Click on the VM Instances dashboard, and then select your instance. A dashboard for your VM will appear.
Property | Value |
---|---|
Protocol | HTTPS |
Resource Type | URL |
Hostname | <your-project-id>.appspot.com |
Path | / |
Check Frequency | 1 minute |
App Engine Uptime Check
in Title.Click Check my progress to verify the objective.
Return to the open App Engine tab in order to disable the application to see whether your uptime check and alerting policy work.
Click Settings.
Click Disable application. Follow the instructions to disable the application.
Return to the App Engine Dashboard and test the URL. It shouldn't work anymore.
Return to the tab that contains Monitoring, and then click Uptime checks. Your uptime check should be failing. If you get there too fast, wait a minute and click refresh.
Click Alerting. An incident should have been fired.
Check your email. You should get a message from Cloud Monitoring.
Return to App Engine Settings and re-enable your application.Then return to the Uptime checks page. The uptime check should be working again. If not, wait a minute and then click refresh.
Return to the Alerting page. Your incident should be resolved. As before, you might have to wait a minute and then click refresh.
Check your email again. You should get a second email indicating that the alert recovered.
To make sure you don't get any emails after the project is deleted, delete your alerting policy and then delete your notification channel. At the top of the Alerting page, click Edit Notification Channels.
Find your email address and click the trash can icon to delete it.
Now click Uptime checks and delete your App Engine Uptime check.
In this lab, you deployed an application to Google Cloud and then used the tools provided by Google Cloud to monitor it. You used Cloud Logging, Trace, Profiler, and dashboards and created uptime checks and alerting policies.
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 2022 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.
This content is not currently available
We will notify you via email when it becomes available
Great!
We will contact you via email if it becomes available
One lab at a time
Confirm to end all existing labs and start this one