Minio Bucket Notification Guide

Events occurring on objects in a bucket can be monitored using bucket event notifications. Event types supported by Minio server are

Supported Event Types

s3:ObjectCreated:Put

s3:ObjectCreated:CompleteMultipartUpload

s3:ObjectAccessed:Head

s3:ObjectCreated:Post

s3:ObjectRemoved:Delete

s3:ObjectCreated:Copy

s3:ObjectAccessed:Get

Use client tools like mc to set and listen for event notifications using the event sub-command. Minio SDK's BucketNotification APIs can also be used. The notification message Minio sends to publish an event is a JSON message with the following structure.

Prerequisites

Publish Minio events via AMQP

Step 1: Add AMQP endpoint to Minio

The Minio server configuration file is stored on the backend in json format. The AMQP configuration is located in the amqp key under the notify 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.

To update the configuration, use mc admin config get command to get the current configuration file for the minio deployment in json format, and save it locally.

$ mc admin config get myminio/ > /tmp/myconfig

After updating the AMQP configuration in /tmp/myconfig , use mc admin config set command to update the configuration for the deployment.Restart the Minio server to put the changes into effect. The server will print a line like SQS ARNs: arn:minio:sqs::1:amqp at start-up if there were no errors.

$ mc admin config set myminio < /tmp/myconfig

Minio supports all the exchanges available in RabbitMQ. For this setup, we are using fanout exchange.

Note that, you can add as many AMQP server endpoint configurations as needed by providing an identifier (like "1" in the example above) for the AMQP instance and an object of per-server configuration parameters.

Step 2: Enable bucket notification using Minio client

We will enable bucket event notification to trigger whenever a JPEG image is uploaded or deleted images bucket on myminio server. Here ARN value is arn:minio:sqs::1:amqp. To understand more about ARN please follow AWS ARN documentation.

Publish Minio events MQTT

Step 1: Add MQTT endpoint to Minio

The Minio server configuration file is stored on the backend in json format. The MQTT configuration is located in the mqtt key under the notify top-level key. Create a configuration key-value pair here for your MQTT instance. The key is a name for your MQTT endpoint, and the value is a collection of key-value parameters described in the table below.

To update the configuration, use mc admin config get command to get the current configuration file for the minio deployment in json format, and save it locally.

$ mc admin config get myminio/ > /tmp/myconfig

After updating the MQTT configuration in /tmp/myconfig , use mc admin config set command to update the configuration for the deployment.Restart the Minio server to put the changes into effect. The server will print a line like SQS ARNs: arn:minio:sqs::1:mqtt at start-up if there were no errors.

$ mc admin config set myminio < /tmp/myconfig

Minio supports any MQTT server that supports MQTT 3.1 or 3.1.1 and can connect to them over TCP, TLS, or a Websocket connection using tcp://, tls://, or ws:// respectively as the scheme for the broker url. See the Go Client documentation for more information.

Note that, you can add as many MQTT server endpoint configurations as needed by providing an identifier (like "1" in the example above) for the MQTT instance and an object of per-server configuration parameters.

Step 2: Enable bucket notification using Minio client

We will enable bucket event notification to trigger whenever a JPEG image is uploaded or deleted images bucket on myminio server. Here ARN value is arn:minio:sqs::1:mqtt.

Publish Minio events via Elasticsearch

When the namespace format is used, Minio synchronizes objects in the bucket with documents in the index. For each event in the Minio, the server creates a document with the bucket and object name from the event as the document ID. Other details of the event are stored in the body of the document. Thus if an existing object is over-written in Minio, the corresponding document in the Elasticsearch index is updated. If an object is deleted, the corresponding document is deleted from the index.

When the access format is used, Minio appends events as documents in an Elasticsearch index. For each event, a document with the event details, with the timestamp of document set to the event's timestamp is appended to an index. The ID of the documented is randomly generated by Elasticsearch. No documents are deleted or modified in this format.

The steps below show how to use this notification target in namespace format. The other format is very similar and is omitted for brevity.

Step 1: Ensure minimum requirements are met

Minio requires a 5.x series version of Elasticsearch. This is the latest major release series. Elasticsearch provides version upgrade migration guidelines here.

Step 2: Add Elasticsearch endpoint to Minio

The Minio server configuration file is stored on the backend in json format. The Elasticsearch configuration is located in the elasticsearch key under the notify top-level key. Create a configuration key-value pair here for your Elasticsearch instance. The key is a name for your Elasticsearch endpoint, and the value is a collection of key-value parameters described in the table below.

If Elasticsearch has authentication enabled, the credentials can be supplied to Minio via the url parameter formatted as PROTO://USERNAME:PASSWORD@ELASTICSEARCH_HOST:PORT.

To update the configuration, use mc admin config get command to get the current configuration file for the minio deployment in json format, and save it locally.

$ mc admin config get myminio/ > /tmp/myconfig

After updating the Elasticsearch configuration in /tmp/myconfig , use mc admin config set command to update the configuration for the deployment.Restart the Minio server to put the changes into effect. The server will print a line like SQS ARNs: arn:minio:sqs::1:elasticsearch at start-up if there were no errors.

$ mc admin config set myminio < /tmp/myconfig

Note that, you can add as many Elasticsearch server endpoint configurations as needed by providing an identifier (like "1" in the example above) for the Elasticsearch instance and an object of per-server configuration parameters.

Step 3: Enable bucket notification using Minio client

We will now enable bucket event notifications on a bucket named images. Whenever a JPEG image is created/overwritten, a new document is added or an existing document is updated in the Elasticsearch index configured above. When an existing object is deleted, the corresponding document is deleted from the index. Thus, the rows in the Elasticsearch index, reflect the .jpg objects in the images bucket.

To configure this bucket notification, we need the ARN printed by Minio in the previous step. Additional information about ARN is available here.

With the mc tool, the configuration is very simple to add. Let us say that the Minio server is aliased as myminio in our mc configuration. Execute the following:

This output shows that a document has been created for the event in Elasticsearch.

Here we see that the document ID is the bucket and object name. In case access format was used, the document ID would be automatically generated by Elasticsearch.

Publish Minio events via Redis

Install Redis server. For illustrative purposes, we have set the database password as "yoursecret".

This notification target supports two formats: namespace and access.

When the namespace format is used, Minio synchronizes objects in the bucket with entries in a hash. For each entry, the key is formatted as "bucketName/objectName" for an object that exists in the bucket, and the value is the JSON-encoded event data about the operation that created/replaced the object in Minio. When objects are updated or deleted, the corresponding entry in the hash is also updated or deleted.

When the access format is used, Minio appends events to a list using RPUSH. Each item in the list is a JSON encoded list with two items, where the first item is a timestamp string, and the second item is a JSON object containing event data about the operation that happened in the bucket. No entries appended to the list are updated or deleted by Minio in this format.

The steps below show how to use this notification target in namespace and access format.

Step 1: Add Redis endpoint to Minio

The Minio server configuration file is stored on the backend in json format.The Redis configuration is located in the redis key under the notify top-level key. Create a configuration key-value pair here for your Redis instance. The key is a name for your Redis endpoint, and the value is a collection of key-value parameters described in the table below.

Parameter

Type

Description

enable

bool

(Required) Is this server endpoint configuration active/enabled?

format

string

(Required) Either namespace or access.

address

string

(Required) The Redis server's address. For example: localhost:6379.

password

string

(Optional) The Redis server's password.

key

string

(Required) The name of the redis key under which events are stored. A hash is used in case of namespace format and a list in case of access format.

To update the configuration, use mc admin config get command to get the current configuration file for the minio deployment in json format, and save it locally.

$ mc admin config get myminio/ > /tmp/myconfig

After updating the Redis configuration in /tmp/myconfig , use mc admin config set command to update the configuration for the deployment.Restart the Minio server to put the changes into effect. The server will print a line like SQS ARNs: arn:minio:sqs::1:redis at start-up if there were no errors.

$ mc admin config set myminio < /tmp/myconfig

Note that, you can add as many Redis server endpoint configurations as needed by providing an identifier (like "1" in the example above) for the Redis instance and an object of per-server configuration parameters.

Step 2: Enable bucket notification using Minio client

We will now enable bucket event notifications on a bucket named images. Whenever a JPEG image is created/overwritten, a new key is added or an existing key is updated in the Redis hash configured above. When an existing object is deleted, the corresponding key is deleted from the Redis hash. Thus, the rows in the Redis hash, reflect the .jpg objects in the images bucket.

To configure this bucket notification, we need the ARN printed by Minio in the previous step. Additional information about ARN is available here.

With the mc tool, the configuration is very simple to add. Let us say that the Minio server is aliased as myminio in our mc configuration. Execute the following:

In case, access format was used, then minio_events would be a list, and the Minio server would have performed an RPUSH to append to the list. A consumer of this list would ideally use BLPOP to remove list items from the left-end of the list.

To update the configuration, use mc admin config get command to get the current configuration file for the minio deployment in json format, and save it locally.

$ mc admin config get myminio/ > /tmp/myconfig

After updating the NATS configuration in /tmp/myconfig , use mc admin config set command to update the configuration for the deployment.Restart Minio server to reflect config changes. bucketevents is the subject used by NATS in this example.

Step 2: Enable bucket notification using Minio client

We will enable bucket event notification to trigger whenever a JPEG image is uploaded or deleted from images bucket on myminio server. Here ARN value is arn:minio:sqs::1:nats. To understand more about ARN please follow AWS ARN documentation.

Publish Minio events via PostgreSQL

Install PostgreSQL database server. For illustrative purposes, we have set the "postgres" user password as password and created a database called minio_events to store the events.

This notification target supports two formats: namespace and access.

When the namespace format is used, Minio synchronizes objects in the bucket with rows in the table. It creates rows with two columns: key and value. The key is the bucket and object name of an object that exists in Minio. The value is JSON encoded event data about the operation that created/replaced the object in Minio. When objects are updated or deleted, the corresponding row from this table is updated or deleted respectively.

When the access format is used, Minio appends events to a table. It creates rows with two columns: event_time and event_data. The event_time is the time at which the event occurred in the Minio server. The event_data is the JSON encoded event data about the operation on an object. No rows are deleted or modified in this format.

The steps below show how to use this notification target in namespace format. The other format is very similar and is omitted for brevity.

Step 1: Ensure minimum requirements are met

Minio requires PostgreSQL version 9.5 or above. Minio uses the INSERT ON CONFLICT (aka UPSERT) feature, introduced in version 9.5 and the JSONB data-type introduced in version 9.4.

Step 2: Add PostgreSQL endpoint to Minio

The Minio server configuration file is stored on the backend in json format. The PostgreSQL configuration is located in the postgresql key under the notify top-level key. Create a configuration key-value pair here for your PostgreSQL instance. The key is a name for your PostgreSQL endpoint, and the value is a collection of key-value parameters described in the table below.

Note that for illustration here, we have disabled SSL. In the interest of security, for production this is not recommended.
To update the configuration, use mc admin config get command to get the current configuration file for the minio deployment in json format, and save it locally.

$ mc admin config get myminio/ > /tmp/myconfig

After updating the Postgres configuration in /tmp/myconfig , use mc admin config set command to update the configuration for the deployment.Restart the Minio server to put the changes into effect. The server will print a line like SQS ARNs: arn:minio:sqs::1:postgresql at start-up if there were no errors.

$ mc admin config set myminio < /tmp/myconfig

Note that, you can add as many PostgreSQL server endpoint configurations as needed by providing an identifier (like "1" in the example above) for the PostgreSQL instance and an object of per-server configuration parameters.

Step 3: Enable bucket notification using Minio client

We will now enable bucket event notifications on a bucket named images. Whenever a JPEG image is created/overwritten, a new row is added or an existing row is updated in the PostgreSQL configured above. When an existing object is deleted, the corresponding row is deleted from the PostgreSQL table. Thus, the rows in the PostgreSQL table, reflect the .jpg objects in the images bucket.

To configure this bucket notification, we need the ARN printed by Minio in the previous step. Additional information about ARN is available here.

With the mc tool, the configuration is very simple to add. Let us say that the Minio server is aliased as myminio in our mc configuration. Execute the following:

Publish Minio events via MySQL

Install MySQL from here. For illustrative purposes, we have set the root password as password and created a database called miniodb to store the events.

This notification target supports two formats: namespace and access.

When the namespace format is used, Minio synchronizes objects in the bucket with rows in the table. It creates rows with two columns: key_name and value. The key_name is the bucket and object name of an object that exists in Minio. The value is JSON encoded event data about the operation that created/replaced the object in Minio. When objects are updated or deleted, the corresponding row from this table is updated or deleted respectively.

When the access format is used, Minio appends events to a table. It creates rows with two columns: event_time and event_data. The event_time is the time at which the event occurred in the Minio server. The event_data is the JSON encoded event data about the operation on an object. No rows are deleted or modified in this format.

The steps below show how to use this notification target in namespace format. The other format is very similar and is omitted for brevity.

Step 1: Ensure minimum requirements are met

Minio requires MySQL version 5.7.8 or above. Minio uses the JSON data-type introduced in version 5.7.8. We tested this setup on MySQL 5.7.17.

Step 2: Add MySQL server endpoint configuration to Minio

The Minio server configuration file is stored on the backend in json format. The MySQL configuration is located in the mysql key under the notify top-level key. Create a configuration key-value pair here for your MySQL instance. The key is a name for your MySQL endpoint, and the value is a collection of key-value parameters described in the table below.

Parameter

Type

Description

enable

bool

(Required) Is this server endpoint configuration active/enabled?

format

string

(Required) Either namespace or access.

dsnString

string

(Optional) Data-Source-Name connection string for the MySQL server. If not specified, the connection information specified by the host, port, user, password and database parameters are used.

table

string

(Required) Table name in which events will be stored/updated. If the table does not exist, the Minio server creates it at start-up.

host

string

Host name of the MySQL server (used only if dsnString is empty).

port

string

Port on which to connect to the MySQL server (used only if dsnString is empty).

To update the configuration, use mc admin config get command to get the current configuration file for the minio deployment in json format, and save it locally.

$ mc admin config get myminio/ > /tmp/myconfig

After updating the MySQL configuration in /tmp/myconfig , use mc admin config set command to update the configuration for the deployment.Restart the Minio server to put the changes into effect. The server will print a line like SQS ARNs: arn:minio:sqs::1:mysql at start-up if there were no errors.

$ mc admin config set myminio < /tmp/myconfig

Note that, you can add as many MySQL server endpoint configurations as needed by providing an identifier (like "1" in the example above) for the MySQL instance and an object of per-server configuration parameters.

Step 3: Enable bucket notification using Minio client

We will now setup bucket notifications on a bucket named images. Whenever a JPEG image object is created/overwritten, a new row is added or an existing row is updated in the MySQL table configured above. When an existing object is deleted, the corresponding row is deleted from the MySQL table. Thus, the rows in the MySQL table, reflect the .jpg objects in the images bucket.

To configure this bucket notification, we need the ARN printed by Minio in the previous step. Additional information about ARN is available here.

With the mc tool, the configuration is very simple to add. Let us say that the Minio server is aliased as myminio in our mc configuration. Execute the following:

To update the configuration, use mc admin config get command to get the current configuration file for the minio deployment in json format, and save it locally.

$ mc admin config get myminio/ > /tmp/myconfig

After updating the Kafka configuration in /tmp/myconfig , use mc admin config set command to update the configuration for the deployment.Restart the Minio server to put the changes into effect. The server will print a line like SQS ARNs: arn:minio:sqs::1:kafka at start-up if there were no errors.bucketevents is the topic used by kafka in this example.

$ mc admin config set myminio < /tmp/myconfig

Step 3: Enable bucket notification using Minio client

We will enable bucket event notification to trigger whenever a JPEG image is uploaded or deleted from images bucket on myminio server. Here ARN value is arn:minio:sqs::1:kafka. To understand more about ARN please follow AWS ARN documentation.

To update the configuration, use mc admin config get command to get the current configuration file for the minio deployment in json format, and save it locally.

$ mc admin config get myminio/ > /tmp/myconfig

After updating the webhook configuration in /tmp/myconfig , use mc admin config set command to update the configuration for the deployment.Here the endpoint is the server listening for webhook notifications. Save the file and restart the Minio server for changes to take effect. Note that the endpoint needs to be live and reachable when you restart your Minio server.

$ mc admin config set myminio < /tmp/myconfig

Step 2: Enable bucket notification using Minio client

We will enable bucket event notification to trigger whenever a JPEG image is uploaded to images bucket on myminio server. Here ARN value is arn:minio:sqs::1:webhook. To learn more about ARN please follow AWS ARN documentation.

Step 3: Test with Thumbnailer

We used Thumbnailer to listen for Minio notifications when a new JPEG file is uploaded (HTTP PUT). Triggered by a notification, Thumbnailer uploads a thumbnail of new image to Minio server. To start with, download and install Thumbnailer.

git clone https://github.com/minio/thumbnailer/
npm install

Then open the Thumbnailer config file at config/webhook.json and add the configuration for your Minio server and then start Thumbnailer by

NODE_ENV=webhook node thumbnail-webhook.js

Thumbnailer starts running at http://localhost:3000/. Next, configure the Minio server to send notifications to this URL (as mentioned in step 1) and use mc to set up bucket notifications (as mentioned in step 2). Then upload a JPEG image to Minio server by

Publish Minio events to NSQ

Install an NSQ Daemon from here. Or use the following Docker
command for starting an nsq daemon:

docker run --rm -p 4150-4151:4150-4151 nsqio/nsq /nsqd

Step 1: Add NSQ endpoint to Minio

The Minio server configuration file is stored on the backend in json format. The NSQ configuration is located in the nsq key under the notify top-level key. Create a configuration key-value pair here for your NSQ instance. The key is a name for your NSQ endpoint, and the value is a collection of key-value parameters.

To update the configuration, use mc admin config get command to get the current configuration file for the minio deployment in json format, and save it locally.

$ mc admin config get myminio/ > /tmp/myconfig

After updating the NSQ configuration in /tmp/myconfig , use mc admin config set command to update the configuration for the deployment.Restart the Minio server to put the changes into effect. The server will print a line like SQS ARNs: arn:minio:sqs::1:nsq at start-up if there were no errors.

$ mc admin config set myminio < /tmp/myconfig

Note that, you can add as many NSQ daemon endpoint configurations as needed by providing an identifier (like "1" in the example above) for the NSQ instance and an object of per-server configuration parameters.

Step 2: Enable bucket notification using Minio client

We will enable bucket event notification to trigger whenever a JPEG image is uploaded or deleted images bucket on myminio server. Here ARN value is arn:minio:sqs::1:nsq.