1 # Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
19 url => "${dmaap_base_url}/events/${event_topic}/${dmaap_consumer_group}/${dmaap_consumer_id}?timeout=15000"
21 Accept => "application/json"
23 topic => "${event_topic}"
24 tags => [ "dmaap_source" ]
26 notification_queue => {
28 url => "${dmaap_base_url}/events/${notification_topic}/${dmaap_consumer_group}/${dmaap_consumer_id}?timeout=15000"
30 Accept => "application/json"
32 topic => "${notification_topic}"
33 tags => [ "dmaap_source" ]
37 url => "${dmaap_base_url}/events/${request_topic}/${dmaap_consumer_group}/${dmaap_consumer_id}?timeout=15000"
39 Accept => "application/json"
41 topic => "${request_topic}"
42 tags => [ "dmaap_source" ]
47 schedule => { "every" => "1m" }
49 cacert => "/certs.d/aafca.pem"
55 # avoid noise if no entry in the list
56 if [message] == "[]" {
60 if [http_request_failure] or [@metadata][code] != 200 {
62 add_tag => [ "error" ]
66 if "dmaap_source" in [@metadata][request][tags] {
68 # Dmaap provides a json list, whose items are Strings containing the event
69 # provided to Dmaap, which itself is an escaped json.
71 # We first need to parse the json as we have to use the plaintext as it cannot
72 # work with list of events, then split that list into multiple string events,
73 # that we then transform into json.
87 remove_field => [ "message" ]
92 # Some timestamps are expressed as milliseconds, some are in microseconds
94 if [closedLoopAlarmStart] {
97 if event.get('closedLoopAlarmStart').to_s.to_i(10) > 9999999999999
98 event.set('closedLoopAlarmStart', event.get('closedLoopAlarmStart').to_s.to_i(10) / 1000)
100 event.set('closedLoopAlarmStart', event.get('closedLoopAlarmStart').to_s.to_i(10))
105 match => [ "closedLoopAlarmStart", UNIX_MS ]
106 target => "closedLoopAlarmStart"
110 if [closedLoopAlarmEnd] {
113 if event.get('closedLoopAlarmEnd').to_s.to_i(10) > 9999999999999
114 event.set('closedLoopAlarmEnd', event.get('closedLoopAlarmEnd').to_s.to_i(10) / 1000)
116 event.set('closedLoopAlarmEnd', event.get('closedLoopAlarmEnd').to_s.to_i(10))
121 match => [ "closedLoopAlarmEnd", UNIX_MS ]
122 target => "closedLoopAlarmEnd"
129 # Notification time are expressed under the form "yyyy-MM-dd HH:mm:ss", which
130 # is close to ISO8601, but lacks of T as spacer: "yyyy-MM-ddTHH:mm:ss"
132 if [notificationTime] {
135 "notificationTime", " ", "T"
139 match => [ "notificationTime", ISO8601 ]
140 target => "notificationTime"
146 # Renaming some fields for readability
148 if [AAI][generic-vnf.vnf-name] {
150 add_field => { "vnfName" => "%{[AAI][generic-vnf.vnf-name]}" }
153 if [AAI][generic-vnf.vnf-type] {
155 add_field => { "vnfType" => "%{[AAI][generic-vnf.vnf-type]}" }
158 if [AAI][vserver.vserver-name] {
160 add_field => { "vmName" => "%{[AAI][vserver.vserver-name]}" }
163 if [AAI][complex.city] {
165 add_field => { "locationCity" => "%{[AAI][complex.city]}" }
168 if [AAI][complex.state] {
170 add_field => { "locationState" => "%{[AAI][complex.state]}" }
176 # Adding some flags to ease aggregation
178 if [closedLoopEventStatus] =~ /(?i)ABATED/ {
180 add_field => { "flagAbated" => "1" }
183 if [notification] =~ /^.*?(?:\b|_)FINAL(?:\b|_).*?(?:\b|_)FAILURE(?:\b|_).*?$/ {
185 add_field => { "flagFinalFailure" => "1" }
190 if "error" not in [@metadata][request][tags]{
192 # Creating data for a secondary index
195 clones => [ "event-cl-aggs" ]
196 add_tag => [ "event-cl-aggs" ]
199 if "event-cl-aggs" in [@metadata][request][tags]{
201 # we only need a few fields for aggregations; remove all fields from clone except :
202 # vmName,vnfName,vnfType,requestID,closedLoopAlarmStart, closedLoopControlName,closedLoopAlarmEnd,abated,nbrDmaapevents,finalFailure
205 whitelist_names => ["^@.*$","^topic$","^type$","^tags$","^flagFinalFailure$","^flagAbated$","^locationState$","^locationCity$","^vmName$","^vnfName$","^vnfType$","^requestID$","^closedLoopAlarmStart$","^closedLoopControlName$","^closedLoopAlarmEnd$","^target$","^target_type$","^triggerSourceName$","^policyScope$","^policyName$","^policyVersion$"]
218 if "error" in [tags] {
221 cacert => "/clamp-cert/ca-certs.pem"
222 ssl_certificate_verification => false
223 hosts => ["${elasticsearch_base_url}"]
224 user => ["${logstash_user}"]
225 password => ["${logstash_pwd}"]
226 index => "errors-%{+YYYY.MM.DD}"
227 doc_as_upsert => true
230 } else if "event-cl-aggs" in [tags] {
233 hosts => ["${elasticsearch_base_url}"]
234 cacert => "/clamp-cert/ca-certs.pem"
235 ssl_certificate_verification => false
236 user => ["${logstash_user}"]
237 password => ["${logstash_pwd}"]
238 document_id => "%{requestID}"
239 index => "events-cl-%{+YYYY.MM.DD}" # creates daily indexes for control loop
240 doc_as_upsert => true
247 hosts => ["${elasticsearch_base_url}"]
248 cacert => "/clamp-cert/ca-certs.pem"
249 ssl_certificate_verification => false
250 user => ["${logstash_user}"]
251 password => ["${logstash_pwd}"]
252 index => "events-%{+YYYY.MM.DD}" # creates daily indexes
253 doc_as_upsert => true