# MinIO Bucket Notification Guide [![Slack](https://slack.min.io/slack?type=svg)](https://slack.min.io)
Events occurring on objects in a bucket can be monitored using bucket event notifications.
> NOTE: Gateway mode does not support bucket notifications (except NAS gateway).
Various event types supported by MinIO server are
| Supported Object Event Types | | |
| :---------------------- | ------------------------------------------ | ------------------------------------- |
| `s3:ObjectCreated:Put` | `s3:ObjectCreated:CompleteMultipartUpload` | `s3:ObjectAccessed:Head` |
| `s3:ObjectCreated:Post` | `s3:ObjectRemoved:Delete` | `s3:ObjectRemoved:DeleteMarkerCreated` |
| `s3:ObjectCreated:Copy` | `s3:ObjectAccessed:Get` | |
| `s3:ObjectCreated:PutRetention` | `s3:ObjectCreated:PutLegalHold` | |
| `s3:ObjectAccessed:GetRetention` | `s3:ObjectAccessed:GetLegalHold` | |
| Supported Replication Event Types |
| :------------ |
| `s3:Replication:OperationFailedReplication` |
| `s3:Replication:OperationCompletedReplication` |
| `s3:Replication:OperationNotTracked` |
| `s3:Replication:OperationMissedThreshold` |
| `s3:Replication:OperationReplicatedAfterThreshold` |
| Supported ILM Transition Event Types |
| :----- |
| `s3:ObjectRestore:Post` |
| `s3:ObjectRestore:Completed` |
| Supported Global Event Types (Only supported through ListenNotification API) |
| :----- |
| `s3:BucketCreated` |
| `s3:BucketRemoved` |
Use client tools like `mc` to set and listen for event notifications using the [`event` sub-command](https://docs.min.io/docs/minio-client-complete-guide#events). MinIO SDK's [`BucketNotification` APIs](https://docs.min.io/docs/golang-client-api-reference#SetBucketNotification) can also be used. The notification message MinIO sends to publish an event is a JSON message with the following [structure](https://docs.aws.amazon.com/AmazonS3/latest/dev/notification-content-structure.html).
Bucket events can be published to the following targets:
| Supported Notification Targets | | |
| :-------------------------------- | --------------------------- | ------------------------------- |
| [`AMQP`](#AMQP) | [`Redis`](#Redis) | [`MySQL`](#MySQL) |
| [`MQTT`](#MQTT) | [`NATS`](#NATS) | [`Apache Kafka`](#apache-kafka) |
| [`Elasticsearch`](#Elasticsearch) | [`PostgreSQL`](#PostgreSQL) | [`Webhooks`](#webhooks) |
| [`NSQ`](#NSQ) | | |
## Prerequisites
- Install and configure MinIO Server from [here](https://docs.min.io/docs/minio-quickstart-guide).
- Install and configure MinIO Client from [here](https://docs.min.io/docs/minio-client-quickstart-guide).
```
$ mc admin config get myminio | grep notify
notify_webhook publish bucket notifications to webhook endpoints
notify_amqp publish bucket notifications to AMQP endpoints
notify_kafka publish bucket notifications to Kafka endpoints
notify_mqtt publish bucket notifications to MQTT endpoints
notify_nats publish bucket notifications to NATS endpoints
notify_nsq publish bucket notifications to NSQ endpoints
notify_mysql publish bucket notifications to MySQL databases
notify_postgres publish bucket notifications to Postgres databases
notify_elasticsearch publish bucket notifications to Elasticsearch endpoints
notify_redis publish bucket notifications to Redis datastores
```
> NOTE:
> - '\*' at the end of arg means its mandatory.
> - '\*' at the end of the values, means its the default value for the arg.
> - When configured using environment variables, the `:name` can be specified using this format `MINIO_NOTIFY_WEBHOOK_ENABLE_<name>`.
<a name="AMQP"></a>
## Publish MinIO events via AMQP
Install RabbitMQ from [here](https://www.rabbitmq.com/).
### Step 1: Add AMQP endpoint to MinIO
The AMQP configuration is located under the sub-system `notify_amqp` top-level key. Create a configuration key-value pair here for your AMQP instance. The key is a name for your AMQP endpoint, and the value is a collection of key-value parameters described in the table below.
```
KEY:
notify_amqp[:name] publish bucket notifications to AMQP endpoints
ARGS:
url* (url) AMQP server endpoint e.g. `amqp://myuser:mypassword@localhost:5672`
exchange (string) name of the AMQP exchange
exchange_type (string) AMQP exchange type
routing_key (string) routing key for publishing
mandatory (on|off) quietly ignore undelivered messages when set to 'off', default is 'on'
durable (on|off) persist queue across broker restarts when set to 'on', default is 'off'
no_wait (on|off) non-blocking message delivery when set to 'on', default is 'off'
internal (on|off) set to 'on' for exchange to be not used directly by publishers, but only when bound to other exchanges
auto_deleted (on|off) auto delete queue when set to 'on', when there are no consumers
delivery_mode (number) set to '1' for non-persistent or '2' for persistent queue
queue_dir (path) staging dir for undelivered messages e.g. '/home/events'
queue_limit (number) maximum limit for undelivered messages, defaults to '100000'
comment (sentence) optionally add a comment to this setting
```
Or environment variables
```
KEY:
notify_amqp[:name] publish bucket notifications to AMQP endpoints
ARGS:
MINIO_NOTIFY_AMQP_ENABLE* (on|off) enable notify_amqp target, default is 'off'
MINIO_NOTIFY_AMQP_URL* (url) AMQP server endpoint e.g. `amqp://myuser:mypassword@localhost:5672`
MINIO_NOTIFY_AMQP_EXCHANGE (string) name of the AMQP exchange
MINIO_NOTIFY_AMQP_EXCHANGE_TYPE (string) AMQP exchange type
MINIO_NOTIFY_AMQP_ROUTING_KEY (string) routing key for publishing
MINIO_NOTIFY_AMQP_MANDATORY (on|off) quietly ignore undelivered messages when set to 'off', default is 'on'
MINIO_NOTIFY_AMQP_DURABLE (on|off) persist queue across broker restarts when set to 'on', default is 'off'
MINIO_NOTIFY_AMQP_NO_WAIT (on|off) non-blocking message delivery when set to 'on', default is 'off'
MINIO_NOTIFY_AMQP_INTERNAL (on|off) set to 'on' for exchange to be not used directly by publishers, but only when bound to other exchanges
MINIO_NOTIFY_AMQP_AUTO_DELETED (on|off) auto delete queue when set to 'on', when there are no consumers
MINIO_NOTIFY_AMQP_DELIVERY_MODE (number) set to '1' for non-persistent or '2' for persistent queue
MINIO_NOTIFY_AMQP_QUEUE_DIR (path) staging dir for undelivered messages e.g. '/home/events'
MINIO_NOTIFY_AMQP_QUEUE_LIMIT (number) maximum limit for undelivered messages, defaults to '100000'
MINIO_NOTIFY_AMQP_COMMENT (sentence) optionally add a comment to this setting
```
MinIO supports persistent event store. The persistent store will backup events when the AMQP broker goes offline and replays it when the broker comes back online. The event store can be configured by setting the directory path in `queue_dir` field and the maximum limit of events in the queue_dir in `queue_limit` field. For eg, the `queue_dir` can be `/home/events` and `queue_limit` can be `100