GCP.Monitoring reference
AlertPolicy
Section titled “AlertPolicy”Source:
src/GCP/Monitoring/AlertPolicy.ts
A Cloud Monitoring alerting policy — conditions that open incidents and optional notification channels.
Policy ids are assigned by the API. Alchemy stamps ownership into
userLabels so list / pnpm nuke:gcp can find them. Display name,
combiner, conditions, channels, documentation, enabled, severity,
strategy, and labels update in place.
AlertPolicy: Creating a Policy
Section titled “AlertPolicy: Creating a Policy”CPU threshold without a notification channel
const policy = yield* GCP.Monitoring.AlertPolicy("CpuHigh", { combiner: "OR", conditions: [ { displayName: "CPU > 90%", conditionThreshold: { filter: 'resource.type = "gce_instance" AND metric.type = "compute.googleapis.com/instance/cpu/utilization"', comparison: "COMPARISON_GT", thresholdValue: 0.9, duration: "60s", aggregations: [ { alignmentPeriod: "60s", perSeriesAligner: "ALIGN_MEAN" }, ], }, }, ],});Policy that emails a channel
const channel = yield* GCP.Monitoring.NotificationChannel("Oncall", { type: "email", labels: { email_address: "oncall@example.com" },});const policy = yield* GCP.Monitoring.AlertPolicy("CpuHigh", { conditions: [ { displayName: "CPU > 90%", conditionThreshold: { filter: 'resource.type = "gce_instance" AND metric.type = "compute.googleapis.com/instance/cpu/utilization"', comparison: "COMPARISON_GT", thresholdValue: 0.9, duration: "60s", }, }, ], notificationChannels: [channel.name],});AlertPolicy: Updating a Policy
Section titled “AlertPolicy: Updating a Policy”const policy = yield* GCP.Monitoring.AlertPolicy("CpuHigh", { combiner: "OR", enabled: false, conditions: [ { displayName: "CPU > 50%", conditionThreshold: { filter: 'resource.type = "gce_instance" AND metric.type = "compute.googleapis.com/instance/cpu/utilization"', comparison: "COMPARISON_GT", thresholdValue: 0.5, duration: "60s", }, }, ],});Source:
src/GCP/Monitoring/Group.ts
A Cloud Monitoring group — a dynamic collection of monitored resources selected by a filter.
Group ids are assigned by the API. Groups have no labels field, so
Alchemy stamps ownership into displayName ([alchemy alchemy-stack=… alchemy-stage=… alchemy-id=…]) so list /
pnpm nuke:gcp can find them. Display name, filter, parent, and
cluster flag update in place.
Group: Creating a Group
Section titled “Group: Creating a Group”Root group of GCE instances in a region
const group = yield* GCP.Monitoring.Group("Prod", { displayName: "production instances", filter: 'resource.metadata.region="us-central1"',});Nested group
const parent = yield* GCP.Monitoring.Group("Prod", { filter: 'resource.metadata.region="us-central1"',});const child = yield* GCP.Monitoring.Group("Workers", { filter: 'resource.metadata.tag="worker"', parentName: parent.name,});Group: Updating a Group
Section titled “Group: Updating a Group”const group = yield* GCP.Monitoring.Group("Prod", { displayName: "production instances", filter: 'resource.metadata.region="us-east1"', isCluster: true,});MetricDescriptor
Section titled “MetricDescriptor”Source:
src/GCP/Monitoring/MetricDescriptor.ts
A Cloud Monitoring metric descriptor — the schema for a custom or external metric type.
Descriptors have no resource labels. Alchemy stamps ownership into
description ([alchemy alchemy-stack=… alchemy-stage=… alchemy-id=…]) so list / pnpm nuke:gcp can find them. type,
metricKind, and valueType are immutable — changing them replaces
the descriptor. Display name, description, unit, metadata, and added
labels update in place via create-as-upsert.
MetricDescriptor: Creating a Descriptor
Section titled “MetricDescriptor: Creating a Descriptor”Generated custom gauge
const metric = yield* GCP.Monitoring.MetricDescriptor("Paid", { displayName: "Invoice paid amount", description: "amount collected per invoice",});Explicit type, kind, and labels
const metric = yield* GCP.Monitoring.MetricDescriptor("Paid", { type: "custom.googleapis.com/invoice/paid/amount", metricKind: "DELTA", valueType: "INT64", unit: "1", labels: [{ key: "currency", valueType: "STRING" }],});MetricDescriptor: Updating a Descriptor
Section titled “MetricDescriptor: Updating a Descriptor”const metric = yield* GCP.Monitoring.MetricDescriptor("Paid", { displayName: "Invoice paid (cents)", unit: "1", description: "amount collected per invoice in cents",});NotificationChannel
Section titled “NotificationChannel”Source:
src/GCP/Monitoring/NotificationChannel.ts
A Cloud Monitoring notification channel — email, webhook, Pub/Sub, or another supported delivery type.
Channel ids are assigned by the API. Alchemy stamps ownership into
userLabels so list / pnpm nuke:gcp can find them. Changing type
replaces the channel. Display name, description, labels, user labels,
and enabled update in place.
NotificationChannel: Creating a Channel
Section titled “NotificationChannel: Creating a Channel”Email channel
const channel = yield* GCP.Monitoring.NotificationChannel("Alerts", { type: "email", labels: { email_address: "alerts@example.com" },});Webhook channel with user labels
const channel = yield* GCP.Monitoring.NotificationChannel("Hooks", { type: "webhook_tokenauth", displayName: "incident webhook", labels: { url: "https://example.com/hooks/alerts" }, userLabels: { env: "prod" },});NotificationChannel: Updating a Channel
Section titled “NotificationChannel: Updating a Channel”const channel = yield* GCP.Monitoring.NotificationChannel("Alerts", { type: "email", labels: { email_address: "alerts@example.com" }, enabled: false,});Service
Section titled “Service”Source:
src/GCP/Monitoring/Service.ts
A Cloud Monitoring service — the root resource for SLO monitoring.
Custom services (custom: {}) are the default when no other
identifier is set. Alchemy stamps ownership into userLabels so
list / pnpm nuke:gcp can find them. Changing serviceId or the
identifier kind replaces the service. Display name, labels, and
telemetry update in place.
Service: Creating a Service
Section titled “Service: Creating a Service”Generated custom service
const checkout = yield* GCP.Monitoring.Service("Checkout", { displayName: "Checkout", labels: { env: "prod" },});Explicit id
const checkout = yield* GCP.Monitoring.Service("Checkout", { serviceId: "checkout", displayName: "Checkout API",});Service: Updating a Service
Section titled “Service: Updating a Service”const checkout = yield* GCP.Monitoring.Service("Checkout", { displayName: "Checkout v2", labels: { env: "prod", team: "payments" },});ServicesServiceLevelObjective
Section titled “ServicesServiceLevelObjective”Source:
src/GCP/Monitoring/ServicesServiceLevelObjective.ts
A Cloud Monitoring service-level objective under a Monitoring Service.
Alchemy stamps ownership into userLabels so list /
pnpm nuke:gcp can find them. Changing service or
serviceLevelObjectiveId replaces the SLO. Goal, period, SLI,
display name, and labels update in place.
ServicesServiceLevelObjective: Creating an SLO
Section titled “ServicesServiceLevelObjective: Creating an SLO”const checkout = yield* GCP.Monitoring.Service("Checkout", {});const slo = yield* GCP.Monitoring.ServicesServiceLevelObjective( "Latency", { service: checkout.name, goal: 0.99, rollingPeriod: "86400s", serviceLevelIndicator: { requestBased: { distributionCut: { distributionFilter: 'metric.type="serviceruntime.googleapis.com/api/request_latencies" AND resource.type="consumed_api"', range: { max: 500 }, }, }, }, },);ServicesServiceLevelObjective: Updating an SLO
Section titled “ServicesServiceLevelObjective: Updating an SLO”const slo = yield* GCP.Monitoring.ServicesServiceLevelObjective( "Latency", { service: checkout.name, goal: 0.95, calendarPeriod: "MONTH", serviceLevelIndicator: { requestBased: { distributionCut: { distributionFilter: 'metric.type="serviceruntime.googleapis.com/api/request_latencies" AND resource.type="consumed_api"', range: { max: 500 }, }, }, }, },);UptimeCheckConfig
Section titled “UptimeCheckConfig”Source:
src/GCP/Monitoring/UptimeCheckConfig.ts
A Cloud Monitoring uptime check — an HTTP, HTTPS, TCP, or synthetic probe that measures availability.
Config ids are assigned by the API. Alchemy stamps ownership into
userLabels so list / pnpm nuke:gcp can find them. Display name,
period, timeout, HTTP/TCP settings, matchers, regions, and labels
update in place.
UptimeCheckConfig: Creating a Check
Section titled “UptimeCheckConfig: Creating a Check”HTTPS probe of example.com
const check = yield* GCP.Monitoring.UptimeCheckConfig("Homepage", { httpCheck: { path: "/", useSsl: true, validateSsl: true }, monitoredResource: { type: "uptime_url", labels: { host: "example.com" }, },});Generated name with labels
const check = yield* GCP.Monitoring.UptimeCheckConfig("Homepage", { timeout: "10s", period: "600s", labels: { env: "prod" },});UptimeCheckConfig: Updating a Check
Section titled “UptimeCheckConfig: Updating a Check”const check = yield* GCP.Monitoring.UptimeCheckConfig("Homepage", { period: "300s", httpCheck: { path: "/health", useSsl: true, validateSsl: true }, monitoredResource: { type: "uptime_url", labels: { host: "example.com" }, },});