Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Linux
Windows
Quando chiami un'API Compute Engine che modifica una risorsa, Compute Engine aggiunge una voce
all'elenco delle operazioni. Ad esempio, quando apporti un aggiornamento a una VM che
muta (modifica) i dati o quando si verifica un evento host
che cambia lo stato di una VM, vengono create le operazioni. Questa pagina
descrive come visualizzare un elenco di operazioni di Compute Engine utilizzando la consoleGoogle Cloud , Google Cloud CLI o REST.
Ricorda che le operazioni possono richiedere del tempo per essere completate, pertanto potresti
trovare operazioni incomplete durante la visualizzazione. Quando vuoi visualizzare lo stato finale delle
operazioni incomplete, non è consigliabile visualizzarle ripetutamente. Devi invece attendere il completamento delle operazioni.
Prima di iniziare
Se non l'hai ancora fatto, configura l'autenticazione.
L'autenticazione è il processo mediante il quale la tua identità viene verificata per l'accesso a servizi e API di Google Cloud .
Per eseguire codice o esempi da un ambiente di sviluppo locale, puoi autenticarti su Compute Engine selezionando una delle seguenti opzioni:
Select the tab for how you plan to use the samples on this page:
Console
When you use the Google Cloud console to access Google Cloud services and
APIs, you don't need to set up authentication.
gcloud
Install the Google Cloud CLI.
After installation,
initialize the Google Cloud CLI by running the following command:
Durante le operazioni di query, tieni presente che le operazioni completate vengono rimosse
automaticamente dal database dopo un determinato periodo.
Compute Engine conserva le operazioni completate per almeno il periodo di conservazione minimo
di 1 ora e fino al periodo di conservazione massimo di 14 giorni.
Sebbene i progetti spesso prevedano un periodo di conservazione per le operazioni completate
superiore al minimo di 1 ora, non è consigliabile fare affidamento su periodi di conservazione
aggiuntivi.
Tieni presente che i periodi di conservazione non si applicano alle operazioni eliminate dagli utenti
tramite il metodo Operations.delete.
Visualizzazione delle operazioni
Per visualizzare un elenco di operazioni per il tuo progetto, segui i passaggi descritti di seguito:
Console
Nella console Google Cloud , vai alla pagina Operazioni.
Per ulteriori dettagli su un'operazione, fai clic sul riepilogo dell'operazione. Ad esempio,
per visualizzare i dettagli della migrazione della VMmy-instance,
fai clic sull'operazione Esegui la migrazione automatica di un'istanza.
gcloud
Per visualizzare un elenco di operazioni per il tuo progetto
utilizzando gcloud compute, usa il sottocomando operations list.
Per visualizzare l'elenco delle operazioni in una zona specificata, aggiungi il flag --filter.
gcloud compute operations list --filter="zone:(ZONE)"
Sostituisci ZONE con la zona in cui vuoi visualizzare un elenco
di operazioni. Ad esempio, per visualizzare l'elenco delle operazioni in us-cental1-c,
esegui il seguente comando:
gcloud compute operations list --filter="zone:(us-central1-c)"
L'output è simile al seguente:
NAME TYPE TARGET HTTP_STATUS STATUS TIMESTAMP
systemevent-1543845145000... compute.instances.migrateOnHostMaintenance us-central1-c/instances/my-instance 200 DONE 2018-12-03T05:52:25.000-08:00
REST
Le richieste API per le operazioni devono essere specificate a livello globale,
regionale o di zona.
La migrazione live, l'arresto delle VM e i riavvii automatici sono tutte operazioni a livello di zona.
Per le operazioni a livello di zona, invia una richiesta GET al metodo zoneOperations.list.
GET https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/operations
Sostituisci quanto segue:
PROJECT_ID: l'ID progetto per questa richiesta
ZONE: la zona per questa richiesta
Lascia vuoto il corpo della richiesta.
Di seguito è riportato un output di esempio per una richiesta di operazione a livello di zona. In questo
output vengono visualizzati i dettagli di una migrazione dell'host.
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Difficile da capire","hardToUnderstand","thumb-down"],["Informazioni o codice di esempio errati","incorrectInformationOrSampleCode","thumb-down"],["Mancano le informazioni o gli esempi di cui ho bisogno","missingTheInformationSamplesINeed","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 2025-09-04 UTC."],[[["\u003cp\u003eCompute Engine operations are logged when a resource is mutated, such as during VM updates or host events, which alter the state of a VM.\u003c/p\u003e\n"],["\u003cp\u003eOperations can be viewed using the Google Cloud console, the Google Cloud CLI (gcloud), or REST, and they may be incomplete upon initial viewing.\u003c/p\u003e\n"],["\u003cp\u003eAuthentication is only needed for gcloud or REST usage, and the provided steps outline the necessary commands for both.\u003c/p\u003e\n"],["\u003cp\u003eCompleted operations are retained for a period ranging from a minimum of 1 hour to a maximum of 14 days, during which time they are available for viewing.\u003c/p\u003e\n"],["\u003cp\u003eTo view operations, you must specify the scope of the request as either global, region, or zone level using gcloud or REST.\u003c/p\u003e\n"]]],[],null,["# View Compute Engine operations\n\nLinux Windows\n\n*** ** * ** ***\n\nWhen you call a Compute Engine API that mutates a resource, Compute Engine adds an entry\nto the list of operations. For example, when you make an update to a VM that\nmutates (alters) data, or when a [host event](/compute/docs/instances/host-maintenance-overview)\noccurs that changes the state of a VM, operations are created. This page\ndescribes how you can view a list of Compute Engine operations by\nusing the [Google Cloud console](https://console.cloud.google.com/), the [Google Cloud CLI](/compute/docs/gcloud-compute),\nor [REST](/compute/docs/reference/rest/v1).\n\nRemember that operations can take some time to complete, so you may find\nincomplete operations while viewing. When you want to see the final status of\nincomplete operations, repeatedly viewing operations is not recommended;\ninstead, you should [wait for operations to be done](/compute/docs/api/best-practices#wait-for-operations).\n\nBefore you begin\n----------------\n\n- If you haven't already, set up [authentication](/compute/docs/authentication). Authentication verifies your identity for access to Google Cloud services and APIs. To run code or samples from a local development environment, you can authenticate to Compute Engine by selecting one of the following options:\n\n Select the tab for how you plan to use the samples on this page: \n\n ### Console\n\n\n When you use the Google Cloud console to access Google Cloud services and\n APIs, you don't need to set up authentication.\n\n ### gcloud\n\n 1.\n [Install](/sdk/docs/install) the Google Cloud CLI.\n\n After installation,\n [initialize](/sdk/docs/initializing) the Google Cloud CLI by running the following command:\n\n ```bash\n gcloud init\n ```\n\n\n If you're using an external identity provider (IdP), you must first\n [sign in to the gcloud CLI with your federated identity](/iam/docs/workforce-log-in-gcloud).\n | **Note:** If you installed the gcloud CLI previously, make sure you have the latest version by running `gcloud components update`.\n 2. [Set a default region and zone](/compute/docs/gcloud-compute#set_default_zone_and_region_in_your_local_client).\n\n ### REST\n\n\n To use the REST API samples on this page in a local development environment, you use the\n credentials you provide to the gcloud CLI.\n 1. [Install](/sdk/docs/install) the Google Cloud CLI. After installation, [initialize](/sdk/docs/initializing) the Google Cloud CLI by running the following command: \n\n ```bash\n gcloud init\n ```\n 2. If you're using an external identity provider (IdP), you must first [sign in to the gcloud CLI with your federated identity](/iam/docs/workforce-log-in-gcloud).\n\n\n For more information, see\n [Authenticate for using REST](/docs/authentication/rest)\n in the Google Cloud authentication documentation.\n\nOperation Retention Period\n--------------------------\n\nWhile querying operations, keep in mind that completed operations are\nautomatically removed from the database after a certain period.\n\nCompute Engine retains completed operations for at least the minimum\nretention period of 1 hour, and up to the maximum retention period of 14 days.\nAlthough projects often observe a retention period for completed operations that\nis longer than the minimum of 1 hour, depending on the additional retention\nperiod is not recommended.\n\nNote that the retention periods don't apply to operations deleted by the users\nthrough `Operations.delete` method.\n\nViewing operations\n------------------\n\nTo view a list of operations for your project, perform the following steps: \n\n### Console\n\n1. In the Google Cloud console, go to the **Operations** page.\n\n [Go to Operations](https://console.cloud.google.com/compute/operations)\n2. For more details on an operation, click the operation summary. For\n example, to view the migration details for the `my-instance` VM,\n click the **Automatically migrate an instance** operation.\n\n\n### gcloud\n\nTo view a list of operations for your project\nusing `gcloud compute`, use the [`operations list`](/sdk/gcloud/reference/compute/operations/list)\nsub-command.\n\nTo view the list of operations in a specified zone, add the `--filter` flag.\n\n\u003cbr /\u003e\n\n```\ngcloud compute operations list --filter=\"zone:(ZONE)\"\n```\n\n\u003cbr /\u003e\n\nReplace \u003cvar translate=\"no\"\u003eZONE\u003c/var\u003e with the zone where you want to view a list of\noperations. For example, to view the list of operations in `us-cental1-c`,\nrun the following command: \n\n```\ngcloud compute operations list --filter=\"zone:(us-central1-c)\"\n```\n\nThe output is similar to the following: \n\n```\nNAME TYPE TARGET HTTP_STATUS STATUS TIMESTAMP\nsystemevent-1543845145000... compute.instances.migrateOnHostMaintenance us-central1-c/instances/my-instance 200 DONE 2018-12-03T05:52:25.000-08:00\n```\n\n\u003cbr /\u003e\n\n### REST\n\nAPI requests for operations must be specified at either the [global](/compute/docs/reference/rest/v1/globalOperations/list),\n[region](/compute/docs/reference/rest/v1/regionOperations/list), or [zone](/compute/docs/reference/rest/v1/zoneOperations/list) level.\nLive migration, VM stopping, and automatic restarts are all zone-level operations.\n\nFor zone operations, make a `GET` request to the [`zoneOperations.list`](/compute/docs/reference/rest/v1/zoneOperations/list) method. \n\n```\nGET https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/operations\n```\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e: the project ID for this request\n- \u003cvar translate=\"no\"\u003eZONE\u003c/var\u003e: the zone for this request\n\nLeave the request body empty.\n\nThe following is a sample output for a zone operation request. In this\noutput, details for a host migration displays. \n\n```\n{\n \"kind\": \"compute#operation\",\n \"id\": \"3216798767364213712\",\n \"name\": \"systemevent-1543845145000-57c1e7574b840-a195b637-5ff74d9b\",\n \"zone\": \"https://www.googleapis.com/compute/v1/projects/my-project/zones/us-central1-c\",\n \"operationType\": \"compute.instances.migrateOnHostMaintenance\",\n \"targetLink\": \"https://www.googleapis.com/compute/v1/projects/my-project/zones/us-central1-c/instances/my-instance\",\n \"targetId\": \"3070988523247098025\",\n \"status\": \"DONE\",\n \"statusMessage\": \"Instance migrated during Compute Engine maintenance.\",\n \"user\": \"system\",\n \"progress\": 100,\n \"insertTime\": \"2018-12-03T05:52:25.000-08:00\",\n \"startTime\": \"2018-12-03T05:52:25.000-08:00\",\n \"endTime\": \"2018-12-03T05:52:25.000-08:00\",\n \"selfLink\": \"https://www.googleapis.com/compute/v1/projects/my-project/zones/us-central1-c/operations/systemevent-1543845145000-57c1e7574b840-a195b637-5ff74d9b\"\n}\n```"]]