summaryrefslogtreecommitdiffstats
path: root/kubernetes/log/components/log-logstash/resources/config/onap-pipeline.conf
blob: b224bf31736eeb99ed41f08a2cf85bcdcf4b34cc (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
{{/*
# Copyright © 2018  AT&T, Amdocs, Bell Canada Intellectual Property.  All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#       http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
*/}}
input {
 beats {

 ## Add a id to plugin configuration. Can be anything unique.
 id => 'beats_plugin'

 ######## Connection configurations ########

 ## The port to listen on.
 port => {{.Values.service.externalPort}}

 ## Close Idle clients after the specified time in seconds. Default is 60 seconds
 #client_inactivity_timeout => 60

 ######## Security configurations ########

 ## Enable encryption. Default false.
 #ssl => $filebeat_ssl

 ## ssl certificate path.
 #ssl_certificate => $filebeat_ssl_certificate

 ## SSL key to use.
 #ssl_key => $filebeat_ssl_key

 ##SSL key passphrase to use.
 #ssl_key_passphrase => $filebeat_ssl_key_passphrase

 ## Value can be any of: none, peer, force_peer.
 #ssl_verify_mode => $filebeat_ssl_verify_mode

 ## Time in milliseconds for an incomplete ssl handshake to timeout. Default is 10000 ms.
 #ssl_handshake_timeout => 10000
 include_codec_tag => false
 }
}


filter {
  grok {
    break_on_match => false
    match => {
      "source" => ["/var/log/onap/(?<componentName>[^/]+)/",
                   "/var/log/onap/%{GREEDYDATA:componentLogFile}"
                  ]
    }
  }

 # Filter for log4j xml events
 if "</log4j:event>" in [message] {

   #mutate { add_field => { "orgmsg_log4j" => "%{message}" } }    # Copy of orginal msg for debug

   #Filter to parse xml event and retrieve data
   xml {
     source => "message"
     store_xml => false
     remove_namespaces => true
     target => "xml_content"
     xpath => [ "/event/message/text()", "logmsg" ,
                "/event/@logger", "Logger",
                "/event/@timestamp", "Timestamp",
                "/event/@level", "loglevel",
                "/event/@thread", "Thread",
                "/event/throwable/text()", "Exceptionthrowable",
                "/event/NDC/text()", "NDCs",
                "/event/properties/data/@name","mdcname",
                "/event/properties/data/@value","mdcvalue"]

    }

   #Ruby filter to iterate and separate MDCs into documents
   ruby {
     code => '
       $i = 0
       $num = 0
       if event.get("[mdcname]")
         $num = event.get("[mdcname]").length
       end
       if $num != 0
        until $i > $num do
         if event.get("[mdcname]").at($i) and event.get("[mdcvalue]").at($i)
            event.set(event.get("[mdcname]").at($i), event.get("[mdcvalue]").at($i))
         end
         $i=$i+1
        end
       end
          '
    }

   #Validations
   if [Exceptionthrowable]
   {
      mutate {
        replace => {
           "exceptionmessage" => "%{[Exceptionthrowable]}"
        }
      }
    }

   if [NDCs]
   {
      mutate {
        replace => {
          "NDC" => "%{[NDCs]}"
        }
      }
   }

   mutate {
     replace => {
        "Logger" =>"%{[Logger]}"
        "logmsg" =>"%{[logmsg]}"
        "Timestamp" =>"%{[Timestamp]}"
        "loglevel" =>"%{[loglevel]}"
        "message" => "%{logmsg}"
        "Thread" => "%{[Thread]}"
     }
     remove_field => ["mdcname", "mdcvalue", "logmsg","Exceptionthrowable","NDCs"]
   }

   if [Timestamp]
   {
     date {
        match => ["Timestamp", "UNIX_MS"]
        target => "Timestamp"
     }
   }
 }
 # Filter for logback events
 else {

  #mutate { add_field => { "orgmsg" => "%{message}" } }    # Copy of orginal msg for debug

  mutate {
    gsub => [
      'message', ' = ', '=',
      'message', '= ', '=null',
      'message', '=\t', '=null\t', #This null is followed by a tab
      'message', '\t$', '\t'
    ]
  }
  # The grok below parses the message field for all current logback patterns used by oom components.
  # Example logback pattern: %d{&quot;yyyy-MM-dd'T'HH:mm:ss.SSSXXX&quot;, UTC}|%X{RequestId}|%msg
  # Example grok pattern:    %{TIMESTAMP_ISO8601:Timestamp}\|%{UUID:RequestId}\|%{GREEDYDATA:message}
  # Use the following command to find all logback patterns in oom directory: find oom -name "logback*xml" -exec grep "property.*attern.*value" {} \;|sort|uniq
  grok {
    match => {
      "message" => [
                    "%{TIMESTAMP_ISO8601:Timestamp}\\t[%{GREEDYDATA:Thread}]\\t%{GREEDYDATA:loglevel}\\t%{JAVACLASS:Logger}\\t%{GREEDYDATA:MDCs}\\t%{GREEDYDATA:message}",
                    "%{TIMESTAMP_ISO8601:BeginTimestamp}\|%{TIMESTAMP_ISO8601:EndTimestamp}\|%{UUID:RequestId}\|%{GREEDYDATA:ServiceInstanceId}\|%{GREEDYDATA:Thread}\|%{GREEDYDATA:Unknown1}\|%{GREEDYDATA:ServiceName}\|%{GREEDYDATA:PartnerName}\|%{GREEDYDATA:TargetEntity}\|%{GREEDYDATA:TargetServiceName}\|%{GREEDYDATA:StatusCode}\|%{GREEDYDATA:ResponseCode}\|%{GREEDYDATA:ResponseDesc}\|%{UUID:InstanceUUID}\|%{GREEDYDATA:loglevel}\|%{GREEDYDATA:AlertSeverity}\|%{IP:ServerIPAddress}\|%{GREEDYDATA:Timer}\|%{HOSTNAME:ServerFQDN}\|%{IPORHOST:RemoteHost}\|%{GREEDYDATA:Unknown2}\|%{GREEDYDATA:Unknown3}\|%{GREEDYDATA:Unknown4}\|%{GREEDYDATA:TargetVirtualEntity}\|%{GREEDYDATA:Unknown5}\|%{GREEDYDATA:Unknown6}\|%{GREEDYDATA:Unknown7}\|%{GREEDYDATA:Unknown8}\|%{GREEDYDATA:message}",
                    "%{TIMESTAMP_ISO8601:BeginTimestamp}\|%{TIMESTAMP_ISO8601:EndTimestamp}\|%{UUID:RequestId}\|%{GREEDYDATA:ServiceInstanceId}\|%{GREEDYDATA:Thread}\|%{GREEDYDATA:Unknown1}\|%{GREEDYDATA:ServiceName}\|%{GREEDYDATA:PartnerName}\|%{GREEDYDATA:StatusCode}\|%{GREEDYDATA:ResponseCode}\|%{GREEDYDATA:ResponseDesc}\|%{UUID:InstanceUUID}\|%{GREEDYDATA:loglevel}\|%{GREEDYDATA:AlertSeverity}\|%{IP:ServerIPAddress}\|%{GREEDYDATA:Timer}\|%{HOSTNAME:ServerFQDN}\|%{IPORHOST:RemoteHost}\|%{GREEDYDATA:Unknown2}\|%{GREEDYDATA:Unknown3}\|%{GREEDYDATA:Unknown4}\|%{GREEDYDATA:Unknown5}\|%{GREEDYDATA:Unknown6}\|%{GREEDYDATA:Unknown7}\|%{GREEDYDATA:Unknown8}\|%{GREEDYDATA:message}",
                    "%{TIMESTAMP_ISO8601:Timestamp}\|%{UUID:RequestId}\|%{GREEDYDATA:ServiceInstanceId}\|%{GREEDYDATA:Thread}\|%{GREEDYDATA:ServiceName}\|%{UUID:InstanceUUID}\|%{GREEDYDATA:loglevel}\|%{GREEDYDATA:AlertSeverity}\|%{IP:ServerIPAddress}\|%{HOSTNAME:ServerFQDN}\|%{IPORHOST:RemoteHost}\|%{GREEDYDATA:Timer}\|\[%{GREEDYDATA:caller}\]\|%{GREEDYDATA:message}",
                    "%{TIMESTAMP_ISO8601:Timestamp}\|%{GREEDYDATA:RequestId}\|%{GREEDYDATA:Thread}\|%{GREEDYDATA:ServiceName}\|%{GREEDYDATA:PartnerName}\|%{GREEDYDATA:TargetEntity}\|%{GREEDYDATA:TargetServiceName}\|%{GREEDYDATA:loglevel}\|%{GREEDYDATA:ErrorCode}\|%{GREEDYDATA:ErrorDesc}\|%{GREEDYDATA:message}",
                    "%{TIMESTAMP_ISO8601:Timestamp}\|%{GREEDYDATA:RequestId}\|%{GREEDYDATA:Thread}\|%{GREEDYDATA:ClassName}\|%{GREEDYDATA:message}",
                    "%{TIMESTAMP_ISO8601:Timestamp}\|%{UUID:RequestId}\|%{GREEDYDATA:message}",
                    "\[%{TIMESTAMP_ISO8601:Timestamp}\|%{LOGLEVEL:loglevel}\|%{GREEDYDATA:Logger}\|%{GREEDYDATA:Thread}\] %{GREEDYDATA:message}"
      ]
    }
    overwrite => ["message"]
  }
  # The MDCs are key value pairs that are seperated by "," or "\t". Extra space characters are trimmed from the keys and values.
  kv {
    source => "MDCs"
    field_split => ",\t"
    trim_key => "\s"
    trim_value => "\s"
    remove_field => [ "MDCs" ]
  }

  if (![Timestamp] and [EndTimestamp]) {
    mutate { add_field => { "Timestamp" => "%{EndTimestamp}" } }
  }
  date {
    match => [ "Timestamp", "ISO8601", "yyyy-MM-dd HH:mm:ss,SSS" ]
    target => "Timestamp"
  }

  mutate {
    remove_field => ["DuplicateRequestID", "Unknown1", "Unknown2", "Unknown3", "Unknown4", "Unknown5", "Unknown6", "Unknown7", "Unknown8"]
  }

  if ([source] == "/var/log/onap/sdc/sdc-be/audit.log") {
    #Parse kvps in message
    kv {
      field_split => "\s"
      trim_key => "\s"
      trim_value => "\s"
    }

    #If Request Id is missing and DID is present use as RequestId
    if (![RequestId] and [DID] =~ /.+/) {
      mutate { add_field => { "RequestId" => "%{DID}" } }
    }
  }

 } #Close else statement for logback events
} #Close filter


output {
 elasticsearch {
 id => 'onap_es'

 ######### Security configurations #########

 user => "elastic"
 password => "changeme"

 ## The .cer or .pem file to validate the server's certificate
 #cacert => $es_cacert

 ## The keystore used to present a certificate to the server. It can be either .jks or .p12
 #keystore => $es_keystore
 #keystore_password => $es_keystore_password

 ## Enable SSL/TLS secured communication to Elasticsearch cluster.
 ## Default is not set which in that case depends on the protocol specidfied in hosts list
 #ssl => $es_ssl

 ## Option to validate the server's certificate. Default is true
 #ssl_certificate_verification => $es_ssl_certificate_verification

 ## The JKS truststore to validate the server's certificate.
 #truststore => $es_truststore
 #truststore_password => $es_truststore_password


 ######### Elasticsearchcluster and host configurations #########

 ##can specify one or a list of hosts. If sniffing is set, one is enough and others will be auto-discovered
 hosts => ["http://{{.Values.config.elasticsearchServiceName}}.{{.Release.Namespace}}:{{.Values.config.elasticsearchPort}}"]


 ## This setting asks Elasticsearch for the list of all cluster nodes and adds them to the hosts list. Default is false.
 sniffing => true

 ## How long to wait, in seconds, between sniffing attempts. Default is 5 seconds.
 #sniffing_delay => 5

 ## Set the address of a forward HTTP proxy.
 #proxy => $es_proxy

 ##Use this if you must run Elasticsearch behind a proxy that remaps the root path for the Elasticsearch HTTP API lives
 #path => $es_path

 ######### Elasticsearch request configurations #########

 ## This setting defines the maximum sized bulk request Logstash will make.
 #flush_size => ?

 ######### Document configurations #########

 index => "logstash-%{+YYYY.MM.dd}"
 document_type => "logs"

 ## This can be used to associate child documents with a parent using the parent ID.
 #parent => "abcd'
 }
}