标签:puts last dock hosts orm ica pipe sha usr
想用filebeat读取项目的日志,然后发送logstash。logstash官网有相关的教程,但是docker部署的教程都太简洁了。自己折腾了半天,走了不少坑,总算是将logstash和filebeat用docker部署好了,这儿简单记录一下
1. 编写logstash配置文件logstasgh.conf
输入是从filebeat中获取的,输出配置的是一个http端
input { beats { port => "5044" } } # The filter part of this file is commented out to indicate that it is # optional. # filter { # # } output { http { http_method => "post" url => "http://127.0.0.1/log" format => "json" } stdout { codec => rubydebug } }
2. 获取logstash的docker镜像
docker pull docker.elastic.co/logstash/logstash:7.1.1
3. 通过dokcer启动logstash
docker run -p 5044:5044 --name logstash -d -v /path/to/logstash.conf:/usr/share/logstash/pipeline/logstash.conf docker.elastic.co/logstash/logstash:7.1.1
1. 编写filebeat的配置文件filebeat.yml
filebeat.inputs: - type: log paths: # 容器内的路径,可以不用修改,映射到这个路径就可以 - /val/log/ fields: # 额外添加的字段 project-name: your_project_name # 需要排除和包括的行(正则表达式) exclude_lines: [‘INFO‘] include_lines: [‘ERROR‘] # 这个是用来处理异常产生多行数据时,将多行数据当作一条日志处理,根据自己的异常日志的格式做修改 multiline.pattern: ‘^\[‘ multiline.negate: true multiline.match: after ignore_older: 168h tail_files: true output.logstash: hosts: ["127.0.0.1:5044"]
2. 获取filebeat的docker镜像
docker pull docker.elastic.co/beats/filebeat:7.1.1
3. 通过dokcer启动filebeat
docker run --name filebeat -d -v /path/to/:/var/log/:ro -v /path/to/filebeat.yml:/usr/share/filebeat/filebeat.yml docker.elastic.co/beats/filebeat:7.1.1
标签:puts last dock hosts orm ica pipe sha usr
原文地址:https://www.cnblogs.com/time-read/p/10981731.html