自学内容网 自学内容网

filebeat把日志文件上传到Es中配置(ES8版本)

默认的filebeat配置会把所有的索引都放到一个文件中,通过摸索发现可以自定义索引的名字、模板、生命周期

(重点注意)该配置文件只适应于ES版本是8,不适应于其他版本

  • /app/logs/info.log日志文件为JSON格式
  • 自定义索引生命周期名为:pn_springboot,可提前建好
  • 自定义索引名为:idx_springboot
  • 自写义索引模板名为:tn_springboot

ES8版本默认生成的是数据流,不是默认的索引,这么配置生成的数据流名称就是idx_springboot,不是默认的filebeat了,如查索引发现生成长索引名是.ds-idx_springboot-2024.07.21-000001这种格式的,但我们配置视图时,选idx_springboot就行了

filebeat.inputs:
  - type: filestream
    id: my-filestream-id
    enabled: true
    paths:
      - /app/logs/info.log
    parsers:
      - ndjson:
          keys_under_root: true
          overwrite_keys: true

setup.template.name: "tn_springboot"
setup.template.pattern: "idx_springboot"
setup.template.overwrite: true
setup.template.settings:
  index.lifecycle.name: "pn_springboot"
  index.number_of_replicas: 0

output.elasticsearch:
  hosts: ["http://192.168.21.2:8800"]
  username: "elastic"
  password: "elastic"
  index: "idx_springboot"

为保护我的个人隐私,有的生命周期名、索引名、模板名我做过修改,如发现有问题,可评论,或与我联系


原文地址:https://blog.csdn.net/zhaojiyuan1024/article/details/140593020

免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!