Pulumi
Add uptime monitors and a status page from a Pulumi TypeScript or JavaScript program.
npm install @databuddy/pulumi
pulumi config set --secret databuddy:apiKey dbdy_...import * as pulumi from "@pulumi/pulumi";
import { StatusPage, StatusPageMonitor, UptimeMonitor } from "@databuddy/pulumi";
const api = new UptimeMonitor("api", {
url: "https://api.databuddy.cc/health",
granularity: "minute",
});
const status = new StatusPage("status", {
name: "Databuddy",
slug: `databuddy-${pulumi.getStack()}`,
});
new StatusPageMonitor("api-on-status", {
statusPageId: status.id,
monitorId: api.id,
displayName: "API",
});Needs Pulumi 3.216 or newer on the nodejs runtime. Make the key in Organization settings → API keys with the Monitors and Status pages presets. Resources go into the key's organization. Status page slugs are unique across all Databuddy accounts, so start them with your own name.
Configure resources
All arguments are also available as outputs.
UptimeMonitor
StatusPage
Also exports organizationId.
StatusPageMonitor
Keep dashboard edits
pulumi refresh picks up dashboard changes, and the next pulumi up reverts them. To let the dashboard own a field, ignore it:
new UptimeMonitor(
"checkout",
{ url: "https://databuddy.cc/checkout", granularity: "minute" },
{ ignoreChanges: ["paused"] }
);Monitors and status pages that already exist in the dashboard can't be imported.
Rename without replacing
Monitor URLs are unique per organization and slugs across all accounts, so a rename without aliases fails with a conflict. A replaced monitor starts a new check history, and its dashboard alerts need pointing at it again.
new UptimeMonitor(
"api-health",
{ url: "https://api.databuddy.cc/health", granularity: "minute" },
{ aliases: [{ name: "api" }] }
);Run it in CI
- run: pulumi up --yes --stack prod
env:
PULUMI_ACCESS_TOKEN: ${{ secrets.PULUMI_ACCESS_TOKEN }}
DATABUDDY_API_KEY: ${{ secrets.DATABUDDY_API_KEY }}Stack config wins over environment variables, which go on the pulumi process, not inside your program. The API URL must use HTTPS unless it's localhost.
Fix errors
Related
How is this guide?