Configurar um alerta baseado em registros para recursos armazenados
Mantenha tudo organizado com as coleções
Salve e categorize o conteúdo com base nas suas preferências.
Nesta página, explicamos como configurar um alerta com base em registros para recursos protegidos
na página Explorador de registros do console Google Cloud .
A página Explorador de registros orienta você nas seguintes etapas para criar e editar alertas com base em registros:
Forneça um nome e uma descrição para o alerta.
Escolha os registros para receber uma notificação.
Defina o intervalo de tempo entre as notificações.
Defina o horário para o encerramento automático de incidentes.
Especifique quem você quer notificar.
É possível configurar alertas para as categorias de jobs de backup e restauração: SCHEDULED_BACKUP, ON_DEMAND_BACKUP e RESTORE.
Também é possível configurar alertas para as categorias de jobs de plano de backup e associação de plano de backup: UPDATE.
Os status de jobs disponíveis são: SUCCESSFUL, FAILED, SKIPPED e RUNNING.
Você pode configurar um ou mais canais de notificação, como Google Chat, e-mail, SMS
ou canais de programas de chat, para receber notificações quando um alerta for acionado. Para instruções,
consulte Criar e gerenciar canais de notificação.
Na seção Escolher registros a serem incluídos no alerta, faça o seguinte:
Clique em Visualizar registros para verificar a consulta e os resultados. É possível editar a consulta neste painel, se necessário.
Clique em Adicionar um rótulo e faça o seguinte: Com os rótulos, você pode personalizar as notificações e deixá-las mais informativas.
No campo Nome de exibição, insira um nome para o rótulo.
Na lista Nome do campo de registro, selecione um nome. Esses campos são mostrados com base no resultado da consulta selecionado.
No campo Expressão regular, insira uma expressão para extrair um valor do campo que precisa conter exatamente um grupo de expressão regular.
Clique em Próxima.
Na seção Definir a frequência da notificação e a duração do fechamento automático, faça o seguinte:
Na lista Tempo entre notificações, selecione o tempo mínimo entre as notificações. Esse valor permite controlar o número de notificações que você
recebe desse alerta se ele for acionado várias vezes.
Na lista Duração do fechamento automático de incidentes, selecione um período após o qual o incidente será fechado automaticamente quando as entradas de registro correspondentes estiverem ausentes.
Clique em Próxima.
Na lista Canais de notificação, selecione um ou mais canais de
notificação para seu alerta. Se você não tiver um canal de notificação configurado,
clique em Gerenciar canais de notificação para criar um. Para instruções,
consulte Criar e gerenciar canais de notificação.
Clique em Salvar.
Testar o alerta com base em registros
Para testar o alerta com base em registro que você criou, grave manualmente uma entrada de registro
que corresponda à consulta.
Use as instruções a seguir para gravar a entrada de registro.
Copie a entrada de registro configurada anteriormente.
No painel Testar esta API, siga estas etapas:
No campo Corpo da solicitação, substitua o conteúdo pela entrada de registro que você copiou na etapa anterior.
Clique em Executar. Se solicitado, siga o fluxo de autenticação.
Se a chamada logEntries.write for bem-sucedida, você vai receber um código de resposta HTTP 200 e um corpo de resposta vazio, {}. Para mais informações sobre o APIs Explorer,
consulte Usar o APIs Explorer.
A entrada de registro corresponde ao filtro especificado para o alerta das seguintes maneiras:
O valor logName especifica os registros de jobs de backup ou restauração no seu projeto do Cloud.
O jsonPayload contém uma categoria de job com falha, SCHEDULED_BACKUP, que indica que o registro está relacionado a um backup programado por um plano de backup.
O jsonPayload contém o status do job como FAILED, o que
significa que o job falhou.
Depois que você grava a entrada de registro, ocorre a seguinte sequência:
A nova entrada de registro aparece no Explorador de registros e aciona o alerta.
Um incidente é aberto na página Cloud Monitoring.
Você recebe uma notificação sobre o incidente. Se você tiver configurado um canal de notificação de e-mail, a notificação vai aparecer.
Clique em Ver incidente no e-mail para ver o incidente na página do
Cloud Monitoring. Para mais informações sobre incidentes, incluindo
como confirmar e fechar, consulte Gerenciar incidentes para alertas com base em registros.
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Informações incorretas ou exemplo de código","incorrectInformationOrSampleCode","thumb-down"],["Não contém as informações/amostras de que eu preciso","missingTheInformationSamplesINeed","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Outro","otherDown","thumb-down"]],["Última atualização 2025-09-04 UTC."],[[["\u003cp\u003eThis page provides instructions on how to configure log-based alerts for vaulted resources using the \u003cstrong\u003eLogs Explorer\u003c/strong\u003e in the Google Cloud console.\u003c/p\u003e\n"],["\u003cp\u003eYou can set up alerts for specific job categories like \u003ccode\u003eSCHEDULED_BACKUP\u003c/code\u003e, \u003ccode\u003eON_DEMAND_BACKUP\u003c/code\u003e, and \u003ccode\u003eRESTORE\u003c/code\u003e, as well as job statuses like \u003ccode\u003eSUCCESSFUL\u003c/code\u003e, \u003ccode\u003eFAILED\u003c/code\u003e, \u003ccode\u003eSKIPPED\u003c/code\u003e, and \u003ccode\u003eRUNNING\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThe alert configuration includes setting an alert name, choosing the relevant logs, defining notification frequency, setting the incident auto-close duration, and adding notification channels like Google Chat, email, or SMS.\u003c/p\u003e\n"],["\u003cp\u003eThe process of creating an alert involves defining a query in the \u003cstrong\u003eLogs Explorer\u003c/strong\u003e, setting up an \u003cstrong\u003eAlert Policy\u003c/strong\u003e, adding labels, and managing notification frequency and incident auto-close.\u003c/p\u003e\n"],["\u003cp\u003eThe page also contains instructions on how to test the created log-based alert by manually writing a log entry that triggers the defined criteria.\u003c/p\u003e\n"]]],[],null,["# Configure a log-based alert for vaulted resources\n\nThis page explains how to configure a log-based alert for vaulted resources\nfrom the **Log Explorer** page in the Google Cloud console.\n\nThe **Logs Explorer** page guides you through the following steps to create\nand edit log-based alerts:\n\n- Provide a name and description for the alert.\n- Choose the logs you want to receive a notification for.\n- Set the time interval between notifications.\n- Set the time for automatic closure of incidents.\n- Specify whom to notify.\n\nYou can configure alerts for the job categories: `SCHEDULED_BACKUP`,\n`ON_DEMAND_BACKUP`, and `RESTORE`. You can also set alerts for the job status:\n`SUCCESSFUL`, `FAILED`, `SKIPPED`, and `RUNNING`.\n\nYou can configure one or more notification channels, such as Google chat, email, SMS,\nor chat program channels, to receive notifications when an alert occurs. For instructions,\nsee [Create and manage notification channels](/monitoring/support/notification-options).\n\nBefore you begin\n----------------\n\n- [Assign permissions for log-based alerting policies](/logging/docs/access-control#lba-permissions).\n\nCreate a log-based alert\n------------------------\n\nTo notify an alert, you need to have a [notification channel](/monitoring/support/notification-options).\nYou can create the notification channel before creating an alert or while creating an alert.\n\nUse the following instructions to create a log-based alert.\n\n1. In the Google Cloud console, go to the **Logs Explorer** page.\n\n [Go to Logs Explorer](https://console.cloud.google.com/logs/query)\n2. In the **Query** pane define the alert on which you want to be notified.\n\n The following query is an example to get notified whenever a scheduled backup job fails. \n\n logName=\"projects/\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e/logs/backupdr.googleapis.com%2Fbdr_backup_restore_jobs\"\n jsonPayload.jobCategory=\"SCHEDULED_BACKUP\"\n jsonPayload.jobStatus=\"FAILED\"\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e: the name of the project.\n3. In the header of the **Query results** pane, click **Create alert**.\n\n4. In the **Alert details** section, do the following:\n\n 1. In the **Alert Policy Name** field, enter a name for your alert. This name gets displayed in the notification header.\n 2. In the **Documentation** field, enter the description for the alert. For information about how you can format and refine the content of this field, see [Using Markdown and variables in documentation templates](/monitoring/alerts/doc-variables).\n5. Click **Next**.\n\n6. In the **Choose logs to include in the alert** section, do the following:\n\n 1. Click **Preview logs** to check the query and results. You can also edit the query in this pane, if necessary.\n 2. Click **Add a label** and do the following. The [labels](/monitoring/alerts/labels)\n let you customize notifications and make them more informative.\n\n 1. In the **Display name** field**,** enter a name for the label.\n 2. From the **Log field name** list, select a log field name. These fields are displayed based on the selected query result.\n 3. In the **Regular expression** field, enter an expression to extract a value from the field that must contain exactly one regular expression group.\n7. Click **Next**.\n\n8. In the **Set notification frequency and autoclose duration** section, do the following:\n\n 1. From the **Time between notifications** list, select the minimum time between notifications. This value lets you control the number of notifications you get from this alert if it is triggered multiple times.\n 2. From the **Incident autoclose duration** list, select a duration after which the incident to be closed automatically when matching log entries are absent.\n9. Click **Next**.\n\n10. From the **Notification channels** list, select one or more notification\n channels for your alert. If you don't have a notification channel configured,\n click **Manage notification channels** to create one. For instructions,\n see [Create and manage notification channels](/monitoring/support/notification-options).\n\n11. Click **Save**.\n\nTest the log-based alert\n------------------------\n\nTo test the log-based alert you created, you can manually write a log entry\nthat matches the query.\n\nUse the following instructions to write the log entry.\n\n1. Go to the [`logEntries.write`](/logging/docs/reference/v2/rest/v2/entries/write) reference page.\n\n [Go to logEntries.write](/logging/docs/reference/v2/rest/v2/entries/write)\n2. Configure the following log entry by changing the \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e\n variable to your project ID.\n\n {\n \"entries\": [\n {\n \"jsonPayload\": {\n \"jobCategory\": \"SCHEDULED_BACKUP\",\n \"jobStatus\": \"FAILED\"\n }\n }\n ],\n \"resource\": {\n \"type\": \"backupdr.googleapis.com/BackupDRProject\"\n },\n \"logName\": \"projects/\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e/logs/backupdr.googleapis.com%2Fbdr_backup_restore_jobs\"\n }\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e: the name of the project.\n3. Copy the log entry you configured previously.\n\n4. In the **Try this API** pane, follow these steps:\n\n 1. In the **Request body** field, replace the content with the log entry you copied in the previous step.\n 2. Click **Execute**. If prompted, follow the authentication flow.\n5. If the `logEntries.write` call is successful, then you get an HTTP `200` response\n code and an empty response body, `{}`. For more information about **APIs Explorer** ,\n see [Using the APIs Explorer](/monitoring/api/apis-explorer).\n\n The log entry matches the filter specified for the alert in the following ways:\n - The `logName` value specifies the backup or restore job logs in your cloud project.\n - The `jsonPayload` contains a failed job category, `SCHEDULED_BACKUP`, which indicates that the log is related to a backup scheduled by a backup plan.\n - The `jsonPayload` contains the field job status as `FAILED`, which signifies that the job is failed.\n6. After you write the log entry, the following sequence occurs:\n\n 1. The new log entry appears in the Logs Explorer and triggers the alert.\n 2. An incident is opened in the **Cloud Monitoring** page.\n 3. You receive a notification for the incident. If you configured an email\n notification channel, then the notification displays.\n\n You can click **View incident** in the email to see the incident in the\n **Cloud Monitoring** page. For more information about incidents including\n how to acknowledge and close them, see [Manage incidents for log-based alerts](/logging/docs/alerting/log-based-incidents)."]]