0
0
GCPcloud~10 mins

Cloud Logging overview in GCP - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to write a log entry using Cloud Logging client in Python.

GCP
from google.cloud import logging
client = logging.Client()
logger = client.logger('my-log')
logger.[1]('This is a log entry')
Drag options to blanks, or click blank then click option'
Alog_text
Bwrite
Attempts:
3 left
💡 Hint
Common Mistakes
Using a non-existent method like 'write' or 'log'.
Confusing the method with other logging libraries.
2fill in blank
medium

Complete the command to view logs for a specific GCP project using gcloud CLI.

GCP
gcloud logging read 'resource.type=gae_app' --project=[1]
Drag options to blanks, or click blank then click option'
Amy-project-id
Cdefault
Dall-projects
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'default' or 'all-projects' which are invalid project IDs.
Omitting the --project flag.
3fill in blank
hard

Fix the error in the log filter to show only ERROR severity logs.

GCP
severity [1] ERROR
Drag options to blanks, or click blank then click option'
A==
B:
C=
D!=
Attempts:
3 left
💡 Hint
Common Mistakes
Using '=' or '==' which are invalid in Cloud Logging filters.
Using '!=' which filters out ERROR logs.
4fill in blank
hard

Complete the code to create a log-based metric that counts ERROR logs.

GCP
gcloud logging metrics create error_count --description='Count of error logs' --log-filter='severity : ERROR' --metric-descriptor.metric-kind=[1]
Drag options to blanks, or click blank then click option'
A:
BDELTA
C=
DCUMULATIVE
Attempts:
3 left
💡 Hint
Common Mistakes
Using '=' instead of ':' in filter.
Using 'CUMULATIVE' which is for total sums, not counts.
5fill in blank
hard

Fill both blanks to create a sink that exports logs to a Cloud Storage bucket.

GCP
gcloud logging sinks create my-sink storage.googleapis.com/[1] --log-filter='severity : ERROR' --project=[2]
Drag options to blanks, or click blank then click option'
Amy-logs-bucket
B:
Cmy-project-123
D=
Attempts:
3 left
💡 Hint
Common Mistakes
Using '=' instead of ':' in filter.
Using wrong bucket or project names.