Filebeat7.2.1環境搭建

Filebeat7.2.1環境搭建

 

1 filebeat.yml配置文件

1】輸出到logstash

 filebeat.inputs:
 - type: log
   enabled: true
   paths:
     - /app/nginx/logs/access.log
   fields:
     log_source: next-sfpay-core-nginx-access
   multiline.pattern: '^[0-9]{2}-[0-9]{2}'
   multiline.negate: true
   multiline.match: after    
    
 filebeat.config.modules:
   path: ${path.config}/modules.d/*.yml
   reload.enabled: false
 setup.template.settings:
   index.number_of_shards: 1
 output.logstash:
   hosts: ["192.168.1.21:5044"]
 processors:
   - add_host_metadata: ~
   - add_cloud_metadata: ~

 

2】輸出到elasticsearch

 filebeat.inputs:
 - type: log
   enabled: true
   paths:
     - /home/appdeploy/stdout_20200113.21.log
   tags: ["test"]
   multiline.pattern: '^[0-9]{2}-[0-9]{2}'
   multiline.negate: true
   multiline.match: after
   
 filebeat.config.modules:
   path: ${path.config}/modules.d/*.yml
   reload.enabled: false
 setup.template.settings:
   index.number_of_shards: 1
 processors:
   - add_host_metadata: ~
   - add_cloud_metadata: ~
 ​
 output.elasticsearch:
   hosts: ["http://10.110.39.241:9200"]
   index: "test-%{+yyyy.MM.dd}"
 setup.template.name: "test"
 setup.template.pattern: "test-*"
 setup.ilm.enabled: false

 

3】輸出到kafka

 output.kafka:
   hosts: ["10.216.23.13:9092", "10.216.23.14:9092", "10.216.23.15:9092"]
   topic: 'test'
   partition.round_robin:
     reachable_only: false
   required_acks: 1
   compression: gzip
   max_message_bytes: 1000000

 

 

 

 

 multiline.pattern:指定要匹配的正則表達式模式
 multiline.negate:定義是否否定模式。默認值爲false。
 multiline.match:指定Filebeat如何將匹配的行組合到事件中,設置爲after或before。
 ​
 # 不以日期開頭(如:2017-02-14)的行都合併到上一行的末尾
 multiline.pattern: '^[0-9]{4}-[0-9]{2}-[0-9]{2}'
 multiline.negate: true
 multiline.match: after
 ​
 # 不以[開頭的行都合併到上一行的末尾
 multiline.pattern: '^\['
 multiline.negate: true
 multiline.match: after 

 

 # 多個輸入路徑文件
 filebeat.inputs:
 - type: log
   paths:
     - /var/log/*.log
     - /var/path2/*.log

 

 # include_lines包含行,exclude_lines排除行
 ​
 ​
 filebeat.inputs:
 - type: log
   ...
   exclude_lines: ['^DBG']
 ​
 filebeat.inputs:
 - type: log
   ...
   include_lines: ['^ERR', '^WARN']

 

 

 

2 實例啓動/關閉

 cd /app/deploy/filebeat/
 chmod 755 filebeat
  
 # 啓動
 nohup /app/filebeat/filebeat -e -c /app/filebeat/filebeat.yml &
  
 # 關閉
 ps -ef|grep filebeat|awk '{print $2}'|xargs kill -9

 

3 filebeat監控

默認端口:16900

 ps -ef|grep filebeat
  
 netstat -nap|grep PID
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章