Merge "src: ensure hostname is included in collectd conf"
[barometer.git] / docs / release / userguide / collectd.ves.userguide.rst
1 .. This work is licensed under a Creative Commons Attribution 4.0 International License.
2 .. http://creativecommons.org/licenses/by/4.0
3 .. (c) OPNFV, Intel Corporation and others.
4
5 ==========================
6 VES Application User Guide
7 ==========================
8
9 The Barometer repository contains a python based application for VES (VNF Event
10 Stream) which receives the `collectd`_ specific metrics via `Kafka`_ bus,
11 normalizes the metric data into the VES message and sends it into the VES
12 collector.
13
14 The application currently supports pushing platform relevant metrics through the
15 additional measurements field for VES.
16
17 Collectd has a ``write_kafka`` plugin that sends collectd metrics and values to
18 a Kafka Broker. The VES application uses Kafka Consumer to receive metrics
19 from the Kafka Broker.
20
21
22 Install Kafka Broker
23 --------------------
24
25 1. Dependencies: install JAVA & Zookeeper.
26
27     JAVA:
28
29     .. code:: bash
30
31         $ sudo apt install default-jre
32
33     CentOS 7.x use:
34
35     .. code:: bash
36
37         $ sudo yum install java-1.6.0-openjdk
38
39     Zookeeper:
40
41     .. code:: bash
42
43         $ sudo apt install zookeeperd
44
45     CentOS 7.x use:
46
47     .. code:: bash
48
49         $ sudo yum install zookeeper
50
51     .. note:: You may need to add the repository that contains zookeeper.
52       To do so, follow the step below and try to install `zookeeper` again
53       using steps above. Otherwise, skip next step.
54
55     .. code:: bash
56
57         $ sudo yum install
58         https://archive.cloudera.com/cdh5/one-click-install/redhat/7/x86_64/cloudera-cdh-5-0.x86_64.rpm
59
60     CentOS 7.x start zookeeper:
61
62     .. code:: bash
63
64         $ sudo zookeeper-server start
65
66     if you get the error message like ``ZooKeeper data directory is missing at /var/lib/zookeeper``
67     during the start of zookeeper, initialize zookeeper data directory using
68     the command below and start zookeeper again, otherwise skip the next step.
69
70     .. code:: bash
71
72         $ sudo /usr/lib/zookeeper/bin/zkServer-initialize.sh
73         No myid provided, be sure to specify it in /var/lib/zookeeper/myid if using non-standalone
74
75     To test if Zookeeper is running as a daemon.
76
77     .. code:: bash
78
79         $ telnet localhost 2181
80
81     Type 'ruok' & hit enter.
82     Expected response is 'imok'. Zookeeper is running fine.
83
84     .. note::
85
86         VES doesn't work with version 0.9.4 of kafka-python.
87         The recommended/tested version is 1.3.3.
88
89     .. code:: bash
90
91         $ sudo yum install python-pip
92         $ sudo pip install kafka-python
93
94 2. Download Kafka:
95
96     .. code:: bash
97
98         $ wget "http://www-eu.apache.org/dist/kafka/0.11.0.0/kafka_2.11-0.11.0.0.tgz"
99
100 3. Extract the archive:
101
102     .. code:: bash
103
104         $ tar -xvzf kafka_2.11-0.11.0.0.tgz
105
106 4. Configure Kafka Server:
107
108     .. code:: bash
109
110         $ vi kafka_2.11-0.11.0.0/config/server.properties
111
112     By default Kafka does not allow you to delete topics. Please uncomment:
113
114     .. code:: bash
115
116         delete.topic.enable=true
117
118 5. Start the Kafka Server.
119
120     Run 'kafka-server-start.sh' with nohup as a background process:
121
122     .. code:: bash
123
124         $ sudo nohup kafka_2.11-0.11.0.0/bin/kafka-server-start.sh \
125           kafka_2.11-0.11.0.0/config/server.properties > kafka_2.11-0.11.0.0/kafka.log 2>&1 &
126
127 6. Test Kafka Broker Installation
128
129     To test if the installation worked correctly there are two scripts, producer and consumer scripts.
130     These will allow you to see messages pushed to broker and receive from broker.
131
132     Producer (Publish "Hello World"):
133
134     .. code:: bash
135
136         $ echo "Hello, World" | kafka_2.11-0.11.0.0/bin/kafka-console-producer.sh \
137           --broker-list localhost:9092 --topic TopicTest > /dev/null
138
139     Consumer (Receive "Hello World"):
140
141     .. code:: bash
142
143         $ kafka_2.11-0.11.0.0/bin/kafka-console-consumer.sh --zookeeper \
144           localhost:2181 --topic TopicTest --from-beginning
145
146
147 Install collectd
148 ----------------
149
150 Install development tools:
151
152 .. code:: bash
153
154     $ sudo yum group install 'Development Tools'
155
156 .. The libkafka installed via yum pkg manager is 0.11.0 which doesn't work with
157    collectd (compilation issue). Thus, we have to use the library installed
158    from sources using latest stable version which works with collectd.
159
160 Install Apache Kafka C/C++ client library:
161
162 .. code:: bash
163
164     $ git clone https://github.com/edenhill/librdkafka.git ~/librdkafka
165     $ cd ~/librdkafka
166     $ git checkout -b v0.9.5 v0.9.5
167     $ ./configure --prefix=/usr
168     $ make
169     $ sudo make install
170
171 Build collectd with Kafka support:
172
173 .. code:: bash
174
175     $ git clone https://github.com/collectd/collectd.git ~/collectd
176     $ cd ~/collectd
177     $ ./build.sh
178     $ ./configure --with-librdkafka=/usr --without-perl-bindings --enable-perl=no
179     $ make && sudo make install
180
181 Configure and start collectd. Create ``/opt/collectd/etc/collectd.conf``
182 collectd configuration file as following:
183
184 .. note:: The following collectd configuration file allows user to run VES
185    application in the guest mode. To run the VES in host mode, please follow
186    the `Configure VES in host mode`_ steps.
187
188 .. include:: collectd-ves-guest.conf
189    :code: bash
190
191 Start collectd process as a service as described in :ref:`install-collectd-as-a-service`.
192
193
194 Setup VES Test Collector
195 ------------------------
196
197 .. note:: Test Collector setup is required only for VES application testing
198    purposes.
199
200 Install dependencies:
201
202 .. code:: bash
203
204     $ sudo pip install jsonschema
205
206 Clone VES Test Collector:
207
208 .. code:: bash
209
210     $ git clone https://github.com/att/evel-test-collector.git ~/evel-test-collector
211
212 Modify VES Test Collector config file to point to existing log directory and
213 schema file:
214
215 .. code:: bash
216
217     $ sed -i.back 's/^\(log_file[ ]*=[ ]*\).*/\1collector.log/' ~/evel-test-collector/config/collector.conf
218     $ sed -i.back 's/^\(schema_file[ ]*=.*\)event_format_updated.json$/\1CommonEventFormat.json/' ~/evel-test-collector/config/collector.conf
219
220 Start VES Test Collector:
221
222 .. code:: bash
223
224     $ cd ~/evel-test-collector/code/collector
225     $ nohup python ./collector.py --config ../../config/collector.conf > collector.stdout.log &
226
227
228 Setup VES application (guest mode)
229 ----------------------------------
230
231 Install dependencies:
232
233 .. code:: bash
234
235     $ sudo pip install pyyaml
236
237 Clone Barometer repo and start the VES application:
238
239 .. code:: bash
240
241     $ git clone https://gerrit.opnfv.org/gerrit/barometer ~/barometer
242     $ cd ~/barometer/3rd_party/collectd-ves-app/ves_app
243     $ nohup python ves_app.py --events-schema=guest.yaml --config=ves_app_config.conf > ves_app.stdout.log &
244
245 .. note::
246
247     The above configuration is used for a localhost. The VES application can be
248     configured to use remote real VES collector and remote Kafka server. To do
249     so, the IP addresses/host names needs to be changed in ``collector.conf``
250     and ``ves_app_config.conf`` files accordingly.
251
252
253 Configure VES in host mode
254 --------------------------
255
256 Running the VES in host mode looks like steps described in
257 `Setup VES application (guest mode)`_ but with the following exceptions:
258
259 - The ``host.yaml`` configuration file should be used instead of ``guest.yaml``
260   file when VES application is running.
261
262 - Collectd should be running on host machine only.
263
264 - Addition ``libvirtd`` dependencies needs to be installed on a host where
265   collectd daemon is running. To install those dependencies, see :ref:`virt-plugin`
266   section of Barometer user guide.
267
268 - At least one VM instance should be up and running by hypervisor on the host.
269
270 - The next (minimum) configuration needs to be provided to collectd to be able
271   to generate the VES message to VES collector.
272
273   .. include:: collectd-ves-host.conf
274      :code: bash
275
276   to apply this configuration, the ``/opt/collectd/etc/collectd.conf`` file
277   needs to be modified based on example above and collectd daemon needs to
278   be restarted using the command below:
279
280   .. code:: bash
281
282     $ sudo systemctl restart collectd
283
284 .. note:: The list of the plugins can be extented depends on your needs.
285
286
287 VES application configuration description
288 -----------------------------------------
289
290 **Details of the Vendor Event Listener REST service**
291
292 REST resources are defined with respect to a ``ServerRoot``::
293
294     ServerRoot = https://{Domain}:{Port}/{optionalRoutingPath}
295
296 REST resources are of the form::
297
298     {ServerRoot}/eventListener/v{apiVersion}`
299     {ServerRoot}/eventListener/v{apiVersion}/{topicName}`
300     {ServerRoot}/eventListener/v{apiVersion}/eventBatch`
301
302 Within the VES directory (``3rd_party/collectd-ves-app/ves_app``) there is a
303 configuration file called ``ves_app.conf``. The description of the
304 configuration options are described below:
305
306 **Domain** *"host"*
307   VES domain name. It can be IP address or hostname of VES collector
308   (default: ``127.0.0.1``)
309
310 **Port** *port*
311   VES port (default: ``30000``)
312
313 **Path** *"path"*
314   Used as the "optionalRoutingPath" element in the REST path (default: empty)
315
316 **Topic** *"path"*
317   Used as the "topicName" element in the REST  path (default: empty)
318
319 **UseHttps** *true|false*
320   Allow application to use HTTPS instead of HTTP (default: ``false``)
321
322 **Username** *"username"*
323   VES collector user name (default: empty)
324
325 **Password** *"passwd"*
326   VES collector password (default: empty)
327
328 **SendEventInterval** *interval*
329   This configuration option controls how often (sec) collectd data is sent to
330   Vendor Event Listener (default: ``20``)
331
332 **ApiVersion** *version*
333   Used as the "apiVersion" element in the REST path (default: ``5.1``)
334
335 **KafkaPort** *port*
336   Kafka Port (Default ``9092``)
337
338 **KafkaBroker** *host*
339   Kafka Broker domain name. It can be an IP address or hostname of local or remote server
340   (default: ``localhost``)
341
342
343 VES YAML configuration format
344 -----------------------------
345
346 The format of the VES message is generated by the VES application based on the
347 YAML schema configuration file provided by user via ``--events-schema``
348 command-line option of the application.
349
350 .. note:: Use ``--help`` option of VES application to see the
351     description of all available options
352
353 .. note:: The detailed installation guide of the VES application is described in
354     the `VES Application User Guide`_.
355
356 The message defined by YAML schema should correspond to format defined in
357 `VES shema definition`_.
358
359 .. warning:: This section doesn't explain the YAML language itself, so the
360     knowledge of the YAML language is required before continue reading it!
361
362 Since, the VES message output is a JSON format, it's recommended to understand
363 how YAML document is converted to JSON before starting to create a new YAML
364 definition for the VES. E.g.:
365
366 The following YAML document:
367
368 .. code:: yaml
369
370     ---
371     additionalMeasurements:
372       plugin: somename
373       instance: someinstance
374
375 will be converted to JSON like this:
376
377 .. code:: json
378
379     {
380       "additionalMeasurements": {
381         "instance": "someinstance",
382         "plugin": "somename"
383       }
384     }
385
386 .. note:: The `YAML syntax` section of `PyYAML documentation`_ can be used
387     as a reference for this.
388
389
390 VES message types
391 -----------------
392
393 The VES agent can generate two type of messages which are sent to the VES
394 collector. Each message type must be specified in the YAML configuration file
395 using a specific YAML tag.
396
397 Measurements
398   This type is used to send a message defined in YAML configuration to the VES
399   collector with a specified interval (default is 20 sec and it's configurable
400   via command line option of the application). This type can be specified in
401   the configuration using ``!Measurements`` tag. For instance:
402
403   .. code:: yaml
404
405       ---
406       # My comments
407       My Host Measurements: !Measurements
408         ... # message definition
409
410 Events
411   This type is used to send a message defined in YAML configuration to the VES
412   collector when collectd notification is received from Kafka bus (collectd
413   ``write_kafka`` plugin). This type can be specified in the configuration
414   using ``!Events`` tag. For instance:
415
416   .. code:: yaml
417
418       ---
419       # My comments
420       My Events: !Events
421         ... # event definition
422
423
424 Collectd metrics in VES
425 -----------------------
426
427 The VES application caches collectd metrics received via Kafka bus. The data
428 is stored in a table format. It's important to know it before mapping collectd
429 metric values to message defined in YAML configuration file.
430
431 VES collectd metric cache example:
432
433 +-----------+-----------+--------------------+-----------+----------------+-------------------+--------+---------+----------+
434 |   host    |  plugin   |  plugin_instance   |  type     |  type_instace  |       time        | value  | ds_name | interval |
435 +===========+===========+====================+===========+================+===================+========+=========+==========+
436 | localhost | cpu       |                    | percent   | user           | 1509535512.30567  | 16     | value   | 10       |
437 +-----------+-----------+--------------------+-----------+----------------+-------------------+--------+---------+----------+
438 | localhost | memory    |                    | memory    | free           | 1509535573.448014 | 798456 | value   | 10       |
439 +-----------+-----------+--------------------+-----------+----------------+-------------------+--------+---------+----------+
440 | localhost | interface |                    | eth0      | if_packets     | 1509544183.956496 | 253    | rx      | 10       |
441 +-----------+-----------+--------------------+-----------+----------------+-------------------+--------+---------+----------+
442 | 7ec333e7  | virt      | Ubuntu-12.04.5-LTS | percent   | virt_cpu_total | 1509544402.378035 | 0.2    | value   | 10       |
443 +-----------+-----------+--------------------+-----------+----------------+-------------------+--------+---------+----------+
444 | 7ec333e7  | virt      | Ubuntu-12.04.5-LTS | memory    | rss            | 1509544638.55119  | 123405 | value   | 10       |
445 +-----------+-----------+--------------------+-----------+----------------+-------------------+--------+---------+----------+
446 | 7ec333e7  | virt      | Ubuntu-12.04.5-LTS | if_octets | vnet1          | 1509544646.27108  | 67     | tx      | 10       |
447 +-----------+-----------+--------------------+-----------+----------------+-------------------+--------+---------+----------+
448 | cc659a52  | virt      | Ubuntu-16.04       | percent   | virt_cpu_total | 1509544745.617207 | 0.3    | value   | 10       |
449 +-----------+-----------+--------------------+-----------+----------------+-------------------+--------+---------+----------+
450 | cc659a52  | virt      | Ubuntu-16.04       | memory    | rss            | 1509544754.329411 | 4567   | value   | 10       |
451 +-----------+-----------+--------------------+-----------+----------------+-------------------+--------+---------+----------+
452 | cc659a52  | virt      | Ubuntu-16.04       | if_octets | vnet0          | 1509544760.720381 | 0      | rx      | 10       |
453 +-----------+-----------+--------------------+-----------+----------------+-------------------+--------+---------+----------+
454
455 It's possible from YAML configuration file to refer to any field of any row of
456 the table via special YAML tags like ``ValueItem`` or ``ArrayItem``. See the
457 `Collectd metric reference`_ reference for more details.
458
459 .. note:: The `collectd data types file`_ contains map of ``type`` to
460     ``ds_name`` field. It can be used to get possible value for ``ds_name``
461     field. See the `collectd data types description`_ for more details on
462     collectd data types.
463
464
465 Aging of collectd metric
466 ~~~~~~~~~~~~~~~~~~~~~~~~
467
468 If the metric will not be updated by the collectd during the double metric
469 interval time, it will be removed (aged) from VES internal cache.
470
471
472 VES YAML references
473 -------------------
474
475 There are four type of references supported by the YAML format: System,
476 Config, Collectd metric and Collectd notification. The format of the reference
477 is the following:
478
479 .. code:: yaml
480
481     "{<ref type>.<attribute name>}"
482
483 .. note:: Possible values for ``<ref type>`` and ``<attribute name>`` are
484     described in farther sections.
485
486
487 System reference
488 ~~~~~~~~~~~~~~~~
489
490 This reference is used to get system statistics like time, date etc. The system
491 reference (``<ref type>`` = ``system``) can be used in any place of the YAML
492 configuration file. This type of reference provides the following attributes:
493
494 ``hostname``
495   The name of the host where VES application is running.
496
497 ``id``
498   Unique ID during VES application runtime.
499
500 ``time``
501   Current time in seconds since the Epoch. For example ``1509641411.631951``.
502
503 ``date``
504   Current date in ISO 8601 format, ``YYYY-MM-DD``. For instance ``2017-11-02``.
505
506
507 For example:
508
509 .. code:: yaml
510
511     Date: "{system.date}"
512
513
514 Config reference
515 ~~~~~~~~~~~~~~~~
516
517 This reference is used to get VES configuration described in `VES application
518 configuration description`_ sectoin. The reference (``<ref type>`` = ``config``)
519 can be used in any place of the YAML configuration file. This type of reference
520 provides the following attributes:
521
522 ``interval``
523   Measurements dispatch interval. It referenses to ``SendEventInterval``
524   configuration of the VES application.
525
526
527 For example:
528
529 .. code:: yaml
530
531     Interval: "{config.interval}"
532
533
534 Collectd metric reference
535 ~~~~~~~~~~~~~~~~~~~~~~~~~
536
537 This reference is used to get the attribute value of collectd metric from the
538 VES cache. The reference (``<ref type>`` = ``vl``) can be used ONLY inside
539 ``Measurements``, ``ValueItem`` and ``ArrayItem`` tags. Using the reference
540 inside a helper tag is also allowed if the helper tag is located inside the
541 tag where the reference is allowed (e.g.: ``ArrayItem``). The
542 ``<attribute name>`` name corresponds to the table field name described in
543 `Collectd metrics in VES`_ section. For example:
544
545 .. code:: yaml
546
547     name: "{vl.type}-{vl.type_instance}"
548
549
550 Collectd notification reference
551 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
552
553 This reference is used to get the attribute value of received collectd
554 notification. The reference (``<ref type>`` = ``n``) can be used ONLY inside
555 ``Events`` tag. Using the reference inside a helper tag is also allowed if
556 the helper tag is located inside the ``Events`` tag. This type of reference
557 provides the following attributes:
558
559 ``host``
560   The hostname of received collectd notification.
561
562 ``plugin``
563   The plugin name of received collectd notification.
564
565 ``plugin_instance``
566   The plugin instance of the received collectd notification.
567
568 ``type``
569   The type name of the received collectd notification.
570
571 ``type_instance``
572   The type instance of the received collectd notification.
573
574 ``severity``
575   The severity of the received collectd notification.
576
577 ``message``
578   The message of the received collectd notification.
579
580
581 .. note:: The exact value for each attribute depends on the collectd plugin
582   which may generate the notification. Please refer to the
583   `collectd plugin description`_ document to get more details on the specific
584   collectd plugin.
585
586 YAML config example:
587
588 .. code:: yaml
589
590     sourceId: "{n.plugin_instance}"
591
592
593 Collectd metric mapping YAML tags
594 ---------------------------------
595
596 This section describes the YAML tags used to map collectd metric values in the
597 YAML configuration file.
598
599
600 Measurements tag
601 ~~~~~~~~~~~~~~~~
602
603 This tag is a YAML map which is used to define the VES measurement message. It's
604 allowed to be used multiple times in the document (e.g.: you can define multiple
605 VES messages in one YAML document). This tag works in the same way as `ArrayItem
606 tag`_ does and all keys have the same description/rules.
607
608
609 ValueItem tag
610 ~~~~~~~~~~~~~
611
612 This tag is used to select a collectd metric and get its attribute value using
613 `Collectd metric reference`_. The type of this tag is a YAML array of maps with
614 the possible keys described below.
615
616 ``SELECT`` (required)
617   Is a YAML map which describes the select metric criteria. Each key name of the
618   map must correspond to the table field name described in `Collectd metrics in VES`_
619   section.
620
621 ``VALUE`` (optional)
622   Describes the value to be assigned. If not provided, the default
623   ``!Number "{vl.value}"`` expression is used.
624
625 ``DEFAULT`` (optional)
626   Describes the default value which will be assigned if no metric is selected
627   by ``SELECT`` criteria.
628
629
630 ValueItem tag description example:
631
632 .. code:: yaml
633
634     memoryFree: !ValueItem
635       - SELECT:
636           plugin: memory
637           type: memory
638           type_instance: rss
639       - VALUE: !Bytes2Kibibytes "{vl.value}"
640       - DEFAULT: 0
641
642 The tag process workflow is described on the figure below.
643
644 .. figure:: value-item-parse-workflow.png
645
646     YAML ValueItem tag process workflow
647
648
649 ArrayItem tag
650 ~~~~~~~~~~~~~
651
652 This tag is used to select a list of collectd metrics and generate a YAML array
653 of YAML items described by ``ITEM-DESC`` key. If no collectd metrics are
654 selected by the given criteria, the empty array will be returned.
655
656 ``SELECT`` (optional)
657   Is a YAML map which describes the select metrics criteria. Each key name of
658   the map must correspond to the table field name described in `Collectd
659   metrics in VES`_ section. The value of the key may be regular expression. To
660   enable regular expression in the value, the YAML string containing ``/`` char
661   at the beginning and at the end should be used. For example:
662
663   .. code:: yaml
664
665       plugin: "/^(?!virt).*$/" # selected all metrics except ``virt`` plugin
666
667   The VES application uses the python RE library to work with regular
668   expression specified in the YAML configuration. Please refer to `python
669   regular expression syntax`_ documentation for more details on a syntax
670   used by the VES.
671
672   Multiple ``SELECT`` keys are allowed by the tag. If nor ``SELECT`` or
673   ``INDEX-KEY`` key is specified, the VES error is generated.
674
675 ``INDEX-KEY`` (optional)
676   Is a YAML array which describes the unique fields to be selected by the tag.
677   Each element of array is a YAML string which should be one of the table field
678   name described in `Collectd metrics in VES`_ section. Please note, if this
679   key is used, only fields specified by the key can be used as a collectd
680   reference in the ``ITEM-DESC`` key.
681
682 ``ITEM-DESC`` (required)
683   Is a YAML map which describes each element of the YAML array generated by
684   the tag. Using ``ArrayItem`` tags and other `Helper YAML tags`_ are also
685   allowed in the definition of the key.
686
687 In the example below, the ArrayItem tag is used to generate an array of
688 ``ITEM-DESC`` items for each collectd metrics except ``virt`` plugin with
689 unique ``plugin``, ``plugin_instance`` attribute values.
690
691 .. code:: yaml
692
693     Measurements: !ArrayItem
694       - SELECT:
695           plugin: "/^(?!virt).*$/"
696       - INDEX-KEY:
697           - plugin
698           - plugin_instance
699       - ITEM-DESC:
700           name: !StripExtraDash "{vl.plugin}-{vl.plugin_instance}"
701
702 The tag process workflow is described on the figure below.
703
704 .. figure:: array-item-parse-workflow.png
705
706     YAML ArrayItem tag process workflow
707
708
709 Collectd event mapping YAML tags
710 --------------------------------
711
712 This section describes the YAML tags used to map the collectd notification to
713 the VES event message in the YAML configuration file.
714
715
716 Events tag
717 ~~~~~~~~~~
718
719 This tag is a YAML map which is used to define the VES event message. It's
720 allowed to be used multiple times in the document (e.g.: you can map multiple
721 collectd notification into VES message in one YAML document). The possible
722 keys of the tag are described below.
723
724 ``CONDITION`` (optional)
725   Is a YAML map which describes the select metric criteria. Each key name of
726   the map must correspond to the name of attribute provided by `Collectd
727   notification reference`_. If no such key provided, any collectd notification
728   will map the defined YAML message.
729
730 ``ITEM-DESC`` (required)
731   Is a YAML map which describes the message generated by this tag. Only `Helper
732   YAML tags`_ are allowed in the definition of the key.
733
734 The example of the VES event message which will be generate by the VES
735 application when collectd notification of the ``virt`` plugin is triggered
736 is described below.
737
738 .. code:: yaml
739
740     ---
741     Virt Event: !Events
742       - ITEM-DESC:
743           event:
744             commonEventHeader:
745               domain: fault
746               eventType: Notification
747               sourceId: &event_sourceId "{n.plugin_instance}"
748               sourceName: *event_sourceId
749               lastEpochMicrosec: !Number "{n.time}"
750               startEpochMicrosec: !Number "{n.time}"
751             faultFields:
752               alarmInterfaceA: !StripExtraDash "{n.plugin}-{n.plugin_instance}"
753               alarmCondition: "{n.severity}"
754               faultFieldsVersion: 1.1
755       - CONDITION:
756           plugin: virt
757
758
759 Helper YAML tags
760 ----------------
761
762 This section describes the YAML tags used as utilities for formatting the output
763 message. The YAML configuration process workflow is described on the figure
764 below.
765
766 .. figure:: parse-work-flow.png
767
768     YAML configuration process workflow
769
770
771 Convert string to number tag
772 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
773
774 The ``!Number`` tag is used in YAML configuration file to convert string value into
775 the number type. For instance:
776
777 .. code:: yaml
778
779     lastEpochMicrosec: !Number "3456"
780
781 The output of the tag will be the JSON number.
782
783 .. code:: json
784
785     {
786       lastEpochMicrosec: 3456
787     }
788
789
790 Convert bytes to Kibibytes tag
791 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
792
793 The ``!Bytes2Kibibytes`` tag is used in YAML configuration file to convert
794 bytes into kibibytes (1 kibibyte = 1024 bytes). For instance:
795
796 .. code:: yaml
797
798     memoryConfigured: !Bytes2Kibibytes 4098
799     memoryConfigured: !Bytes2Kibibytes "1024"
800
801 The output of the tag will be the JSON number.
802
803 .. code:: json
804
805     {
806       memoryConfigured: 4
807       memoryConfigured: 1
808     }
809
810
811 Convert one value to another tag
812 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
813
814 The ``!MapValue`` tag is used in YAML configuration file to map one value
815 into another value defined in the configuration. For instance:
816
817 .. code:: yaml
818
819     Severity: !MapValue
820       VALUE: Failure
821       TO:
822         Failure: Critical
823         Error: Warnign
824
825 The output of the tag will be the mapped value.
826
827 .. code:: json
828
829     {
830       Severity: Critical
831     }
832
833
834 Strip extra dash tag
835 ~~~~~~~~~~~~~~~~~~~~
836
837 The ``!StripExtraDash`` tag is used in YAML configuration file to strip extra
838 dashes in the string (dashes at the beginning, at the end and double dashes).
839 For example:
840
841 .. code:: yaml
842
843     name: !StripExtraDash string-with--extra-dashes-
844
845 The output of the tag will be the JSON string with extra dashes removed.
846
847 .. code:: json
848
849     {
850       name: string-with-extra-dashes
851     }
852
853
854 Limitations
855 -----------
856
857 #. Only one document can be defined in the same YAML configuration file.
858
859 #. The collectd notification is not supported by `Kafka collectd plugin`_. Due to
860    this limitation, the collectd notifications cannot be received by the VES
861    application and the defined YAML event will not be generated and sent to the
862    VES collector. Please note, that VES YAML format already supports the events
863    definition and the format is descibed in the document.
864
865
866 .. _collectd: http://collectd.org/
867 .. _Kafka: https://kafka.apache.org/
868 .. _`VES`: https://wiki.opnfv.org/display/fastpath/VES+plugin+updates
869 .. _`VES shema definition`: https://gerrit.onap.org/r/gitweb?p=demo.git;a=tree;f=vnfs/VES5.0/evel/evel-test-collector/docs/att_interface_definition;hb=refs/heads/master
870 .. _`PyYAML documentation`: https://pyyaml.org/wiki/PyYAMLDocumentation
871 .. _`collectd plugin description`: https://github.com/collectd/collectd/blob/master/src/collectd.conf.pod
872 .. _`collectd data types file`: https://github.com/collectd/collectd/blob/master/src/types.db
873 .. _`collectd data types description`: https://github.com/collectd/collectd/blob/master/src/types.db.pod
874 .. _`python regular expression syntax`: https://docs.python.org/2/library/re.html#regular-expression-syntax
875 .. _`Kafka collectd plugin`: https://collectd.org/wiki/index.php/Plugin:Write_Kafka