viewing Apigee X documentation.
View Apigee Edge documentation.
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 a specified event occurs. An actual event that triggers an alert is called an incident.
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 incident for the alert occurs, you can view its details in the Events pane of the Cloud Console Alerting dashboard.
You define an alert rule using two main properties:
- The metric: The quantity that triggers the alert—for example, number of requests.
- The threshold: The level that the metric must reach to trigger the alert.
If you want to be notified when a particular alert is triggered, you can set up a notification for the alert. When an incident occurs, Apigee sends you a notification 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.
Open the Create alerting policy dashboard in the Google Cloud Console.
Note: Open the Create alerting policy dashboard in a new tab if you want to follow the steps below.
- Click ADD CONDITION. This opens a new window where you can add the alert condition.
- 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.
Copy and paste the following in the Find resource type and metric field:
Apigee proxy (v2)
The Target pane now appears as shown below.
The pane displays the Select a metric field, where you can specify the metric, such as total traffic or latency percentile.
After completing the initial steps above, you can continue by selecting a metric and adding conditions for the alert in the Configuration pane.
The next two sections present 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.
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.
In the Target pane:
- 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.
- In the Metrics menu, choose either Apigee proxy request cumulative
or Apigee proxy response cumulative.
- In the Aggregator field, select sum. This sums the total traffic over the time span specified by Period.
- Set Period to 1 minute.
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.
Enter the following in the Configuration pane:
- Set Threshold to
- Set For to
The Configuration pane now appears as shown below.
Finally, click ADD to add the alert condition. This takes you back to the Create alerting policy dashboard, which displays the new condition, as shown below.
From here you can choose to either:
- Click ADD Condition to create another condition for the alert, or
- Click NEXT to go to Step 2, where you will have the option to [create a notification for the alert](#creating-a-notification-for-an-alert), as described in the next section.
If you don't want to create a notification, click NEXT twice without entering anything to bypass Steps 2 and 3.
Click SAVE to save the alert.
Viewing incident details
An API event that triggers an alert is called an incident. You can view the details of recent incidents in the Cloud Console Alerting dashboard.
Creating a notification for an alert
If an alert requires you immediate attention when triggered, you can create a notification for the alert. When the alert is triggered, Apigee sends you a notification. You can choose any of the following channels to receive the notification:
To create a notification for an alert:
If you just created the alert (as shown in the preceding example) and are currently viewing the Create alerting policy dashboard, skip to the next step.
Otherwise, open the Policies pane in the Cloud Console Alerting dashboard, and in the row for the alert you created, click the three dots icon at the end of the row and select Edit.
This opens the Edit alerting policy dashboard:
In the What do you want to track? section, click NEXT.
In the Who should be notified section, select Notification Channels, where you can choose from existing channels for receiving notifications.
If you want to create a new notification channel, select MANAGE NOTIFICATION CHANNELS. This opens the Notification channels dashboard in the Cloud Console, where you can add channels. See Managing notification channels for more details.
Click NEXT. This displays the options 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.
- Click Save to create the alert.
When an alert is triggered, you will receive a notification providing a summary of the incident and when it occurred. The notification also contains two links to help you investigate the incident:
- VIEW INCIDENT: View the incident in the Cloud Console.
- VIEW IN APIGEE: View a timeline graph of API traffic and related data tables in the API Monitoring Investigate dashboard.
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.
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.
Next, do the following steps in the Target pane:
- Copy the code below and paste it in the Select a metric field.
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 pane, do the following steps:
- 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 dashboard.
See Creating a notification to learn how to create a notification for the alert.