zoukankan      html  css  js  c++  java
  • ELK部署文档filebeat

    ELK部署文档--filebeat

    1 背景

    ELK是三个开源软件的缩写,分别表示:Elasticsearch , Logstash, Kibana , 它们都是开源软件。新增了一个FileBeat,它是一个轻量级的日志收集处理工具(Agent),Filebeat占用资源少,适合于在各个服务器上搜集日志后传输给Logstash。

    这是一个最简单的架构图:

    filebeat ==> logstash ==> elasticsearch ==> kibana

    • 资源准备

      下载部署包地址:https://www.elastic.co/cn/downloads/past-releases#elasticsearch

      注:elk全家桶各个应用版本需一致

    • 创建用户

      elk需要用非root用户部署,因此需要创建一个账号用于部署
      useradd elk

      修改目录的权限,给elk赋权
      chown elk:elk /data/software/elk -R

    2 filebeat

    Filebeat是用于收集和转发日志数据的轻量级传送工具。Filebeat监视指定的日志文件或位置,收集日志事件,并将它们转发到Elasticsearch或 Logstash进行索引

    filebeat默认端口为5044

    img

    2.1 下载安装

    • 解压安装包到指定目录/data/software/elk
      tar -vxf filebeat-7.15.2-linux-x86_64 -C /data/software/elk

    2.2 配置文件

    • 在filebeat目录下创建配置文件
      vim itcast.yml
    filebeat.inputs:
    - type: log
      enabled: true
      paths:  # 配置采集文件路径
      - /data/logs/devicelog/*/*.log
      tags: ["device"]  # 自定义标签
      fields:  # 自定义标签
        service: syslogs
        fields_under_root: true  #默认创建的service标签在fields下,配置为true后service字段在根节点下
    output.logstash:  # 输出到logstash
      hosts: ["176.16.9.3:5044"]  # 配置为logstash服务器ip
    # output.elasticsearch: # 输出到elasticsearch
    #   hosts: ["176.16.9.3"]
      
    # 可通过配置多个- type采集多个目录数据
    

    2.3 服务部署

    在filebeat目录下启用:
    nohup ./filebeat -e -c itcast.yml > filebeat.log &

    输出日志在filebeat.log目录下

    检查服务:
    ps -ef | grep filebeat

    2.4 基本命令

    • export

      export命令可把信息输出到终端,在终端中快速查看配置、索引模板和ILM策略等内容

      • 输出配置内容

        在filebeat文件夹下查看itcast.yml文件:
        ./filebeat export config -c itcast.yml

      • 输出索引模板
        ./filebeat export template

        也可以把信息输出到指定文件夹(/data/template)下
        ./filebeat export template --dir /data/template

      • 输出索引生命周期管理策略(可通过--dir指定输出文件中)
        ./filebeat export ilm-policy

    • modules

      管理配置模块,该模块可以设置使用或者取消使用特定的模块配置

      • 查看模块配置
        ./filebeat modules list
      • 使用模块配置
        ./filebeat modules enable (模块名称)
      • 取消使用模块配置
        ./filebeat modules disable (模块名称)
    • run

      运行filebeat模块,指定特定的运行规则

      • 指定CPU数据文件
        -cpuprofile /data/file

      • 指定内存数据文件
        -memprofile /data/file

      • 启用指定选择器的调试
        -d "publisher"

      • 指定配置文件
        -c ./conf.yml

        指定自定义配置文件,不指定默认指定为filebeat.yml

    • 覆盖配置参数

      覆盖配置文件中输出地址,可以作用于正在运行的filebeat,并且不修改配置文件,可以指定多个配置
      ./filebeat -E "output.logstash.hosts=['http://localhost:5044']"

    详细命令信息可参考:https://www.elastic.co/guide/en/beats/filebeat/current/command-line-options.html#global-flags

    本文来自博客园,作者:liu_kx,转载请注明原文链接:https://www.cnblogs.com/liukx/p/15711515.html

  • 相关阅读:
    02_5if switch分支与循环语句
    02_4运算符
    02_3程序格式
    Shell脚本调用ftp上传文件
    02_2数据类型转换
    02_1标识符_关键字_数据类型
    01_3Java Application初步
    01_2Java开发环境的下载 安装 配置
    Mac 安装MySQL
    用 Homebrew 带飞你的 Mac
  • 原文地址:https://www.cnblogs.com/liukx/p/15711515.html
Copyright © 2011-2022 走看看