Seed of deployment of log components
[oom.git] / kubernetes / log / resources / logstash / pipeline / onap-pipeline.conf
1 input {
2  beats {
3
4  ## Add a id to plugin configuration. Can be anything unique.
5  id => 'beats_plugin'
6
7  ######## Connection configurations ########
8
9  ## The port to listen on.
10  port => 5044
11
12  ## Close Idle clients after the specified time in seconds. Default is 60 seconds
13  #client_inactivity_timeout => 60
14
15  ######## Security configurations ########
16
17  ## Enable encryption. Default false.
18  #ssl => $filebeat_ssl
19
20  ## ssl certificate path.
21  #ssl_certificate => $filebeat_ssl_certificate
22
23  ## SSL key to use.
24  #ssl_key => $filebeat_ssl_key
25
26  ##SSL key passphrase to use.
27  #ssl_key_passphrase => $filebeat_ssl_key_passphrase
28
29  ## Value can be any of: none, peer, force_peer.
30  #ssl_verify_mode => $filebeat_ssl_verify_mode
31
32  ## Time in milliseconds for an incomplete ssl handshake to timeout. Default is 10000 ms.
33  #ssl_handshake_timeout => 10000
34  include_codec_tag => false
35  }
36 }
37
38
39 filter {
40  # Filter for log4j xml events
41  if "</log4j:event>" in [message] {
42    #Filter to parse xml event and retrieve data
43    xml {
44      source => "message"
45      store_xml => false
46      remove_namespaces => true
47      target => "xml_content"
48      xpath => [ "/event/message/text()", "logmsg" ,
49                 "/event/@logger", "Logger",
50                 "/event/@timestamp", "Timestamp",
51                 "/event/@level", "loglevel",
52                 "/event/@thread", "Thread",
53                 "/event/throwable/text()", "Exceptionthrowable",
54                 "/event/NDC/text()", "NDCs",
55                 "/event/properties/data/@name","mdcname",
56                 "/event/properties/data/@value","mdcvalue"]
57
58     }
59
60    #Ruby filter to iterate and separate MDCs into documents
61    ruby {
62      code => '
63        $i = 0
64        $num = 0
65        if event.get("[mdcname]")
66          $num = event.get("[mdcname]").length
67        end
68            if $num != 0
69         until $i > $num do
70          if event.get("[mdcname]").at($i) and event.get("[mdcvalue]").at($i)
71             event.set(event.get("[mdcname]").at($i), event.get("[mdcvalue]").at($i))
72          end
73          $i=$i+1
74         end
75            end
76           '
77     }
78
79    #Validations
80    if [Exceptionthrowable]
81    {
82       mutate {
83         replace => {
84            "exceptionmessage" => "%{[Exceptionthrowable]}"
85         }
86       }
87     }
88
89    if [NDCs]
90    {
91       mutate {
92         replace => {
93           "NDC" => "%{[NDCs]}"
94         }
95       }
96    }
97
98    mutate {
99      replace => {
100         "Logger" =>"%{[Logger]}"
101         "logmsg" =>"%{[logmsg]}"
102         "Timestamp" =>"%{[Timestamp]}"
103         "loglevel" =>"%{[loglevel]}"
104         "message" => "%{logmsg}"
105         "Thread" => "%{[Thread]}"
106      }
107      remove_field => ["mdcname", "mdcvalue", "logmsg","Exceptionthrowable","NDCs"]
108    }
109
110    if [Timestamp]
111    {
112      date {
113         match => ["Timestamp", "UNIX_MS"]
114         target => "Timestamp"
115      }
116    }
117  }
118  # Filter for logback events
119  else {
120   mutate {
121     gsub => [
122       'message', '= ', '=null',
123       'message', '=\t', '=null  ', #This null is followed by a tab
124       'message', '\t$', '\t'
125     ]
126   }
127   kv {
128     field_split => "\t"
129     trim_key => "\s"
130     trim_value => "\s"
131   }
132   grok {
133     break_on_match => false
134     match => {
135       "message" => "%{TIMESTAMP_ISO8601:Timestamp}\t%{GREEDYDATA:Thread}\t%{SPACE}%{LOGLEVEL:loglevel}%{SPACE}\t%{JAVACLASS:Logger}\t(?:[^\t]+\t)*%{GREEDYDATA:message}"
136     }
137     overwrite => ["message"]
138   }
139  }
140 }
141
142
143 output {
144  elasticsearch {
145  id => 'onap_es'
146
147  ######### Security configurations #########
148
149  user => "elastic"
150  password => "changeme"
151
152  ## The .cer or .pem file to validate the server’s certificate
153  #cacert => $es_cacert
154
155  ## The keystore used to present a certificate to the server. It can be either .jks or .p12
156  #keystore => $es_keystore
157  #keystore_password => $es_keystore_password
158
159  ## Enable SSL/TLS secured communication to Elasticsearch cluster.
160  ## Default is not set which in that case depends on the protocol specidfied in hosts list
161  #ssl => $es_ssl
162
163  ## Option to validate the server’s certificate. Default is true
164  #ssl_certificate_verification => $es_ssl_certificate_verification
165
166  ## The JKS truststore to validate the server’s certificate.
167  #truststore => $es_truststore
168  #truststore_password => $es_truststore_password
169
170
171  ######### Elasticsearchcluster and host configurations #########
172
173 #can specify one or a list of hosts. If sniffing is set, one is enough and others will be auto-discovered
174 ##Also protocol can be specified like ["http://10.247.186.12:9200"]
175  hosts => ["http://elasticsearch.onap-log:9200"]
176
177
178  ## This setting asks Elasticsearch for the list of all cluster nodes and adds them to the hosts list. Default is false.
179  sniffing => true
180
181  ## How long to wait, in seconds, between sniffing attempts. Default is 5 seconds.
182  #sniffing_delay => 5
183
184  ## Set the address of a forward HTTP proxy.
185  #proxy => $es_proxy
186
187  ##Use this if you must run Elasticsearch behind a proxy that remaps the root path for the Elasticsearch HTTP API lives
188  #path => $es_path
189
190  ######### Elasticsearch request configurations #########
191
192  ## This setting defines the maximum sized bulk request Logstash will make.
193  #flush_size => ?
194
195  ######### Document configurations #########
196
197  index => "onaplogs-%{+YYYY.MM.dd}"
198  document_type => "logs"
199
200  ## This can be used to associate child documents with a parent using the parent ID.
201  #parent => "abcd'
202  }
203 }
204