大數據Elasticsearch之輕量級日誌採集工具FileBeat的安裝、配置與使用


beats

beats是一個代理,將不同類型的數據發送到elasticsearch。beats可以直接將數據發送到elasticsearch,也可以通過logstash將數據發送elasticsearch。


Filebeat

Filebeat是File採集專用beats,用來收集日誌


1. 下載&解壓

$ wget https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-7.3.2-linux-x86_64.tar.gz
$ tar -zxvf filebeat-7.3.2-linux-x86_64.tar.gz

2. 配置filebeat.yml

     #定義日誌文件路徑
     filebeat.inputs:
     - type: log
        enabled: true
        paths:
             - /var/log/*.log
    #發送到Elasticseach
     output.elasticsearch:
        hosts: ["192.168.0.22:9200"]
    #如果要用kibana儀表盤
     setup.kibana:
        host: "localhost:5601"
    #如果有安全策略,則需要指定訪問憑據
    output.elasticsearch:
        hosts: ["elasticsearchlocalhost:9200"]
        username: "elasticsearch"
        password: "pwd"
     setup.kibana:
        host: "kibanalocalhost:5601"
        username: "kibana"
        password: "pwd"
    #如果使用logstash
     output.logstash:
        hosts: ["127.0.0.1:5044"]
     #索引模板加載。索引模板用於定義設置和映射,以確定如何分析字段。默認模板文件 fields.yml
     #加載不同的模板
     setup.template.name: "template"
     setup.template.fields: "path/to/fields.yml"
    #覆蓋一個已存在的模板
     setup.template.overwrite: true
    #禁用自動加載模板
     setup.template.enabled: false
    #修改索引名稱
     # 默認情況下,Filebeat寫事件到名爲filebeat-6.3.2-yyyy.MM.dd的索引,其中yyyy.MM.dd是事件被索引的日期。爲了用一個不同的名字,你可以在Elasticsearch輸出中設置index選項。例如:
     output.elasticsearch.index: "customname-%{[beat.version]}-%{+yyyy.MM.dd}"
     setup.template.name: "customname"
     setup.template.pattern: "customname-*"
     setup.dashboards.index: "customname-*"    

3. 啓動Filebeat

$ ./filebeat -e -c filebeat.yml -d "publish"
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章