Edits history of script submission #20165 for ' Delete a metric alert rule (sentry)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    /**
     * Delete a metric alert rule
     * Delete a specific 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.
     */
    export async function main(auth: RT.Sentry, alert_rule_id: string) {
    	const url = new URL(
    		`https://${auth.region}.sentry.io/api/0/organizations/${auth.organizationSlug}/alert-rules/${alert_rule_id}/`
    	)
    
    	const response = await fetch(url, {
    		method: 'DELETE',
    		headers: {
    			Authorization: 'Bearer ' + auth.token
    		},
    		body: undefined
    	})
    	if (!response.ok) {
    		const text = await response.text()
    		throw new Error(`${response.status} ${text}`)
    	}
    	return await response.text()
    }
    

    Submitted by hugo697 235 days ago