Use the methods on this page to view information about your managed instance groups (MIGs) and to view information about the virtual machine (VM) instances within each MIG.
Note: Various policies and actions can create, delete, and modify instances that are managed by a MIG. Those operations are returned asDONE
after the group has scheduled actions to create, delete, or update those instances. However, this doesn't mean that the instances in the group have been created, deleted, or updated until those underlying actions are complete. You must verify the status of the group, or alternatively verify the status of those instances. Before you begin
Select the tab for how you plan to use the samples on this page:
ConsoleWhen you use the Google Cloud console to access Google Cloud services and APIs, you don't need to set up authentication.
gcloudInstall the Google Cloud CLI. After installation, initialize the Google Cloud CLI by running the following command:
gcloud init
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
Note: If you installed the gcloud CLI previously, make sure you have the latest version by runninggcloud components update
.To use the REST API samples on this page in a local development environment, you use the credentials you provide to the gcloud CLI.
Install the Google Cloud CLI. After installation, initialize the Google Cloud CLI by running the following command:
gcloud init
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
For more information, see Authenticate for using REST in the Google Cloud authentication documentation.
You can retrieve information about groups themselves, for example, to inspect the policies that are attached to the group and to check if the group is stable or undergoing changes. To get info about the VM instances within a MIG, see View info about managed instances.
List MIGsTo get a list of your managed instance groups, use the console, the gcloud CLI, or REST.
ConsoleIn the Google Cloud console, go to the Instance groups page.
If you have existing instance groups, the page lists those groups, including both managed instance groups and unmanaged instance groups.
The Group type column specifies whether the group is managed, stateful, or unmanaged. The stateful group types are also managed instance groups.
List all managed instance groups within a project:
gcloud compute instance-groups managed listREST
For zonal MIGs, call the instanceGroupManagers.list
method method:
GET https://compute.googleapis.com/compute/v1/projects/project-id/zones/zone/instanceGroupManagers
For regional MIGs, call the regionInstanceGroupManagers.list
method.
GET https://compute.googleapis.com/compute/v1/projects/project-id/regions/region/instanceGroupManagersView a MIG's properties
To view information about a specific MIG, including its policies (for example, the group's autohealing and update policies), use the console, the gcloud CLI, or REST.
To view the group's id
value, you must use the gcloud CLI or the Compute Engine API.
To perform this task, you must have the following permissions:
compute.instanceGroupManagers.get
on the instance groupIn the Google Cloud console, go to the Instance groups page.
If you have existing instance groups, the page lists those groups. The page also lists unmanaged instance groups.
Under the Name column of the list, click the name of the instance group that you want to examine. A page opens with the instance group properties and a list of instances that are included in the group.
Click Details to see the group's configuration.
To get information about a specific group:
gcloud compute instance-groups managed describe instance-group \ [--zone zone | --region region]
The command returns details about the group, including attached policies.
Use the --format
flag to limit the output. For example, the following command only returns the group's autoscaler configuration if it exists.
gcloud compute instance-groups managed describe instance-group --format="(autoscaler)"REST
For zonal MIG, call the instanceGroupManagers.get
method. For regional MIGs, call the regionInstanceGroupManagers.get
method.
GET https://compute.googleapis.com/compute/v1/projects/project-id/regions/region/instanceGroupManagers/instance-group
The response includes details about the group, including attached policies except for the group's autoscaling policy. Although autoscaling is a feature of MIGs, it is a separate REST resource.
Autoscaling policy
If an autoscaler is attached to the group, the autoscaler resource is listed in the group's status.autoscaler
field.
To get information about that autoscaler, call the autoscalers.get
method for a zonal MIG or the regionAutoscalers.get
method for a regional MIG. The URL of the autoscaler resource includes its name, which, by default, is the name of the group that the autoscaler is attached to. For example, you might make the following request for a regional MIG's autoscaler:
GET https://compute.googleapis.com/compute/v1/projects/project-id/regions/region/regionAutoscalers/mig_nameCheck whether a MIG is stable
Several commands and requests create, delete, and modify instances in a managed instance group. Those operations are returned as DONE
after the group has scheduled actions to create, delete, or update those instances. However, this doesn't mean that instances in the group have been created, deleted, or updated until those underlying actions are complete. You must verify the status of the group, or alternatively verify the status of those instances.
A managed instance group is stable when all instances in the managed instance group are not undergoing any change, no future changes are scheduled for the instances, and the group itself is not being modified.
You might need to know whether the group is stable when you have dependencies that rely on all instances in the group being healthy and serving. For example, you might want to start scheduling jobs, sending traffic, or assigning key ranges after you have confirmation that all the VMs are running and healthy.
Verify that all instances in a managed instance group are running and healthy by checking the value of the group's status.isStable
field.
Use the describe
command:
gcloud compute instance-groups managed describe instance-group-name \ [--zone zone | --region region]
The gcloud CLI returns detailed information about the MIG including its status.isStable
field.
To pause a script until the MIG is stable, use the wait-until
command with the --stable
flag. For example:
gcloud compute instance-groups managed wait-until instance-group-name \ --stable \ [--zone zone | --region region] Waiting for group to become stable, current operations: deleting: 4 Waiting for group to become stable, current operations: deleting: 4 ... Group is stable
The command returns after status.isStable
is set to true
for the MIG.
For a zonal MIG, make a GET
request to the instanceGroupManagers.get
method:
GET https://compute.googleapis.com/compute/v1/projects/project-id/zones/zone/instanceGroupManagers/instance-group-name/get
For a regional managed instance group, replace zones/zone
with regions/region
:
GET https://compute.googleapis.com/compute/v1/projects/project-id/regions/region/instanceGroupManagers/instance-group-name/get
These requests returns detailed information about the MIG including its status.isStable
field.
status.isStable
set to false
indicates that changes are active, pending, or that the MIG itself is being modified.
status.isStable
set to true
indicates the following:
currentAction
for all instances is NONE
.Remember that the stability of a MIG depends on numerous factors because a MIG can be modified in numerous ways. For example:
As soon as all actions are finished, status.isStable
is set to true
again for that MIG.
For individual VM instances, see Checking the status of managed instances.
Check whether VM repairs are turned off in a MIGTo check whether VM repairs are turned off in a MIG, use the console, the gcloud CLI, or REST.
Permissions required for this taskTo perform this task, you must have the following permissions:
compute.instanceGroupManagers.get
on the instance groupcompute.instanceGroupManagers.list
on the instance groupIn the VM instance lifecycle section, check the values of the following fields:
Use the beta describe
method as follows:
gcloud beta compute instance-groups managed describe instance-group \ --format="(instanceLifecyclePolicy)" \ --zone=zone
Replace the following:
instance-group
: The name of the MIG.zone
: For a zonal MIG, specify the zone. For a regional MIG, use the --region=region
flag.In the output, check the following values:
defaultActionOnFailure
: If the value is DO_NOTHING
, then automatic repairs of failed VMs are off.onFailedHealthCheck
: If the value is any of the following, then autohealing is off.
DEFAULT_ACTION
, provided the value of defaultActionOnFailure
field is DO_NOTHING
DO_NOTHING
The following is a sample output when repairs of failed and unhealthy VMs are turned off in a MIG:
instanceLifecyclePolicy: defaultActionOnFailure: DO_NOTHING forceUpdateOnRepair: NO onFailedHealthCheck: DEFAULT_ACTIONREST
For a zonal MIG, use the beta instanceGroupManagers.get
method, or, for a regional MIG, use the beta regionInstanceGroupManagers.get
method.
To view the MIG action on VM failures in a zonal MIG, make the following call:
GET https://compute.googleapis.com/compute/beta/projects/project_ID/zones/zone/instanceGroupManagers/instance_group
In the response body, check the values of the following fields:
defaultActionOnFailure
: If the value is DO_NOTHING
, then automatic repairs of failed VMs are off.onFailedHealthCheck
: If the value is any of the following, then autohealing is off.
DEFAULT_ACTION
, provided the value of defaultActionOnFailure
field is DO_NOTHING
DO_NOTHING
The following is a sample output when repairs of failed and unhealthy VMs are turned off in a MIG:
... "instanceLifecyclePolicy": { "forceUpdateOnRepair": "NO", "defaultActionOnFailure": "DO_NOTHING", "onFailedHealthCheck": "DEFAULT_ACTION" } ...
If the repairs are turned off and you want to turn them back on again, see Turn on repairs or autohealing.
View historical autohealing operationsIf you configured autohealing, then you can view past autohealing events.
Monitor rolling updatesIf you initiated a rolling update, and want to know when the update is complete, then see Monitoring updates.
View stateful configurationIf you configured a stateful MIG and want to review your configuration, then see Viewing stateful configuration.
View details about the managed VM instances within a MIGThis section explains how to view various details about managed instances in a MIG.
List a MIG's managed instancesTo view a list of the managed instances in a group, including their states and templates, use the console, the gcloud CLI, or REST.
Permissions required for this taskTo perform this task, you must have the following permissions:
compute.instanceGroupManagers.get
on the instance groupcompute.instanceGroupManagers.list
on the instance groupIn the Google Cloud console, go to the Instance groups page.
If you have existing instance groups, the page lists those groups. The page also lists unmanaged instance groups.
Under the Name column of the list, click the name of the instance group that you want to examine. A page opens with the instance group properties and a list of instances that are included in the group.
Use the gcloud CLI list-instances
sub-command.
gcloud compute instance-groups managed list-instances instance-group \ [--zone zone | --region region]
The command returns a list of instances and their details, including their current status, instance template, and last error.
RESTFor a zonal MIG, construct a GET
request to the instanceGroupManagers.listManagedInstances
method and include the name of a specific managed instance group:
GET https://compute.googleapis.com/compute/v1/projects/project-id/zones/zone/instanceGroupManagers/instance-group
For regional (multiple-zone) managed instance groups, use the regionInstanceGroupManagers
resource instead: regionInstanceGroupManagers.list.
GET https://compute.googleapis.com/compute/v1/projects/project-id/regions/region/instanceGroupManagers/instance-group
The response includes a list of instances and their details, including their current status and instance template.
Check the status of managed instancesSeveral commands and requests create, delete, and modify instances in a managed instance group. Those operations are returned as DONE
after the group has scheduled actions to create, delete, or update those instances. However, this doesn't mean that instances in the group have been created, deleted, or updated until those underlying actions are complete. You must verify the status of those instances, or alternatively verify the status of the group itself.
Use the Google Cloud CLI or REST to see details about the instances in a managed instance group. Details include instance status and current actions that the group is performing on its instances.
Permissions required for this taskTo perform this task, you must have the following permissions:
compute.instanceGroupManagers.get
on the groupcompute.instanceGroupManagers.list
on the groupAll managed instances
To check the status and current actions on all instances in the group, use the list-instances
command.
gcloud compute instance-groups managed list-instances INSTANCE_GROUP_NAME \ [--zone=ZONE | --region=REGION]
The command returns a list of instances in the group, including their status, current actions, and other details:
NAME: vm-instances-9pk4 ZONE: us-central1-f STATUS: HEALTH_STATE: ACTION: CREATING INSTANCE_TEMPLATE: my-new-template VERSION_NAME: LAST_ERROR: NAME: vm-instances-h2r1 ZONE: us-central1-f STATUS: STOPPING HEALTH_STATE: ACTION: DELETING INSTANCE_TEMPLATE: my-old-template VERSION_NAME: LAST_ERROR:
The HEALTH_STATE
column appears empty unless you have set up health checking.
A specific managed instance
To check the status and current action for a specific instance in the group, use the describe-instance
command.
gcloud compute instance-groups managed describe-instance INSTANCE_GROUP_NAME \ --instance INSTANCE_NAME \ [--zone=ZONE | --region=REGION]
The command returns details about the instance, including instance status, current action, and, for stateful MIGs, preserved state:
currentAction: NONE id: '6789072894767812345' instance: https://www.googleapis.com/compute/v1/projects/example-project/zones/us-central1-a/instances/example-mig-hz41 instanceStatus: RUNNING name: example-mig-hz41 preservedStateFromConfig: metadata: example-key: example-value preservedStateFromPolicy: disks: persistent-disk-0: autoDelete: NEVER mode: READ_WRITE source: https://www.googleapis.com/compute/v1/projects/example-project/zones/us-central1-a/disks/example-mig-hz41 version: instanceTemplate: https://www.googleapis.com/compute/v1/projects/example-project/global/instanceTemplates/example-templateREST
Call the listManagedInstances
method on a regional or zonal MIG resource. For example, to see details about the instances in a zonal MIG resource, you can make the following request:
GET https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/instanceGroupManagers/INSTANCE_GROUP_NAME/listManagedInstances
The call returns a list of instances for the MIG including each instance's instanceStatus
and currentAction
.
{ "managedInstances": [ { "instance": "https://www.googleapis.com/compute/v1/projects/example-project/zones/us-central1-f/instances/vm-instances-prvp", "instanceStatus": "RUNNING", "currentAction": "REFRESHING", "id": "5317605642920955957", "version": { instanceTemplate": "https://www.googleapis.com/compute/v1/projects/example-project/global/instanceTemplates/example-template" }, "name": "vm-instances-prvp" }, { "instance": "https://www.googleapis.com/compute/v1/projects/example-project/zones/us-central1-f/instances/vm-instances-w2t5", "instanceStatus": "RUNNING", "currentAction": "REFRESHING", "id": "2800161036826218547", "version": { "instanceTemplate": "https://www.googleapis.com/compute/v1/projects/example-project/global/instanceTemplates/example-template" }, "name": "vm-instances-w2t5" } ] }
If you set up health checking, then the response also includes the instanceHealth
field.
To see a list of valid instanceStatus
field values, see VM instance lifecycle.
If an instance is undergoing some type of change, the managed instance group sets the instance's currentAction
field to one of the following actions to help you track the progress of the change. Otherwise, the currentAction
field is set to NONE
.
Possible currentAction
values are:
ABANDONING
. The instance is being removed from the MIG.CREATING
. The instance is in the process of being created.CREATING_WITHOUT_RETRIES
. The instance is being created without retries; if the instance isn't created on the first try, the MIG doesn't try to replace the instance again.DELETING
. The instance is in the process of being deleted.RECREATING
. The instance is being replaced.REFRESHING
. The instance is being removed from its current target pools and being readded to the list of current target pools (this list might be the same or different from existing target pools).RESTARTING
. The instance is in the process of being restarted using the stop
and start
methods.RESUMING
. The instance is in the process of being resumed after being suspended.STARTING
. The instance is in the process of being started after being stopped.STOPPING
. The instance is being stopped.SUSPENDING
. The instance is being suspended.VERIFYING
. The instance has been created and is in the process of being verified.NONE
. No actions are being performed on the instance.To check if the group as a whole is stable or is undergoing changes, see Checking the status of the group.
Check health statesIf you have configured autohealing for your managed instance group, you can review the health state of each VM. See Checking health status.
List instance errorsIf your managed instances encountered errors, you can view those errors to diagnose and mitigate the cause.
Use the Google Cloud console, the gcloud CLI, or REST to list errors.
ConsoleIn the Google Cloud console, go to the Instance groups page.
Under the Name column of the list, click the name of the instance group that you want to examine. A page opens with the instance group properties and a list of instances that are included in the group.
Click Errors.
Use the instance-groups managed list-errors
command to list the most recent errors in the group
gcloud compute instance-groups managed list-errors instance-group-name \ [--zone zone | --region region]
For example:
gcloud compute instance-groups managed list-errors example-group \ --region us-west1
INSTANCE_URL ACTION ERROR_CODE ERROR_MESSAGE TIMESTAMP INSTANCE_TEMPLATE VERSION_NAME https://www.googleapis.com/compute/v1/projects/my-project/zones/us-central1-a/instances/igm-1-v0hl CREATING QUOTA_EXCEEDED Instance 'igm-1-v0hl' creation failed: Quota 'CPUS' exceeded. Limit: 1.0 in zone us-central1-a. 2019-07-11T07:44:40.156-07:00 https://www.googleapis.com/compute/v1/projects/my-project/global/instanceTemplates/instance-template-1 https://www.googleapis.com/compute/v1/projects/my-project/zones/us-central1-a/instances/igm-1-qp3d CREATING QUOTA_EXCEEDED Instance 'igm-1-qp3d' creation failed: Quota 'CPUS' exceeded. Limit: 1.0 in zone us-central1-a. 2019-07-11T07:44:40.081-07:00 https://www.googleapis.com/compute/v1/projects/my-project/global/instanceTemplates/instance-template-1 ...REST
Construct a GET
request to the listErrors
method for a zonal or regional managed instance group.
For example:
GET https://compute.googleapis.com/compute/v1/projects/project-id/zones/zone/instanceGroupManagers/instance-group-name/listErrors&maxResults=100
The request gets a response similar to:
{ "items": [ { "error": { "code": "QUOTA_EXCEEDED", "message": "Instance 'example-mig-m1sz' creation failed: Quota 'CPUS' exceeded. Limit: 50.0 in zone us-central1-c." }, "timestamp": "2019-01-03T18:47:28.457-08:00", "instanceDetails" : { "instance": "zones/us-central1-c/instances/example-mig-m1sz", "action": "CREATING", "version": { "name": "example-version-name", "instanceTemplate": "global/instanceTemplates/example-template", } } } ], ... "nextPageToken": "Ch0yMDE5LTA3LTI5VDExOjA4OjA2LjYxMi0wNzowMBJ5aHR0cHM6Ly93d3cuZ29vZ2xlYXBpcy5jb20vY29tcHV0ZS9zdGFnaW5nX2FscGhhL3Byb2plY3RzL215cnpha2VyZXltcy1zdGFnaW5nL3pvbmVzL3VzLWNlbnRyYWwxLWlyMS9pbnN0YW5jZXMvaWdtLTEtcXAzZA==" }
The listErrors
API supports list pagination. To get the next page of results, use the nextPageToken
field from one response in a subsequent request. For example: GET https://compute.googleapis.com/compute/v1/projects/project-id/zones/zone/instanceGroupManagers/instance-group-name/listErrors&maxResults=100&nextPageToken=next-page-token
, replacing next-page-token
with the token that was obtained from the previous response.
The list of possible errors includes, but is not limited to, the following examples:
properties.disks[].initializeParams.sourceImage
field was deleted, or its permissions have changed.compute.instances.delete
permission.After inspecting such errors, you can mitigate them. For example:
compute.instances.delete
permission to the service account used by the group.If an action that is triggered by a managed instance group fails (for example, if an autoscaler encounters an error when attempting to increase the group's size), the group might immediately retry that action. If the last immediate retry attempt fails, the MIG records the error, and you can view the error by listing instance errors. After some backoff time, the group again retries the failed action. If the error persists, it might be recorded multiple times.
Compute Engine retains the most recent 500 errors for the last 8 days even if the underlying instances no longer exist or couldn't be created.
Check if a VM instance is part of a MIGTo check if a specific VM is a member of a group, you can use the console or REST.
ConsoleSee Viewing referrers to VM instances.
Alternatively, to identify whether a VM is or was a member of a managed instance group, look for these two metadata keys in the instance's metadata:
instance-template
indicates the template the VM was created from.created-by
indicates the managed instance group that created the VM.Even if you abandon the instance, the VM will still have these metadata entries, unless you manually remove them.
For example, if there was an VM named random-instance-biy
and you wanted to know whether the VM was created by a managed instance group, you can describe the instance and look for the metadata keys. For example:
gcloud compute instances describe random-instance-biy \ --zone us-central1-f
gcloud CLI returns a response similar to:
canIpForward: false cpuPlatform: Intel Ivy Bridge creationTimestamp: '2016-08-24T14:11:38.012-07:00' ... metadata: items: - key: instance-template value: projects/123456789012/global/instanceTemplates/example-it - key: created-by value: projects/123456789012/zones/us-central1-f/instanceGroupManagers/igm-metadataView the preserved state of a managed instance
If you configured a stateful MIG and want to view the preserved state of each managed instance, see Viewing stateful configuration and preserved state.
What's nextRetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4