SDK — Alerts
The rivano.alerts resource lets you manage notification channels and query the history of alerts fired by budget thresholds, SLA violations, and governance events.
Alert channels
Channels define where alert notifications are sent. Rivano supports Slack, email, and generic webhooks.
List channels
import Rivano from '@rivano/sdk';
const rivano = new Rivano({ apiKey: 'rv_...' });
const { data } = await rivano.alerts.channels.list();
for (const channel of data) {
console.log(`${channel.id} [${channel.type}] ${channel.name}`);
} Create a channel
import Rivano from '@rivano/sdk';
const rivano = new Rivano({ apiKey: 'rv_...' });
// Slack channel
const slackChannel = await rivano.alerts.channels.create({
name: 'ops-alerts',
type: 'slack',
config: {
webhookUrl: 'https://hooks.slack.com/services/T.../B.../...',
},
});
// Email channel
const emailChannel = await rivano.alerts.channels.create({
name: 'on-call-email',
type: 'email',
config: {
address: 'oncall@example.com',
},
});
// Webhook channel
const webhookChannel = await rivano.alerts.channels.create({
name: 'pagerduty-webhook',
type: 'webhook',
config: {
url: 'https://events.pagerduty.com/v2/enqueue',
headers: { 'X-PagerDuty-Token': 'pd_...' },
},
});
console.log('Channels created:', slackChannel.id, emailChannel.id, webhookChannel.id); Channel types and config
| Type | Config fields | Description |
|---|---|---|
slack | webhookUrl: string | Slack incoming webhook URL |
email | address: string | Email address to notify |
webhook | url: string, headers?: Record<string, string> | Generic HTTP POST webhook |
Update a channel
import Rivano from '@rivano/sdk';
const rivano = new Rivano({ apiKey: 'rv_...' });
await rivano.alerts.channels.update('channel_abc123', {
name: 'updated-channel-name',
config: { webhookUrl: 'https://hooks.slack.com/services/new/...' },
});
Delete a channel
await rivano.alerts.channels.delete('channel_abc123');
⚠
Deleting a channel does not disable the budgets or SLA policies that reference it — those continue to fire, but without a destination. Update or reassign alert channels before deleting them.
Alert history
Returns a log of all alerts that have fired, with their trigger reason and resolution status:
import Rivano from '@rivano/sdk';
const rivano = new Rivano({ apiKey: 'rv_...' });
const { data, total } = await rivano.alerts.history();
for (const alert of data) {
console.log(`${alert.firedAt} [${alert.triggerType}] ${alert.message}`);
console.log(` Channel: ${alert.channelId}, Resolved: ${alert.resolved}`);
} Error handling
| Error | When it occurs |
|---|---|
SdkAuthError | Invalid API key |
SdkNotFoundError | Channel ID does not exist |
SdkError | Invalid channel type or missing config field |
Related
- SDK Costs — Budget thresholds that trigger alerts
- SDK Governance — Governance events that trigger alerts