作者:Eddy  历史版本:1  更新时间:2024-05-13 18:33

注意命令执行时的所使用的用户

下载

wget https://artifacts.elastic.co/downloads/filebeat/filebeat-6.8.0.tar.gz

安装

tar -zxvf filebeat-6.8.0.tar.gz

配置

# 1.更改filebeat文件夹及内部文件的所属用户及组为 es:elsearch
[root@localhost ~]# chown -R es:elsearch filebeat

# 2.添加成功保存后切换到es用户操作
[root@localhost ~]# su es
[es@localhost]$

# 3.在 filebeat 目录下修改 filebeat.yml 配置文件
[es@localhost]$ vim filebeat.yml

修改内容如下所示:

- type: log

  # Change to true to enable this prospector configuration.
  # 下面这行要注释掉
  ## enabled: false

  # Paths that should be crawled and fetched. Glob based paths.
  paths:
  # 这修改为要收集的日志文件
    - /var/log/*.log
    #- c:\programdata\elasticsearch\logs\*

#-------------------------- Elasticsearch output ------------------------------
output.elasticsearch:
  # Array of hosts to connect to.
  # 改成 elasticsearch地址
  hosts: ["192.168.3.207:9200"]

启动

# 在 filebeat 目录下执行; & 表示程序将在后台运行
[es@localhost]$ ./filebeat &

访问 elasticsearch 的IP和端口 IP:端口/_cat/indices?v
本示例访问地址为:http://192.168.3.207:9200/_cat/indices?v

启动成功如下图所示: