It talks to the Oh Dear API directly and is authenticated with a single API token sent as a Bearer token on every request.

Example#

{{< chooser language "typescript" >}}

{{% choosable language typescript %}}

import * as ohdear from "@matthiashamacher/ohdear";
 
// Monitor a website with the uptime and certificate checks.
const site = new ohdear.Monitor("docs", {
    url: "https://example.com",
    teamId: 1,
    type: "http",
    checks: ["uptime", "certificate_health"],
    tags: ["production"],
});
 
// Group related tags together.
const envs = new ohdear.TagGroup("environments", {
    teamId: 1,
    label: "Environments",
    tags: ["production", "staging"],
});
 
// A public status page that lists the monitor.
const status = new ohdear.StatusPage("public", {
    teamId: 1,
    title: "Example Status",
    monitors: [{ id: site.monitorId, clickable: true }],
});
 
// Email alerts for the monitor.
const alerts = new ohdear.NotificationDestination("email", {
    level: "monitor",
    ownerId: site.monitorId,
    channel: "mail",
    destination: { mail: "alerts@example.com" },
    notificationTypes: [
        "HttpUptimeCheckFailedNotification",
        "HttpUptimeCheckRecoveredNotification",
    ],
});

{{% /choosable %}}

{{< /chooser >}}

Resources#

Resource Purpose
Monitor A monitored URL or host (http, ping, tcp, ai) and its checks.
CronCheck A cron job monitor on a Monitor; ping its URL on each successful run.
RecurringMaintenancePeriod A recurring maintenance schedule (daily, weekly or monthly) for a Monitor.
Tag A tag used to organize monitors. Create-only upstream.
TagGroup A named group of tags, with wildcard matching.
StatusPage A public status page and the monitors shown on it.
NotificationDestination Where alerts are delivered, scoped to a team, monitor, tag or tag group.

See the Installation & Configuration tab for setup and the API Docs tab for the full input and output reference of each resource.

Updated

Was this page helpful?