Lab Overview: Getting Started With Bigquery: Overview in This Lab You Stream Log Data From The Guestbook Application
Lab Overview: Getting Started With Bigquery: Overview in This Lab You Stream Log Data From The Guestbook Application
Version 1.2
Overview In this lab you stream log data from the Guestbook application
to Cloud Logging. Using BigQuery, you analyze and query the log
data.
Component Timing
Introduction 5 minutes
Lab 15 minutes
Total 20 minutes
©Google, Inc. or its affiliates. All rights reserved. Do not distribute. 1
Google Cloud Platform Fundamentals
Version 1.2
Overview In this lab you stream log data from the Guestbook application
to Cloud Logging. Using BigQuery, you analyze and query the log
data.
Clone the The instructions in this section repeat the steps in one of the
project earlier labs. You do not need to follow these steps if you
completed Lab 8: Getting Started with App Engine. If you have
already cloned the Git repository used in Lab 8, skip to the next
section.
Step Action
https://console.developers.google.com
3 Click
Compute Engine > VM instances
.
git clone \
https://github.com/GoogleCloudPlatformTraining/
cp100-appengine-memcache-python.git
©Google, Inc. or its affiliates. All rights reserved. Do not distribute. 2
Google Cloud Platform Fundamentals
Version 1.2
cd cp100-appengine-memcache-python
http://<Project ID>.appspot.com
©Google, Inc. or its affiliates. All rights reserved. Do not distribute. 3
Google Cloud Platform Fundamentals
Version 1.2
2 In the
Google Developers Console , click
Products &
services > Logging . Note that by default, App Engine
logs are selected in the drop-down list. You can see the
application logs in the window below the toolbar.
4 In the
Export These Sources section, click
+ Add item
.
This should automatically add an entry for
appengine.googleapis.com/request_log.
5 In the
Select export destinations
section, for
Stream
to BigQuery dataset , choose
Add new dataset .
7 Click
Save
.
Use To view and query log data using the BigQuery web console:
BigQuery
Step Action
1 In the
Google Developers Console , click
Products &
services > BigQuery or click this link: BigQuery Web
Console. The BigQuery console opens in a separate
window.
5 Click
Logs
. You should see a request log entry below
Logs similar to:
appengine_googleapis_com_request_log_<YYYYMMDD
>.
6 Click
©Google, Inc. or its affiliates. All rights reserved. Do not distribute. 4
Google Cloud Platform Fundamentals
Version 1.2
appengine_googleapis_com_request_log_<YYYYMMDD
> and review the schema for the log data you are
streaming to Big Query. In particular, note the
following attributes that may be useful in queries:
8 In the
New Query window, delete the existing query
and type the following query to view the top 10
requests ordered by latency. Replace <YYYYMMDD>
(including the brackets) with the date appended to
your request log; for example, 20150814.
SELECT protoPayload.resource,
protoPayload.latency
FROM
FLATTEN([Logs.appengine_googleapis_com_request
_log_<YYYYMMDD>], metadata.labels.value)
ORDER BY protoPayload.latency DESC
LIMIT 10
9 Click
RUN QUERY
. The results will appear in the
window below.
10 In the
New Query window, type the following query to
view the count of HTTP status codes. Replace
<YYYYMMDD> (including the brackets) with the date
appended to your request log; for example, 20150814.
SELECT protoPayload.status,
count(protoPayload.status) AS Count
FROM
FLATTEN([Logs.appengine_googleapis_com_request
_log_<YYYYMMDD>], metadata.labels.value)
GROUP BY protoPayload.status
11 Click
RUN QUERY
. The results will appear in the
©Google, Inc. or its affiliates. All rights reserved. Do not distribute. 5
Google Cloud Platform Fundamentals
Version 1.2
window below.
Clean up Google Cloud Logging will charge you for streaming your log
data to BigQuery, so we recommend that you disable the
streaming to BigQuery once you are done with this lab. To
remove the resources used in the lab:
Step Action
1 In the
Google Developers Console
, click
Products &
services > Logging
.
2 Click the
Exports
tab.
3 In the
Select export destinations section, for
Stream
to BigQuery dataset , choose No existing datasets .
This stops log streaming to BigQuery.
4 Click
Save
.
©Google, Inc. or its affiliates. All rights reserved. Do not distribute. 6