ELK实践(二):基础入门 -filebeat安装

为了让测试简单,我们手动模拟日志的生成:

echo "test - test2" >> /tmp/test1.log
echo "test - test2" >> /tmp/test2.log

生成了2个日志文件test1.log、test2.log,各有一行日志。

新建一个filebeat配置文件:

cd /usr/local/elk

vim beats/filebeat/filebeat.test.yml

配置内容:

# filebeat.test.yml
filebeat.inputs:
- type: log
  paths:
    - /tmp/test1.log
  tags: ["test1"]
  document_type: test1

- type: log
  paths:
    - /tmp/test2.log
  tags: ["test2"]
  document_type: test2

output.elasticsearch:
  hosts: ["127.0.0.1:9200"]
  index: "test-filebeat"

配置说明:

filebeat.inputs:

type 日志类型,默认log
input_type 输入类型,默认log
paths 采集的日志,可以使用通配符。支持多个
tags 自定义标签,是个数组。自定义
document_type 自定义字段,用于Logsatsh区分来源,在Logsatsh里用变量type表示
一个-表示一个filebeat.prospector,这里设置了2个。日志发送到elasticsearch,索引index 是test-filebeat。

检查es是否正常:
创建customer 索引
curl -u elastic:changeme  -XPUT 'localhost:9200/customer?pretty'
运行配置文件
filebeat -c filebeat.yml  -e
自定义索引

难点:

setup.ilm.enabled: false 在7.4版本中,需要把ilm这个设置关闭掉,才能自定义索引
参考:
详细配置:https://www.cnblogs.com/cjsblog/p/9495024.html
自定义索引:https://www.cnblogs.com/lemon-le/p/11932813.html

posted @ 2020-10-13 12:44  鲁哒哒  阅读(181)  评论(0编辑  收藏  举报