0
0
GCPcloud~10 mins

Log-based metrics 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 create a log-based metric that counts error logs.

GCP
gcloud logging metrics create error_count --description="Count of error logs" --log-filter="severity=[1]"
Drag options to blanks, or click blank then click option'
AWARNING
BINFO
CDEBUG
DERROR
Attempts:
3 left
💡 Hint
Common Mistakes
Using INFO or DEBUG severity will count non-error logs.
Using WARNING counts warnings, not errors.
2fill in blank
medium

Complete the code to create a metric that counts logs with the text 'timeout'.

GCP
gcloud logging metrics create timeout_count --description="Count of timeout logs" --log-filter="textPayload:[1]"
Drag options to blanks, or click blank then click option'
A"error"
B"success"
C"timeout"
D"warning"
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'error' or 'success' will count wrong logs.
Not using quotes around the text.
3fill in blank
hard

Fix the error in the log filter to count logs with severity WARNING or higher.

GCP
gcloud logging metrics create warning_and_above --description="Count of warnings and above" --log-filter="severity [1] WARNING"
Drag options to blanks, or click blank then click option'
A=
B>=
C<=
D!=
Attempts:
3 left
💡 Hint
Common Mistakes
Using '=' only matches exactly WARNING, not higher severities.
Using '<=' or '!=' filters wrong logs.
4fill in blank
hard

Fill both blanks to create a metric that counts logs from a specific resource type and severity ERROR.

GCP
gcloud logging metrics create resource_error_count --description="Count of error logs from resource" --log-filter="resource.type=[1] AND severity=[2]"
Drag options to blanks, or click blank then click option'
A"gce_instance"
B"ERROR"
C"cloud_function"
D"WARNING"
Attempts:
3 left
💡 Hint
Common Mistakes
Using WARNING instead of ERROR for severity.
Using wrong resource types like cloud_function when gce_instance is needed.
5fill in blank
hard

Fill all three blanks to create a metric that counts logs with severity ERROR, from a specific project, and containing the word 'failure'.

GCP
gcloud logging metrics create project_failure_errors --description="Count of failure errors in project" --log-filter="resource.labels.project_id=[1] AND severity=[2] AND textPayload:[3]"
Drag options to blanks, or click blank then click option'
A"my-project-123"
B"ERROR"
C"failure"
D"success"
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong project ID or severity.
Searching for 'success' instead of 'failure'.