filebeat7.0安装和基本使用

1 filebeat概述

1.1 EFK日志采集架构图

filebeat实现日志采集架构图:

在这里插入图片描述

1.2 filebeat概述

filebeat知识众多beat中的其中一个,elastic还有很多的beat

在这里插入图片描述

1.3 filebeat下载

filebeat7-17-5下载,安装:dpki -i 包名

1.4 filebeat架构

  • input,数据从哪来
  • output,数据到哪去

在这里插入图片描述

2 filebeat基本数据流采集方式

01 stdin --> stdout

1.输入端为stdin,也就是采集终端上显示的内容,配置文件如下

cat > 01-stdin-to-stdout.yaml <<EOF
filebeat.inputs:
  # 从当前终端采集
- type: stdin

# 输出到终端
output.console:
  # 以漂亮格式输出
  pretty: true
EOF

2.执行该配置文件,==注意:==filebeat默认从 /etc/filebeat/获取配置文件,因此执行时要采用绝对路径,或则把配置文件放到 /etc/filebeat/

[root@elk93filebeat]# filebeat -e -c 01-stdin-to-stdout.yaml 
Exiting: error loading config file: stat /etc/filebeat/01-stdin-to-stdout.yaml: no such file or directory

3.在当前linux终端输入任意字符,最后就会输出了

filebeat -e -c `pwd`/01-stdin-to-stdout.yaml
// 在终端输意任意字符

{
  "@timestamp": "2024-11-16T11:07:57.854Z",
  "@metadata": {
    "beat": "filebeat",
    "type": "_doc",
    "version": "7.17.22"
  },
  "log": {
    "offset": 0,
    "file": {
      "path": ""
    }
  },
  "message": "wzy luckboy",
  "input": {
    "type": "stdin"
  },
  "ecs": {
    "version": "1.12.0"
  },
  "host": {
    "name": "elk93"
  },
  "agent": {
    "id": "62413f83-90ff-4adc-ba6a-08881508e2d7",
    "name": "elk93",
    "type": "filebeat",
    "version": "7.17.22",
    "hostname": "elk93",
    "ephemeral_id": "d524ac62-52f6-4817-bb7a-21d7b91ec306"
  }
}

02 stdin --> ES

1.执行该配置,并在终端上输入任意字符

cat >02-stdin-to-es.yaml <<EOF
filebeat.inputs:
- type: stdin

output.elasticsearch:
  hosts: ["http://10.0.0.91:9200","http://10.0.0.92:9200","http://10.0.0.93:9200"] 
EOF

2.然后ES就会多出这么一条 filebeat + 时间 - 索引编号 命名的索引

在这里插入图片描述

3.去创建索引模式查看filebeat传输的数据

在这里插入图片描述

4.输入的字段叫 message

在这里插入图片描述

5.其实filebeat还默认设置了其他的一些字段,如时间,主机名,…

在这里插入图片描述

03 TCP数据流 --> ES

1.输入端为TCP

cat > 03-tcp-to-es.yaml <<EOF
filebeat.inputs:
- type: tcp
  host: "0.0.0.0:9000"

output.elasticsearch:
  hosts: ["http://10.0.0.91:9200","http://10.0.0.92:9200","http://10.0.0.93:9200"]
EOF

2.发送测试数据,输入端为tcp

[root@elk91 ~]# echo "https://www.wzy.com"  | nc 10.0.0.93 9000

3.查看messages内容和TCP传输的一致

在这里插入图片描述

为tcp

[root@elk91 ~]# echo "https://www.wzy.com"  | nc 10.0.0.93 9000

3.查看messages内容和TCP传输的一致

[外链图片转存中…(img-BV9rvJeg-1734711384835)]

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值