Google compute engine – CPU usage alarms

google-cloud-platformgoogle-compute-engine

Currently we use AWS EC2 alarms to shut down idle instances. It works well because we can kick off a long running batch job and let AWS kill the instance when it's work is done.

Does GCE have anything similar? or does anyone know of a workaround to achieve this?

Best Answer

The link that ceejayoz shared is good. I want to add that you can also stop an GCE VM instance instead of deleting it in the case you wish to keep the installed and configured applications or your logs and data. This way after stopping the instance, you will be charged only for the disk storage.

Also note that gcutil is a deprecated tool which is replaced by gcloud tool. For more information of creating, deleting, stopping of VM instances using gcloud command take a look at article [1][2] and [3]. In the link [1] you can find a full list of scopes for GCE instances.

To remove your VM instances manually, you can configure Alert in Google Cloud Monitoring (powered by Stackdriver), select CPU or CPU usage as monitoring metric below a threshold for a duration of time to notify your system admin. This way you will have a chance to re-run your jobs or scripts if they failed before deleting or stopping the instance.

[1] https://cloud.google.com/sdk/gcloud/reference/compute/instances/create
[2] https://cloud.google.com/sdk/gcloud/reference/compute/instances/delete
[3] https://cloud.google.com/sdk/gcloud/reference/compute/instances/stop

Related Topic