# subscribe

Subscribes to events from a channel with a topic.

```tql
subscribe [topic:string...]
```

## Description

The `subscribe` operator subscribes to events from a channel with the specified topic. Multiple `subscribe` operators with the same topic receive the same events.

Subscribers propagate back pressure to publishers. If a subscribing pipeline fails to keep up, all publishers will slow down as well to a matching speed to avoid data loss. This mechanism is disabled for pipelines that are not visible on the overview page on [app.tenzir.com](https://app.tenzir.com), which drop data rather than slow down their publishers.

During shutdown, `subscribe` will wait for `publish` to drain all data before shutting down itself. This prevents data loss, as long as pub/sub do not form cycles and `publish` does not use dynamic topic names.

### `topic: string... (optional)`

Optional channel names to subscribe to. If unspecified, the operator subscribes to the topic `main`.

## Examples

### Subscribe to the events under a topic

```tql
subscribe "zeek-conn"
```

### Subscribe to the multiple topics

```tql
subscribe "alerts", "notices", "critical"
```

## See Also

* [`export`](https://preview.docs.tenzir.com/375/375/reference/operators/export.md)
* [`publish`](https://preview.docs.tenzir.com/375/375/reference/operators/publish.md)
* [Quickstart](https://preview.docs.tenzir.com/375/375/guides/quickstart.md)
* [Split and merge streams](https://preview.docs.tenzir.com/375/375/guides/routing/split-and-merge-streams.md)
* [Learn idiomatic TQL](https://preview.docs.tenzir.com/375/375/tutorials/learn-idiomatic-tql.md)