filebeatde的安装,读取文件写入到ElasticSearch(es)
前置条件:
确保ES和fileBeat的版本是一致的,我们本次使用的版本是7.16.2,filebeat的下载地址:https://www.elastic.co/cn/downloads/beats/filebeat
选择下载版本 7.16.2
下载到本地并且 解压到本地:接下来我们修改一下filebeat.yml文件
增加如下内容,读取本地路径的log文件 并且输入到es里面,前置条件必须已经安装过es 并且启动起来
该文件里面的内容 copy后的文件:
# ============================== Filebeat inputs ===============================
filebeat.inputs:
- type: log #默认是log 从日志文件读取每一行 stdin 从标准输入读取
enabled: true
paths: ## 日志存储的地址
- C:\Users\junnan.lang\log\logs\filebeat.log
multiline.pattern: '^\d{4}\-\d{2}\-\d{2}\s\d{2}:\d{2}:\d{2}' #匹配的正则 不是以2019-09-08 12:23:23 格式开头的将合并到上一行
multiline.negate: true #多行匹配模式后配置的模式是否取反,默认false
multiline.match: after #定义多行内容被添加到模式匹配行之后还是之前,默认无,可以被设置为after或者before
fields:
index: 'filebeat'
# ---------------------------- Elasticsearch Output ----------------------------
output.elasticsearch:
# Array of hosts to connect to.
hosts: ["127.0.0.1:9200"] #本次es的地址和端口
indices:
- index: "filebeat-%{+yyyy.MM.dd}" #索引名 按照日期
when.contains:
fields:
index: "filebeat"
保存文件后,我们从cmd命令窗口进入 ,并且启动 filebeat的服务
命令如下: