Alerts API
Create and manage alert rules, and view alert history.
createRule(rule): Promise<AlertRule>
Create a new alert rule
const rule = await client.alerts.createRule({
name: 'High Error Rate',
description: 'Alert when error rate exceeds threshold',
query_dsl: "level = 'error'",
threshold: 100,
comparison: 'gt',
window_minutes: 5,
cooldown_minutes: 15,
enabled: true,
notification_destinations: ['email', 'webhook'],
notification_config: {
email: 'admin@example.com',
webhook_url: 'https://example.com/webhook'
}
})listHistory(params?): Promise<AlertHistory[]>
List alert history with optional filters
const history = await client.alerts.listHistory({
rule_id: 'rule-id',
ts_from: '2025-01-15T00:00:00Z',
ts_to: '2025-01-15T23:59:59Z',
acknowledged: false,
limit: 100
})