ELK-FileBeat入门

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: ~


配置具体字段意思这里不表。

授之以鱼不如授之以渔

filebeats的文档

输入端配置

支持的输入端
filebeat.inputs可支持的配置如下:

  1. log
  2. stdin
  3. redis
  4. udp
  5. tcp
  6. docker
  7. syslog
    其中log,redis,tcp相对来说比较常用。
    想配置哪种只要相应的从上面找即可。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值