Google Associate Cloud Engineer Question 285
Select 3Google Cloud PlatformYou are tasked with creating custom metrics in Google Cloud Monitoring to track the number of HTTP requests processed by your web application deployed on Google Kubernetes Engine (GKE). Which steps should you follow to successfully create and ingest these custom metrics?
- A
A. Define a MetricDescriptor with the desired metric type and labels.
- B
B. Use the gcloud command-line tool to directly create the custom metric.
- C
C. Implement a monitoring agent on the GKE cluster to collect the metrics.
- D
D. Use the Google Cloud Monitoring API to write time series data to the custom metric.
- E
E. Ensure that the IAM role 'roles/monitoring.metricWriter' is assigned to the service account used by your application.
Show answer and explanation
Correct answers: A, D, E
Explanation
To create and ingest custom metrics in Google Cloud Monitoring, you must first define a MetricDescriptor to specify the custom metric's structure and labels. Then, the Google Cloud Monitoring API is used to write time series data to the metric. Additionally, the service account used by your application must have the 'roles/monitoring.metricWriter' role to ensure it has the necessary permissions to write data to Cloud Monitoring. These three steps are essential for setting up and using custom metrics effectively.
- A. Correct.
Option A is correct because defining a MetricDescriptor is the first step in creating a custom metric in Google Cloud Monitoring to specify the type and labels of the metric.
- B. Incorrect.
Option B is incorrect because the gcloud command-line tool cannot be used to directly create custom metrics; it is primarily used for managing Google Cloud resources.
- C. Incorrect.
Option C is incorrect because while a monitoring agent can be used to collect standard metrics, custom metrics require explicit programmatic creation and ingestion.
- D. Correct.
Option D is correct because using the Google Cloud Monitoring API to write time series data is necessary to actually ingest data into the custom metric.
- E. Correct.
Option E is correct because assigning the 'roles/monitoring.metricWriter' IAM role allows the service account to write metrics data to Cloud Monitoring.