Generated banner for Agent Platform Alert Configuration
Generated logo for Agent Platform Alert Configuration

Agent Platform Alert Configuration

GoogleOfficialPublished by Google

  • Skill
  • Workflow
  • Cloud and DevOps
  • Apache-2.0
  • Low risk
  • Has scripts

From the author

Configures best-practice alerting policies for AI agents using OpenTelemetry (OTel) metrics, generating output as Terraform (.tf) configuration files. Use when analyzing, writing, or deploying alerting policies to monitor agent latency, error rates, token usage, and quality metrics. Don't use for standard infrastructure monitoring unrelated to AI agents, or when the agent is not instrumented with OpenTelemetry (for Reliability, Cost, Safety, Security alerts). NOTE: Reliability, Cost, Safety, and Security alerts use generic OTel metrics and work across runtimes (such as Cloud Run, Vertex AI). Quality alerts rely on Vertex AI Online Monitors and are strictly bound to Vertex AI deployments.
— the description by Google

AutoGineer summary

Written by AutoGineer from the skill’s own files, not by the author

This skill provides a structured approach to configuring alerting policies for AI agents instrumented with OpenTelemetry. It automates the creation of Terraform files for monitoring reliability, quality, cost, safety, and security metrics. The skill includes discovery scripts to identify agent runtimes and metric scopes, ensuring that generated alerts are correctly targeted. It emphasizes dynamic grouping of metrics to avoid hardcoding resource names and provides specific guidance for integrating with Vertex AI Online Monitors and Google Cloud Monitoring.

What it does

  • Discovers agent runtime and telemetry configuration using automated scripts.
  • Generates Terraform (.tf) files for defining alerting policies.
  • Configures reliability alerts for latency, error rates, and tool calls.
  • Sets up quality monitoring policies for Vertex AI Online Evaluators.
  • Defines cost-based alerts for token usage patterns.
  • Validates configuration syntax and PromQL queries using linting tools.

When to use it

  • When you need to deploy standardized alerting policies for AI agents.
  • When your agent is instrumented with OpenTelemetry and requires monitoring.
  • When you need to manage agent observability via Terraform infrastructure-as-code.
  • When you need to configure quality monitoring for Vertex AI deployments.

Advantages

  • Ensures consistent monitoring across different agent runtimes.
  • Promotes dynamic alerting by avoiding hardcoded resource filters.
  • Integrates directly with Terraform workflows for infrastructure management.
  • Provides automated discovery to reduce manual configuration errors.

Usage examples

“Generate Terraform alerting policies for my agent named support-bot in project my-gcp-project.”
The agent will run discovery scripts to identify the agent's telemetry setup and then generate the required Terraform files for reliability, quality, cost, safety, and security alerts.
“I need to monitor token usage for a new agent. How should I proceed?”
The agent will guide you through selecting a token usage pattern and generate the appropriate Rapid Token Burn Rate alert policy in Terraform.

Install

  1. Download the skill as a ZIP:

    https://mp-staging.autogineer.com/agent-skills/google/agent-platform-alert-configuration/download
  2. Unzip it into the cross-client skills folder of your project:

    mkdir -p .agents/skills && unzip agent-platform-alert-configuration.zip -d .agents/skills

Documentation by Google

Agent Platform Alert Configuration

Attribution

MUST READ: Before executing any gcloud, REST API, or MCP command, you MUST read Usage Attribution. For commands executed directly in the terminal (never in generated scripts, Terraform, or user code), prefix gcloud with CLOUDSDK_METRICS_REQUEST_ATTRIBUTION="agent-skills/1.0 (skill:agent-platform-alert-configuration)" and append agent-skills/1.0 (skill:agent-platform-alert-configuration) to User-Agent headers.

Critical Steps

1. Safety & Confirmation Tiers (CRITICAL)

Before executing any commands or writing configurations on behalf of the user, you MUST adhere to the following safety tiers based on the action requested:

  1. Tier R: Read-only (check_telemetry.py / gather_agent_info.py)

    • Rule: No confirmation needed. You may execute these scripts immediately to inspect telemetry status or gather agent configuration details.

  2. Tier B: Billing & Resource Creation (create_online_monitor.py / provisioning)

    • Rule: Explicit User Confirmation Required. These actions incur additional billing charges and create cloud resources. The agent MUST ALWAYS warn the user explicitly about the potential extra billing costs of BOTH the Online Monitor (specifically mentioning LLM evaluations) and Telemetry (specifically mentioning Cloud Trace/Cloud Logging export). You MUST STOP and ask for explicit approval before proceeding with provisioning or providing setup commands.

2. Prerequisites & Dependencies
Agent Telemetry
  • Disclaimer: For Reliability, Cost, Safety, and Security alerts to function, the underlying agent MUST be instrumented to emit OpenTelemetry (OTel) metrics. If the agent does not emit these metrics, the alerting policies will have no data stream to evaluate.

Python Environment

Before executing any python script in this skill you MUST install the required dependencies in your environment. Run this command first:

pip install -r scripts/requirements.txt
3. Input Assumptions
  • Explicit Project Adherence: You must ONLY configure alerts, query telemetry, or interact with the Google Cloud Project(s) explicitly provided by the user in the prompt. Do NOT assume or use other projects from your environment or history unless the user explicitly directs you to do so.

  • Sequential File Transformations: If the user explicitly asks to copy a file and then modify it, you MUST perform these actions sequentially (copy first, then modify) rather than writing the final content directly.

4. Execution Steps
  1. Mandatory Prerequisite Execution Protocol (SEQUENTIAL): Before generating or writing ANY configuration, you MUST execute these steps in order:

    1. Step 1: Streamlined Discovery (Mandatory): Run gather_agent_info.py to automatically identify agent runtime, verify telemetry, metric scopes, linked datasets, and more. This script covers most of the manual verifications listed in subsequent steps.

      • Command: python3 scripts/gather_agent_info.py --project-id {project_id} --agent-name {agent_name}

      • Note: If this script fails, returns partial data, or doesn't produce everything you need, you MUST satisfy requirements by running the manual fallback steps listed in Step 2 and then perform Step 3 below. If Step 1 succeeds and provides all info, SKIP to Step 3 (Pre-existing Policies Verification).

    2. Step 2: Metric Scope Verification (Fallback): Run this ONLY if Step 1 failed to determine the metric scope.

      • Action A (CLI): Run gcloud beta monitoring metrics-scopes list projects/{project_id}. If a scoping project is returned, you MUST deploy policies there.

      • Action B (Code Scan): Search Terraform configurations for google_monitoring_monitored_project resources to extract the scoping project.

      • Action C (Fallback): If ambiguous, ASK the user: "Are you using a multi-project Cloud Monitoring Metric Scope? If so, what is the scoping project ID?"

    3. Step 3: Pre-existing Policies Verification: Avoid duplicates.

      • Action: Scan the target directory to see if aggregated policies already exist targeting the same metrics (grouped by reasoning_engine_id or gen_ai_agent_name). Use scan_duplicates.py to verify.

  2. Alert Policy Type Resource Files: You MUST list and read files under references/ with names ending in _alert_policies.md to learn how to configure alert policies based on type. By default you MUST configure all of the following alert types UNLESS the user requests to generate explicit alert policies and/or types. Follow their tables of content to help you find the reference sections you need to read:

5. Outputs & Formats
  • Always configure the supported alerting policies for the target agent:

    • For Reliability Monitoring: You MUST configure exactly five alerting policies:

      1. Latency (anomaly monitoring)

      2. Error Rate - Fast Burn SLO (1-Hour Window)

      3. Error Rate - Slow Burn SLO (3-Day Window)

      4. Model Call Error Rate (SQL-based Observability Analytics Alerting)

      5. Tool Call Error Rate (SQL-based Observability Analytics Alerting)

    • For Quality Monitoring: You MUST configure exactly three alerting policies (Requires Vertex AI Online Monitors):

      1. Final Response Quality

      2. Tool Use Quality

      3. Hallucination

    • For Cost Monitoring: You MUST configure exactly one cost alerting policy:

      1. Rapid Token Burn Rate (anomaly monitoring)

    • For Safety Monitoring: You MUST configure exactly one safety alerting policy:

      1. High Model Armor Safety Policy Trigger Rate (SQL-based Observability Analytics Alerting)

    • For Security Monitoring: You MUST configure exactly one security alerting policy:

      1. High IAM Permission Denied Trigger Rate (SQL-based Observability Analytics Alerting)

  • Terraform Only: Write the generated observability configuration ONLY as Terraform (.tf) files (such as alerts.tf, variables.tf).

    • You ONLY need to install Terraform if you're asked to deploy the alerts AND there is no valid Terraform install. SQL-based alerting using condition_sql requires the provider version >= 6.0.0 (or late 5.x versions supporting the feature).

    • If you are NOT asked to deploy the alerts you do not need to install terraform.

  • Dynamic Multi-Resource Alerting (No Single-Resource Pinning): You MUST NOT hardcode specific agent IDs or resource name filters (for example, {gen_ai_agent_name="{agent_name}"} or metric.labels.agent_resource_name="{agent_name}") in alerting conditions unless explicitly requested (for example, "ONLY for this agent"). Merely mentioning a specific agent name or ID in the request does NOT constitute an explicit request to pin/filter; you MUST still default to dynamic grouping to cover all agents. To cover all active agents in the project dynamically:

    Good Example (PromQL Grouping):

    sum(rate(workload_googleapis_com:gen_ai_invoke_agent_duration_count{monitored_resource="generic_node"}[5m])) by (gen_ai_agent_name)

    Bad Example (PromQL Hardcoded Filter):

    sum(rate(workload_googleapis_com:gen_ai_invoke_agent_duration_count{monitored_resource="generic_node", gen_ai_agent_name="support-bot"}[5m]))
    • For Reliability Metrics using PromQL: ALWAYS use grouping aggregations. Group by gen_ai_agent_name (for example, by (gen_ai_agent_name)). Avoid filtering to a single ID/Name unless requested.

    • For Quality Metrics using Standard Threshold Filters: Omit the agent_resource_name filter entirely. Configure the condition filter to only target the monitored resource type (aiplatform.googleapis.com/OnlineEvaluator) and metric type (aiplatform.googleapis.com/online_evaluator/scores) globally for the project.

    Good Example (SQL Grouping):

    SELECT
      JSON_VALUE(resource.attributes, '$."cloud.resource_id"') as agent_id,
      ...
    FROM ...
    GROUP BY agent_id

    Bad Example (SQL Hardcoded Filter):

    SELECT ...
    FROM ...
    WHERE JSON_VALUE(resource.attributes, '$."cloud.resource_id"') = 'support-bot'
    • For Downstream Calls using SQL: Omit the ENDS_WITH filter targeting a specific agent name. Instead, extract the agent identifier (for example, JSON_VALUE(resource.attributes, '$."cloud.resource_id"')) and add it to the GROUP BY clause alongside the model or tool name.

  • Directory Inference: Prefer the path explicitly provided by the user (if any). Otherwise, deploy configuration files to target Terraform or SRE folders (such as monitoring/, ops/, sre/). Use tools to locate where alert policies or state pointers exist in the project, rather than blindly writing to the root.

  • Notification Channels: By default, never configure any notification channels without user input. If the user explicitly provides a notification channel in their prompt, configure the alerts to use it. If no notification channel is provided, you MUST explicitly ask the user in your final response if they would like to configure notification channels. This is a mandatory question and you MUST NOT omit it from your response. IMPORTANT Do NOT make assumptions about notification channels. If you search the codebase for a notification channel you must ALWAYS confirm with the user before using it.

  • Plain English Response: You MUST include a plain English explanation for what the alerts do in your response. This must explain in plain English what the alert measures, how the algorithm works, and what a trigger indicates.

6. Output Verification
  • Background Task Cleanup: You MUST verify the status of all background tasks that you spawn. Before completing your execution and returning your final response, you MUST terminate or kill any active or hanging background tasks (using the manage_task tool with action kill).

  • Validate Configuration: Run the Config Linting tool to make sure all the output files are written with the correct grammar and structure. See details about the tool in the Tooling Scripts section below.

Tooling Scripts

Use the following scripts to discover agents, gather configuration details, resolve duplicates, and validate configs:

  1. Agent Information Gathering: Streamlines discovery, environment auditing (Metric Scopes, BQ Datasets, Notification Channels), table derivations (Log & Trace), and Online Evaluator verifications.

    • Command: python3 scripts/gather_agent_info.py --project-id {project_id} --agent-name {agent_name}

  2. Duplicate Verification & Merge: Verifies pre-existing alerts in the target folder to ensure changes are merged in-place rather than appended:

    • Command: python3 scripts/scan_duplicates.py {target_tf_dir} --engine-var '${var.gen_ai_agent_name}'

  3. Config Linting: Validates PromQL grammar, matching engine labels, and HCL structure:

    • Command: python3 scripts/lint_syntax.py {path_to_tf_file}

    • Self-Correction Loop: If validation fails (exits non-zero or outputs errors), you MUST read the command output, locate the line/file containing the lint error, analyze the PromQL syntax or Terraform HCL issue, apply adjustments in-place, and re-run the lint_syntax.py validation. Repeat this loop until the validation script passes successfully.

Gotchas & Behavioral Corrections

  • Raw Error Boundaries: Explain that raw error counts or absolute failed request count boundaries do not scale under changing traffic throughput. Recommend ratio-based error rate alerts instead.

  • Safe Threshold Modulation E2E Validation: When verifying a dynamic metric threshold policy end-to-end, do NOT attempt to force real platform errors. Instead, deploy the alert policy with standard safe bounds (Z-score multiplier > 15), then temporarily update standard deviation Z-score limits to a negative value (for example, > -3) to trigger/verify the "Firing" state before reverting. Always get confirmation before taking this action proactively.

  • Expected Script Failures:

    • scan_duplicates.py exiting with code 1: Parse the JSON output for duplicate resource targets. Perform in-place upgrade edits, then re-check until it passes with 0.

    • Avoid Redundant Discovery Calls: If gather_agent_info.py successfully returns the Trace or Log table names (or writes them to variables file), do NOT redundantly call list_trace_scope_table_names.py or list_log_scope_table_names.py. These scripts are run internally by gather_agent_info.py and are provided as external Fallbacks only.

    • Script Execution Failures & Self-Correction: If the execution of utility scripts (such as gather_agent_info.py, check_telemetry.py, create_online_monitor.py, analyze_traffic.py, list_log_scope_table_names.py, or list_trace_scope_table_names.py) fails unexpectedly, you MUST read and inspect the stdout/stderr logs or error output. Analyze the error message and attempt to dynamically correct parameters and retry execution before escalating or falling back to manual plans. Consult the relevant domain-specific reference file for detailed troubleshooting steps for specific scripts.

  • Distribution Metric Aligner Constraint: Standard ALIGN_MEAN cannot be applied to DELTA distribution metrics like online_evaluator/scores. You MUST use percentile-based aligners (like ALIGN_PERCENTILE_50) to reduce the score distribution into a comparable numeric stream.

  • HCL Heredoc Interpolation: When referencing Terraform variables inside PromQL or SQL queries (which are defined as strings), you MUST use the ${var.variable_name} syntax. Bare references like var.variable_name will fail at deployment time.

  • Avoid Recursive Directory Operations: You MUST NOT run recursive listing or search commands (such as ls -R, find ., or raw recursive grep) from the repository root if it contains a very large number of files, as this will freeze your session. Always target specific subdirectories.

Files

references/reliability_alert_policies.md

Reliability Alert Policies

These alert policies will help users pinpoint the root cause of ongoing increased agent latency and high error rates with model and tool requests.

Table of Contents

  • Prerequisites (~Line 21)

    • Alert Policies with SQL Metrics (~Line 23)

    • Alert Policies with PromQL Metrics (~Line 67)

  • Critical Rules (~Line 89)

  • Policy Specifications (~Line 127)

    • Latency (~Line 129)

    • Error Rate Fast Burn SLO (~Line 261)

    • Error Rate Slow Burn SLO (~Line 317)

    • Model Call Error Rate (~Line 374)

    • Tool Call Error Rate (~Line 447)

  • Tooling Scripts (~Line 519)

  • Gotchas & Behavioral Corrections (~Line 526)

Prerequisites

Alert Policies with SQL Metrics
Trace Scope Observability Analytics table

You will need to retrieve the Observability Analytics table where all the Trace scope spans are stored for the SQL based alerts.

BigQuery dataset

A linked BigQuery dataset instance is required to configure SQL alert policies depending on Observability Analytics trace data. This dataset MUST hold views for the _Trace trace bucket of the target GCP project.

Applicable BigQuery datasets have a "type": "LINKED" attribute and reference the _Trace bucket in their description. To list all existing BigQuery datasets in a project run the following command:

bq ls --format=prettyjson --project_id={project_id}

Where:

  • {project_id}: The target GCP project id.

If missing, you MUST get user confirmation before creating it. If denied, skip SQL reliability alerts. Otherwise, create it using:

gcloud beta observability buckets datasets links create \
  projects/{project_id}/locations/{location}/buckets/{bucket_id}/datasets/{dataset_id}/links/{link_id} \
 --dataset={dataset_id} \
 --bucket={bucket_id} \
 --location={location} \
 --project={project_id}

Where:

  • {project_id}: Target GCP project ID.

  • {location}: Observability bucket location (found in analytics table name).

  • {bucket_id}: Bucket ID (default: _Trace).

  • {dataset_id}: Dataset ID (default: Spans).

  • {link_id}: New BQ dataset name (default: trace_bq_linked_dataset).

Alert Policies with PromQL Metrics
Algorithm Selection & Policy Mapping Process

Alerting policies for agents MUST map to the correct algorithms to ensure statistical stability and prevent alert noise or blind spots based on data classes:

  • Latency: Follows workload traffic pattern (Steady / Consistent -> Z-Score; Seasonal / Cyclical -> Seasonal Decomposition; Bursty / Inconsistent -> Moving Averages).

  • Error Rate: ALWAYS use Multi-Window Multi-Burn Rate SLOs (or ratio-based static thresholds). Error rate is naturally sparse (0). If standard deviation is 0, Z-scores are mathematically unstable (division-by-zero), causing false alerts.

To resolve the workload traffic pattern (Seasonal / Cyclical, Steady / Consistent, or Bursty / Inconsistent), follow the instructions corresponding to the availability of historical metrics data:

Critical Rules

  • Brand New Agents (No Traffic History): When setting up alerts for a brand new agent, you MUST explicitly ask the user what traffic pattern they expect (Steady / Consistent, Seasonal / Cyclical, or Bursty / Inconsistent) in your response. If immediate setup is requested, ask the question but proceed using the default Steady/Consistent (Short-Window Z-Score) pattern. Follow no_historical_traffic_data.md.

  • Query Types for Reliability (No MQL or Threshold Filters):

    • For latency and container SLO error rate metrics, you MUST use condition_prometheus_query_language with PromQL.

    • For the downstream model call and tool call error rate metrics, you MUST use condition_sql with GoogleSQL querying _Trace.Spans._AllSpans.

    • Do NOT use MQL or standard condition_threshold for these reliability metrics.

  • Critical alert thresholds: We recommend configuring alerts with a 5% critical threshold (aligned with the Vertex AI SLA uptime definition). For warning alerts, you may optionally configure a 1% threshold to catch downstream degradation or quota exhausting before it affects user experience.

  • For Metrics using PromQL: ALWAYS use grouping aggregations. Group by gen_ai_agent_name (for example, by (gen_ai_agent_name)). Avoid filtering to a single ID/Name unless requested. Metrics are emitted via OpenTelemetry.

Telemetry Metrics

All raw telemetry metrics for the Agent Platform container runtime are cumulative counters monitored via PromQL. Downstream model calls are tracked via Open Telemetry Trace Spans exported to Observability Analytics and monitored via SQL queries.

SignalSource / Raw MetricTypeDescription
Latencygen_ai_invoke_agent_duration_bucketCounterHistogram bucket of agent request latencies
Error Rategen_ai_invoke_agent_duration_countCounterCumulative count of agent requests
Model Call Error Rateglobal._Trace.Spans._AllSpans viewTrace SpansDownstream LLM API call traces (status.code = 2 is error)
Tool Call Error Rateglobal._Trace.Spans._AllSpans viewTrace SpansDownstream tool execution traces (status.code = 2 is error)

Policy Specifications

Latency
Telemetry query

Long-Window Z-Score (For Established Agents - >1 week history)

Compares the 5-minute 95th percentile latency to the 1-week baseline.

  • LATENCY_ALGORITHM_NAME_SHORT: "long_window_zscore"

  • LATENCY_ALGORITHM_NAME_LONG: "Long-Window Z-Score"

  • LATENCY_ALGORITHM_CONDITION_DESCRIPTION: "Z-Score > 3"

abs(
  histogram_quantile(0.95, sum(rate(workload_googleapis_com:gen_ai_invoke_agent_duration_bucket{monitored_resource="generic_node"}[5m])) by (le, gen_ai_agent_name))
  -
  histogram_quantile(0.95, sum(rate(workload_googleapis_com:gen_ai_invoke_agent_duration_bucket{monitored_resource="generic_node"}[1w])) by (le, gen_ai_agent_name))
)
/
stddev_over_time(
  (histogram_quantile(0.95, sum(rate(workload_googleapis_com:gen_ai_invoke_agent_duration_bucket{monitored_resource="generic_node"}[5m])) by (le, gen_ai_agent_name)))[1w:5m]
) > 3

Note: The denominator uses a subquery [1w:5m] to calculate standard deviation of the 5-minute latency over 1 week. The numerator uses [1w] rate directly to avoid a second subquery for the mean.

Short-Window Z-Score (For Newer Agents - >1 hour history)

Compares the 1-minute 95th percentile latency to the 1-hour baseline. Useful for quick activation on new agents.

  • LATENCY_ALGORITHM_NAME_SHORT: "short_window_zscore"

  • LATENCY_ALGORITHM_NAME_LONG: "Short-Window Z-Score"

  • LATENCY_ALGORITHM_CONDITION_DESCRIPTION: "Z-Score > 3"

abs(
  histogram_quantile(0.95, sum(rate(workload_googleapis_com:gen_ai_invoke_agent_duration_bucket{monitored_resource="generic_node"}[1m])) by (le, gen_ai_agent_name))
  -
  histogram_quantile(0.95, sum(rate(workload_googleapis_com:gen_ai_invoke_agent_duration_bucket{monitored_resource="generic_node"}[1h])) by (le, gen_ai_agent_name))
)
/
stddev_over_time(
  (histogram_quantile(0.95, sum(rate(workload_googleapis_com:gen_ai_invoke_agent_duration_bucket{monitored_resource="generic_node"}[1m])) by (le, gen_ai_agent_name)))[1h:1m]
) > 3

Compares the 5-minute latency to the 1-hour average.

  • LATENCY_ALGORITHM_NAME_SHORT: "moving_average"

  • LATENCY_ALGORITHM_NAME_LONG: "Moving Average"

  • LATENCY_ALGORITHM_CONDITION_DESCRIPTION: "5m Above 1h Average"

histogram_quantile(0.95, sum(rate(workload_googleapis_com:gen_ai_invoke_agent_duration_bucket{monitored_resource="generic_node"}[5m])) by (le, gen_ai_agent_name))
>
1.5 * histogram_quantile(0.95, sum(rate(workload_googleapis_com:gen_ai_invoke_agent_duration_bucket{monitored_resource="generic_node"}[1h])) by (le, gen_ai_agent_name))

[!NOTE] For the Latency alert policy, ONLY use seasonal decomposition to track Latency spikes. Alert policies using seasonal decomposition tracking both spikes and drops can falsely trigger alerts.

[!CRITICAL] The numerator (current latency) MUST NOT have any offset. Offsets (offset 1d, offset 1w) MUST only be applied to the denominator to construct the historical baseline for comparison. Never apply an offset to the first numerator.

Compares the 5-minute latency to the average of 1-week and 1-day lookback baselines.

  • LATENCY_ALGORITHM_NAME_SHORT: "seasonal_decomposition"

  • LATENCY_ALGORITHM_NAME_LONG: "Seasonal Decomposition"

  • LATENCY_ALGORITHM_CONDITION_DESCRIPTION: "Seasonal Decomposition > 2"

histogram_quantile(0.95, sum(rate(workload_googleapis_com:gen_ai_invoke_agent_duration_bucket{monitored_resource="generic_node"}[5m])) by (le, gen_ai_agent_name))
/
(
  (
    histogram_quantile(0.95, sum(rate(workload_googleapis_com:gen_ai_invoke_agent_duration_bucket{monitored_resource="generic_node"}[5m] offset 1d)) by (le, gen_ai_agent_name))
    +
    histogram_quantile(0.95, sum(rate(workload_googleapis_com:gen_ai_invoke_agent_duration_bucket{monitored_resource="generic_node"}[5m] offset 1w)) by (le, gen_ai_agent_name))
  ) / 2
)
> 2
Terraform HCL
resource "google_monitoring_alert_policy" "latency_{latency_algorithm_name_short}" {
  project      = var.project_id
  display_name = "Agent Reliability - Latency {latency_algorithm_name_long}"
  combiner     = "OR"

  conditions {
    display_name = "Latency {latency_algorithm_condition_description}"
    condition_prometheus_query_language {
      query    = <<EOT
{latency_telemetry_query}
EOT
    }
  }

  documentation {
    content   = "High latency detected for the agent."
    mime_type = "text/markdown"
    subject   = "Agent Reliability - Latency {latency_algorithm_name_long} on $${metric.label.gen_ai_agent_name}"
  }

  user_labels = {
    created-with-google-skill = "agent-platform-alert-configuration"
  }
}

Where:

  • {latency_algorithm_name_short}: Short algorithm name.

  • {latency_algorithm_name_long}: Long algorithm name.

  • {latency_algorithm_condition_description}: Condition description.

  • {latency_telemetry_query}: PromQL query from above.

Error Rate Fast Burn SLO (1-Hour and 5-Minute Windows)
Telemetry query

Always use Multi-Window Multi-Burn Rate SLOs. Z-score is not recommended due to sparsity.

(
  sum(rate(workload_googleapis_com:gen_ai_invoke_agent_duration_count{monitored_resource="generic_node",error_type!=""}[5m])) by (gen_ai_agent_name)
  /
  sum(rate(workload_googleapis_com:gen_ai_invoke_agent_duration_count{monitored_resource="generic_node"}[5m])) by (gen_ai_agent_name)
  > (1 - ${var.slo_target}) * 14.4
)
and
(
  sum(rate(workload_googleapis_com:gen_ai_invoke_agent_duration_count{monitored_resource="generic_node",error_type!=""}[1h])) by (gen_ai_agent_name)
  /
  sum(rate(workload_googleapis_com:gen_ai_invoke_agent_duration_count{monitored_resource="generic_node"}[1h])) by (gen_ai_agent_name)
  > (1 - ${var.slo_target}) * 14.4
)
Terraform HCL
resource "google_monitoring_alert_policy" "error_rate_fast_burn" {
  project      = var.project_id
  display_name = "Agent Reliability - Error Rate Fast Burn SLO"
  combiner     = "OR"

  conditions {
    display_name = "Error Rate Fast Burn (1h/5m)"
    condition_prometheus_query_language {
      query    = {error_rate_fast_slo_telemetry_query}
      duration = "300s" # 5m buffer
    }
  }

  documentation {
    content   = "Fast Burn error rate SLO violation detected."
    mime_type = "text/markdown"
    subject   = "Error Rate Fast Burn (1h/5m) on $${metric.label.gen_ai_agent_name}"
  }

  user_labels = {
    created-with-google-skill = "agent-platform-alert-configuration"
  }
}

Where:

  • {error_rate_fast_slo_telemetry_query}: The PromQL alert query configured in the Telemetry query section above.

Error Rate Slow Burn SLO (3-Day and 6-Hour Windows)
Telemetry query

Always use Multi-Window Multi-Burn Rate SLOs. Z-score is not recommended due to sparsity.

(
  sum(rate(workload_googleapis_com:gen_ai_invoke_agent_duration_count{monitored_resource="generic_node",error_type!=""}[6h])) by (gen_ai_agent_name)
  /
  sum(rate(workload_googleapis_com:gen_ai_invoke_agent_duration_count{monitored_resource="generic_node"}[6h])) by (gen_ai_agent_name)
  > (1 - ${var.slo_target}) * 1.0
)
and
(
  sum(rate(workload_googleapis_com:gen_ai_invoke_agent_duration_count{monitored_resource="generic_node",error_type!=""}[3d])) by (gen_ai_agent_name)
  /
  sum(rate(workload_googleapis_com:gen_ai_invoke_agent_duration_count{monitored_resource="generic_node"}[3d])) by (gen_ai_agent_name)
  > (1 - ${var.slo_target}) * 1.0
)
Terraform HCL
resource "google_monitoring_alert_policy" "error_rate_slow_burn" {
  project      = var.project_id
  display_name = "Agent Reliability - Error Rate Slow Burn SLO"
  combiner     = "OR"

  conditions {
    display_name = "Error Rate Slow Burn (3d/6h)"
    condition_prometheus_query_language {
      query = <<EOT
{error_rate_slow_slo_telemetry_query}
EOT
    }
  }

  documentation {
    content   = "Slow Burn error rate SLO violation detected."
    mime_type = "text/markdown"
    subject   = "Error Rate Slow Burn (3d/6h) on $${metric.label.gen_ai_agent_name}"
  }

  user_labels = {
    created-with-google-skill = "agent-platform-alert-configuration"
  }
}

Where:

  • {error_rate_slow_slo_telemetry_query}: The PromQL alert query configured in the Telemetry query section above.

Model Call Error Rate
Telemetry query

When configuring a SQL-based alerting condition (condition_sql) in Google Cloud Monitoring for an agent, use the following template to query trace spans exported to Observability Analytics:

SELECT
  JSON_VALUE(resource.attributes, '$."cloud.resource_id"') as agent_id,
  JSON_VALUE(attributes, '$."gen_ai.request.model"') as model,
  (COUNTIF(status.code = 2) * 100.0) / COUNT(*) AS model_error_rate
FROM
  `${TRACE_SCOPE_TABLE_NAME}`
WHERE
  JSON_VALUE(attributes, '$."gen_ai.request.model"') IS NOT NULL
GROUP BY
  agent_id,
  model
HAVING
  model_error_rate > 5.0

Where:

  • {trace_scope_table_name}: The Trace scope observability analytics table name retrieved in the Prerequisites section.

Terraform HCL

Implement the alert policy resource using a condition_sql block with a row_count_test check:

resource "google_monitoring_alert_policy" "model_call_error_rate" {
  project      = var.project_id
  display_name = "Agent Reliability - High Model Call Error Rate"
  combiner     = "OR"

  conditions {
    display_name = "Agent Model Call Error Rate Exceeds 5%"
    condition_sql {
      query = <<EOT
{model_call_high_error_rate_telemetry_query}
EOT

      # Run evaluation periodically (periodicity value must be between 5 and 1440 minutes)
      minutes {
        periodicity = 5
      }

      # Test triggers when one or more models violate the threshold (returning rows)
      row_count_test {
        comparison = "COMPARISON_GT"
        threshold  = 0
      }
    }
  }

  user_labels = {
    created-with-google-skill = "agent-platform-alert-configuration"
  }

  notification_channels = [google_monitoring_notification_channel.email.name]
}

Where:

  • {model_call_high_error_rate_telemetry_query}: The SQL alert query configured in the Telemetry query section above.

Tool Call Error Rate
Telemetry query

When configuring a SQL-based alerting condition (condition_sql) in Google Cloud Monitoring for an agent to monitor tool call error rates, use the following template to query trace spans exported to Observability Analytics:

SELECT
  JSON_VALUE(resource.attributes, '$."cloud.resource_id"') as agent_id,
  JSON_VALUE(attributes, '$."gen_ai.tool.name"') as tool_name,
  (COUNTIF(status.code = 2) * 100.0) / COUNT(*) AS tool_error_rate
FROM
  `${TRACE_SCOPE_TABLE_NAME}`
WHERE
  JSON_VALUE(attributes, '$."gen_ai.operation.name"') = 'execute_tool'
  AND JSON_VALUE(attributes, '$."gen_ai.tool.name"') IS NOT NULL
GROUP BY
  agent_id,
  tool_name
HAVING
  tool_error_rate > 5.0

Where:

  • {trace_scope_table_name}: The Trace scope observability analytics table name retrieved in the Prerequisites section.

Terraform HCL

Implement the alert policy resource using a condition_sql block with a row_count_test check:

resource "google_monitoring_alert_policy" "tool_call_error_rate" {
  project      = var.project_id
  display_name = "Agent Reliability - High Tool Call Error Rate"
  combiner     = "OR"

  conditions {
    display_name = "Agent Tool Call Error Rate Exceeds 5%"
    condition_sql {
      query = <<EOT
{tool_call_high_error_rate_telemetry_query}
EOT

      minutes {
        periodicity = 5
      }

      row_count_test {
        comparison = "COMPARISON_GT"
        threshold  = 0
      }
    }
  }

  user_labels = {
    created-with-google-skill = "agent-platform-alert-configuration"
  }

  notification_channels = [google_monitoring_notification_channel.email.name]
}

Where:

  • {tool_call_high_error_rate_telemetry_query}: The SQL alert query configured in the Telemetry query section above.

Tooling Scripts

  • list_trace_scope_table_names (Fallback): Use this script ONLY if gather_agent_info.py failed to retrieve the associated Trace scope observability SQL table name.

    • Command: python3 scripts/list_trace_scope_table_names.py --project_id={gcp_project}

Gotchas & Behavioral Corrections

  • SQL Alert Constraints:

    1. No manual timestamp filters or temporal groupings.

    2. Group by agent identifier: Use cloud.resource_id (Reasoning Engine ID or Cloud Run service) to monitor dynamically. Do NOT filter for specific agents unless requested.

    3. Aggregate failures: Group by agent or tool name, the ratio of failed requests (status code 2 indicating ERROR) to total requests.

    4. Use HAVING clause to filter out healthy tools/models.

    5. Pinning (Only if explicitly requested): Use ENDS_WITH(JSON_VALUE(resource.attributes, '$."cloud.resource_id"'), 'AGENT_IDENTIFIER') with string identifier (for example, 'support-bot'), not numeric, unless instructed. This should be avoided by default in favor of dynamic grouping as described in the main skill instructions.

  • Duration Buffers (Transient Glitches): To avoid alerts firing on transient spikes, use duration/retest window buffers appropriately:

    • Reliability Metrics (PromQL / Cloud Monitoring):

      • For short-lookback alerts querying data under 25 hours (such as Short-Window Z-Score, Moving Averages, Fast Burn SLO), ALWAYS use a duration = "300s" (5 minutes) buffer to filter out transient cold start/deployment spikes.

      • For long-lookback alerts querying data longer than 25 hours (such as Long-Window Z-Score, Seasonal Decomposition, Slow Burn SLO), duration/retest windows are disabled by the platform. You must not set a duration (omit it entirely).

  • Dynamic Baseline Adaptation Blind Spot: Explain to users that dynamic statistical Z-score thresholds compare current rates to a moving statistical baseline. If a system degrades slowly over days, the standard baseline curve adapts to this slow drift, making standard Z-score alerts blind to persistent slow errors. Recommend a hard static threshold alert in parallel for strict SLA enforcement.

  • Seasonal Decomposition Double Alerting: The agent MUST ONLY configure seasonal decomposition alert policies to track spikes (for example, latency spikes) OR drops AND MUST NOT use dual-direction evaluations (like absolute deviation). Explain this limitation to the user: comparing to a historical offset (for example, offset 1w) the alert policy triggers twice if tracking both directions (once for the anomaly, and once 1 week later when the anomaly becomes the baseline). To prevent this, the generated policy MUST only track either spikes (using >) or drops (using <), avoiding using abs().

  • Script Failures: If list_trace_scope_table_names.py fails unexpectedly, verify the project ID and ensure you have permissions to view trace scopes and linked datasets.

Requirements and compatibility

Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta

“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.

Needs: Declares allowed tools, Needs Python

Security

What our scanner noticed· Low risk

  • Instructions that use the network
  • Scripts that your agent may run

This skill includes scripts that your agent may run. Read them before you use it.

A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.

Attribution and licence

Published by
Google
Publisher
Google (Official)
Source
google/skills · skills/cloud/agent-platform-alert-configuration · commit 2194d3b
Licence
Apache License 2.0 (redistribution allowed)
  • LICENSE (added by AutoGineer from LICENSE)
  • ATTRIBUTION.md (written by AutoGineer)
Synced

AutoGineer is not affiliated with or endorsed by Google.

Download ZIP

The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download agent-platform-alert-configuration.zip