Setting up alerts and notifications

One of the main purposes of API Monitoring is to keep you informed of unusual events or patterns, such as spikes in traffic or latencies. To track events like these, you can set up alerts, which are triggered when an event occurs. You can set specific rules for an alert—for example, it might be triggered when the number of API requests exceeds 3600 over a period of 1 minute. When an alerted event occurs, you can view its details in the Events pane of the Cloud Console Alerting page.

If you want to be notified when a particular alert is triggered, you can set up a notification for the alert. When the alert event occurs, Apigee sends you an email with a summary of the event, including links to the Cloud Console and the Apigee UI, for further investigation.

To learn more about alerts, see Introduction to alerting.

Initial steps for creating an alert

To create an alert, start by doing the steps below.

Note: You'll need to do these steps each time you create an alert.

  1. Open the Create alerting policy page in the Google Cloud Console, as shown below.

    Create alerting policy page

  2. Click ADD CONDITION. This opens a new window where you can add the alert condition.

    Configure an alert.

  3. Optional: Add a title for the condition in the Untitled Condition field. We'll leave it blank for this example, in which case the condition is given a default title.
  4. In the Find resource type and metric field, enter Apigee proxy (v2). The field now appears as shown below:

    Select a metric.

    Notice that the Target pane now displays the Select a metric field, where you can specify the metric—the API quantity that triggers the alert—such as total traffic or latency percentile.

After completing the initial steps above, you can further define the alert by selecting a metric and adding configuration options. The next two sections present simple examples that show how to do this:

Traffic spike alert

The following sections show how to create an alert that is triggered when the total API traffic is above 3600 for 1 minute.

Initial steps

To set up the alert, start by doing the Initial steps described in the preceding section. When you are done, add the settings described below.

Target settings

In the Target pane:

  1. Copy one of the code samples below, depending on whether you want an alert for requests or responses, and paste it in the Select a metric field.


  2. In the Metrics menu, choose either Apigee proxy request cumulative or Apigee proxy response cumulative.

    Select a metric.

    This displays the fields shown below.

    Select target options.

  3. In the Aggregator field, select sum. This sums the total traffic over the time span specified by Period, which is 1 minute by default.

    These settings will trigger an alert based on the total number of requests in each 1 minute interval of the time range.

Configuration settings

The Configuration settings specify the conditions that trigger the alert. The Threshold is the minimum value of the quantity specified in the Target section per second—which in this case is requests per second—that will set off the alert.

For example, suppose you want the alert to be triggered if the total traffic in any 1 minute interval is above 36. Since the threshold is measured in requests per second, you divide 3600 by 60 to get a threshold of 60.

Set the Threshold to 60, as shown below.

Configuration settings

Finally, click ADD to add the alert condition. This takes you back to the Create alerting policy page, which displays the new condition, as shown below.

New condition added.

From here you can choose to either:

  • Click ADD Condition to create another condition for the alert, or
  • Click NEXT, where you will have the option to add a notification for the alert, as described in the next section, and finally, create the alert.

Viewing triggered alerts

You can view the details of alerts that have been triggered in the Events pane of the Cloud Console Alerting page.

Creating a notification for an alert

To receive an email message when an alert is triggered, you can set a notification for the alert:

To create a notification for an alert:

  1. If you just created the alert (as shown in the preceding example) and are currently viewing the Create alerting policy page, skip to the next step. Otherwise, open the Policies pane in the Cloud Console Alerting page and select the alert. (Note: An alert is just a particular type of policy.)
  2. Click NEXT.
  3. In the Who should be notified section, click Notification Channels and select the email address where you want notifications sent.

    To learn how to create your own email notifications channel, see Managing notification channels.

  4. Click NEXT. This displays the options for What are the steps to fix the issue? as shown below. Notification options
  5. In the Alert name field, enter a name for the alert.
  6. In the Documentation field, enter the URL for a web page that provides information on how to fix the issue that caused the alert. The URL will be included in the notification email.
  7. Click Save to create the alert.

When an alert is triggered, you will receive a notification email providing a summary of the alert and when it occurred. The email also contains two links to help you investigate the alert:

  • VIEW INCIDENT: View the event in the Cloud Console.
  • VIEW IN APIGEE View a graph of API traffic at the time of the event in the Apigee UI Investigate view.

Latency alert

The following section shows how to create an alert that is triggered when the 90th percentile of API latency is above 600 ms for 10 minutes.

Initial steps

To create the alert, start by doing the Initial steps described in the first section. After doing so, the Target pane appears as shown below.

Select a metric.

Target settings

Next, do the following steps in the Target pane:

  1. Copy the code below and paste it in the Select a metric field.

    or select Percentile of Apigee proxy response.

    Select latency metric.

  2. Under Filter, click in the Add a filter field and select percentile.

    Select a metric.

  3. In the Value field that appears below Select a metric, select 90.

    Select a metric.

  4. Click Apply.

Configuration settings

In the Configuration pane, do the following steps:

  1. Set Threshold to 600.

    Select threshold.

With these settings, an alert will be triggered when the 90th percentile of the API's latency is above 600 for 10 minutes.

The UI displays the latency graph with the threshold, as shown below.

Select a metric.

To create the alert, click Add at the bottom of the UI. This takes you back to the Create alerting policy page.

See Creating a notification to learn how to create an email notification for the alert.