Can we set alert based on graph/metrics available in API Monitoring tab (APIGEE-X)

Hi All,

I am using API Monitoring tab in Apigee X for monitoring graph: Proxy Error Rate by Proxy, which is present under view: recent.
Is there a way to set a alert which will trigger when Error Rate for any proxy is grater than 5?
I tried creating alert policy which processes logs present in log explorer to trigger alerts, but its not having metric for proxy_error_rate. If I filter by response code (400 - 599) the results are not accurate as compared to what are present in API Monitoring graph.

2 Likes

Hi Rohit,

You can set up alerts and notifications in the Google Cloud console, not the API Monitoring UI, for proxy_error_rate based on filter by response code (400-599).

Refer Setting up alerts and notifications  |  Apigee  |  Google Cloud

2 Likes

You can create this alert using a Metric Ratio in Google Cloud Monitoring. The “Proxy Error Rate” graph in the Apigee UI specifically calculates the rate of server-side errors (5xx status codes), which is why filtering for all 400-599 codes gives you a different result.

The correct approach is to build a ratio comparing the count of 5xx responses to the total number of responses for each proxy.


## Create the Alert Policy in Cloud Monitoring

Here’s the step-by-step guide to set up the alert correctly in the Google Cloud Console.

  1. Navigate to Alerting: Go to the Google Cloud Console and navigate to Monitoring > Alerting.

  2. Create Policy: Click + Create Policy.

  3. Configure Metric:

    • Click Select a metric.
    • In the “Select a metric” filter bar, type proxy/request_count and select the metric Apigee Proxy > proxy/request_count.
    • Click Apply.
  4. Set Up Metric Ratio:

    • Just above the chart, find the Transformation section. Change the Aggregation dropdown from None to Metric Ratio. This will reveal Numerator and Denominator configuration sections.
  5. Configure the Numerator (5xx Errors):

    • Metric: This should already be set to apigee.googleapis.com/proxy/request_count.
    • Filter: Click Add Filter.
      • Label: response_code
      • Comparator: >= (greater than or equal to)
      • Value: 500
    • Group By: In the Group By field, select proxy_name. This ensures the error rate is calculated for each proxy individually.
  6. Configure the Denominator (Total Traffic):

    • Metric: This should also be set to apigee.googleapis.com/proxy/request_count.
    • Group By: In the Group By field, select proxy_name. Do not add any filters here, as you need the total request count.
  7. Configure the Alert Trigger:

    • Click Next.
    • Condition type: Keep the default Threshold.
    • Alert trigger: Set to Any time series violates.
    • Threshold Position: Above threshold.
    • Threshold Value: 0.05 (this represents 5%).
    • For: Set a duration like 5 minutes to avoid alerts for brief, insignificant spikes.
    • Click Next.
  8. Configure Notifications and Finalize:

    • Choose your preferred notification channels (e.g., Email, PagerDuty, Slack).
    • Give the alert policy a descriptive name, like “Proxy 5xx Error Rate > 5%”.
    • Click Create Policy.

## Using Monitoring Query Language (MQL)

For a more direct setup, you can use the MQL editor within the alert policy creation screen. This query precisely defines the ratio you need.

fetch apigee.googleapis.com/proxy/request_count
| {
    filter response_code >= 500 && response_code < 600;
    group_by [proxy_name], sum(value.request_count)
  }
| join
| {
    group_by [proxy_name], sum(value.request_count)
  }
| ratio

After pasting this query, you would then configure the trigger condition to be condition > 0.05 for a duration of your choice.

  • Disclaimer - Gemini AI generated answer - using Gemini Pro paid subscription - fyi
1 Like

Hi @atanu2531 I am using Apigee X, The API Monitoring graph: Proxy Error Rate by Proxy, which is present under view: recent, shows total error traffic rate for a proxy, irrespective of whether it’s from proxy or target.
I have verified this using traffic graph present in API Proxy Performance under API metrics in Analysis tab.
I tried to find Metric Ratio in Aggregation, but it’s not available.
And for MQl there is notice: Starting July 22, 2025, Monitoring Query Language (MQL) will no longer be available for new dashboards and alerts in the Google Cloud console

hi @rohitshete are you using which version ( paid , free , enterprise , public , private etc) ?
also try to configure if there are some options available ..

Hi Dino @dchiesa1 ,

Referring your response and video on :GCP Monitoring & Alerts based on Proxy error percentage.

I am working on similar Apigee-X alert in GCP alerting policy which should trigger alert if error percentage for proxy is greater than 10%.

I am using below promQL query which is showing perfect result if I use it in GCP Metric explorer (Widget type: table), but does not give correct results if I use same query in Alerting Policy.

(sum by ("proxy_name")(increase({"__name__"="apigee_googleapis_com:proxy_response_count","monitored_resource"="apigee.googleapis.com/Proxy","response_code"=~"400|401|403|404|405|409|412|415|429|500|502|503|504"}[60m])) / (sum by ("proxy_name")(increase({"__name__"="apigee_googleapis_com:proxy_response_count","monitored_resource"="apigee.googleapis.com/Proxy"}[60m])) > 100))*100>10

I am calculating error percentage only if proxy have 100+ events in last 60 minutes. Will you please help me to rectify the issue.