[**Documentation**](../../../README)

***

[Documentation](../../../README) / [@zerotal/monitor](../README) / onAlert

# Function: onAlert()

> **onAlert**(`fn`): () => `void`

Defined in: [monitor/src/alerting.ts:156](https://github.com/zerotaldev/zerotal/blob/1d6fb26b05b18ba077de1bfaeb46c42131cd8b70/packages/monitor/src/alerting.ts#L156)

Register a handler called once whenever a monitor alert fires. Returns an
unsubscribe function. Wire it to notifications:

  onAlert((a) => Notification.route("slack", SLACK_URL).notify(new MonitorAlert(a)));

## Parameters

### fn

`AlertHandler`

## Returns

() => `void`
