Skip to content

# `nautobot.apps.events`

APIs for Nautobot event-notification subsystem.

## `nautobot.apps.events.EventBroker`

Bases: `ABC`

Abstract base class for concrete implementations of event brokers such as syslog, Redis, Kafka, etc.

### `publish(*, topic, payload)` `abstractmethod`

Possibly publish the given data `payload` to the given event `topic`.

Parameters:

Name | Type | Description | Default
--- | --- | --- | ---
`topic` | `str` | Topic identifier. Convention is to use snake_case and use periods to delineate related groups of topics, similar to Python logger naming. For example, you might receive topics such as `create.dcim.device`, `update.dcim.device`, `delete.dcim.device`, `create.dcim.interface`, `create.ipam.ipaddress`, etc. | required
`payload` | `dict` | JSON-serializable structured data to publish. While not all EventBrokers may actually use JSON as their data format, it makes for a reasonable lowest common denominator for serializability. | required

## `nautobot.apps.events.RedisEventBroker`

Bases: `EventBroker`

EventBroker for publishing events to Redis.

### `__init__(*args, url, **kwargs)`

Initialize and configure a RedisEventBroker.

Parameters:

Name | Type | Description | Default
--- | --- | --- | ---
`url` | `str` | The Redis URL to connect to. | required

## `nautobot.apps.events.SyslogEventBroker`

Bases: `EventBroker`

### `__init__(*args, level=logging.INFO, **kwargs)`

Initialize a SyslogEventBroker that emits logs at the given level.

## `nautobot.apps.events.deregister_event_broker(event_broker)`

Deregister a previously registered `EventBroker` instance so that it no longer receives published events.

## `nautobot.apps.events.publish_event(*, topic, payload)`

Publish the given event payload to the given topic via all registered `EventBroker` instances.

Parameters:

Name | Type | Description | Default
--- | --- | --- | ---
`topic` | `str` | Topic identifier. Convention is to use snake_case and use periods to delineate related groups of topics, similar to Python logger naming. For example, you might use `nautobot.create.dcim.device`, `nautobot.update.dcim.device`, `nautobot.delete.dcim.device`, `nautobot.create.dcim.interface`, `nautobot.create.ipam.ipaddress`, etc. | required
`payload` | `dict` | JSON-serializable structured data to publish. While not all EventBrokers may actually use JSON as their data format, it makes for a reasonable lowest common denominator for serializability. | required

## `nautobot.apps.events.register_event_broker(event_broker)`

Register an `EventBroker` instance for use by Nautobot.

The `publish_event()` API will publish events to each registered broker. The expectation/intent here, at least initially, is that a given deployment will instantiate zero or more EventBrokers, then call `register_event_broker()` for each one, as part of Nautobot initial startup.

Parameters:

Name | Type | Description | Default
--- | --- | --- | ---
`event_broker` | `EventBroker` | The initialized/configured EventBroker instance to register. | required