Incidents.Monitor
A Better Stack Uptime monitor: checks a URL, host or port on a schedule and
opens an incident when it fails. HTTP checks (status, keyword,
expected_status_code, …), ping, tcp/udp, mail ports, dns and
playwright scenarios.
authPassword is never returned by the API: changes are detected against
the previous deploy’s props, never against the live monitor. teamId
replaces the monitor when changed.
Creating a monitor
Section titled “Creating a monitor”HTTP status check
const api = yield* BetterStack.Incidents.Monitor("api", { url: "https://api.example.com/health", monitorType: "status", checkFrequency: 60,});Keyword check with basic auth
yield* BetterStack.Incidents.Monitor("admin", { url: "https://admin.example.com", monitorType: "keyword", requiredKeyword: "Dashboard", authUsername: "monitor", authPassword: Redacted.make(process.env.ADMIN_PASSWORD ?? ""), regions: ["us", "eu"],});Grouping monitors
Section titled “Grouping monitors”A monitor in a MonitorGroup
const group = yield* BetterStack.Incidents.MonitorGroup("public", { name: "Public endpoints" });yield* BetterStack.Incidents.Monitor("site", { url: "https://example.com", monitorType: "status", monitorGroupId: group.id,});Looking up an existing monitor
Section titled “Looking up an existing monitor”Reference a monitor by id
const existing = BetterStack.Incidents.Monitor.lookup({ id: "123456" });Reference a monitor by the URL it checks, or by its pronounceable name (either fails with AmbiguousLookup when several monitors match)
const api = BetterStack.Incidents.Monitor.lookup({ url: "https://api.example.com/health" });const homepage = BetterStack.Incidents.Monitor.lookup({ pronounceableName: "Homepage" });authPassword string | Redacted<string> | null
HTTP basic-auth password. Not returned after it's saved. Sending null doesn't remove a stored value.
authUsername string | Redacted<string> | null
HTTP basic-auth username. null when none is set. Sending null doesn't remove a stored value.
call boolean
Whether to call the on-call person. Ignored while an escalation policy is set.
checkFrequency number
How often to check, in seconds. Must be at least the request_timeout. A new or changed value below the plan's shortest interval is refused with a 422. A value the monitor already has, such as one set before a plan change, can still be sent. Accepted values depend on monitor_type. - playwright: accepts 60, 180, 300, 600, 900, 1800, 3600, 21600, 43200 or 86400. - Every other type: accepts 30, 45, 60, 120, 180, 300, 600, 900 or 1800.
confirmationPeriod number
How long to wait after a failure before starting an incident, in seconds, from 0 to 86400.
criticalAlert boolean
Whether to send a critical push notification that ignores the mute switch and Do Not Disturb mode. Ignored while an escalation policy is set.
domainExpiration 1 | 2 | 3 | 7 | 14 | 30 | 60 | number | null
How many days before the domain expires we alert you. null turns the check off and is the default. Monitors of the same domain share this setting, subdomains included. For example, monitors of example.com and www.example.com share it. A value set on one monitor is copied to all of them, so set the same value on each.
email boolean
Whether to send an e-mail to the on-call person. Ignored while an escalation policy is set.
environmentVariables CreateMonitorRequestEnvironmentVariablesMap
Environment variables the playwright scenario can use, as name and value pairs like {"PASSWORD": "passw0rd"}. Responses return each name with a null value. An object you send replaces all of them, and a name sent with null keeps its saved value. To add one, send the saved names with null and the new name with its value.
escalationPolicyId string | null
ID of the escalation policy for alerts, or null to alert the current on-call person directly.
expectedStatusCodes number[]
HTTP status codes from 100 to 599 that count as up. A 3xx code needs follow_redirects set to false. Required for expected_status_code monitors.
expirationEscalationPolicyId string | null
ID of the escalation policy for alerts about expiring SSL certificates and domains. Monitors of the same domain share this setting, subdomains included. For example, monitors of example.com and www.example.com share it. A value set on one monitor is copied to all of them, so set the same value on each.
followRedirects boolean
Whether we follow HTTP redirects.
httpMethod string
The HTTP method of the request. Accepts get, head, post, put, patch or options. Responses return the method in lowercase. head can't be used with keyword or keyword_absence monitors.
ipVersion "ipv4" | "ipv6" | string | null
The IP version to check over. null checks over both IPv4 and IPv6.
maintenanceDays string[]
Days of the week the maintenance window applies to, any of mon, tue, wed, thu, fri, sat and sun. An overnight window belongs to the day it starts. Order doesn't matter.
maintenanceFrom string | null
Start of the daily maintenance window, when we don't check, as HH:MM:SS, like 01:00:00. null when no window is set.
maintenanceTimezone string | null
The time zone of the maintenance window, as a Rails time zone name like Amsterdam or its IANA ID like Europe/Amsterdam. null when it isn't set, which works as UTC.
maintenanceTo string | null
End of the daily maintenance window, as HH:MM:SS, like 03:00:00. Required with maintenance_from. null when no window is set.
metadata CreateMonitorRequestMetadataMap
Custom metadata. Each key holds a list of values. A value is a string, written as {type: "String", value}, or a catalog reference, written as {type, item_id, name, email}. User references are returned as u123 and team references as t123. Get a user's ID via List team members, and a team's ID via List teams. Values under one key must all be the same type and can't repeat.
monitorGroupId string | null
ID of the monitor group this monitor belongs to.
monitorType "status" | "tcp" | "udp" | "expected_status_code" | "keyword" | "keyword_absence" | "ping" | "smtp" | "pop" | "imap" | "dns" | "playwright" | string
What the monitor checks.
paused boolean
Whether the monitor is paused. A paused monitor opens no incidents and sends no alerts. Send true to pause it or false to resume it.
playwrightScript string | null
The JavaScript source of the scenario, for playwright monitors.
port string | null
The port to check. tcp and udp accept one port. smtp accepts 25, 465 or 587, pop accepts 110 or 995, and imap accepts 143 or 993, with several separated by commas like 25,465,587. Required for tcp, udp, smtp, pop and imap monitors.
pronounceableName string
The name of the monitor, which we use when we call you.
proxyHost string | Redacted<string> | null
The host of the proxy server we send the check through, without a protocol. Can include credentials, like user:pass@proxy.example.com. Only for status, expected_status_code, keyword and keyword_absence monitors.
proxyPort number | null
The port of the proxy server, from 1 to 65535. Requires proxy_host.
push boolean
Whether to send a push notification to the on-call person. Ignored while an escalation policy is set.
recoveryPeriod 0 | 60 | 180 | 300 | 900 | 1800 | 3600 | 7200 | number
How long checks must keep passing before the incident resolves, in seconds.
regions string[]
Regions to check from, as any combination of us, eu, as and au. When none are set, we check from all regions. Responses then list all of them.
rememberCookies boolean
Whether we keep cookies when redirecting.
requestBody string | null
The body of the request. A dns monitor requires it. Set it to the domain to query. A udp monitor sends it as its content. Must be empty for get, head and options requests.
requestHeaders CreateMonitorRequestRequestHeadersItem[]
Custom request headers, as a list of {name, value} objects. A list replaces all headers, and an empty list removes them all.
requestTimeout number
How long a check waits before it times out. The unit and accepted values depend on monitor_type. - status, expected_status_code, keyword and keyword_absence: in seconds, accepts 2, 3, 5, 10, 15, 30, 45, 60, 90, 120 or 180 and defaults to 30. - ping, tcp, udp, smtp, pop, imap and dns: in milliseconds, accepts 500, 1000, 2000, 3000 or 5000 and defaults to 5000. - playwright: in seconds, accepts 15, 30, 45, 60, 120, 180, 240, 300, 360, 480, 600 or 900 and defaults to 30.
requiredKeyword string | null
The keyword to look for. Required for keyword, keyword_absence and udp monitors.
scenarioName string
The name of a playwright monitor's scenario. Required for playwright monitors, and returned only for them.
sms boolean
Whether to send an SMS to the on-call person. Ignored while an escalation policy is set.
sslExpiration 1 | 2 | 3 | 7 | 14 | 30 | 60 | number | null
How many days before the SSL certificate expires we alert you. null turns the check off and is the default. Monitors of exactly the same domain share this setting, not its subdomains. For example, monitors of example.com/a and example.com/b share it, while www.example.com has its own. A value set on one monitor is copied to all of them, so set the same value on each.
teamId string
Team that owns the resource, such as t123. Defaults to the credentials' team (BETTERSTACK_TEAM_ID, or the profile's team). Changing it replaces the resource.
teamWait number | null
Seconds to wait before escalating to the whole team. 0 alerts the whole team right away, and null never escalates to the team. Ignored while an escalation policy is set.
url string | null
The URL of your website, or the host to check for ping, tcp, udp, smtp, pop, imap and dns monitors, without a protocol. null on playwright monitors. Required for every type except playwright, which accepts scenario_name instead.
verifySsl boolean
Whether a check fails on an invalid SSL certificate.
Attributes
Section titled “Attributes”id string always set
The monitor's id.
authUsername string | Redacted<string> | null
HTTP basic-auth username. null when none is set.
call boolean
Whether to call the on-call person. Ignored while an escalation policy is set.
checkFrequency number
How often to check, in seconds. Must be at least the request_timeout. A new or changed value below the plan's shortest interval is refused with a 422. A value the monitor already has, such as one set before a plan change, can still be sent. Accepted values depend on monitor_type. - playwright: accepts 60, 180, 300, 600, 900, 1800, 3600, 21600, 43200 or 86400. - Every other type: accepts 30, 45, 60, 120, 180, 300, 600, 900 or 1800.
checksVersion string
Version of the checks engine. Always v2.
confirmationPeriod number
How long to wait after a failure before starting an incident, in seconds, from 0 to 86400.
createdAt string
When the monitor was created.
criticalAlert boolean
Whether to send a critical push notification that ignores the mute switch and Do Not Disturb mode. Ignored while an escalation policy is set.
domainExpiration 1 | 2 | 3 | 7 | 14 | 30 | 60 | null
How many days before the domain expires we alert you. null turns the check off and is the default. Monitors of the same domain share this setting, subdomains included. For example, monitors of example.com and www.example.com share it. A value set on one monitor is copied to all of them, so set the same value on each.
effectiveCheckFrequency number
How often the monitor actually checks, in seconds. effective_check_frequency_reason says why it differs from check_frequency.
effectiveCheckFrequencyReason "slowed_down" | "plan_minimum" | "request_timeout" | null
Why effective_check_frequency differs from check_frequency. null when they're the same.
email boolean
Whether to send an e-mail to the on-call person. Ignored while an escalation policy is set.
environmentVariables MonitorEnvironmentVariablesMap
Environment variables the playwright scenario can use, as name and value pairs like {"PASSWORD": "passw0rd"}.
escalationPolicyId string | null
ID of the escalation policy for alerts, or null to alert the current on-call person directly.
expectedStatusCodes number[]
HTTP status codes from 100 to 599 that count as up. A 3xx code needs follow_redirects set to false.
expirationEscalationPolicyId string | null
ID of the escalation policy for alerts about expiring SSL certificates and domains. Monitors of the same domain share this setting, subdomains included. For example, monitors of example.com and www.example.com share it. A value set on one monitor is copied to all of them, so set the same value on each.
followRedirects boolean
Whether we follow HTTP redirects.
httpMethod string
The HTTP method of the request. Accepts get, head, post, put, patch or options. Responses return the method in lowercase. head can't be used with keyword or keyword_absence monitors.
ipVersion "ipv4" | "ipv6" | null
The IP version to check over. null checks over both IPv4 and IPv6.
lastCheckedAt string | null
When the monitor was last checked.
maintenanceDays string[]
Days of the week the maintenance window applies to, any of mon, tue, wed, thu, fri, sat and sun. An overnight window belongs to the day it starts. Order doesn't matter.
maintenanceFrom string | null
Start of the daily maintenance window, when we don't check, as HH:MM:SS, like 01:00:00. null when no window is set.
maintenanceTimezone string | null
The time zone of the maintenance window, as a Rails time zone name like Amsterdam or its IANA ID like Europe/Amsterdam. null when it isn't set, which works as UTC.
maintenanceTo string | null
End of the daily maintenance window, as HH:MM:SS, like 03:00:00. Required with maintenance_from. null when no window is set.
metadata MonitorMetadataMap
Custom metadata. Each key holds a list of values. A value is a string, written as {type: "String", value}, or a catalog reference, written as {type, item_id, name, email}. User references are returned as u123 and team references as t123. Get a user's ID via List team members, and a team's ID via List teams. Values under one key must all be the same type and can't repeat.
monitorGroupId string | null
ID of the monitor group this monitor belongs to.
monitorType "status" | "tcp" | "udp" | "expected_status_code" | "keyword" | "keyword_absence" | "ping" | "smtp" | "pop" | "imap" | "dns" | "playwright"
What the monitor checks.
paused boolean
Whether the monitor is paused. A paused monitor opens no incidents and sends no alerts.
pausedAt string | null
When the monitor was paused.
playwrightScript string | null
The JavaScript source of the scenario, for playwright monitors.
port string | null
The port to check. tcp and udp accept one port. smtp accepts 25, 465 or 587, pop accepts 110 or 995, and imap accepts 143 or 993, with several separated by commas like 25,465,587.
pronounceableName string
The name of the monitor, which we use when we call you.
proxyHost string | Redacted<string> | null
The host of the proxy server we send the check through, without a protocol. Can include credentials, like user:pass@proxy.example.com. Only for status, expected_status_code, keyword and keyword_absence monitors.
proxyPort number | null
The port of the proxy server, from 1 to 65535. Requires proxy_host.
push boolean
Whether to send a push notification to the on-call person. Ignored while an escalation policy is set.
recoveryPeriod 0 | 60 | 180 | 300 | 900 | 1800 | 3600 | 7200
How long checks must keep passing before the incident resolves, in seconds.
regions string[]
Regions to check from, as any combination of us, eu, as and au. When none are set, we check from all regions. Responses then list all of them.
rememberCookies boolean
Whether we keep cookies when redirecting.
requestBody string | null
The body of the request. A dns monitor requires it. Set it to the domain to query. A udp monitor sends it as its content.
requestHeaders MonitorRequestHeadersItem[]
Custom request headers, as a list of {name, value} objects. A list replaces all headers, and an empty list removes them all.
requestTimeout number
How long a check waits before it times out. The unit and accepted values depend on monitor_type. - status, expected_status_code, keyword and keyword_absence: in seconds, accepts 2, 3, 5, 10, 15, 30, 45, 60, 90, 120 or 180 and defaults to 30. - ping, tcp, udp, smtp, pop, imap and dns: in milliseconds, accepts 500, 1000, 2000, 3000 or 5000 and defaults to 5000. - playwright: in seconds, accepts 15, 30, 45, 60, 120, 180, 240, 300, 360, 480, 600 or 900 and defaults to 30.
requiredKeyword string | null
The keyword to look for.
scenarioName string
The name of a playwright monitor's scenario. Required for playwright monitors, and returned only for them.
sms boolean
Whether to send an SMS to the on-call person. Ignored while an escalation policy is set.
sslExpiration 1 | 2 | 3 | 7 | 14 | 30 | 60 | null
How many days before the SSL certificate expires we alert you. null turns the check off and is the default. Monitors of exactly the same domain share this setting, not its subdomains. For example, monitors of example.com/a and example.com/b share it, while www.example.com has its own. A value set on one monitor is copied to all of them, so set the same value on each.
status "paused" | "pending" | "maintenance" | "up" | "validating" | "down"
The monitor's current status.
teamId string
Team that owns this monitor, such as t123.
teamName string
Name of the team that owns this monitor.
teamWait number | null
Seconds to wait before escalating to the whole team. 0 alerts the whole team right away, and null never escalates to the team. Ignored while an escalation policy is set.
updatedAt string
When the monitor was last updated.
url string | null
The URL of your website, or the host to check for ping, tcp, udp, smtp, pop, imap and dns monitors, without a protocol. null on playwright monitors.
verifySsl boolean
Whether a check fails on an invalid SSL certificate.
Lookup
Section titled “Lookup”Monitor.lookup(props) reads an object this stack does not manage. It is never created, updated or deleted.
teamId string
Team that owns it, such as t123. Defaults to the credentials' team.