divyadesai | ca035d1 | 2020-08-13 13:02:50 +0000 | [diff] [blame] | 1 | # Copyright (c) 2020 Open Networking Foundation |
| 2 | # |
| 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: |
| 6 | # |
| 7 | # http:#www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 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. |
| 14 | |
| 15 | # input plugin to collect openolt logs |
| 16 | # formating the input logs using regex and creating a feilds such as level, instanceId, caller and msg. |
| 17 | <source> |
| 18 | @id openolt.log |
| 19 | @type tail |
| 20 | path /var/log/openolt.log |
| 21 | pos_file /var/log/td-agent/openolt.log.pos |
| 22 | read_from_head true |
| 23 | tag openolt |
| 24 | <parse> |
| 25 | @type multiline |
| 26 | format_firstline /\[(\d+)(.\s+)(?<level>\w+)(?<instanceId>[\s]\w+)(\s+)\](?<caller>.\w+...\s\d+)(.\s)/ |
| 27 | format1 /\[(\d+)(.\s+)(?<level>\w+)(?<instanceId>[\s]\w+)(\s+)\](?<caller>.\w+...\s\d+)(.\s)(?<msg>.*)/ |
| 28 | </parse> |
| 29 | </source> |
| 30 | |
| 31 | # Formating the `instanceId` field by concating with the device `Ip Address`. |
| 32 | # For example: If the extracted value for the field 'instanceId' is `OPENOLT` and `Ip` of the device is `192.x.x.x` after concating the |
| 33 | # `instanceId` will be "OPENOLT-192.x.x.x" |
| 34 | # The log levels which are coming in the logs are like 'I', 'E' etc so replacing the log level 'I' to 'info', 'W' to 'warn' and 'E' to 'error' |
| 35 | <filter openolt.**> |
| 36 | @type record_transformer |
| 37 | enable_ruby true |
| 38 | <record> |
| 39 | instanceId ${record["instanceId"]}-${"#{(Socket.ip_address_list.detect do |intf| intf.ipv4_private? end).ip_address}"} |
| 40 | level ${if record['level'] == 'I' then 'info' elsif record['level'] == 'W' then 'warn' else 'error'; end} |
| 41 | </record> |
| 42 | </filter> |
| 43 | |
| 44 | # input plugin to collect dev_mgmt_daemon logs |
| 45 | # formating the input logs using regex and creating a feilds such as level, instanceId, caller and msg. |
| 46 | <source> |
| 47 | @id dev_mgmt_daemon.log |
| 48 | @type tail |
| 49 | path /var/log/dev_mgmt_daemon.log |
| 50 | pos_file /var/log/td-agent/dev_mgmt_daemon.log.pos |
| 51 | tag dev_mgmt |
| 52 | read_from_head true |
| 53 | <parse> |
| 54 | @type multiline |
| 55 | format_firstline /\[(\d+)(.\s+)(?<level>\w+)(?<instanceId>[\s]\w+)(\s+)\](?<caller>.\w+...\s\d+)(.\s)/ |
| 56 | format1 /\[(\d+)(.\s+)(?<level>\w+)(?<instanceId>[\s]\w+)(\s+)\](?<caller>.\w+...\s\d+)(.\s)(?<msg>.*)/ |
| 57 | </parse> |
| 58 | </source> |
| 59 | |
| 60 | # Formating the `instanceId` field by concating with the device `Ip Address`. |
| 61 | # For example: If the extracted value for the field 'instanceId' is `SW_UTIL` and `Ip` of the device is `192.x.x.x` after concating the |
| 62 | # `instanceId` will be "SW_UTIL-192.x.x.x" |
| 63 | # The log levels which are coming in the logs are like 'I', 'E' etc so replacing the log level 'I' to 'info', 'W' to 'warn' and 'E' to 'error' |
| 64 | <filter dev_mgmt.**> |
| 65 | @type record_transformer |
| 66 | enable_ruby true |
| 67 | <record> |
| 68 | instanceId ${record["instanceId"]}-${"#{(Socket.ip_address_list.detect do |intf| intf.ipv4_private? end).ip_address}"} |
| 69 | level ${if record['level'] == 'I' then 'info' elsif record['level'] == 'W' then 'warn' else 'error'; end} |
| 70 | </record> |
| 71 | </filter> |
| 72 | |
| 73 | # input plugin to collect system logs |
| 74 | # formating the input logs using regex and creating a feilds such as host, caller and msg. |
| 75 | <source> |
| 76 | @type syslog |
| 77 | port 42185 |
| 78 | tag system |
| 79 | format /(.*\S \d{1,2}:\d{1,2}:\d{1,2}.)(?<host>[^\s]\w+) (?<caller>[^\s][^:]+)(.)(?<msg>.*)/ |
| 80 | </source> |
| 81 | |
| 82 | <filter **> |
| 83 | @type stdout |
| 84 | </filter> |
| 85 | |
| 86 | # Output elasticsearch plugin |
| 87 | # provide host and port of elasticsearch |
| 88 | <match **> |
| 89 | @id elasticsearch |
| 90 | @type elasticsearch |
| 91 | @log_level info |
| 92 | include_tag_key true |
| 93 | host localhost |
| 94 | port 9200 |
| 95 | scheme http |
| 96 | ssl_verify false |
| 97 | logstash_format true |
| 98 | reconnect_on_error true |
| 99 | reload_on_failure false |
| 100 | reload_connections false |
| 101 | <buffer> |
| 102 | @type file |
| 103 | path /var/log/td-agent/buffer/elasticsearch |
| 104 | flush_mode interval |
| 105 | retry_type exponential_backoff |
| 106 | flush_thread_count 8 |
| 107 | flush_interval 5s |
| 108 | retry_max_interval 30 |
| 109 | chunk_limit_size 32MB |
| 110 | queue_limit_length 8 |
| 111 | overflow_action block |
| 112 | </buffer> |
| 113 | </match> |