Cuando se crea un trabajo de aplicación de parches, VM Manager publica el estado de la VM agregada en la API de Cloud Monitoring. Este estado se publica cada minuto después de que se inicia el trabajo de aplicación de parches. La publicación del estado se detiene 15 minutos después de que se completa el trabajo de aplicación de parches.
Para supervisar tus trabajos de aplicación de parches con alertas, completa los siguientes pasos:
Configura métricas en Cloud Monitoring para el trabajo de aplicación de parches.
Crea alertas de parches.
Antes de empezar
Si aún no lo hiciste, configura la autenticación.
La autenticación verifica tu identidad para acceder a los Google Cloud servicios y las APIs. Para ejecutar código o muestras desde un entorno de desarrollo local, puedes autenticarte en Compute Engine seleccionando una de las siguientes opciones:
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
Instala Google Cloud CLI.
Después de la instalación,
inicializa Google Cloud CLI ejecutando el siguiente comando:
Para obtener más información, consulta
Autentícate para usar REST
en la documentación de autenticación de Google Cloud .
Configura métricas
En esta sección, configurarás las métricas de seguimiento para tu trabajo de aplicación de parches con el Explorador de métricas.
Para obtener información más detallada sobre cómo usar el Explorador de métricas, consulta Elige métricas cuando usas el Explorador de métricas.
Puedes usar Cloud Monitoring para realizar un seguimiento de los recursos en varios proyectos. Si deseas ver las métricas de los trabajos de aplicación de parches que se encuentran en proyectos diferentes, agrega los proyectos al mismo lugar de trabajo de supervisión. A fin de obtener más información, consulta Visualiza métricas para varios proyectos.
En la consola de Google Cloud , ve a la página Cloud Monitoring > Explorador de métricas.
En Cloud Monitoring, puedes configurar una política de alertas que proporcione notificaciones sobre el estado del parche para que puedas resolver los problemas que se presenten de manera oportuna. Para obtener más información sobre las alertas, consulta Introducción a las alertas.
Estados de parches de las instancias de VM
A fin de crear la alerta para los trabajos de aplicación de parches, usa el estado del parche de la instancia de VM como la condición del filtro de la alerta. Los siguientes estados de parches de las instancias de VM están disponibles:
ACKED: el agente de configuración del SO recibió la notificación del parche, pero aún no comenzó a aplicar parches
APPLYING_PATCHES: el agente de configuración del SO está aplicando los parches a la VM
DOWNLOADING_PATCHES: el agente de configuración del SO está descargando los parches en la VM
FAILED: el trabajo de aplicación de parches falló
INACTIVE: la VM no se está ejecutando
NO_AGENT_DETECTED: el servicio de parche no puede comunicarse con el agente de configuración del SO en la VM. Asegúrate de que tus VM estén conectadas de forma correcta. Para obtener más información, consulta Configura VM Manager.
NOTIFIED: se notifica al agente de configuración del SO en la VM, pero no se inició el trabajo de aplicación de parches
PATCH_STATE_UNSPECIFIED: se desconoce el estado del trabajo de aplicación de parches
PENDING: la VM aún no recibió una tarea de aplicación de parches. Esto sucede porque el trabajo de aplicación de parches se inició recientemente o la VM está esperando un lanzamiento gradual.
REBOOTING: la VM se está reiniciando
RUNNING_PRE_PATCH_STEP: el agente de configuración del SO ejecuta pasos previos a la aplicación de parches
RUNNING_POST_PATCH_STEP: el agente de configuración del SO ejecuta pasos posteriores a la aplicación del parche
STARTED: el trabajo de aplicación de parche se inició en la VM
SUCCEEDED: se completó correctamente el trabajo de aplicación de parche
SUCCEEDED_REBOOT_REQUIRED: el trabajo de aplicación de parche se completó de forma correcta, pero es necesario reiniciar la VM
TIMED_OUT: se agotó el tiempo de espera del proceso de aplicación de parches
Ejemplo de alerta de parche
En el siguiente ejemplo, se crea una alerta de parche que te notifica si hay más de cinco VM con errores en un trabajo de aplicación de parches reciente.
Puedes crear alertas con la consola de Google Cloud o la API de Cloud Monitoring. En el siguiente ejemplo, se usa la consola de Google Cloud . Para obtener información detallada sobre cómo crear una alerta con la consola de Google Cloud , consulta Crea una política de alertas.
En la consola de Google Cloud , ve a la página Monitoring.
[[["Fácil de comprender","easyToUnderstand","thumb-up"],["Resolvió mi problema","solvedMyProblem","thumb-up"],["Otro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Información o código de muestra incorrectos","incorrectInformationOrSampleCode","thumb-down"],["Faltan la información o los ejemplos que necesito","missingTheInformationSamplesINeed","thumb-down"],["Problema de traducción","translationIssue","thumb-down"],["Otro","otherDown","thumb-down"]],["Última actualización: 2025-09-09 (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)."]]