Integrations
Better Stack incidents don’t only come from its own monitors and heartbeats.
An incoming integration gives another tool somewhere to send its alerts, a
secret webhook URL or an e-mail address, and turns them into incidents. An
outgoing integration sends Better Stack’s incidents somewhere else. Each is
a resource; every prop updates in place except teamId, which replaces the
integration and, for an incoming one, gives it a new URL.
Most integrations need a paid plan: their live tests are gated, and the take-over and e-mail ones are tested against the offline mock only. See Compatibility.
Incoming: alerts from other tools
Section titled “Incoming: alerts from other tools”Each of these gives you a secret URL (Redacted) to paste into the other tool:
| Resource | Gives you | Where it goes |
|---|---|---|
GrafanaIntegration |
webhookUrl |
a Grafana Webhook contact point |
PrometheusIntegration |
webhookUrl |
an Alertmanager receiver’s webhook_configs |
DatadogIntegration |
webhookUrl |
a webhook in Datadog’s Webhooks integration |
NewRelicIntegration |
webhookUrl |
a New Relic Webhook destination |
ElasticIntegration |
webhookUrl |
a Kibana Webhook connector |
AzureIntegration |
webhookUrl |
a Webhook action in an Azure Monitor action group |
GoogleMonitoringIntegration |
webhookUrl |
a Google Cloud Monitoring Webhooks notification channel |
AwsCloudWatchIntegration |
webhookUrl |
an HTTPS subscription on the SNS topic your alarms notify |
AmazonSnsIntegration |
url |
an HTTPS subscription on an SNS topic, with rules over the message |
IncomingWebhookIntegration |
url |
any tool that can send an HTTP request, with your own rules |
IncomingEmailIntegration |
emailAddress |
any tool that sends alert e-mails |
Create one with the policy that should handle its incidents:
const grafana = yield* BetterStack.Incidents.GrafanaIntegration("grafana", { name: "Grafana alerts", escalationPolicyId: policy.id,});Without an escalation policy, the integration’s own call, sms, email,
push and criticalAlert settings decide how the current on-call person is
alerted.
Hand over the URL
Section titled “Hand over the URL”The URL is a secret. Export it from the stack and paste it into the other tool, or pass it to whatever provisions that tool:
return { grafanaWebhookUrl: grafana.webhookUrl };Open incidents on warnings too
Section titled “Open incidents on warnings too”Datadog and New Relic integrations take alertingRule: only alerts, or alerts
and warnings:
yield* BetterStack.Incidents.DatadogIntegration("datadog", { name: "Datadog alerts", escalationPolicyId: policy.id, alertingRule: "alert_and_warn",});Every incoming integration also takes paused: true, to stop opening incidents
during maintenance.
Outgoing: incidents to other tools
Section titled “Outgoing: incidents to other tools”| Resource | Sends incidents to |
|---|---|
OutgoingPagerDutyIntegration |
a PagerDuty service, through its Events API V2 routing key |
SplunkOnCallIntegration |
Splunk On-Call’s REST endpoint url |
OutgoingWebhookIntegration |
your own url, on incident, on-call or monitor changes |
OutgoingEmailIntegration |
addresses outside Better Stack, with templates per stage |
PagerDuty gets incidents with the severity you choose. With
notifyAlongsidePrimaryResponder, incidents without an escalation policy reach
it too; with a policy, only a step that notifies the integration does:
yield* BetterStack.Incidents.OutgoingPagerDutyIntegration("pagerduty", { name: "PagerDuty (payments)", key: yield* Config.Redacted("PAGERDUTY_ROUTING_KEY"), severity: "critical", notifyAlongsidePrimaryResponder: true,});An outgoing webhook sends the incident as JSON, or your own body through
customWebhookTemplateAttributes. triggerType replaces the integration:
yield* BetterStack.Incidents.OutgoingWebhookIntegration("ops-hook", { name: "Incidents to ops tooling", url: "https://ops.example.com/hooks/better-stack", triggerType: "incident_change", onIncidentStarted: true, onIncidentResolved: true, onIncidentAcknowledged: false, onIncidentReopened: false, onIncidentComment: false,});Jira and Linear: connect first, then configure
Section titled “Jira and Linear: connect first, then configure”A Jira or Linear integration is connected with OAuth in the Better Stack web
app, so the API can’t create or delete one. Connect it once, then name it by
integrationId: deploying configures it, and destroying only forgets it.
yield* BetterStack.Incidents.JiraIntegration("jira", { integrationId: "12345", automaticIssueCreation: true, jiraProjectKey: "OPS", jiraIssueTypeId: "10004",});Deploying fails when no integration has that id.
Open incidents from your own code
Section titled “Open incidents from your own code”Incidents.CreateIncident opens a manual incident from a running Service.
Incidents.AcknowledgeIncident and Incidents.ResolveIncident move it along.
They need an API token, which you pass explicitly; use a team-scoped Uptime API
token:
import * as BetterStack from "betterstack-alchemy";import * as Effect from "effect/Effect";import * as HttpServerResponse from "effect/http/HttpServerResponse";import { Box } from "./shared.ts";
const IncidentsToken = BetterStack.apiTokenFromConfig("BETTERSTACK_INCIDENTS_TOKEN");
export default class Api extends BetterStack.Cloud.Service<Api>()( "Api", { server: Box, main: import.meta.url, port: 3000 }, Effect.gen(function* () { const openIncident = yield* BetterStack.Incidents.CreateIncident(IncidentsToken); return { fetch: Effect.gen(function* () { const incident = yield* openIncident({ summary: "Payments are failing", requesterEmail: "oncall@example.com", email: true, }); return yield* HttpServerResponse.json({ id: incident.id }); }).pipe(Effect.orDie), }; }).pipe(Effect.provide(BetterStack.Incidents.CreateIncidentHttp)),) {}Opening an incident alerts the on-call team through the channels the request turns on. These bindings are tested against the offline mock only.
Where next
Section titled “Where next”- Escalation policies: what handles an integration’s incidents.
- Releases & integrations: error tracking’s own Slack, Jira, Linear and Teams integrations.
- Better Stack: Incoming webhooks, Outgoing webhooks.