]> git.proxmox.com Git - ceph.git/blame - ceph/doc/radosgw/notifications.rst
import ceph quincy 17.2.6
[ceph.git] / ceph / doc / radosgw / notifications.rst
CommitLineData
eafe8130
TL
1====================
2Bucket Notifications
3====================
4
5.. versionadded:: Nautilus
6
7.. contents::
8
39ae355f
TL
9Bucket notifications provide a mechanism for sending information out of radosgw
10when certain events happen on the bucket. Notifications can be sent to HTTP
11endpoints, AMQP0.9.1 endpoints, and Kafka endpoints.
12
13The `PubSub Module`_ (and *not* the bucket-notification mechanism) should be
14used for events stored in Ceph.
15
16A user can create topics. A topic entity is defined by its name and is "per
17tenant". A user can associate its topics (via notification configuration) only
18with buckets it owns.
19
20A notification entity must be created in order to send event notifications for
21a specific bucket. A notification entity can be created either for a subset
22of event types or for all event types (which is the default). The
23notification may also filter out events based on matches of the prefixes and
24suffixes of (1) the keys, (2) the metadata attributes attached to the object,
25or (3) the object tags. Regular-expression matching can also be used on these
26to create filters. There can be multiple notifications for any specific topic,
27and the same topic can used for multiple notifications.
28
29REST API has been defined so as to provide configuration and control interfaces
30for the bucket notification mechanism. This API is similar to the one defined
31as the S3-compatible API of the `PubSub Module`_.
eafe8130
TL
32
33.. toctree::
34 :maxdepth: 1
35
36 S3 Bucket Notification Compatibility <s3-notification-compatibility>
37
f67539c2
TL
38.. note:: To enable bucket notifications API, the `rgw_enable_apis` configuration parameter should contain: "notifications".
39
40Notification Reliability
41------------------------
42
39ae355f
TL
43Notifications can be sent synchronously or asynchronously. This section
44describes the latency and reliability that you should expect for synchronous
45and asynchronous notifications.
46
47Synchronous Notifications
48~~~~~~~~~~~~~~~~~~~~~~~~~
49
50Notifications can be sent synchronously, as part of the operation that
51triggered them. In this mode, the operation is acknowledged (acked) only after
52the notification is sent to the topic's configured endpoint. This means that
53the round trip time of the notification (the time it takes to send the
54notification to the topic's endpoint plus the time it takes to receive the
55acknowledgement) is added to the latency of the operation itself.
56
57.. note:: The original triggering operation is considered successful even if
58 the notification fails with an error, cannot be delivered, or times out.
f67539c2 59
39ae355f
TL
60Asynchronous Notifications
61~~~~~~~~~~~~~~~~~~~~~~~~~~
f67539c2 62
39ae355f
TL
63Notifications can be sent asynchronously. They are committed into persistent
64storage and then asynchronously sent to the topic's configured endpoint. In
65this case, the only latency added to the original operation is the latency
66added when the notification is committed to persistent storage.
f67539c2 67
39ae355f
TL
68.. note:: If the notification fails with an error, cannot be delivered, or
69 times out, it is retried until it is successfully acknowledged.
f67539c2 70
39ae355f
TL
71.. tip:: To minimize the latency added by asynchronous notification, we
72 recommended placing the "log" pool on fast media.
f67539c2
TL
73
74
75Topic Management via CLI
76------------------------
77
78Configuration of all topics, associated with a tenant, could be fetched using the following command:
79
39ae355f 80.. prompt:: bash #
f67539c2 81
39ae355f 82 radosgw-admin topic list [--tenant={tenant}]
f67539c2
TL
83
84
85Configuration of a specific topic could be fetched using:
86
39ae355f 87.. prompt:: bash #
f67539c2 88
39ae355f 89 radosgw-admin topic get --topic={topic-name} [--tenant={tenant}]
f67539c2
TL
90
91
92And removed using:
93
39ae355f 94.. prompt:: bash #
f67539c2 95
39ae355f 96 radosgw-admin topic rm --topic={topic-name} [--tenant={tenant}]
f67539c2
TL
97
98
9f95a23c 99Notification Performance Stats
eafe8130 100------------------------------
9f95a23c 101The same counters are shared between the pubsub sync module and the bucket notification mechanism.
eafe8130 102
9f95a23c 103- ``pubsub_event_triggered``: running counter of events with at least one topic associated with them
eafe8130
TL
104- ``pubsub_event_lost``: running counter of events that had topics associated with them but that were not pushed to any of the endpoints
105- ``pubsub_push_ok``: running counter, for all notifications, of events successfully pushed to their endpoint
106- ``pubsub_push_fail``: running counter, for all notifications, of events failed to be pushed to their endpoint
107- ``pubsub_push_pending``: gauge value of events pushed to an endpoint but not acked or nacked yet
108
f67539c2 109.. note::
eafe8130 110
f67539c2
TL
111 ``pubsub_event_triggered`` and ``pubsub_event_lost`` are incremented per event, while:
112 ``pubsub_push_ok``, ``pubsub_push_fail``, are incremented per push action on each notification
eafe8130
TL
113
114Bucket Notification REST API
115----------------------------
116
117Topics
118~~~~~~
119
f67539c2
TL
120.. note::
121
39ae355f
TL
122 In all topic actions, the parameters are URL-encoded and sent in the
123 message body using this content type:
124 ``application/x-www-form-urlencoded``.
125
f67539c2 126
eafe8130
TL
127Create a Topic
128``````````````
129
39ae355f
TL
130This creates a new topic. Provide the topic with push endpoint parameters,
131which will be used later when a notification is created. A response is
132generated. A successful response includes the the topic's `ARN
133<https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html>`_
134(the "Amazon Resource Name", a unique identifier used to reference the topic).
135To update a topic, use the same command that you used to create it (but when
136updating, use the name of an existing topic and different endpoint values).
137
138.. tip:: Any notification already associated with the topic must be re-created
139 in order for the topic to update.
eafe8130 140
39ae355f
TL
141.. note:: For rabbitmq, ``push-endpoint`` (with a hyphen in the middle) must be
142 changed to ``push_endpoint`` (with an underscore in the middle).
eafe8130
TL
143
144::
145
146 POST
f67539c2 147
eafe8130
TL
148 Action=CreateTopic
149 &Name=<topic-name>
eafe8130 150 [&Attributes.entry.1.key=amqp-exchange&Attributes.entry.1.value=<exchange>]
e306af50 151 [&Attributes.entry.2.key=amqp-ack-level&Attributes.entry.2.value=none|broker|routable]
9f95a23c
TL
152 [&Attributes.entry.3.key=verify-ssl&Attributes.entry.3.value=true|false]
153 [&Attributes.entry.4.key=kafka-ack-level&Attributes.entry.4.value=none|broker]
154 [&Attributes.entry.5.key=use-ssl&Attributes.entry.5.value=true|false]
155 [&Attributes.entry.6.key=ca-location&Attributes.entry.6.value=<file path>]
156 [&Attributes.entry.7.key=OpaqueData&Attributes.entry.7.value=<opaque data>]
f67539c2
TL
157 [&Attributes.entry.8.key=push-endpoint&Attributes.entry.8.value=<endpoint>]
158 [&Attributes.entry.9.key=persistent&Attributes.entry.9.value=true|false]
20effc67 159 [&Attributes.entry.10.key=cloudevents&Attributes.entry.10.value=true|false]
eafe8130
TL
160
161Request parameters:
162
39ae355f
TL
163- push-endpoint: This is the URI of an endpoint to send push notifications to.
164- OpaqueData: Opaque data is set in the topic configuration and added to all
165 notifications that are triggered by the topic.
166- persistent: This indicates whether notifications to this endpoint are
167 persistent (=asynchronous) or not persistent. (This is "false" by default.)
eafe8130 168
f67539c2 169- HTTP endpoint
eafe8130 170
9f95a23c 171 - URI: ``http[s]://<fqdn>[:<port]``
39ae355f
TL
172 - port: This defaults to 80 for HTTP and 443 for HTTPS.
173 - verify-ssl: This indicates whether the server certificate is validated by
174 the client. (This is "true" by default.)
175 - cloudevents: This indicates whether the HTTP header should contain
176 attributes according to the `S3 CloudEvents Spec`_. (This is "false" by
177 default.)
eafe8130 178
9f95a23c
TL
179- AMQP0.9.1 endpoint
180
f67539c2 181 - URI: ``amqp[s]://[<user>:<password>@]<fqdn>[:<port>][/<vhost>]``
39ae355f
TL
182 - user/password: This defaults to "guest/guest".
183 - user/password: This must be provided only over HTTPS. Topic creation
184 requests will otherwise be rejected.
185 - port: This defaults to 5672 for unencrypted connections and 5671 for
186 SSL-encrypted connections.
187 - vhost: This defaults to "/".
188 - verify-ssl: This indicates whether the server certificate is validated by
189 the client. (This is "true" by default.)
190 - If ``ca-location`` is provided and a secure connection is used, the
191 specified CA will be used to authenticate the broker. The default CA will
192 not be used.
193 - amqp-exchange: The exchanges must exist and must be able to route messages
194 based on topics. This parameter is mandatory. Different topics that point
195 to the same endpoint must use the same exchange.
196 - amqp-ack-level: No end2end acking is required. Messages may persist in the
197 broker before being delivered to their final destinations. Three ack methods
198 exist:
199
200 - "none": The message is considered "delivered" if it is sent to the broker.
201 - "broker": The message is considered "delivered" if it is acked by the broker (default).
202 - "routable": The message is considered "delivered" if the broker can route to a consumer.
203
204.. tip:: The topic-name (see :ref:`radosgw-create-a-topic`) is used for the
205 AMQP topic ("routing key" for a topic exchange).
f67539c2
TL
206
207- Kafka endpoint
9f95a23c
TL
208
209 - URI: ``kafka://[<user>:<password>@]<fqdn>[:<port]``
39ae355f
TL
210 - ``use-ssl``: If this is set to "true", a secure connection is used to
211 connect to the broker. (This is "false" by default.)
212 - ``ca-location``: If this is provided and a secure connection is used, the
213 specified CA will be used insted of the default CA to authenticate the
214 broker.
215 - user/password: This must be provided only over HTTPS. Topic creation
216 requests will otherwise be rejected.
217 - user/password: This must be provided along with ``use-ssl``. Connections to
218 the broker will otherwise fail.
219 - port: This defaults to 9092.
220 - kafka-ack-level: No end2end acking is required. Messages may persist in the
221 broker before being delivered to their final destinations. Two ack methods
222 exist:
223
224 - "none": Messages are considered "delivered" if sent to the broker.
225 - "broker": Messages are considered "delivered" if acked by the broker. (This
226 is the default.)
eafe8130 227
f67539c2 228.. note::
eafe8130 229
39ae355f
TL
230 - The key-value pair of a specific parameter need not reside in the same
231 line as the parameter, and need not appear in any specific order, but it
232 must use the same index.
233 - Attribute indexing need not be sequential and need not start from any
234 specific value.
235 - `AWS Create Topic`_ provides a detailed explanation of the endpoint
236 attributes format. In our case, however, different keys and values are
237 used.
eafe8130 238
39ae355f 239The response has the following format:
eafe8130
TL
240
241::
242
243 <CreateTopicResponse xmlns="https://sns.amazonaws.com/doc/2010-03-31/">
244 <CreateTopicResult>
245 <TopicArn></TopicArn>
246 </CreateTopicResult>
247 <ResponseMetadata>
248 <RequestId></RequestId>
249 </ResponseMetadata>
f67539c2 250 </CreateTopicResponse>
eafe8130 251
39ae355f
TL
252The topic `ARN
253<https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html>`_
254in the response has the following format:
eafe8130
TL
255
256::
257
258 arn:aws:sns:<zone-group>:<tenant>:<topic>
f67539c2
TL
259
260Get Topic Attributes
261````````````````````
262
39ae355f
TL
263This returns information about a specific topic. This includes push-endpoint
264information, if provided.
f67539c2
TL
265
266::
267
268 POST
269
270 Action=GetTopicAttributes
271 &TopicArn=<topic-arn>
272
39ae355f 273The response has the following format:
f67539c2
TL
274
275::
276
277 <GetTopicAttributesResponse>
20effc67 278 <GetTopicAttributesResult>
f67539c2
TL
279 <Attributes>
280 <entry>
281 <key>User</key>
282 <value></value>
283 </entry>
284 <entry>
285 <key>Name</key>
286 <value></value>
287 </entry>
288 <entry>
289 <key>EndPoint</key>
290 <value></value>
291 </entry>
292 <entry>
293 <key>TopicArn</key>
294 <value></value>
295 </entry>
296 <entry>
297 <key>OpaqueData</key>
298 <value></value>
299 </entry>
300 </Attributes>
301 </GetTopicAttributesResult>
302 <ResponseMetadata>
303 <RequestId></RequestId>
304 </ResponseMetadata>
305 </GetTopicAttributesResponse>
306
39ae355f
TL
307- User: the name of the user that created the topic.
308- Name: the name of the topic.
309- EndPoint: The JSON-formatted endpoint parameters, including:
310 - EndpointAddress: The push-endpoint URL.
311 - EndpointArgs: The push-endpoint args.
312 - EndpointTopic: The topic name to be sent to the endpoint (can be different
313 than the above topic name).
314 - HasStoredSecret: This is "true" if the endpoint URL contains user/password
315 information. In this case, the request must be made over HTTPS. The "topic
316 get" request will otherwise be rejected.
317 - Persistent: This is "true" if the topic is persistent.
318- TopicArn: topic `ARN
319 <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html>`_.
320- OpaqueData: The opaque data set on the topic.
f67539c2 321
eafe8130
TL
322Get Topic Information
323`````````````````````
324
39ae355f
TL
325This returns information about a specific topic. This includes push-endpoint
326information, if provided. Note that this API is now deprecated in favor of the
327AWS compliant `GetTopicAttributes` API.
eafe8130
TL
328
329::
330
331 POST
f67539c2
TL
332
333 Action=GetTopic
334 &TopicArn=<topic-arn>
eafe8130 335
39ae355f 336The response has the following format:
eafe8130
TL
337
338::
339
340 <GetTopicResponse>
20effc67 341 <GetTopicResult>
eafe8130
TL
342 <Topic>
343 <User></User>
344 <Name></Name>
345 <EndPoint>
346 <EndpointAddress></EndpointAddress>
347 <EndpointArgs></EndpointArgs>
348 <EndpointTopic></EndpointTopic>
f67539c2
TL
349 <HasStoredSecret></HasStoredSecret>
350 <Persistent></Persistent>
eafe8130
TL
351 </EndPoint>
352 <TopicArn></TopicArn>
9f95a23c 353 <OpaqueData></OpaqueData>
eafe8130
TL
354 </Topic>
355 </GetTopicResult>
356 <ResponseMetadata>
357 <RequestId></RequestId>
358 </ResponseMetadata>
f67539c2 359 </GetTopicResponse>
eafe8130 360
39ae355f
TL
361- User: The name of the user that created the topic.
362- Name: The name of the topic.
363- EndpointAddress: The push-endpoint URL.
364- EndpointArgs: The push-endpoint args.
365- EndpointTopic: The topic name to be sent to the endpoint (which can be
366 different than the above topic name).
367- HasStoredSecret: This is "true" if the endpoint URL contains user/password
368 information. In this case, the request must be made over HTTPS. The "topic
369 get" request will otherwise be rejected.
370- Persistent: "true" if topic is persistent.
371- TopicArn: topic `ARN
372 <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html>`_.
373- OpaqueData: the opaque data set on the topic.
eafe8130
TL
374
375Delete Topic
376````````````
377
378::
379
380 POST
eafe8130 381
f67539c2
TL
382 Action=DeleteTopic
383 &TopicArn=<topic-arn>
384
39ae355f 385This deletes the specified topic.
f67539c2
TL
386
387.. note::
388
39ae355f
TL
389 - Deleting an unknown notification (for example, double delete) is not
390 considered an error.
391 - Deleting a topic does not automatically delete all notifications associated
392 with it.
eafe8130 393
39ae355f 394The response has the following format:
eafe8130
TL
395
396::
397
398 <DeleteTopicResponse xmlns="https://sns.amazonaws.com/doc/2010-03-31/">
399 <ResponseMetadata>
400 <RequestId></RequestId>
401 </ResponseMetadata>
f67539c2 402 </DeleteTopicResponse>
eafe8130
TL
403
404List Topics
405```````````
406
f67539c2 407List all topics associated with a tenant.
eafe8130
TL
408
409::
410
f67539c2
TL
411 POST
412
eafe8130 413 Action=ListTopics
f67539c2 414
39ae355f 415The response has the following format:
eafe8130
TL
416
417::
418
20effc67
TL
419 <ListTopicsResponse xmlns="https://sns.amazonaws.com/doc/2010-03-31/">
420 <ListTopicsResult>
eafe8130
TL
421 <Topics>
422 <member>
423 <User></User>
424 <Name></Name>
425 <EndPoint>
426 <EndpointAddress></EndpointAddress>
427 <EndpointArgs></EndpointArgs>
428 <EndpointTopic></EndpointTopic>
429 </EndPoint>
430 <TopicArn></TopicArn>
9f95a23c 431 <OpaqueData></OpaqueData>
eafe8130
TL
432 </member>
433 </Topics>
434 </ListTopicsResult>
435 <ResponseMetadata>
436 <RequestId></RequestId>
437 </ResponseMetadata>
f67539c2 438 </ListTopicsResponse>
eafe8130 439
39ae355f
TL
440- If the endpoint URL contains user/password information in any part of the
441 topic, the request must be made over HTTPS. The "topic list" request will
442 otherwise be rejected.
9f95a23c 443
eafe8130
TL
444Notifications
445~~~~~~~~~~~~~
446
447Detailed under: `Bucket Operations`_.
448
f67539c2 449.. note::
eafe8130
TL
450
451 - "Abort Multipart Upload" request does not emit a notification
eafe8130
TL
452 - Both "Initiate Multipart Upload" and "POST Object" requests will emit an ``s3:ObjectCreated:Post`` notification
453
eafe8130
TL
454Events
455~~~~~~
456
39ae355f
TL
457Events are in JSON format (regardless of the actual endpoint), and share the
458same structure as S3-compatible events that are pushed or pulled using the
459pubsub sync module. For example:
eafe8130
TL
460
461::
462
f67539c2 463 {"Records":[
eafe8130 464 {
f67539c2
TL
465 "eventVersion":"2.1",
466 "eventSource":"ceph:s3",
467 "awsRegion":"us-east-1",
468 "eventTime":"2019-11-22T13:47:35.124724Z",
a4b75251 469 "eventName":"ObjectCreated:Put",
f67539c2
TL
470 "userIdentity":{
471 "principalId":"tester"
eafe8130
TL
472 },
473 "requestParameters":{
474 "sourceIPAddress":""
475 },
476 "responseElements":{
f67539c2
TL
477 "x-amz-request-id":"503a4c37-85eb-47cd-8681-2817e80b4281.5330.903595",
478 "x-amz-id-2":"14d2-zone1-zonegroup1"
eafe8130
TL
479 },
480 "s3":{
481 "s3SchemaVersion":"1.0",
f67539c2 482 "configurationId":"mynotif1",
eafe8130 483 "bucket":{
f67539c2 484 "name":"mybucket1",
eafe8130 485 "ownerIdentity":{
f67539c2 486 "principalId":"tester"
eafe8130 487 },
f67539c2
TL
488 "arn":"arn:aws:s3:us-east-1::mybucket1",
489 "id":"503a4c37-85eb-47cd-8681-2817e80b4281.5332.38"
eafe8130
TL
490 },
491 "object":{
f67539c2
TL
492 "key":"myimage1.jpg",
493 "size":"1024",
494 "eTag":"37b51d194a7513e45b56f6524f2d51f2",
eafe8130 495 "versionId":"",
f67539c2 496 "sequencer": "F7E6D75DC742D108",
9f95a23c
TL
497 "metadata":[],
498 "tags":[]
eafe8130
TL
499 }
500 },
501 "eventId":"",
f67539c2 502 "opaqueData":"me@example.com"
eafe8130
TL
503 }
504 ]}
505
39ae355f
TL
506- awsRegion: The zonegroup.
507- eventTime: The timestamp, indicating when the event was triggered.
508- eventName: For the list of supported events see: `S3 Notification
509 Compatibility`_. Note that eventName values do not start with the `s3:`
510 prefix.
511- userIdentity.principalId: The user that triggered the change.
eafe8130 512- requestParameters.sourceIPAddress: not supported
39ae355f
TL
513- responseElements.x-amz-request-id: The request ID of the original change.
514- responseElements.x_amz_id_2: The RGW on which the change was made.
515- s3.configurationId: The notification ID that created the event.
516- s3.bucket.name: The name of the bucket.
517- s3.bucket.ownerIdentity.principalId: The owner of the bucket.
518- s3.bucket.arn: The ARN of the bucket.
519- s3.bucket.id: The ID of the bucket. (This is an extension to the S3
520 notification API.)
521- s3.object.key: The object key.
522- s3.object.size: The object size.
523- s3.object.eTag: The object etag.
524- s3.object.versionId: The object version, if the bucket is versioned. When a
525 copy is made, it includes the version of the target object. When a delete
526 marker is created, it includes the version of the delete marker.
527- s3.object.sequencer: The monotonically-increasing identifier of the "change
528 per object" (hexadecimal format).
529- s3.object.metadata: Any metadata set on the object that is sent as
530 ``x-amz-meta-`` (that is, any metadata set on the object that is sent as an
531 extension to the S3 notification API).
532- s3.object.tags: Any tags set on the object. (This is an extension to the S3
533 notification API.)
534- s3.eventId: The unique ID of the event, which could be used for acking. (This
535 is an extension to the S3 notification API.)
536- s3.opaqueData: This means that "opaque data" is set in the topic configuration
537 and is added to all notifications triggered by the topic. (This is an
538 extension to the S3 notification API.)
eafe8130
TL
539
540.. _PubSub Module : ../pubsub-module
541.. _S3 Notification Compatibility: ../s3-notification-compatibility
542.. _AWS Create Topic: https://docs.aws.amazon.com/sns/latest/api/API_CreateTopic.html
543.. _Bucket Operations: ../s3/bucketops
20effc67 544.. _S3 CloudEvents Spec: https://github.com/cloudevents/spec/blob/main/cloudevents/adapters/aws-s3.md