"entries":[{"jsonPayload":{"eventId":10046,"errorMessage":"this is a manually generated error message created for testing"},"resource":{"type":"backupdr.googleapis.com/BackupRecoveryAppliance",},"severity":"ERROR","logName":"projects/PROJECT_ID/logs/backupdr.googleapis.com%2Fbackup_recovery_appliance_events",}]
复制您之前配置的日志条目。
在试用此 API 窗格中,按以下步骤操作:
将 API Explorer 中请求正文字段中的内容替换为您在上一步中复制的日志条目。
点击 Execute。如果出现提示,请按照身份验证流程操作。
如果 logEntries.write 调用成功,您将收到 HTTP 200 响应代码和空响应正文 {}。如需详细了解 API Explorer,请参阅使用 API Explorer。API Explorer 的工作方式与 Logging API 相同。
需要紧急参加的活动,因此需要更频繁的通知。例如,需要每 30 分钟报告一次事件 ID 43901(快照作业失败)。使用以下查询创建提醒。
Policyname='Snapshot job has failed'Notificationratelimit=30minlogName="projects/PROJECT_ID/logs/backupdr.googleapis.com%2Fbackup_recovery_appliance_events"ANDjsonPayload.eventId=43901
不太紧急的事件,因此不需要频繁发送通知。例如,事件 ID 10085(违反备份方案)每天只需报告一次。使用以下查询创建提醒。
Policyname='Backup Plan Violation has occurred'Notificationratelimit=1daylogName="projects/PROJECT_ID/logs/backupdr.googleapis.com%2Fbackup_recovery_appliance_events"ANDjsonPayload.eventId=10085
无影响且可以忽略的事件。例如,事件 ID 10229(存储空间超出错误)和 42356(检测到文件更改)可以忽略,因为 Google 支持团队已声明它们是误报。使用以下查询创建提醒。
Policyname='Backup/DR event has occurred'Notificationratelimit=6hrlogName="projects/PROJECT_ID/logs/backupdr.googleapis.com%2Fbackup_recovery_appliance_events"ANDNOTjsonPayload.eventId=(10085OR10229OR42356OR43901)
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-08-18。"],[[["\u003cp\u003eThis guide outlines the process of configuring log-based alerts for the Backup and DR Service using the Logs Explorer in the Google Cloud console.\u003c/p\u003e\n"],["\u003cp\u003eCreating an alert involves specifying the alert name and description, selecting the logs to monitor, setting notification frequency and incident auto-closure times, and choosing notification channels.\u003c/p\u003e\n"],["\u003cp\u003eTo set up log-based alerts, users need the correct Identity and Access Management (IAM) permissions and must have or create a notification channel to receive alerts.\u003c/p\u003e\n"],["\u003cp\u003eYou can define custom labels for your alerts to extract specific data from log events and make your alerts more informative.\u003c/p\u003e\n"],["\u003cp\u003eLog-based alert policies can be tailored to different event priorities and urgencies, allowing for varied notification frequencies for events like failed snapshots, backup plan violations, or non-impacting issues.\u003c/p\u003e\n"]]],[],null,["# Configure a log-based alert\n\nThis page explains how to configure a log-based alert from the **Log Explorer** for the\nBackup and DR Service in the Google Cloud console.\n\nThe **Logs Explorer** interface for creating and editing log-based alerts guides you through the following steps:\n\n- Provide a name and description for the alert.\n- Choose the logs for which you want to receive a notification.\n- Set the time between notifications.\n- Set the time for automatic closure of incidents.\n- Specify whom to notify.\n\nPermissions and roles\n---------------------\n\nTo create and manage log-based alerts, your **Identity and Access Management (IAM)** role\nmust include the permissions described in [Permissions for log-based alerts](/logging/docs/access-control#lba-permissions).\n\nCreate a log-based alert\n------------------------\n\nTo notify an alert, you need to have a\n[notification channel](/monitoring/support/notification-options). You can create the\n[notification channel](/monitoring/support/notification-options) before creating\nan alert or while creating an alert.\n\nTo create a log-based alert, follow these steps:\n\n1. In the Google Cloud console, select **Logging** and then **Logs Explorer**.\n2. Use the **Query** pane to define the event on which you want to be notified. You can use the query examples shown in [sample queries](/backup-disaster-recovery/docs/configuration/appliance-events#log) in the query pane to configure alerts.\n\n The following is the sample query to get notified on an event with a specific event ID. \n\n logName=\"projects/\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e/logs/backupdr.googleapis.com%2Fbackup_recovery_appliance_events\"\n jsonPayload.eventId=10046\n\n3. In the header of the **Query results** pane, click **Create alert** . If your window is too narrow, the **Create alert** option appears on the **Actions** menu instead.\n\n4. In the **Alert details** pane, give the alert a name and description:\n\n 1. Enter a name for your alert in the **Alert Policy Name** field. 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](https://cloud.google.com/monitoring/alerts/doc-variables). We suggest you include the URL of the management console in the documentation field. You can also add the workaround to resolve the event.\n5. Click **Next**.\n\n6. In the **Choose logs to include in the alert** pane, do the following:\n\n 1. Check the query and results by clicking **Preview logs**. You can also edit the query in this pane, if necessary.\n 2. You can add [labels](/monitoring/alerts/labels) to customize notifications\n and make them more informative. Click **Add a label** and do the following:\n\n 1. Entry a **Display name** for the label.\n 2. Select **Log field name** from the list. These fields are displayed based on the selected query result.\n 3. Enter **Regular expression** to extract a value from the field that must contain exactly one regular expression group.\n7. Click **Next**.\n\n8. 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. For example, you can select **5 min** from the options to limit the notifications to every five minutes. You can adjust the incident autoclose duration by selecting an option on the menu if applicable.\n\n9. Click **Next**.\n\n10. Select one or more notification channels for your alert, for example, select an email notification channel.\n If you already have an email notification channel configured, then you can select it from the list. If not, click **Manage notification channels** and add an email channel. For information about creating notification channels, see [Manage notification channels](/monitoring/support/notification-options).\n\n11. Click **Save**.\n\n We recommend you to configure alerts for important [*Event IDs*](/backup-disaster-recovery/docs/event-codes).\n\nTest the log-based alert\n------------------------\n\nTo test the log-based alert you created, you can manually write a log entry that matches\nthe query. To write the log entry, follow these steps:\n\n1. Go to the [`logEntries.write`](/logging/docs/reference/v2/rest/v2/entries/write) reference page, or click\n the following button:\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. If your alert policy includes or excludes specific\n event IDs then you need to modify the event ID as well:\n\n \"entries\": [\n {\n \"jsonPayload\": {\n \"eventId\": 10046,\n \"errorMessage\": \"this is a manually generated error message created for testing\"\n },\n \"resource\": {\n \"type\": \"backupdr.googleapis.com/BackupRecoveryAppliance\",\n },\n \"severity\": \"ERROR\",\n \"logName\": \"projects/\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e/logs/backupdr.googleapis.com%2Fbackup_recovery_appliance_events\",\n }\n ]\n\n3. Copy the log entry you configured previously.\n\n4. In the **Try this API** pane, follow these steps:\n\n 1. Replace the content in the **Request body** field in **APIs Explorer** with the log entry you copied in the previous step.\n 2. Click **Execute**. If prompted, follow the authentication flow.\n\n If the logEntries.write call is successful, then you get an HTTP 200 response code and an empty response body, {}. For more information about **APIs Explorer** , see [Using the APIs Explorer](/monitoring/api/apis-explorer), The **APIs Explorer** works the same way with the **Logging API**.\n\n The log entry matches the filter specified for the alert in the following ways:\n - The logName value specifies the backup/recovery appliance event sign in for your Cloud project.\n - The severity value for this log entry is ERROR.\n - The jsonPayload contains a 10046 pool full event.\n\n After you write the log entry, the following sequence occurs:\n 1. The new log entry appears in the \"Logs Explorer and triggers the alert.\n 2. An incident is opened in Cloud Monitoring.\n 3. You receive a notification for the incident. If you configured an email notification channel, then the notification displays.\n\nYou can click **View incident** in the email to see the incident in\n**Cloud Monitoring** . For more information about incidents including how to\nacknowledge and close them, see [Manage incidents for log-based alerts](/logging/docs/alerting/log-based-incidents).\n\nCreate multiple alert policies\n------------------------------\n\nYou may want to create alert policies based on the priority and urgency of events.\nFrom alerting perspective, events can be broadly categorized into the following categories:\n\n1. Events that are required to be attended urgently and hence require more\n frequent notifications. For example, the event ID 43901 (failed snapshot job) needs to be reported every 30 minutes. Use the following query to create the alert.\n\n Policyname = 'Snapshot job has failed'\n Notification rate limit = 30 min\n logName=\"projects/\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e/logs/backupdr.googleapis.com%2Fbackup_recovery_appliance_events\" AND jsonPayload.eventId=43901\n\n2. Events that are less urgent and hence require less frequent notifications. For example, the event ID 10085 (backup plan violations) need to only be reported once per day. Use the following query to create the alert.\n\n Policyname = 'Backup Plan Violation has occurred'\n Notification rate limit = 1 day\n logName=\"projects/\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e/logs/backupdr.googleapis.com%2Fbackup_recovery_appliance_events\" AND jsonPayload.eventId=10085\n\n3. Events that are non-impacting and can be ignored. For example, the event IDs 10229 (exceeded storage errors) and 42356 (file changes have been detected) can be ignored, as Google support have declared they are false positives. Use the following query to create the alert.\n\n Policyname = 'Backup/DR event has occurred'\n Notification rate limit = 6 hr\n logName=\"projects/\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e/logs/backupdr.googleapis.com%2Fbackup_recovery_appliance_events\" AND NOT jsonPayload.eventId=(10085 OR 10229 OR 42356 OR 43901)"]]