API Monitoring enables you to set up alerts and notifications that are triggered by specific events, such as spikes in API traffic or latencies. After you set up a notification, an email will be sent to you when an event occurs. To learn more about alerts, see Introduction to alerting.
Creating an alert
To create an alert from the API Monitoring UI, start by doing the following steps, which you'll need to do whenever you create a new alert.
- Click ALERT at the top of the UI. This opens the
Create alerting policy page in the Google Cloud Console, as shown below.
- Click ADD CONDITION. This opens a new page where you can add the alert condition.
- In the Find resource type and metric field, enter
Apigee proxyv2. The Target section now appears as in the
After doing these steps, you can select additional options for the alert, depending on what event you want alerted. The following sections give a couple of examples.
The last step above displays the Select a metric field, where you can specify the metric—the API quantity that triggers the alert. Here are a couple of examples of metrics you can use:
- Total traffic: Number of requests per minute. Use this to detect unexpected traffic .
- Latency percentile. Use this to detect a slowdown in request time.
- Response count. Use this to detect unexpected activity related to "Status Code", "Fault Code", or "Fault Source," etc.
The next two sections present examples of creating alerts based on the first two metrics.
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. To set up the alert, continue from step 2 in the Initial steps in the preceding section, and add the settings described below.
In the Target section:
- Click in the Select a metric field and type
or select Apigee proxy request cumulative.
- 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.
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.
Finally, click Add to add the alert condition. This takes you back to the Create alerting policy page where you started.
Creating a notification
To create a notification for the alert:
- Click NEXT.
- In the Who should be notified section, click
and select the email address where you want notifications sent.
To learn how to create your own email notifications channel, see Managing notification channels.
- Click NEXT. This displays the options for What are the steps to fix the issue? as shown below.
- In the Alert name field, enter a name for the alert.
- 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.
- Click Save to create the alert.
When you receive an alert notification email, click VIEW IN APIGEE in the email. This will open the Apigee documentation page Using the Investigate view.
The following section shows how to create an alert that is triggered when the 90th percentile of the API's latency is above 600 ms for 10 minutes. To create the alert, continue from step 2 in the Initial steps described in the first section. After doing so, the Target section appears as shown below.
Now do the following steps:
- In the Select a metric field, type
or select Percentile of Apigee proxy response.
- Under Filter, click in the Add a filter field and select
In the Value field that appears below Select a metric, select
- Click Apply.
- In the Configuration section, set Threshold to 600.
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.
To create the alert, click Add at the bottom of the UI. This takes you back to the Create alerting policy page where you started.
See Creating a notification to learn how to create an email notification for the alert. When you receive an alert notification email, click VIEW IN APIGEE in the email. This will open the Apigee documentation page Using the Investigate view.