Beats 是用于数据采集使用,通常用于 日志文件, 指标,网络数据, windows事件日志,审计数据,运行事件监控,无需服务器的采集器。
1)filebeat,轻量级日志采集器。
1.写入一个itcast.yml文件
filebeat.inputs: //inputs filebeat的输入
- type: stdin //一个标准输入的类型
enabled: true //启用
paths: /xxx/xxx //读取文件内容路径
tags: ["",""] //添加变量
fields:
from: test_web //fields添加字段,from字段的名称,test_web字段值。默认添加再子节点
fields_unber_root: true //true 为添加到根节点,false为添加到子节点
setup.template.settings:
index.number_of_shards: 3
output.console: //输出在 console
pretty: true //美化
enable: true //启用
output.elasticsearch:
host:["",""]
setup.kibana:
host["",""]
2. ./filebeat -e -c itcast.yeml (-e 标准启动 ,-c 指定位置 -d 输出debug的信息) 启动。
-d: 可在控制台打印debug的相关信息
Filebeat工作原理
Filebeat由两个主要组件组成:prospector (探索者) 和 harcester(收割者)
prospector: 负责管理harvester并找到所有的读取文件来源,如果输入类型为日志,则查找器将查找路径匹配的所有文件,并为每个文件启动一个harvester。Filebeat目前支持两种prospector类型:log 和 stdin。
文件状态记录在: data/registry 文件中
./filebeat modules list 查看有多少模型,例如nginx
1)启动模型 ./filebeat modules enable nginx
2)禁用模型 ./filebeat modules disable nginx
在itcast.yml 中配置
filebeat.config.modules
path: ${path.config}/modules.d/*.yml
reload.enabled: false
Metricbeat: 不同与filebeat是采取文本数据,而Metricbeat采取指标数据
例如:CPU 的运行情况,IO 的运行情况,内存的运行情况,等等。
安装仪表盘:./filebeat -c itcast-nginx.yml setup