"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",}]
複製先前設定的日誌項目。
在「Try this API (試用這個 API)」窗格中,請按照下列步驟操作:
在 API Explorer 的「Request body」欄位中,將內容替換為您在先前步驟複製的記錄項目。
按一下 [Execute] (執行)。如果系統出現提示,請按照驗證流程操作。
如果 logEntries.write 呼叫成功,您會收到 HTTP 200 回應碼和空白回應主體 ({})。如要進一步瞭解 API Explorer,請參閱「使用 API Explorer」一文。API Explorer 的運作方式與 Logging API 相同。
需要緊急參加的活動,因此需要更頻繁的通知。舉例來說,事件 ID 43901 (快照工作失敗) 必須每 30 分鐘回報一次。使用下列查詢建立快訊。
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"]],["上次更新時間:2025-09-04 (世界標準時間)。"],[[["\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)"]]