Google Cloud Platform: How to Monitor Compute Engine CPU Usage

Receive Email Alerts for Compute Engine CPU Consumption

Question

You have a Compute Engine instance hosting a production application.

You want to receive an email if the instance consumes more than 90% of its CPU resources for more than 15 minutes.

You want to use Google services.

What should you do?

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D.

D.

The correct answer is B. Create a Stackdriver Workspace, and associate your Google Cloud Platform (GCP) project with it. Create an Alerting Policy in Stackdriver that uses the threshold as a trigger condition. Configure your email address in the notification channel.

Explanation:

In this scenario, you want to receive an email notification if the CPU usage of your Compute Engine instance goes beyond 90% for more than 15 minutes. Google Cloud Platform offers various services that can help you monitor your Compute Engine instance's resources and send notifications when thresholds are exceeded.

Option A is not the best solution, as it requires you to create a Gmail account and a script that continuously monitors the CPU usage and sends an email notification. This approach is not scalable and may require maintenance efforts.

Option C is also not the best solution, as it requires you to write a script that monitors CPU usage and sends the data as a custom metric to Stackdriver. This solution involves more setup work and requires you to maintain the script's reliability and performance.

Option D is close to the correct answer, but it uses logs-based metrics, which can have a delay in processing the data. These metrics may not be real-time, and you may receive notifications with a delay.

Option B is the best solution as it uses Stackdriver, which is a monitoring and logging service provided by Google Cloud Platform. You can create a Stackdriver Workspace and associate your GCP project with it. Then, create an Alerting Policy in Stackdriver that uses the threshold as a trigger condition. You can set the threshold to 90% for 15 minutes. Finally, configure your email address in the notification channel, and you will receive an email when the policy's conditions are met.

In summary, the best solution to receive an email if the CPU usage of a Compute Engine instance goes beyond 90% for more than 15 minutes is to use Stackdriver to monitor the instance's resources and configure an Alerting Policy to send email notifications.