Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Dopo aver
creato un job di applicazione patch,
puoi utilizzare Cloud Monitoring per configurare avvisi che puoi utilizzare per monitorare
il processo di applicazione delle patch.
Quando viene creato un job di applicazione patch, VM Manager pubblica lo stato aggregato della VM
nell'API Cloud Monitoring. Questo stato viene pubblicato ogni minuto dopo l'avvio del job di applicazione patch. La pubblicazione dello stato si interrompe 15 minuti dopo il completamento del job di patch.
Per monitorare i job di applicazione patch utilizzando gli avvisi, completa i seguenti passaggi:
Configura le metriche in Cloud Monitoring per il job di applicazione patch.
Crea avvisi sulle patch.
Prima di iniziare
Se non l'hai ancora fatto, configura l'autenticazione.
L'autenticazione verifica la tua identità per l'accesso a Google Cloud servizi e API. 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
Installa Google Cloud CLI.
Dopo l'installazione,
inizializza Google Cloud CLI eseguendo il seguente comando:
In questa sezione, configuri le metriche di monitoraggio per il job di applicazione patch utilizzando Metrics Explorer.
Per informazioni più dettagliate sull'utilizzo di Metrics Explorer, consulta
Selezione delle metriche durante l'utilizzo di Esplora metriche.
Puoi utilizzare Cloud Monitoring per monitorare le risorse in più progetti. Per visualizzare le metriche per i job di patch che si trovano in progetti separati,
aggiungi i progetti allo stesso workspace di monitoraggio. Per saperne di più,
consulta Visualizzazione delle metriche per più progetti.
Nella console Google Cloud , vai alla pagina Cloud Monitoring > Esplora metriche.
In Cloud Monitoring puoi configurare una criterio di avviso che fornisca notifiche sullo stato della patch in modo da poter risolvere questi problemi in modo tempestivo. Per saperne di più sugli avvisi, consulta Introduzione agli
avvisi.
Stati delle patch delle istanze VM
Per creare l'avviso per i job di applicazione patch, utilizza lo stato della patch dell'istanza VM come
condizione di filtro per l'avviso. Sono disponibili i seguenti stati delle patch delle istanze VM:
ACKED: l'agente OS Config ha ricevuto la notifica della patch, ma non ha ancora iniziato l'applicazione
APPLYING_PATCHES: l'agente OS Config sta applicando patch alla VM
DOWNLOADING_PATCHES: l'agente OS Config sta scaricando patch sulla VM
FAILED: il job di applicazione patch non è riuscito
INACTIVE: la VM non è in esecuzione
NO_AGENT_DETECTED: il servizio patch non è in grado di comunicare con l'agente OS Config sulla VM. Assicurati che le VM siano collegate
correttamente. Per maggiori informazioni, consulta
Configurazione di VM Manager.
NOTIFIED: l'agente OS Config sulla VM viene avvisato, ma il job di applicazione patch
non è stato avviato
PATCH_STATE_UNSPECIFIED: lo stato del job di applicazione patch è sconosciuto
PENDING: la VM non ha ancora ricevuto un'attività di patch. Ciò accade
perché il job di applicazione patch è stato avviato di recente o la VM è in attesa di un'implementazione
graduale.
REBOOTING: la VM si sta riavviando
RUNNING_PRE_PATCH_STEP: l'agente OS Config esegue i passaggi precedenti alla patch
RUNNING_POST_PATCH_STEP: l'agente OS Config esegue i passaggi post-patch
STARTED: il job di applicazione patch è stato avviato sulla VM
SUCCEEDED: il job di applicazione patch è stato completato correttamente
SUCCEEDED_REBOOT_REQUIRED: il job di applicazione patch è stato completato correttamente, ma è richiesto il riavvio di una VM
TIMED_OUT: il processo di applicazione delle patch è scaduto
Esempio di avviso di patch
L'esempio seguente crea un avviso di patch che ti avvisa se si verificano più di cinque errori di VM in un recente job di applicazione patch.
Puoi creare avvisi utilizzando la console Google Cloud o l'API Cloud Monitoring. L'esempio seguente utilizza la console Google Cloud . Per informazioni dettagliate sulla
creazione di un avviso utilizzando la console Google Cloud , consulta
Creazione di una policy di avviso.
Nella console Google Cloud , vai alla pagina Monitoring.
[[["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\u003eVM Manager posts the aggregate VM state to the Cloud Monitoring API every minute after a patch job starts, stopping 15 minutes after completion, for monitoring purposes.\u003c/p\u003e\n"],["\u003cp\u003eCloud Monitoring allows you to track patch job resources across multiple projects by adding them to the same monitoring workspace.\u003c/p\u003e\n"],["\u003cp\u003eYou can set up alerts in Cloud Monitoring using VM instance patch states, such as \u003ccode\u003eFAILED\u003c/code\u003e, to receive notifications about the patching process and resolve issues promptly.\u003c/p\u003e\n"],["\u003cp\u003eCreating alerts involves specifying the resource type as "Patch Job," the metric as "VM instance patch state," and filtering by specific states like \u003ccode\u003eFAILED\u003c/code\u003e to trigger notifications based on the number of affected VMs.\u003c/p\u003e\n"],["\u003cp\u003eBefore using the Cloud Monitoring or the REST API, the gcloud CLI needs to be installed and initialized, including setting a default region and zone.\u003c/p\u003e\n"]]],[],null,["# Monitor patch jobs\n\nAfter you\n[create a patch job](/compute/vm-manager/docs/patch/create-patch-job),\nyou can use Cloud Monitoring to set up alerts that you can use to monitor\nthe patching process.\n\nWhen a patch job is created, VM Manager posts the aggregate VM state\nto the Cloud Monitoring API. This state is posted every minute after the\npatch job is started. The posting of the state stops 15 minutes after the patch\njob completes.\n\nTo monitor your patch jobs by using alerts complete the following steps:\n\n1. Start a patch job. See [Creating patch jobs](/compute/vm-manager/docs/patch/create-patch-job).\n2. Set up metrics in Cloud Monitoring for your patch job.\n3. Create patch alerts.\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\nSet up metrics\n--------------\n\nIn this section, you set up tracking metrics for your patch job using Metrics Explorer.\nFor more detailed information about using the Metrics Explorer, see\n[Selecting metrics when using Metrics Explorer](/monitoring/charts/metrics-selector).\n\nYou can use Cloud Monitoring to track resources across multiple\nprojects. To see metrics for patch jobs that are in separate projects,\nadd your projects to the same monitoring workspace. For more information,\nsee [View metrics for multiple projects](/monitoring/settings/multiple-projects)\n\n1. In the Google Cloud console, go to the\n **Cloud Monitoring \\\u003e Metrics Explorer** page.\n\n [Go to the Metrics Explorer page](https://console.cloud.google.com/monitoring/metrics-explorer)\n2. In the **Select a metric** section, select **Patch Job**.\n\n3. Select the **Patch** active metric category list, and then select\n **VM instance patch state**.\n\n4. Click **Apply**.\n\n5. Review the metrics.\n\n6. Optional. Create a chart. For more information, see\n [Creating a chart with Metrics Explorer](/monitoring/charts/metrics-explorer).\n\nCreate patch alerts\n-------------------\n\nIn Cloud Monitoring, you can set up an alerting policy that provides\nnotifications of the patch state so that you can resolve these issues in a\ntimely manner. For more information about alerting, see [Introduction to\nalerting](/monitoring/alerts).\n\n### VM instance patch states\n\nTo create the alert for patch jobs, use the VM instance patch state as the\nfilter condition for the alert. The following VM instance patch states are\navailable:\n\n- `ACKED`: the OS Config agent received the patch notification, but has not started patching yet\n- `APPLYING_PATCHES`: the OS Config agent is applying patches to the VM\n- `DOWNLOADING_PATCHES`: the OS Config agent is downloading patches to the VM\n- `FAILED`: the patch job failed\n- `INACTIVE`: the VM is not running\n- `NO_AGENT_DETECTED`: the Patch service is unable to communicate with the OS Config agent on the VM. Ensure your VMs are properly connected. For more information, see [Setting up VM Manager](/compute/vm-manager/docs/setup#overview).\n- `NOTIFIED`: the OS Config agent on the VM is notified, but the patch job has not started\n- `PATCH_STATE_UNSPECIFIED`: the state of the patch job is unknown\n- `PENDING`: the VM hasn't received a patch task as yet. This happens because either the patch job has recently started or the VM is awaiting a gradual rollout.\n- `REBOOTING`: the VM is rebooting\n- `RUNNING_PRE_PATCH_STEP`: the OS Config agent is running pre patch steps\n- `RUNNING_POST_PATCH_STEP`: the OS Config agent is running post patch steps\n- `STARTED`: the patch job has started on the VM\n- `SUCCEEDED`: the patch job completed successfully\n- `SUCCEEDED_REBOOT_REQUIRED`: the patch job completed successfully but a VM reboot is required\n- `TIMED_OUT`: the patching process timed out\n\nExample patch alert\n-------------------\n\nThe following example creates a patch alert that notifies you if there are more\nthan five failed VMs in a recent patch job.\n\nYou can create alerts by using either the Google Cloud console or the Cloud Monitoring\nAPI. The following example uses the Google Cloud console. For detailed information about\ncreating an alert using the Google Cloud console, see\n[Creating an alerting policy](/monitoring/alerts/using-alerting-ui#create-policy).\n\n1. In the Google Cloud console, go to the **Monitoring** page.\n\n [Go to Monitoring](https://console.cloud.google.com/monitoring)\n2. In the Monitoring navigation pane, click **Alerting**.\n\n3. Click **Create Policy**.\n\n4. Click **Add Condition**.\n\n 1. In the **Resource type** drop-down, select **Patch Job**.\n 2. In the **Metric** drop-down, select **VM instance patch state**.\n 3. In the **Filter** field, specify `state=FAILED`.\n 4. In the **Configuration** section set `Any time series violate = 5.`\n 5. Click **Add** .\n\n5. Click **Next** to advance to the notifications section.\n\n 1. Set up notification channels.\n6. Click **Next** to advance to the documentation section.\n\n 1. Set up an alert policy name\n 2. Provide fix instructions\n7. Click **Save**.\n\nWhat's next?\n------------\n\n- Learn more about [Patch](/compute/vm-manager/docs/patch).\n- [Manage your patch jobs](/compute/vm-manager/docs/patch/manage-patch-jobs).\n- [Schedule patch jobs](/compute/vm-manager/docs/patch/schedule-patch-jobs)."]]