summaryrefslogtreecommitdiff
path: root/specs/stein/approved/monasca-events-listener.rst
blob: c01d5b14277a949016c5038562f804cd4e0ce8b4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
..
 This work is licensed under a Creative Commons Attribution 3.0 Unported
 License.

 http://creativecommons.org/licenses/by/3.0/legalcode

=======================
Monasca Events Listener
=======================

https://storyboard.openstack.org/#!/story/2003023

Monasca Events API [1]_ was developed to store event data in Elasticsearch.
A new application could use the Monasca Events API to post an event directly for processing
and storage.
However, a general collection service is needed to capture the existing OpenStack Notifications
already generated by OpenStack Services and pass them to Monasca for storage and processing.
This specification proposes creating a new Monasca Events Listener to capture events and pass
them to Monasca services.


Problem description
===================

All Openstack services generate a lot of notifications or events which contain large amounts of
operational and state information about the service and its resources. Services such as Nova [14]_
already publish to a RabbitMQ topic.
This notification data is not currently available in Monasca.

Ceilometer data processing pipeline [3]_ provides an extensible mechanism of publishing samples and
events using a custom publisher.  Ceilometer samples represent a quantity that can be measured
(e.g. the size of a volume) and events represent an occurrence of an event and do not have any
associated quantity (e.g. volume was created).  The Telemetry project also has the Panko [5]_
service for indexing and storing these events.

A previous `spec <../../rocky/not-implemented/monasca-events-publishing.html>`_ was created to
specify an enhancement to Ceilometer to allow collected events to be published to the Monasca
Events API.
However, with the recent deprecation of Ceilometer's Event functionality [13]_, this is no longer
a long-term option.

This spec is for creating a new Monasca service which would listen for OpenStack Event messages
(often called notifications) and process them through Monasca by consuming the RabbitMQ message
and producing a post to the Monasca Events API with that event.

This service could use Ceilometer, Vitrage, Watcher, or another service as an example of how to
listen to notifications from OpenStack services such as Nova [14]_.

It is being proposed to make the Monasca Events Listener service a part of the Monasca Agent
code base and reuse code, including the existing monasca_setup script and config.


Use Cases
---------

#. Openstack notification data would be stored in Elasticsearch via the Monasca services

   Example sequence:

   #. Nova completes the creation of a VM
   #. Nova generates a Notification message to oslo.messaging
   #. oslo.messaging posts the message to RabbitMQ
   #. Monasca Event Listener receives the Notification message from RabbitMQ
   #. Monasca Event Listener validates and translates the Notification to a Monasca Events
      API format according to the configuration
   #. Monasca Event Listener publishes formatted Notification to Monasca Events API
   #. Monasca Events API receives and validates formatted Notification
   #. Monasca Events API stores event Notification in configured Elasticsearch instance


Proposed change
===============

#. Monasca Event Listener will be a new service which can be run in a Highly
   Available configuration by running an instance of Monasca Event Listener
   on each Controller node in a cloud.  Each node will listen to OpenStack
   notifications in RabbitMQ and convert notifications to a post to the Monasca
   Events API.  The Monasca Events API then passes the notification on as Kafka
   messages on the 'monevents' topic, where the Monasca Persister will receive
   and store them. By the nature of RabbitMQ clients, the load will be
   distributed between the Monasca Events Listener instances (only one listener
   will process each RabbitMQ message).

#. Monasca Event Listener will filter messages from OpenStack services based on
   specification of event_types to be collected.  This will reduce 'noise' and
   focus event collection on those events that are deemed valuable.
   This filtering specification can be from a configuration file, or optionally
   could be controlled through a new API implemented as part of the Monasca
   Events API service.

#. OpenStack Notifications consist of envelope and payload fields.  See [15]_ and [16]_ for
   examples.

   Example OpenStack Notification data format:

   .. code-block:: javascript

        {
            "_context_auth_token": "42630b3ea13242fcad20e0a92d0207f1",
            "_context_domain": null,
            "_context_instance_lock_checked": false,
            "_context_is_admin": true,
            "_context_project_domain": null,
            "_context_project_id": "a4f77",
            "_context_project_name": "admin",
            "_context_quota_class": null,
            "_context_read_deleted": "no",
            "_context_read_only": false,
            "_context_remote_address": "192.168.245.4",
            "_context_request_id": "req-5948338c-f223-4fd8-9249-8769f7a3e460",
            "_context_resource_uuid": null,
            "_context_roles": [
                "monasca-user",
                "admin",
                "KeystoneAdmin"
            ],
            "_context_service_catalog": [
                {
                    "endpoints": [
                        {
                            "adminURL": "http://192.168.245.8:8776/v2/a4f77",
                            "internalURL": "http://192.168.245.8:8776/v2/a4f77",
                            "publicURL": "http://192.168.245.9:8776/v2/a4f77",
                            "region": "region1"
                        }
                    ],
                    "name": "cinderv2",
                    "type": "volumev2"
                },
                {
                    "endpoints": [
                        {
                            "adminURL": "http://192.168.245.8:8776/v1/a4f77",
                            "internalURL": "http://192.168.245.8:8776/v1/a4f77",
                            "publicURL": "http://192.168.245.9:8776/v1/a4f77",
                            "region": "region1"
                        }
                    ],
                    "name": "cinder",
                    "type": "volume"
                }
            ],
            "_context_show_deleted": false,
            "_context_tenant": "a4f77",
            "_context_timestamp": "2015-09-18T20:54:23.468522",
            "_context_user": "be396488c7034811a200a3cb1d103a28",
            "_context_user_domain": null,
            "_context_user_id": "be396488c7034811a200a3cb1d103a28",
            "_context_user_identity": "be396488c7034811a200a3cb1d103a28 a4f77 - - -",
            "_context_user_name": "admin",
            "_unique_id": "ff9699d587bf4283a3c367ab88be1541",
            "event_type": "compute.instance.create.start",
            "message_id": "c6149ba1-34b3-4367-b8c2-b1d6f073742d",
            "payload": {
                "access_ip_v4": null,
                "access_ip_v6": null,
                "architecture": null,
                "availability_zone": null,
                "cell_name": "",
                "created_at": "2015-09-18 20:55:25+00:00",
                "deleted_at": "",
                "disk_gb": 1,
                "display_name": "testeee",
                "ephemeral_gb": 0,
                "host": null,
                "hostname": "testeee",
                "image_meta": {
                    "base_image_ref": "df0c8",
                    "container_format": "bare",
                    "disk_format": "qcow2",
                    "min_disk": "1",
                    "min_ram": "0"
                },
                "image_name": "glanceaaa3",
                "image_ref_url": "http://192.168.245.5:9292/images/df0c8",
                "instance_flavor_id": "1",
                "instance_id": "abd2ef5c-0381-434a-8efc-d7b39b28a2b6",
                "instance_type": "m1.tiny",
                "instance_type_id": 4,
                "kernel_id": "",
                "launched_at": "",
                "memory_mb": 512,
                "metadata": {},
                "node": null,
                "os_type": null,
                "progress": "",
                "ramdisk_id": "",
                "reservation_id": "r-1ghilddw",
                "root_gb": 1,
                "state": "building",
                "state_description": "",
                "tenant_id": "a4f77",
                "terminated_at": "",
                "user_id": "be396488c7034811a200a3cb1d103a28",
                "vcpus": 1
            },
            "priority": "INFO",
            "publisher_id": "compute.ccp-compute0001-mgmt",
            "timestamp": "2015-09-18 20:55:37.639023"
        }

#. All the fields with the prefix of '_context' are the envelope fields, the
   other interesting fields are

   #. 'message_id' - notification identifier
   #. 'payload' - contains most of the relevant and useful information in JSON format
   #. 'priority' - notification priority
   #. 'publisher_id' - notification publisher
   #. 'timestamp' - notification timestamp

#. Monasca Event Listener converts the OpenStack notifications to Monasca events format.
   This format will be suitable for Kafka messaging and will match the expected data fields
   of the Monasca Persister.  This conversion and validation should be common between the
   Monasca Event Listener and Monasca Event API.

#. The Kafka client connection will handle communication issues such as reconnections and
   resending as needed.

#. Monasca Events API allows a field called 'payload' which can be in an arbitrary
   nested JSON format.
   TODO: mappings

   Example Monasca Event Format:

   .. code-block:: javascript

        events: [
        {
          dimensions": {
                "service": "compute.ccp-compute0001-mgmt",
                "topic": "notification.sample",
                "hostname": "nova-compute:compute
          },
          event: {

                  "event_type": "compute.instance.create.start",

                  "payload": {
                       "access_ip_v4": null,
                       "access_ip_v6": null,
                       "architecture": null,
                       "availability_zone": null,
                       "cell_name": "",
                       "created_at": "2015-09-18 20:55:25+00:00",
                       "deleted_at": "",
                       "disk_gb": 1,
                       "display_name": "testeee",
                       "ephemeral_gb": 0,
                       "host": null,
                       "hostname": "testeee",
                       "image_meta": {
                           "base_image_ref": "df0c8",
                           "container_format": "bare",
                           "disk_format": "qcow2",
                           "min_disk": "1",
                           "min_ram": "0"
                       },
                      "image_name": "glanceaaa3",
                      "image_ref_url": "http://192.168.245.5:9292/images/df0c8",
                      "instance_flavor_id": "1",
                      "instance_id": "abd2ef5c-0381-434a-8efc-d7b39b28a2b6",
                      "instance_type": "m1.tiny",
                      "instance_type_id": 4,
                      "kernel_id": "",
                      "launched_at": "",
                      "memory_mb": 512,
                      "metadata": {},
                      "node": null,
                      "os_type": null,
                      "progress": "",
                      "ramdisk_id": "",
                      "reservation_id": "r-1ghilddw",
                      "root_gb": 1,
                      "state": "building",
                      "state_description": "",
                      "tenant_id": "a4f77",
                      "terminated_at": "",
                      "user_id": "be396488c7034811a200a3cb1d103a28",
                      "vcpus": 1
                      }
                 },
            publisher_id: "compute.ccp-compute0001-mgmt",
            priority: "INFO"
         }
        ]

#. Following fields in Monasca Event data may not be available in the OpenStack notification
   data format:

   * "service"
   * "dimensions.topic"
   * "event.priority"

   We are proposing removing these fields from Monasca Event format (will be done as a separate
   spec/implementation process) for the following reasons:

   "service": Currently OpenStack notifications do not specify a service, that
   generated the notification in a consistent way. It might be possible to create an external
   mapping file which maps event name to a service but its hard to maintain such mapping over a
   period of time.

   "dimensions.topic": This field is not available in the source OpenStack notification.
   However, the Monasca Event Listener may be able to save the RabbitMQ topic that the notification
   was collected from.  In that case, this field should be used.

   "event.priority": This field is not currently available in Ceilometer Event format. It is
   available in the source OpenStack notification. Note: If we think this field can be useful we can
   propose adding it to the Monasca Event Listener format.

#. Following new fields will be added to Monasca Event data as dimensions:

   * "dimensions.publisher_id": Identifier for the publisher that generated the event.
   * "dimensions.user_id": Identifier for user that generated the event.
   * "dimensions.project_id": Identifier of the project that generated the event.

#. 'hostname' is available in the event payload, but its location might differ from event to event.

#. The proposed new Monasca Event Listener will have the ability to submit event
   data in a batch and at a configurable frequency (similar to current samples publisher). The
   event data will be published if the items in the current batch reach their maximum size
   (config setting) or if certain time interval has elapsed since the last publish
   (config setting). This will make sure that the batch does not get huge at the same time
   there is no significant delay in publishing of the events to Monasca Events API.

#. Monasca Event Listener will have a configuration file to configure connection information for
   both RabbitMQ and Monasca Events API.

#. The "tenant_id" and "user_id" that the notification relates to are available in "payload"
   section of the notification, and these notifications are generated by each service itself.

   There is no additional "OpenStack-operator-agent" like component or functionality required to
   fetch that data from the service and publish to monasca event api on behalf of the original
   tenant.
   (Ceilometer publishing pipeline simply extracts these "tenant_id" and "user_id" fields from the
   "payload" and makes those fields available as "tenant_id" and "user_id" traits, which would then
   be mapped to "dimensions.project_id" and "dimensions.user_id" fields in monasca events format.)

   In other words, original "tenant_id" and "user_id" values are available in
   the payload of the notification, and will make its way to "dimensions.tenant_id"
   and "dimensions.user_id" in Monasca Event.

   Questions/TODO:

   * Q: Do we need to do anything special to handle multi-tenancy in monasca-events api like being
     done for metrics [9]_ ? Would original user_id and tenant_id in "dimensions.user_id" and
     "dimensions.tenant_id" fields in dimensions serve this purpose?

     * A: Monasca Events Listener can start with sending all events to a single "admin" tenant
       and if required in the future some other process could copy select metrics back to tenant
       projects.

   * Q: In Ceilometer V2 API (which has been deprecated and removed), when querying data the role
     "admin" could access data for all tenants, whereas a user with "ceilometer-admin" role could
     access only data for a particular tenant. Can we implement something like this for
     monasca-events api when querying for data?

     * A: In Monasca API every request is scoped to the project, so there is no equivalent of
       Ceilometer's "admin" role to query data for all projects.  So placing all events in to
       an "admin" project may be the best approach.

   * Q: How should services which generate notifications but do not include a tenant_id be
     handled?  For example Keystone [16]_.
     How does Ceilometer handle such events?

     * A: If all events are in an "admin" project then admin metrics like shared ceph cluster
       load or provider network load can be copied back to tenants so they may understand how
       infrastructure is affecting their workload.

   * Note: Configuration of Elasticsearch cluster is out of scope for this spec. If needed
     could assign a separate Elasticsearch cluster to the events API to avoid overloads.


Alternative Solutions
---------------------

#. Reuse the Ceilometer functionality to collect and publish events to the
   Monasca Events API.  While this may be less work initially, Ceilometer has
   deprecated the Events functionality as of Stein. [13]_

#. An alternate Events Listener was proposed that would listen for RabbitMQ events
   then publish them directly to the 'monevents' topic in Kafka.  Discussion on this
   can be seen in the git history for this document and in IRC logs [18]_.

   Pro:

   * A much simpler approach, more efficient that HTTP hop through another service.
   * No need for batching in service, as RabbitMQ and Kafka clients would handle fast
     throughput and short network interruptions.

   Con:

   * Nova Cells v2 each have their own RabbitMQ instances. While most deployments
     would likely have a centralized RabbitMQ, it is not required in the documented
     architecture.
   * Regions may also cause separation of RabbitMQ instances that need to be monitored.
   * While it might be possible to have a service/agent in each Cell publish back to
     a centralized to Kafka directly, our authentication and networking for Kafka was
     not designed to support that.

#. OpenStack Panko [5]_ is a event storage and REST API for Ceilometer and could
   be used instead of a Monasca solution.

   Pro:

   * An 'official' subproject within Telemetry, so there is some community recognition.

   Con:

   * Its primary storage is in a relational database which has problems with scale.
   * It is not maintained actively and not ready for production. [11]_
   * It will be deprecated eventually. [12]_


Data model impact
-----------------

None

REST API impact
---------------

#. We are proposing to tweak the Monasca Event data format by removing and adding following
   fields as mentioned in "Proposed change" section above.

   Remove fields or make them optional (JSON path notation): "service", "dimensions.topic",
   "dimensions.hostname" and "event.priority"

   Add fields (JSON path notation): "dimensions.publisher_id", "dimensions.user_id" and
   "dimensions.project_id"

   This change will have an impact on Monasca Events API.

Security impact
---------------

The proposed Monasca Event Listener will collect and publish OpenStack event
(notification) data to Monasca Events API. OpenStack notification data does not
have any sensitive data like 'tokens'.
Notifications do contain 'user_id' and 'project_id' fields but do not
contain any Personally Identifiable Information (PII) for the user or
the project.


Other end user impact
---------------------

None.

Performance Impact
------------------

#. The number of notifications(events) generated by different services will depend on the capacity
   of the cloud along with the number of resources being created by the users.

   For example, if there was a large number of compute VM's being created or destroyed it could
   lead to a surge in number of notifications (events) that would have to be published.  Optimum
   configuration options related to say event batch size and event batch interval would have to be
   documented, to reduce any adverse affect on performance.

#. The proposed Monasca Event Listener is a new service, so performance is unknown.  However, the
   Monasca API has been shown to have a high performance throughput.


Other deployer impact
---------------------

#. The proposed Monasca Event Listener will introduce a
   few new configuration options like

   * RabbitMQ connection information
   * Monasca Events API endpoint URL
   * events batch interval
   * events batch size
   * events retry interval
   * Keystone credentials for obtaining a token
   * Conversion options for OpenStack notifications to the Monasca Event format.  This may
     be stored in separate pipeline configuration files, similar to how transform specs
     are configured in Monasca Transform.

#. As part of developing new Monasca Event Listener devstack plugin would be
   updated to add the above configuration changes.


Developer impact
----------------

#. The proposed change to Monasca Event Format will have an impact on existing Monasca Event API,
   since Monasca Event Format will have to be tweaked.  (See REST API Impact section above)

Implementation
==============

Assignee(s)
-----------

Primary assignee:
  joadavis, aagate

Other contributors:
  <launchpad-id or None>


Work Items
----------

#. Implement new Monasca Event Listener.

   * Connection to RabbitMQ for OpenStack Notifications
   * Add filtering of notifications for configured event_types

     * Specification in configuration file
     * (Optional) Creation of a new API to configure event_type subscriptions

   * Validation of OpenStack Notification data and format
   * Conversion of data format to meet Monasca Events requirements
   * Publishing to Monasca Events API
   * Configuration of conversion specifications per-event type

#. Implement monasca devstack plugin changes to deploy
   new Events Listener service.

#. Implement unit tests for Monasca Event Listener.


Dependencies
============

None

Testing
=======

#. New Monasca Event Listener unit tests will be added, which can test publishing with
   various config options events batch size, events batch interval, handling retry when Monasca
   Event API is not available.

#. Adding tempest tests for Monasca Event Listener could be looked at as part of
   separate effort.


Documentation Impact
====================

#. New Monasca Event Listener config options will be documented

#. Recommended values for each of the config options will also be documented based on the size of
   the cloud and resources for Cloud Operators.

References
==========

.. [1] Monasca Events API 1.0: https://git.openstack.org/cgit/openstack/monasca-events-api/

[2] Monasca Ceilometer project: https://github.com/openstack/monasca-ceilometer

.. [3] Ceilometer Data processing and pipelines: https://docs.openstack.org/ceilometer/pike/admin/telemetry-data-pipelines.html

[4] Ceilometer Events: https://docs.openstack.org/ceilometer/latest/admin/telemetry-events.html

.. [5] Openstack Panko: https://github.com/openstack/panko

[6] Monasca Event Format: https://github.com/openstack/monasca-events-api/blob/master/doc/api-samples/v1/req_simple_event.json

[7] Ceilometer System Architecture Diagram: https://docs.openstack.org/ceilometer/ocata/architecture.html

[8] Monasca Events POST v1.0 API: https://github.com/openstack/monasca-events-api/blob/master/api-ref/source/events.inc

.. [9] Cross-Tenant Metric Submission: https://github.com/openstack/monasca-agent/blob/master/docs/MonascaMetrics.md#cross-tenant-metric-submission

[10] Ceilometer pipeline yaml documentation: https://docs.openstack.org/ceilometer/latest/admin/telemetry-data-pipelines.html

.. [11] No future for Panko or Aodh: https://julien.danjou.info/lessons-from-openstack-telemetry-deflation/

.. [12] Ceilometer Events deprecated means Panko also deprecated: http://eavesdrop.openstack.org/irclogs/%23openstack-telemetry/%23openstack-telemetry.2018-10-10.log.html

.. [13] Ceilometer Events marked as deprecated in Stein: https://review.openstack.org/#/c/603336/

.. [14] Nova notification version update lists services effected (see "Deprecating legacy notifications"): https://etherpad.openstack.org/p/nova-ptg-stein

.. [15] Nova notification reference: https://docs.openstack.org/nova/latest/reference/notifications.html#existing-versioned-notifications

.. [16] Keystone notification reference: https://docs.openstack.org/keystone/latest/advanced-topics/event_notifications.html#example-notification-project-create

[17] Monasca Events API publisher to Kafka: https://github.com/openstack/monasca-events-api/blob/master/monasca_events_api/app/common/events_publisher.py

.. [18] Monasca IRC meeting Dec 15, 2018: http://eavesdrop.openstack.org/meetings/monasca/2018/monasca.2018-12-12-15.00.log.html