0

Retrieve a metric alert rule for an organization

by
Published Oct 17, 2025

Return details on an individual metric alert rule. A metric alert rule is a configuration that defines the conditions for triggering an alert. It specifies the metric type, function, time interval, and threshold values that determine when an alert should be triggered. Metric alert rules are used to monitor and notify you when certain metrics, like error count, latency, or failure rate, cross a predefined threshold. These rules help you proactively identify and address issues in your project.

Script sentry Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
/**
3
 * Retrieve a metric alert rule for an organization
4
 * Return details on an individual metric alert rule.
5

6
A metric alert rule is a configuration that defines the conditions for triggering an alert.
7
It specifies the metric type, function, time interval, and threshold
8
values that determine when an alert should be triggered. Metric alert rules are used to monitor
9
and notify you when certain metrics, like error count, latency, or failure rate, cross a
10
predefined threshold. These rules help you proactively identify and address issues in your
11
project.
12
 */
13
export async function main(auth: RT.Sentry, alert_rule_id: string) {
14
	const url = new URL(
15
		`https://${auth.region}.sentry.io/api/0/organizations/${auth.organizationSlug}/alert-rules/${alert_rule_id}/`
16
	)
17

18
	const response = await fetch(url, {
19
		method: 'GET',
20
		headers: {
21
			Authorization: 'Bearer ' + auth.token
22
		},
23
		body: undefined
24
	})
25
	if (!response.ok) {
26
		const text = await response.text()
27
		throw new Error(`${response.status} ${text}`)
28
	}
29
	return await response.json()
30
}
31