Telemetry.Alert
An alert on a DashboardChart (dashboardId + chartId) or a saved
Exploration (explorationId) — exactly one of the two — that
starts an incident when its condition holds: a threshold on the value, a
relative change, or an anomaly_rrcf deviation from the predicted value.
Where the incident goes is escalationTarget (current_team by default,
or an escalation policy) and the per-alert call, sms, email, push
and criticalAlert channels. paused: true keeps it from checking.
name defaults to a generated unique name. dashboardId, chartId and
explorationId are create-only: changing one replaces the alert.
Removing value, stringValue, checkPeriod, incidentName,
incidentCause or metadata from the config clears it.
Alerting on a chart
Section titled “Alerting on a chart”An incident when errors pass 100 in 5 minutes
const Chart = BetterStack.Telemetry.Chart;const app = yield* BetterStack.Telemetry.Source("app-logs", { platform: "http" });const dashboard = yield* BetterStack.Telemetry.Dashboard("app", { name: "Production app" });const errors = yield* BetterStack.Telemetry.DashboardChart("errors", { dashboardId: dashboard.id, ...Chart.line({ name: "Errors", sql: Chart.timeSeries({ where: `${Chart.json("level")} = 'error'` }), }),});yield* BetterStack.Telemetry.Alert("error-spike", { name: "Error spike", dashboardId: dashboard.id, chartId: errors.id, alertType: "threshold", operator: "higher_than", value: 100, sourceVariable: Output.interpolate`source:${app.tableName}`, aggregationInterval: 300, checkPeriod: 60, confirmationPeriod: 300, recoveryPeriod: 300, email: true,});Alerting on an exploration
Section titled “Alerting on an exploration”A paused alert, ready to turn on
const rate = yield* BetterStack.Telemetry.Exploration("error-rate", { ...Chart.exploration(Chart.line({ sql: Chart.timeSeries() })),});yield* BetterStack.Telemetry.Alert("rate", { explorationId: rate.id, alertType: "threshold", operator: "higher_than", value: 1000, checkPeriod: 60, paused: true,});alertType "threshold" | "relative" | "anomaly_rrcf" | string required
Alert type. An update can change it.
additionalConditions CreateAlertRequestAdditionalConditionsItem[]
Up to 4 more conditions on top of the alert's own. A series fires only when it breaches the alert's own condition and every other condition that covers it, in the same time bucket. A condition limited to other series counts as met when any of its own series breaches it. Anomaly detection can't be an additional condition. An empty list removes them all.
aggregationInterval number | null
The size of the buckets the data is aggregated into before each bucket is evaluated, in seconds. Defaults to query_period, then check_period, then 60.
anomalySensitivity number
How far a value must deviate from its prediction to trigger the alert, for anomaly_rrcf alerts only. Shown as Significance in the web app. A higher value needs a larger deviation, so the alert fires less often. Left out for threshold and relative alerts.
anomalyTrainingRangeDays number
Days of history the anomaly model is first trained on, from 1 to 30. For anomaly_rrcf alerts only. Left out of the response on threshold and relative alerts.
anomalyTrigger "any" | "higher" | "lower" | string
Which direction of anomaly fires the alert, for anomaly_rrcf alerts only. Left out of the response on threshold and relative alerts.
call boolean
Trigger phone-call alerts. Left out of responses when the alert routes to an escalation policy. Sending true is refused on a plan without phone call alerts, unless the alert already has them on.
chartId string | null
Chart this alert watches, on the dashboard in dashboard_id. null for an alert on an exploration. Can't be changed after the alert is created.
checkPeriod number | null
How often the alert is checked, in seconds. Not returned for anomaly_rrcf alerts. An update that sends check_period without query_period or aggregation_interval sets both of them to the same value. Required when creating a threshold or relative alert.
confirmationPeriod number
How long the condition must hold before an incident starts, in seconds, from 0 to 86400. 0 starts it at once.
criticalAlert boolean
Trigger critical push alerts that bypass silent mode. Left out of responses when the alert routes to an escalation policy. Sending true is refused on a plan without critical alerts, unless the alert already has them on.
dashboardId string | null
Dashboard of the chart this alert watches. null for an alert on an exploration. Set it with chart_id for an alert on a dashboard chart, or set exploration_id instead. Can't be changed after the alert is created.
email boolean
Trigger e-mail alerts. Left out of responses when the alert routes to an escalation policy.
escalationTarget "current_team" | "unknown" | CreateAlertRequestEscalationTargetCase0
Where the incident is routed. Can be the string current_team, which is the default, an object with policy_id and policy_name, or an object with team_id and team_name. The string unknown means the target can't be found or no longer exists. Name a policy by ID, by name or both, and a team by team_id. An empty object routes to the current team too. A request is refused when it names both a policy and a team, names one that doesn't exist, or gives a policy name several policies share without an ID.
explorationId string | null
Exploration this alert watches. null for an alert on a dashboard chart. Set it instead of dashboard_id and chart_id for an alert on an exploration. Can't be changed after the alert is created.
incidentCause string | null
A custom description for the incidents the alert starts, in Markdown, or null when none is set. Accepts the same template variables as incident_name, such as {{current_value}} and {{threshold_value}}.
incidentName string | null
A custom name for the incidents the alert starts, in plain text, or null when none is set. Accepts template variables such as {{alert_name}}, {{series_name}}, {{current_value}}, {{threshold_value}}, {{team_name}}, the chart's variables and the columns its query returns.
incidentPerSeries boolean
Whether each series that breaches the condition starts its own incident, rather than one incident for the whole alert.
metadata CreateAlertRequestMetadataMap | null
Custom incident metadata, where each key you choose holds a list of strings. A single string is accepted too and saved as a one-item list. The metadata is added to the alert's incidents. An update replaces all the metadata. An empty object clears the metadata, which then reads back as null.
name string
Alert name. Defaults to a unique name generated from the stack, stage and logical id.
onMissingData "treat_as_zero" | "dont_fire" | "treat_as_previous" | "start_incident" | string
What a check does when the query returns no data. Can't be sent for anomaly_rrcf alerts, and is left out of their responses.
operator "equal" | "not_equal" | "higher_than" | "higher_than_or_equal" | "lower_than" | "lower_than_or_equal" | "increases_by" | "decreases_by" | "changes_by" | string
How the value is compared. Required for threshold and relative alerts. anomaly_rrcf alerts don't use it, and it's left out of their responses.
paused boolean
Whether the alert is paused. Send it as a JSON boolean, because the string "true" is ignored.
push boolean
Trigger mobile push alerts. Left out of responses when the alert routes to an escalation policy. Sending true is refused on a plan without push notifications, unless the alert already has them on.
queryPeriod number | null
The time window of data each check looks at, in seconds. Defaults to aggregation_interval, then check_period, then 60.
recoveryPeriod number | null
Seconds the value must stay recovered before the incident resolves on its own, or null to never resolve it automatically.
seriesNames string[]
The series the alert is limited to. An empty list means every series. Can't be combined with series_names_except. Setting either one replaces both.
seriesNamesExcept string[]
The series the alert ignores while it watches every other series. Can't be combined with series_names, so it's empty when series_names is used. Setting either one replaces both.
shownInterval number | null
Interval in seconds the anomaly chart shows, for anomaly_rrcf alerts only. One of 30, 60, 120, 300, 600, 1800, 3600, 7200, 10800, 21600, 43200 or 86400. Left out of the response on threshold and relative alerts. Defaults to 10800 when an anomaly alert is created.
sms boolean
Trigger SMS alerts. Left out of responses when the alert routes to an escalation policy. Sending true is refused on a plan without SMS alerts, unless the alert already has them on.
sourceMode "source_variable" | "platforms_single_source" | "platforms_all_sources" | string
How the alert picks its sources.
sourcePlatforms string[]
Platforms that limit the sources and services the alert runs on, for the platforms_single_source and platforms_all_sources source modes.
sourceVariable string | null
The sources the alert runs on, as source: followed by comma-separated source table names, or null when none is set. With the source_variable and platforms_single_source modes, the value must start with source:.
stringValue string | null
The exact text a threshold alert compares, instead of value, with equal or not_equal only. When it's set, value isn't needed and is null. Returned for threshold alerts only.
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.
value number | null
The threshold for threshold alerts, or the percentage change for relative alerts. 0 is a valid value. null when the alert compares string_value. Creating a threshold or relative alert needs value or string_value. Left out for anomaly_rrcf alerts.
variableValues CreateAlertRequestVariableValuesItem[]
Values this alert sets for the template variables of its dashboard or exploration. Each name must be a variable defined there. Source variables aren't accepted, so use source_mode and source_variable instead.
Attributes
Section titled “Attributes”id string always set
The alert's id.
additionalConditions AlertAdditionalConditionsItem[]
Up to 4 more conditions on top of the alert's own. A series fires only when it breaches the alert's own condition and every other condition that covers it, in the same time bucket. A condition limited to other series counts as met when any of its own series breaches it. Anomaly detection can't be an additional condition. An empty list removes them all.
aggregationInterval number | null
The size of the buckets the data is aggregated into before each bucket is evaluated, in seconds.
alertType "threshold" | "relative" | "anomaly_rrcf"
Alert type. An update can change it.
anomalySensitivity number
How far a value must deviate from its prediction to trigger the alert, for anomaly_rrcf alerts only. Shown as Significance in the web app. A higher value needs a larger deviation, so the alert fires less often. Left out for threshold and relative alerts.
anomalyTrainingRangeDays number
Days of history the anomaly model is first trained on, from 1 to 30. For anomaly_rrcf alerts only. Left out of the response on threshold and relative alerts.
anomalyTrigger "any" | "higher" | "lower"
Which direction of anomaly fires the alert, for anomaly_rrcf alerts only. Left out of the response on threshold and relative alerts.
call boolean
Trigger phone-call alerts. Left out of responses when the alert routes to an escalation policy. Sending true is refused on a plan without phone call alerts, unless the alert already has them on.
chartId string | null
Chart this alert watches, on the dashboard in dashboard_id. null for an alert on an exploration.
checkPeriod number | null
How often the alert is checked, in seconds. Not returned for anomaly_rrcf alerts. An update that sends check_period without query_period or aggregation_interval sets both of them to the same value.
confirmationPeriod number
How long the condition must hold before an incident starts, in seconds, from 0 to 86400. 0 starts it at once.
createdAt string
When the alert was created.
criticalAlert boolean
Trigger critical push alerts that bypass silent mode. Left out of responses when the alert routes to an escalation policy. Sending true is refused on a plan without critical alerts, unless the alert already has them on.
dashboardId string | null
Dashboard of the chart this alert watches. null for an alert on an exploration.
email boolean
Trigger e-mail alerts. Left out of responses when the alert routes to an escalation policy.
escalationTarget "current_team" | "unknown" | AlertEscalationTargetCase0
Where the incident is routed. Can be the string current_team, which is the default, an object with policy_id and policy_name, or an object with team_id and team_name. The string unknown means the target can't be found or no longer exists. Name a policy by ID, by name or both, and a team by team_id. An empty object routes to the current team too. A request is refused when it names both a policy and a team, names one that doesn't exist, or gives a policy name several policies share without an ID.
explorationId string | null
Exploration this alert watches. null for an alert on a dashboard chart.
incidentCause string | null
A custom description for the incidents the alert starts, in Markdown, or null when none is set. Accepts the same template variables as incident_name, such as {{current_value}} and {{threshold_value}}.
incidentName string | null
A custom name for the incidents the alert starts, in plain text, or null when none is set. Accepts template variables such as {{alert_name}}, {{series_name}}, {{current_value}}, {{threshold_value}}, {{team_name}}, the chart's variables and the columns its query returns.
incidentPerSeries boolean
Whether each series that breaches the condition starts its own incident, rather than one incident for the whole alert.
metadata AlertMetadataMap | null
Custom incident metadata, where each key you choose holds a list of strings. A single string is accepted too and saved as a one-item list. The metadata is added to the alert's incidents. An update replaces all the metadata.
name string
Alert name. Until you rename the alert, its name follows the chart's name.
onMissingData "treat_as_zero" | "dont_fire" | "treat_as_previous" | "start_incident"
What a check does when the query returns no data. Can't be sent for anomaly_rrcf alerts, and is left out of their responses.
operator "equal" | "not_equal" | "higher_than" | "higher_than_or_equal" | "lower_than" | "lower_than_or_equal" | "increases_by" | "decreases_by" | "changes_by"
How the value is compared. Required for threshold and relative alerts. anomaly_rrcf alerts don't use it, and it's left out of their responses.
paused boolean
Whether the alert is paused.
pausedReason string | null
Why the alert is paused. Manually paused for an alert paused by hand, or a sentence that says why Better Stack paused it. null when the alert isn't paused.
push boolean
Trigger mobile push alerts. Left out of responses when the alert routes to an escalation policy. Sending true is refused on a plan without push notifications, unless the alert already has them on.
queryPeriod number | null
The time window of data each check looks at, in seconds.
recoveryPeriod number | null
Seconds the value must stay recovered before the incident resolves on its own, or null to never resolve it automatically.
seriesNames string[]
The series the alert is limited to. An empty list means every series. Can't be combined with series_names_except.
seriesNamesExcept string[]
The series the alert ignores while it watches every other series. Can't be combined with series_names, so it's empty when series_names is used.
shownInterval number | null
Interval in seconds the anomaly chart shows, for anomaly_rrcf alerts only. One of 30, 60, 120, 300, 600, 1800, 3600, 7200, 10800, 21600, 43200 or 86400. Left out of the response on threshold and relative alerts.
sms boolean
Trigger SMS alerts. Left out of responses when the alert routes to an escalation policy. Sending true is refused on a plan without SMS alerts, unless the alert already has them on.
sourceMode "source_variable" | "platforms_single_source" | "platforms_all_sources"
How the alert picks its sources.
sourcePlatforms string[]
Platforms that limit the sources and services the alert runs on, for the platforms_single_source and platforms_all_sources source modes.
sourceVariable string | null
The sources the alert runs on, as source: followed by comma-separated source table names, or null when none is set. With the source_variable and platforms_single_source modes, the value must start with source:.
stringValue string | null
The exact text a threshold alert compares, instead of value, with equal or not_equal only. When it's set, value isn't needed and is null. Returned for threshold alerts only.
teamId string
Team that owns the alert's dashboard or exploration, such as t123.
updatedAt string
When the alert was last updated.
value number | null
The threshold for threshold alerts, or the percentage change for relative alerts. 0 is a valid value. null when the alert compares string_value. Creating a threshold or relative alert needs value or string_value. Left out for anomaly_rrcf alerts.
variableValues AlertVariableValuesItem[]
Values this alert sets for the template variables of its dashboard or exploration. Each name must be a variable defined there. Source variables aren't accepted, so use source_mode and source_variable instead.
Lookup
Section titled “Lookup”Alert.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.