Complete the code to write a log entry using Cloud Logging client in Python.
from google.cloud import logging client = logging.Client() logger = client.logger('my-log') logger.[1]('This is a log entry')
The method log_text is used to write a simple text log entry in Cloud Logging client.
Complete the command to view logs for a specific GCP project using gcloud CLI.
gcloud logging read 'resource.type=gae_app' --project=[1]
You must specify your actual GCP project ID with the --project flag to read logs for that project.
Fix the error in the log filter to show only ERROR severity logs.
severity [1] ERRORIn Cloud Logging filters, the colon ':' is used to specify equality for severity levels.
Complete the code to create a log-based metric that counts ERROR logs.
gcloud logging metrics create error_count --description='Count of error logs' --log-filter='severity : ERROR' --metric-descriptor.metric-kind=[1]
The filter uses ':' to match severity, and the metric kind for counting occurrences is 'DELTA'.
Fill both blanks to create a sink that exports logs to a Cloud Storage bucket.
gcloud logging sinks create my-sink storage.googleapis.com/[1] --log-filter='severity : ERROR' --project=[2]
The sink exports logs to the bucket named 'my-logs-bucket'. The filter uses ':' to match ERROR severity. The project ID is 'my-project-123'.