blob: b978e766d38b7787256ae2ac9c5b0f9b100a15f4 [file] [log] [blame]
Jakub Latusekfcf67842020-10-21 13:36:29 +02001{{/*
ac2550a0496b02018-09-20 14:57:22 +02002# Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
Mukul379e2522018-09-05 12:26:02 +00003#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
Jakub Latusekfcf67842020-10-21 13:36:29 +020015*/}}
ac25508ac97172018-04-18 14:23:17 +020016input {
ac2550a0496b02018-09-20 14:57:22 +020017 http_poller {
ac25508ac97172018-04-18 14:23:17 +020018 urls => {
19 event_queue => {
20 method => get
21 url => "${dmaap_base_url}/events/${event_topic}/${dmaap_consumer_group}/${dmaap_consumer_id}?timeout=15000"
22 headers => {
23 Accept => "application/json"
24 }
ac2550a0496b02018-09-20 14:57:22 +020025 topic => "${event_topic}"
26 tags => [ "dmaap_source" ]
ac25508ac97172018-04-18 14:23:17 +020027 }
28 notification_queue => {
29 method => get
30 url => "${dmaap_base_url}/events/${notification_topic}/${dmaap_consumer_group}/${dmaap_consumer_id}?timeout=15000"
31 headers => {
32 Accept => "application/json"
33 }
ac2550a0496b02018-09-20 14:57:22 +020034 topic => "${notification_topic}"
35 tags => [ "dmaap_source" ]
ac25508ac97172018-04-18 14:23:17 +020036 }
37 request_queue => {
38 method => get
39 url => "${dmaap_base_url}/events/${request_topic}/${dmaap_consumer_group}/${dmaap_consumer_id}?timeout=15000"
40 headers => {
41 Accept => "application/json"
42 }
ac2550a0496b02018-09-20 14:57:22 +020043 topic => "${request_topic}"
44 tags => [ "dmaap_source" ]
ac25508ac97172018-04-18 14:23:17 +020045 }
46 }
47 socket_timeout => 30
48 request_timeout => 30
ac2550a0496b02018-09-20 14:57:22 +020049 schedule => { "every" => "1m" }
ac25508ac97172018-04-18 14:23:17 +020050 codec => "plain"
osgn422w79814452020-09-25 02:28:02 +020051{{- if .Values.global.aafEnabled }}
52 cacert => "{{ .Values.certInitializer.credsPath }}/{{ .Values.certInitializer.clamp_ca_certs_pem }}"
53{{- else }}
ac2550a0496b02018-09-20 14:57:22 +020054 cacert => "/certs.d/aafca.pem"
osgn422w79814452020-09-25 02:28:02 +020055{{- end }}
ac2550a0496b02018-09-20 14:57:22 +020056 }
ac25508ac97172018-04-18 14:23:17 +020057}
58
ac25508ac97172018-04-18 14:23:17 +020059
ac2550a0496b02018-09-20 14:57:22 +020060filter {
61 # avoid noise if no entry in the list
62 if [message] == "[]" {
63 drop { }
ac25508ac97172018-04-18 14:23:17 +020064 }
ac2550a0496b02018-09-20 14:57:22 +020065
Krysiak Adam4993cae2019-04-04 09:58:27 +020066 if [http_request_failure] or [@metadata][code] != 200 {
ac2550a0496b02018-09-20 14:57:22 +020067 mutate {
Sylvain Desbureaux8c2a1622020-04-22 10:50:26 +020068 add_tag => [ "error" ]
ac2550a0496b02018-09-20 14:57:22 +020069 }
70 }
71
Krysiak Adam4993cae2019-04-04 09:58:27 +020072 if "dmaap_source" in [@metadata][request][tags] {
ac2550a0496b02018-09-20 14:57:22 +020073 #
74 # Dmaap provides a json list, whose items are Strings containing the event
75 # provided to Dmaap, which itself is an escaped json.
76 #
77 # We first need to parse the json as we have to use the plaintext as it cannot
78 # work with list of events, then split that list into multiple string events,
79 # that we then transform into json.
80 #
81 json {
82 source => "[message]"
83 target => "message"
84 }
Krysiak Adam4993cae2019-04-04 09:58:27 +020085
ac2550a0496b02018-09-20 14:57:22 +020086 split {
87 field => "message"
88 }
89 json {
90 source => "message"
91 }
92 mutate {
93 remove_field => [ "message" ]
94 }
ac25508ac97172018-04-18 14:23:17 +020095 }
ac2550a0496b02018-09-20 14:57:22 +020096
97 #
98 # Some timestamps are expressed as milliseconds, some are in microseconds
99 #
100 if [closedLoopAlarmStart] {
101 ruby {
102 code => "
103 if event.get('closedLoopAlarmStart').to_s.to_i(10) > 9999999999999
104 event.set('closedLoopAlarmStart', event.get('closedLoopAlarmStart').to_s.to_i(10) / 1000)
105 else
106 event.set('closedLoopAlarmStart', event.get('closedLoopAlarmStart').to_s.to_i(10))
107 end
108 "
109 }
110 date {
111 match => [ "closedLoopAlarmStart", UNIX_MS ]
112 target => "closedLoopAlarmStart"
113 }
ac25508ac97172018-04-18 14:23:17 +0200114 }
115
116 if [closedLoopAlarmEnd] {
117 ruby {
osgn422w7bc14fa2018-09-06 15:33:50 +0200118 code => "
ac2550a0496b02018-09-20 14:57:22 +0200119 if event.get('closedLoopAlarmEnd').to_s.to_i(10) > 9999999999999
120 event.set('closedLoopAlarmEnd', event.get('closedLoopAlarmEnd').to_s.to_i(10) / 1000)
121 else
122 event.set('closedLoopAlarmEnd', event.get('closedLoopAlarmEnd').to_s.to_i(10))
123 end
124 "
ac25508ac97172018-04-18 14:23:17 +0200125 }
126 date {
127 match => [ "closedLoopAlarmEnd", UNIX_MS ]
128 target => "closedLoopAlarmEnd"
129 }
130
131 }
ac2550a0496b02018-09-20 14:57:22 +0200132
133
134 #
135 # Notification time are expressed under the form "yyyy-MM-dd HH:mm:ss", which
136 # is close to ISO8601, but lacks of T as spacer: "yyyy-MM-ddTHH:mm:ss"
137 #
ac25508ac97172018-04-18 14:23:17 +0200138 if [notificationTime] {
ac2550a0496b02018-09-20 14:57:22 +0200139 mutate {
140 gsub => [
141 "notificationTime", " ", "T"
142 ]
143 }
144 date {
ac25508ac97172018-04-18 14:23:17 +0200145 match => [ "notificationTime", ISO8601 ]
146 target => "notificationTime"
ac2550a0496b02018-09-20 14:57:22 +0200147 }
148 }
149
150
151 #
152 # Renaming some fields for readability
153 #
154 if [AAI][generic-vnf.vnf-name] {
155 mutate {
156 add_field => { "vnfName" => "%{[AAI][generic-vnf.vnf-name]}" }
157 }
158 }
159 if [AAI][generic-vnf.vnf-type] {
160 mutate {
161 add_field => { "vnfType" => "%{[AAI][generic-vnf.vnf-type]}" }
162 }
163 }
164 if [AAI][vserver.vserver-name] {
165 mutate {
166 add_field => { "vmName" => "%{[AAI][vserver.vserver-name]}" }
167 }
168 }
169 if [AAI][complex.city] {
170 mutate {
171 add_field => { "locationCity" => "%{[AAI][complex.city]}" }
172 }
173 }
174 if [AAI][complex.state] {
175 mutate {
176 add_field => { "locationState" => "%{[AAI][complex.state]}" }
177 }
178 }
179
180
181 #
182 # Adding some flags to ease aggregation
183 #
184 if [closedLoopEventStatus] =~ /(?i)ABATED/ {
185 mutate {
186 add_field => { "flagAbated" => "1" }
187 }
188 }
189 if [notification] =~ /^.*?(?:\b|_)FINAL(?:\b|_).*?(?:\b|_)FAILURE(?:\b|_).*?$/ {
190 mutate {
191 add_field => { "flagFinalFailure" => "1" }
192 }
193 }
194
195
Krysiak Adam4993cae2019-04-04 09:58:27 +0200196 if "error" not in [@metadata][request][tags]{
ac2550a0496b02018-09-20 14:57:22 +0200197 #
198 # Creating data for a secondary index
199 #
200 clone {
201 clones => [ "event-cl-aggs" ]
202 add_tag => [ "event-cl-aggs" ]
203 }
Sylvain Desbureaux8c2a1622020-04-22 10:50:26 +0200204
Krysiak Adam4993cae2019-04-04 09:58:27 +0200205 if "event-cl-aggs" in [@metadata][request][tags]{
ac2550a0496b02018-09-20 14:57:22 +0200206 #
207 # we only need a few fields for aggregations; remove all fields from clone except :
208 # vmName,vnfName,vnfType,requestID,closedLoopAlarmStart, closedLoopControlName,closedLoopAlarmEnd,abated,nbrDmaapevents,finalFailure
209 #
210 prune {
211 whitelist_names => ["^@.*$","^topic$","^type$","^tags$","^flagFinalFailure$","^flagAbated$","^locationState$","^locationCity$","^vmName$","^vnfName$","^vnfType$","^requestID$","^closedLoopAlarmStart$","^closedLoopControlName$","^closedLoopAlarmEnd$","^target$","^target_type$","^triggerSourceName$","^policyScope$","^policyName$","^policyVersion$"]
212 }
Sylvain Desbureaux8c2a1622020-04-22 10:50:26 +0200213
ac2550a0496b02018-09-20 14:57:22 +0200214 }
ac25508ac97172018-04-18 14:23:17 +0200215 }
216}
ac2550a0496b02018-09-20 14:57:22 +0200217
218
ac25508ac97172018-04-18 14:23:17 +0200219output {
220 stdout {
221 codec => rubydebug
222 }
223
ac2550a0496b02018-09-20 14:57:22 +0200224 if "error" in [tags] {
ac25508ac97172018-04-18 14:23:17 +0200225 elasticsearch {
osgn422w87d267d2020-09-26 11:38:01 +0200226 ilm_enabled => false
ac25508ac97172018-04-18 14:23:17 +0200227 codec => "json"
osgn422w79814452020-09-25 02:28:02 +0200228{{- if .Values.global.aafEnabled }}
229 cacert => "{{ .Values.certInitializer.credsPath }}/{{ .Values.certInitializer.clamp_ca_certs_pem }}"
230{{- else }}
osgn422wb561a592020-02-11 15:50:21 +0100231 cacert => "/clamp-cert/ca-certs.pem"
osgn422w79814452020-09-25 02:28:02 +0200232{{- end }}
osgn422wb561a592020-02-11 15:50:21 +0100233 ssl_certificate_verification => false
ac25508ac97172018-04-18 14:23:17 +0200234 hosts => ["${elasticsearch_base_url}"]
osgn422w6e663e42019-08-02 11:31:11 +0200235 user => ["${logstash_user}"]
236 password => ["${logstash_pwd}"]
ac25508ac97172018-04-18 14:23:17 +0200237 index => "errors-%{+YYYY.MM.DD}"
238 doc_as_upsert => true
239 }
ac2550a0496b02018-09-20 14:57:22 +0200240
241 } else if "event-cl-aggs" in [tags] {
242 elasticsearch {
osgn422w87d267d2020-09-26 11:38:01 +0200243 ilm_enabled => false
ac2550a0496b02018-09-20 14:57:22 +0200244 codec => "json"
245 hosts => ["${elasticsearch_base_url}"]
osgn422w79814452020-09-25 02:28:02 +0200246{{- if .Values.global.aafEnabled }}
247 cacert => "{{ .Values.certInitializer.credsPath }}/{{ .Values.certInitializer.clamp_ca_certs_pem }}"
248{{- else }}
osgn422wb561a592020-02-11 15:50:21 +0100249 cacert => "/clamp-cert/ca-certs.pem"
osgn422w79814452020-09-25 02:28:02 +0200250{{- end }}
osgn422wb561a592020-02-11 15:50:21 +0100251 ssl_certificate_verification => false
osgn422w6e663e42019-08-02 11:31:11 +0200252 user => ["${logstash_user}"]
253 password => ["${logstash_pwd}"]
ac2550a0496b02018-09-20 14:57:22 +0200254 document_id => "%{requestID}"
255 index => "events-cl-%{+YYYY.MM.DD}" # creates daily indexes for control loop
256 doc_as_upsert => true
257 action => "update"
258 }
259
ac25508ac97172018-04-18 14:23:17 +0200260 } else {
261 elasticsearch {
osgn422w87d267d2020-09-26 11:38:01 +0200262 ilm_enabled => false
ac25508ac97172018-04-18 14:23:17 +0200263 codec => "json"
264 hosts => ["${elasticsearch_base_url}"]
osgn422w79814452020-09-25 02:28:02 +0200265{{- if .Values.global.aafEnabled }}
266 cacert => "{{ .Values.certInitializer.credsPath }}/{{ .Values.certInitializer.clamp_ca_certs_pem }}"
267{{- else }}
osgn422wb561a592020-02-11 15:50:21 +0100268 cacert => "/clamp-cert/ca-certs.pem"
osgn422w79814452020-09-25 02:28:02 +0200269{{- end }}
osgn422wb561a592020-02-11 15:50:21 +0100270 ssl_certificate_verification => false
osgn422w6e663e42019-08-02 11:31:11 +0200271 user => ["${logstash_user}"]
272 password => ["${logstash_pwd}"]
ac2550a0496b02018-09-20 14:57:22 +0200273 index => "events-%{+YYYY.MM.DD}" # creates daily indexes
ac25508ac97172018-04-18 14:23:17 +0200274 doc_as_upsert => true
ac25508ac97172018-04-18 14:23:17 +0200275 }
276 }
ac25508ac97172018-04-18 14:23:17 +0200277}