filebeat发送日志到logstash转发到elasticearch的日志收集

测试通过filebeat发送日志到logstash转发到elasticearch的日志收集

logstash下载

安装包https://www.elastic.co/cn/downloads/logstash

grok匹配

一个空格都不能多严格匹配
在线工具:https://www.5axxw.com/tools/v2/grok.html#google_vignette
本地环境kibana:http://192.168.1.4:5601/app/dev_tools#/grokdebugger
在这里插入图片描述

示例:

bin/logstash -f job/nginx3.conf
# 文本1
== 127.0.0.1 - frank [10/Oct/2000:13:55:36 -0700] "GET /apache_pb.gif HTTP/1.0" 200 2326
# 规则1
\=\= %{IP:client_ip} \- %{USER:remote_user} \[%{HTTPDATE:timestamp}\] \"%{WORD:method} %{URIPATHPARAM:request_path} HTTP/%{NUMBER:http_version}\" %{NUMBER:response_code} %{NUMBER:response_bytes}

nginx3.conf

input {
  beats {
    port=>5044
    codec=>plain{
        charset=>"GBK"
    }
  }
}
filter {
  grok {
    match => {
       "message" => "\=\= %{IP:client_ip} \- %{USER:remote_user} \[%{HTTPDATE:timestamp}\] \"%{WORD:method} %{URIPATHPARAM:request_path} HTTP/%{NUMBER:http_version}\" %{NUMBER:response_code} %{NUMBER:response_bytes}"
    }
  }
  date {
    match => [ "timestamp", "MMM dd yyyy HH:mm:ss" ]
  }
}
output {
  stdout {
    codec => rubydebug
  }
}

filebeat

cd /Users/yyyyjinying/sortware/filebeat-8.5.2
./filebeat -e -c a.yml

a.yml

filebeat.inputs:
- type: log 
  paths:
    - "/Users/yyyyjinying/sortware/testfile/*.log"
  enabled: true
  fields:
    zjynamestatus: true
  fields_under_root: true
  multiline.type: pattern
  multiline.pattern: '^\=\='
  multiline.negate: true
  multiline.match: after
setup.template.settings:
  index.number_of_shards: 1

output.logstash:
  hosts: ["localhost:5044"]
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值