Configure notifications for log-based metrics

This document explains how to configure notifications when a log-based metric matches criteria that you specify. These instructions, which guide you through creating an alerting policy and configuring notification channels, are for the Google Cloud console. You can also create alerting policies by using the Cloud Monitoring API and by using the Google Cloud CLI command gcloud alpha monitoring policies.

Before you begin

  1. Ensure that your Identity and Access Management role includes the permissions required to create and view log-based metrics, and to create alerting policies. For details, see Log-based metric permissions.

  2. Ensure that you are familiar with log-based metrics. For more information, see Overview of log-based metrics.

  3. Configure the notification channels that you want to use to receive any notifications. For information about these steps, see Create and manage notification channels.

Create an alerting policy on a counter metric

An alerting policy describes a set of conditions that you want to monitor. When you create an alerting policy, you must also specify its conditions: what is monitored and when to send notifications. Notifications include information about the incident, and they include buttons that let you view relevant logs and incident details:

Display of the view logs button on an notification.

To create an alerting policy on a log-based counter metric, do the following:

  1. In the Google Cloud console, go to the Log-based Metrics page:

    Go to Log-based Metrics

    If you use the search bar to find this page, then select the result whose subheading is Logging.

  2. Find the metric that you want to monitor, click More, and then select Create alert from metric.

  3. Ensure that the Enter a Monitoring filter field lists a metric.type and a resource.type. If necessary, add a resource.type clause.

    For example, the following filter specifics a metric and a resource:

    AND resource.type="gce_instance"
  4. Click Next, enter a value in the Threshold value field.

  5. Click Next, click Notification channels, and then select the notification channels that you want to use for the alerting policy.

  6. Optional: In the Documentation section, enter any information that you want included in notifications. Typically, the information includes information about how to respond to the notification.

  7. In the Name the alert policy field, enter a name for the alerting policy.

  8. Click Create policy.


If you encounter issues, see Troubleshoot log-based metrics.

What's next