Skip to content

DigitalOcean.Monitoring reference

Source: packages/digitalocean/src/Monitoring/AlertPolicy.ts

A DigitalOcean Monitoring alert policy: notifies when a droplet metric (CPU, memory, disk, load, bandwidth) crosses a threshold for a while. The droplets need monitoring: true. Every prop updates in place.

A policy has no name or tags of its own, so Alchemy knows it only by the id it recorded.

yield* DigitalOcean.Droplet("app", {
region: "sfo3",
size: "s-1vcpu-1gb",
image: "ubuntu-24-04-x64",
monitoring: true,
tags: ["web"],
});
yield* DigitalOcean.Monitoring.AlertPolicy("web-cpu", {
type: "v1/insights/droplet/cpu",
description: "CPU above 80% for 5 minutes",
compare: "GreaterThan",
value: 80,
window: "5m",
tags: ["web"],
email: ["oncall@example.com"],
});

Source: packages/digitalocean/src/Monitoring/Destination.ts

A log-forwarding destination: an OpenSearch index that Kubernetes log sinks forward to. Any change replaces the destination: the API’s update endpoint answers 405 to the request its spec documents.

Destination: Forwarding Logs to OpenSearch

Section titled “Destination: Forwarding Logs to OpenSearch”
const search = yield* DigitalOcean.Databases.Cluster("logs", {
engine: "opensearch",
size: "db-s-1vcpu-2gb",
region: "nyc3",
});
const logs = yield* DigitalOcean.Monitoring.Destination("logs", {
opensearch: { clusterId: search.clusterId, indexName: "app-logs", retentionDays: 14 },
});

Source: packages/digitalocean/src/Monitoring/Sink.ts

Forwards a Kubernetes cluster’s logs to a Monitoring.Destination (an OpenSearch index). Sinks have no update; a change replaces the sink.

const logs = yield* DigitalOcean.Monitoring.Destination("logs", {
opensearch: { clusterId: search.clusterId, indexName: "k8s" },
});
yield* DigitalOcean.Monitoring.Sink("k8s-logs", {
destinationId: logs.destinationId,
resources: [{ urn: cluster.urn, name: "k8s" }],
});

Source: packages/digitalocean/src/Monitoring/UptimeAlert.ts

An alert on an UptimeCheck, sent by email or Slack when the target is down, slow, or its certificate is about to expire. Every prop but checkId updates in place.

const check = yield* DigitalOcean.Monitoring.UptimeCheck("site", {
type: "https",
target: "https://example.com",
});
yield* DigitalOcean.Monitoring.UptimeAlert("site-down", {
checkId: check.checkId,
type: "down_global",
period: "5m",
notifications: { email: ["oncall@example.com"] },
});
yield* DigitalOcean.Monitoring.UptimeAlert("site-cert", {
checkId: check.checkId,
type: "ssl_expiry",
threshold: 14,
period: "1h",
notifications: { email: ["oncall@example.com"] },
});

Source: packages/digitalocean/src/Monitoring/UptimeCheck.ts

A DigitalOcean uptime check: probes a URL or host from up to four regions every minute. Add UptimeAlerts to be told when it goes down, slows down, or its certificate is about to expire. Every prop updates in place.

Alchemy owns a check whose name it generated or whose id it recorded; a check that already has the chosen name is Unowned and needs --adopt.

const check = yield* DigitalOcean.Monitoring.UptimeCheck("site", {
type: "https",
target: "https://example.com/health",
});
yield* DigitalOcean.Monitoring.UptimeAlert("site-down", {
checkId: check.checkId,
type: "down",
period: "2m",
notifications: { email: ["oncall@example.com"] },
});