이 문서에서는 로그 기반 측정항목이 사용자가 지정한 기준과 일치할 때의 알림을 구성하는 방법을 설명합니다. 알림 정책을 만들고 알림 채널을 구성하는 단계를 안내하는 이 문서의 설명은 Google Cloud 콘솔을 위한 것입니다. 또한 Cloud Monitoring API 및 Google Cloud CLI 명령어 gcloud alpha monitoring policies를 사용하여 알림 정책을 만들 수 있습니다.
시작하기 전에
Identity and Access Management 역할에 로그 기반 측정항목을 만들고 보고 알림 정책을 만드는 데 필요한 권한이 포함되어 있는지 확인하세요.
자세한 내용은 로그 기반 측정항목 권한을 참조하세요.
로그 기반 측정항목에 대해 잘 알고 계셔야 합니다. 자세한 내용은 로그 기반 측정항목 개요를 참조하세요.
알림을 수신하는 데 사용할 알림 채널을 구성합니다. 이 단계에 대한 자세한 내용은 알림 채널 만들기 및 관리를 참조하세요.
카운터 측정항목의 알림 정책 만들기
알림 정책에서는 모니터링할 조건 집합을 지정합니다.
알림 정책을 만들 때 모니터링 대상과 알림을 보낼 시기 등의 조건도 지정해야 합니다. 알림에는 이슈에 대한 정보가 포함되며 관련 로그 및 이슈 세부정보를 볼 수 있는 버튼이 포함됩니다.
로그 기반 카운터 측정항목의 값을 기준점과 비교하는 알림 정책을 만들려면 다음을 수행합니다.
[[["이해하기 쉬움","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-04-22(UTC)"],[],[],null,["# Configure notifications for log-based metrics\n\nThis document explains how to configure notifications when a\nlog-based metric matches criteria that you specify. These instructions,\nwhich guide you through creating an alerting policy and configuring\nnotification channels, are for the Google Cloud console. You can also create\nalerting policies by using the\n[Cloud Monitoring API](/monitoring/alerts/using-alerting-api)\nand by using the Google Cloud CLI command\n[`gcloud alpha monitoring policies`](/sdk/gcloud/reference/alpha/monitoring/policies).\n\nAlerting policies that monitor log-based metrics can't extract data from\nlog entries. If you want a notification to extract data from a log entry,\nthen [create a log-based alert](/logging/docs/alerting/log-based-alerts).\n\nBefore you begin\n----------------\n\n1. Verify that your Identity and Access Management role includes the permissions required to\n create and view log-based metrics, and to create alerting policies.\n For details, see\n [Log-based metric permissions](/logging/docs/access-control#metrics-permissions).\n\n2. Verify that you are familiar with log-based metrics. For more information,\n see [Overview of log-based metrics](/logging/docs/logs-based-metrics).\n\n3. Configure the notification channels that you want to use to receive any\n notifications. For information about these steps, see\n [Create and manage notification channels](/monitoring/support/notification-options).\n\nCreate an alerting policy on a counter metric\n---------------------------------------------\n\nAn alerting policy describes a set of conditions that you want to monitor.\nWhen you create an alerting policy, you must also specify its conditions: what\nis monitored and when to send notifications. Notifications\ninclude information about the incident, and they include buttons that let\nyou view relevant logs and incident details:\n\nTo create an alerting policy that compares the value of a\nlog-based counter metric to a threshold, do the following:\n\n1. In the Google Cloud console, go to the **Log-based Metrics** page:\n\n [Go to **Log-based Metrics**](https://console.cloud.google.com/logs/metrics)\n\n \u003cbr /\u003e\n\n If you use the search bar to find this page, then select the result whose subheading is\n **Logging**.\n2. Find the metric that you want to monitor,\n click *more_vert* **More** ,\n and then select **Create alert from metric**.\n\n3. Verify that the **Select a metric** field lists a\n `metric.type` and a `resource.type`. If necessary,\n add a `resource.type` clause.\n\n For example, the following filter specifics a metric and a resource: \n\n metric.type=\"logging.googleapis.com/byte_count\"\n AND resource.type=\"gce_instance\"\n\n4. In the **Rolling window** menu, we recommend that you select a value that\n is at least 10 minutes. In particular, this value should\n be large enough to make sure that multiple log entries that match your\n filter are counted.\n\n For example, if a log-based metric counts \"heartbeat\" log entries,\n which are expected every `N` minutes, then set the value of the\n **Rolling window** menu to `2N` minutes or 10 minutes,\n whichever is larger.\n | **Note:** Log-based metric data can have gaps and those gaps can result in false notifications. Increasing the value of the **Rolling window** menu can reduce the risk of false notifications. For more information, see [Troubleshoot: Metric is missing logs data](/logging/docs/logs-based-metrics/troubleshooting#slow-startup).\n5. Click **Next** , select **Threshold**.\n\n6. Enter a **Threshold value** , and optionally, configure the\n **Alert trigger** and **Threshold position** fields.\n\n7. Optional: Update the **Retest window** and use the\n **Advanced Options** fields to configure how the alerting policy\n handles missing data. Typically, the default setting is appropriate.\n\n8. Click **Next** , click **Notification channels**, and then select the\n notification channels that you want to use for the alerting policy.\n\n9. Optional: In the **Documentation** section, enter any information that\n you want included in notifications. Typically, the information includes\n information about how to respond to the notification.\n\n Don't include label extraction from log entries in your documentation.\n Alerting policies that monitor a log-based metric can't extract data from\n log entries.\n10. In the **Name the alert policy** field,\n enter a name for the alerting policy.\n\n11. Click **Create policy**.\n\nTroubleshooting\n---------------\n\nIf you encounter issues, then see\n[Troubleshoot log-based metrics](/logging/docs/logs-based-metrics/troubleshooting).\n\nWhat's next\n-----------\n\n- For more information about alerting policies, see the following documents:\n\n - [Introduction to alerting](/monitoring/alerts)\n - [Managing alerting policies](/monitoring/alerts/using-alerting-api)\n- To chart your log-based metric, see\n [View your log-based metrics](/logging/docs/logs-based-metrics/view_your_log_based_metrics).\n\n- For information about how to monitor Cloud Logging and Cloud Monitoring\n usage and receive notifications you when you approach the threshold for\n billing, see [Monitor and optimize Google Cloud Observability costs](/stackdriver/docs/observability/pricing-optimize-and-monitor)."]]