Incidents.Metadata
A Better Stack metadata entry: a key with one or more values attached to a
monitor, heartbeat, incident or integration (ownerType + ownerId), such
as the team that owns it. Values are Strings or references to catalog
items (EscalationPolicy, OnCallSchedule, User, Team, …), and
escalation policies and catalog relations match incidents on them.
key, values, ownerType and ownerId update in place (changing the
owner moves the key to another object); teamId replaces the entry. mode
only says what create does when the owner already has the key (replace
or merge): the API never returns it, and changing it later does nothing.
A monitor’s or heartbeat’s own metadata prop writes the same keys: manage
a key in one place only.
Tagging a monitor
Section titled “Tagging a monitor”The team that owns a monitor
const site = yield* BetterStack.Incidents.Monitor("site", { url: "https://example.com", monitorType: "status",});yield* BetterStack.Incidents.Metadata("site-owner", { ownerType: "Monitor", ownerId: site.id, key: "Owner", values: [{ type: "String", value: "Platform team" }],});Pointing a heartbeat at its escalation policy
Section titled “Pointing a heartbeat at its escalation policy”A reference value
const policy = yield* BetterStack.Incidents.EscalationPolicy("payments", { name: "Payments on-call", steps: [{ type: "escalation", waitBefore: 0, stepMembers: [{ type: "current_on_call" }] }],});const job = yield* BetterStack.Incidents.Heartbeat("settlement", { name: "Settlement job", period: 3600, grace: 600,});yield* BetterStack.Incidents.Metadata("settlement-policy", { ownerType: "Heartbeat", ownerId: job.id, key: "Escalation policy", values: [{ type: "EscalationPolicy", itemId: policy.id }],});key string required
Metadata key. Renaming it keeps the entry's ID and values.
ownerId string required
ID of the object this metadata is attached to.
ownerType string required
Type of object this metadata is attached to, one of Monitor, Heartbeat, Incident, WebhookIntegration, EmailIntegration, IncomingWebhook, AmazonSnsIntegration or CallRouting. Create and update accept every type except CallRouting. Changing it together with owner_id moves the key to another object.
values CreateHeartbeatRequestMetadataValueItem[] required
Values attached to the key. Required on create. An update replaces all current values, and an empty list removes the key.
mode "replace" | "merge" | string
What create does when the object already has this key.
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.
Attributes
Section titled “Attributes”id string always set
The metadata's id.
key string
Metadata key. Renaming it keeps the entry's ID and values.
ownerId string
ID of the object this metadata is attached to.
ownerType string
Type of object this metadata is attached to, one of Monitor, Heartbeat, Incident, WebhookIntegration, EmailIntegration, IncomingWebhook, AmazonSnsIntegration or CallRouting. Create and update accept every type except CallRouting. Changing it together with owner_id moves the key to another object.
teamId string
Team that owns the object this metadata is attached to, such as t123.
teamName string
Name of the team that owns the object this metadata is attached to.
values CreateHeartbeatRequestMetadataValueItem[]
Values attached to the key.
Lookup
Section titled “Lookup”Metadata.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.