| name | agent-platform-alert-configuration |
| description | >- |
Trigger: Use when managing Alert Configuration on Google Cloud's Agent Platform — Google Cloud AI and agent infrastructure.
Agent Platform Alert Configuration
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:
- Tier R: Read-only (
check_telemetry.py)
- Rule: No confirmation needed. You may execute these scripts
immediately to inspect the telemetry status of the Reasoning Engine.
- 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/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
-
Mandatory Prerequisite Execution Protocol (SEQUENTIAL): Before
generating or writing ANY configuration, you MUST execute these steps in
order:
- Step 1: Metric Scope Check: Determine where to deploy policies.
- 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?"
- Step 2: Pre-existing Policies Check: 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
validate_config.py --directory to verify.
-
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 should 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:
- Latency (anomaly monitoring)
- Error Rate - Fast Burn SLO (1-Hour Window)
- Error Rate - Slow Burn SLO (3-Day Window)
- Model Call Error Rate (SQL-based Log Analytics Alerting)
- Tool Call Error Rate (SQL-based Log Analytics Alerting)
- For Quality Monitoring: You MUST configure exactly three alerting
policies (Requires Vertex AI Online Monitors):
- Final Response Quality
- Tool Use Quality
- Hallucination
- For Cost Monitoring: You MUST configure exactly one cost alerting
policy:
- Rapid Token Burn Rate (anomaly monitoring)
- For Safety Monitoring: You MUST configure exactly one safety
alerting policy:
- High Model Armor Safety Policy Trigger Rate (SQL-based Log
Analytics Alerting)
- For Security Monitoring: You MUST configure exactly one security
alerting policy:
- High IAM Permission Denied Trigger Rate (SQL-based Log Analytics
Alerting)
- Terraform Only: Write the generated observability configuration ONLY as
Terraform (
.tf) files (e.g., 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 (e.g.,
{gen_ai_agent_name="{agent_name}"} or
metric.labels.agent_resource_name="{agent_name}") in alerting conditions
unless explicitly requested (e.g., "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:
6. Output Verification
- Background Task Cleanup: You MUST check 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 resolve duplicates and validate configs before
presenting or applying Terraform changes:
- Duplicate Check & Merge: Checks for pre-existing alerts in the target
folder to ensure changes are merged in-place rather than appended:
- Command:
python3 scripts/validate_config.py --directory {target_tf_dir} --engine-var '${var.gen_ai_agent_name}'
- Config Linting: Validates PromQL grammar, matching engine labels, and
HCL structure:
- Command:
python3 scripts/validate_config.py --file {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
validate_config.py --file 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 (e.g. > -3) to trigger/verify the "Firing" state before
reverting. Always get confirmation before taking this action proactively.
- Expected Script Failures:
validate_config.py --directory 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.
- Script Execution Failures & Self-Correction: If script execution
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.
Supporting Links