ELK-FileBeat入门
前言
filebeat是logstash轻量级版,功能相对比nxlog全很多,
介绍了windows上配置采集日志功能。
filebeat启动时随机开启一个端口使用。
如果安装了kibana,可访问http://192.168.1.238:5601/app/kibana#/home/tutorial/redisLogs?_g=()这上面有不同种类应用使用filebeat追踪日志方式。
windows上安装filebeat
Elastic中文官网,基本上下载速度很慢,毕竟跨越国家了。
从我的网盘下载elastcsearch6.5.4,提取码:naqy
下载filebeat-6.5.4-windows-x86_64.zip并解压。
由于安装成服务必需使用powershell,而我的filebeat需要放到windows server 2006上,所以这里先以命令行方式启动:
启动方式:filebeat.exe -e -c filebeat.yml
注册成服务,在powershell(win+x快捷键打开的powershell)里执行命令:PowerShell.exe -ExecutionPolicy UnRestricted -File .\install-service-filebeat.ps1
配置
配置文件是filebeat.yml。
filebeat.inputs是输入端数组,里面可以写多个,
output.xxx(比如output.logstash、output.elasticsearch),只能写一个。
也就是说,多个输入端对应一个输出端,输入端类似可以通过fields里自定义属性区分,注意6xxx版本已经没有document_type配置了。网上还有人写,注意区分。
下面给出一个采集log日志并输出到logstash的配置
filebeat.inputs:
- type: log
enabled: true
paths:
- D:\jar\dongli\logs\spring-boot.log
multiline:
pattern: '^\d{4}-\d{1,2}-\d{1,2}'
negate: true
match: after
fields:
appname: dongli
#============================= Filebeat modules ===============================
filebeat.config.modules:
path: ${path.config}/modules.d/*.yml
reload.enabled: false
#reload.period: 10s
#==================== Elasticsearch template setting ==========================
setup.template.settings:
index.number_of_shards: 3
#index.codec: best_compression
#_source.enabled: false
setup.kibana:
# Kibana Host
# Scheme and port can be left out and will be set to the default (http and 5601)
# In case you specify and additional path, the scheme is required: http://localhost:5601/path
# IPv6 addresses should always be defined as: https://[2001:db8::1]:5601
#host: "localhost:5601"
# Kibana Space ID
# ID of the Kibana Space into which the dashboards should be loaded. By default,
# the Default Space will be used.
#space.id:
#----------------------------- Logstash output --------------------------------
output.logstash:
hosts: ["192.168.1.238:515"]
#================================ Procesors =====================================
processors:
- add_host_metadata: ~
- add_cloud_metadata: ~
配置具体字段意思这里不表。
授之以鱼不如授之以渔
输入端配置
支持的输入端。
filebeat.inputs可支持的配置如下:
- log
- stdin
- redis
- udp
- tcp
- docker
- syslog
其中log,redis,tcp相对来说比较常用。
想配置哪种只要相应的从上面找即可。