//native
/**
* Create alert rule
* Create a new alert rule with PromQL expression
*/
export async function main(auth: RT.Qovery, body: AlertRuleCreationRequest) {
const url = new URL(`https://api.qovery.com/api/alert-rules`)
const response = await fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: 'Token ' + auth.apiKey
},
body: JSON.stringify(body)
})
if (!response.ok) {
const text = await response.text()
throw new Error(`${response.status} ${text}`)
}
return await response.json()
}
/* eslint-disable */
/**
* This file was automatically generated by json-schema-to-typescript.
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
* and run json-schema-to-typescript to regenerate this file.
*/
/**
* Alert severity level:
* - WARNING: Non-critical issue requiring attention
* - CRITICAL: Critical issue requiring immediate action
*/
export type AlertSeverity = 'WARNING' | 'CRITICAL'
export interface AlertRuleCreationRequest {
/**
* Organization identifier
*/
organization_id: string
/**
* Cluster identifier where the rule will be deployed
*/
cluster_id: string
/**
* Name of the alert rule
*/
name: string
/**
* Description of what the alert monitors
*
*/
description: string
/**
* PromQL expression to evaluate
*/
promql_expr: string
/**
* Duration the condition must be true before firing (ISO-8601 duration format)
*/
for_duration: string
severity: AlertSeverity
/**
* Whether the alert rule is enabled
*/
enabled: boolean
/**
* List of alert receiver IDs to send notifications to
*
* @minItems 1
*/
alert_receiver_ids: string[]
presentation: AlertPresentation
[k: string]: unknown
}
export interface AlertPresentation {
summary?: string
/**
* URL to runbook with remediation steps
*/
runbook_url?: string
[k: string]: unknown
}
Submitted by hugo697 235 days ago