日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

轻量型日志采集器 Filebeat基本使用

發(fā)布時(shí)間:2025/5/22 编程问答 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 轻量型日志采集器 Filebeat基本使用 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

文章目錄

    • 1 介紹
    • 2 安裝
      • 2.1 下載安裝
    • 3 收集日志配置
    • 4 啟動(dòng)
      • 5 舉例
      • 5.1 Filebeat收集日志并輸出到控制臺(tái)
      • 5.2 Filebeat收集Nginx運(yùn)行日志并輸出到es
      • 5.3 基于Nginx module使用Filebeat收集Nginx運(yùn)行日志并輸出到es

1 介紹

Filebeat是一個(gè)日志文件托運(yùn)工具,安裝客戶端后,filebeat會(huì)監(jiān)控指令日志,
下載地址:
https://www.elastic.co/cn/beats/filebeat

https://www.elastic.co/cn/downloads/past-releases/filebeat-7-17-0

注意:版本需要和 Elasticearch 版本相同

2 安裝

2.1 下載安裝

tar -zxvf filebeat-7.17.0-linux-x86_64.tar.gz

3 收集日志配置

安裝目錄下新建conf/star_module_log.yml

在這里插入代碼片

4 啟動(dòng)

chown root filebeat.yml chown root modules.d/nginx.yml ./filebeat -e

./filebeat -e -c filebeat_log.yml

./filebeat -e -c filebeat.yml -d "publish"

5 舉例

5.1 Filebeat收集日志并輸出到控制臺(tái)

"name": "ccccccccc":自定義name字段
"message": "你好" :日志中輸出:你好
fields_under_root: true:將name定義為頂級(jí)字段

filebeat.inputs: - type: logenabled: truepaths:- /usr/local/nginx/logs/access.logfields:name: cccccccccfields_under_root: true output.console:pretty: true ./filebeat -e -c filebeat_log.yml

5.2 Filebeat收集Nginx運(yùn)行日志并輸出到es

filebeat_nginx.yml

filebeat.inputs: - type: logenabled: truepaths:- /usr/local/nginx/logs/access.logtags: ["nginx"] setup.template.settings:index.number_of_shards: 1 output.elasticsearch:hosts: ["118.195.175.213:9200"]username: "elastic"password: "EtWvHc8lGh05YS7vS1mq" ./filebeat -e -c filebeat_nginx.yml

查看es,默認(rèn)會(huì)按照f(shuō)ilebeat-版本號(hào)-日期格式生成一個(gè)索引:

  • nginx日志數(shù)據(jù)在字段message中

    到這里,仍然屬于原始數(shù)據(jù)

filebeat_nginx.yml

filebeat.inputs: - type: logenabled: truepaths:- /usr/local/nginx/logs/access.logtags: ["nginx"]#keys_under_root可以讓字段位于根節(jié)點(diǎn),默認(rèn)為falsejson.keys_under_root: true#對(duì)于同名的key,覆蓋原有key值json.overwrite_keys: true#將解析錯(cuò)誤的消息記錄儲(chǔ)存在error.message字段中json.add_error_key: true setup.template.settings:index.number_of_shards: 1 output.elasticsearch:hosts: ["118.19*.17*.213:9200"]username: "elastic"password: "EtWvHc8lGh05YS7vS1mq"

5.3 基于Nginx module使用Filebeat收集Nginx運(yùn)行日志并輸出到es

## 查看module集合 ./filebeat modules list ## 啟用module ./filebeat modules enable module名稱 ## 禁用module ./filebeat modules disable module名稱

啟動(dòng)nginx module

./filebeat modules enable nginx

查看module列表

./filebeat modules list

配置Nginx Module

${FILEBEAT_HOME}/modules.d/ nginx.yml

- module: nginxaccess:enabled: truevar.paths: ["/usr/local/nginx/logs/access.log"]error:enabled: truevar.paths: ["/usr/local/nginx/logs/error.log"]

配置filebeat:filebeat_nginx_module.yml

filebeat.inputs: setup.template.settings:index.number_of_shards: 3 output.elasticsearch:hosts: ["http://118.195.175.213:9200"]username: "elastic"password: "EtWvHc8lGh05YS7vS1mq" filebeat.config.modules:path: ${path.config}/modules.d/*.ymlreload.enabled: false

啟動(dòng)filebeat

./filebeat -e -c filebeat_nginx_module.yml ./filebeat -e -c filebeat_nginx_module.yml -d 'publish'

到此,可以查看數(shù)據(jù)索引

參考地址:
https://blog.csdn.net/zyxwvuuvwxyz/article/details/108831962

總結(jié)

以上是生活随笔為你收集整理的轻量型日志采集器 Filebeat基本使用的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。