filebeat使用笔记
安装filebeat
cd /usr/local/ wget https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-6.1.3-linux-x86_64.tar.gz tar axf filebeat-6.1.3-linux-x86_64.tar.gz cd filebeat-6.1.3-linux-x86_64 ln -s /usr/local/filebeat-6.1.3-linux-x86_64/filebeat /usr/local/bin/ |
加载es中的index模板
filebeat setup --template -E output.logstash.enabled=false -E 'output.elasticsearch.hosts=["192.168.3.161:9400"]' |
配置filebeat
将日志写入elasticsearch
先对原文件进行备份
cp filebeat.yml{,.bak} |
编辑配置文件
vim filebeat.yml |
filebeat.prospectors: - type: log enabled: true paths: - /var/log/*.log #"忽略匹配的行,[^]表示非,['^INFO']只匹配INFO行,其他忽略" # exclude_lines: ['^INFO'] #"标签,用于过滤" tags: ["var-log"] - type: log enabled: true paths: - /usr/local/elasticsearch-6-node1/logs/*.log #"匹配包含的行,默认所有" # include_lines: ['^ERR', '^WARN'] tags: ["es-node1-log"] - type: log enabled: true paths: - /usr/local/elasticsearch-6-node3/logs/* #"排除的文件" exclude_files: ['\.gz$'] tags: ["es-node3-log"] output.elasticsearch: hosts: ["192.168.3.162:9200"] |
测试配置文件
filebeat test config |
启动
filebeat -e -c filebeat.yml -d "publish" |
线上启动
nohup filebeat -e -c filebeat.yml -d "publish" 2&>filebeat.log & |
kibana中使用tags过滤信息
创建index。。。
设置时间范围。。。
添加过滤器
参考文档:https://www.elastic.co/guide/en/beats/filebeat/current/index.html
input配置参考:https://www.elastic.co/guide/en/beats/filebeat/current/configuration-filebeat-options.html#configuration-filebeat-options
转载于:https://blog.51cto.com/13323775/2068979