Filebeat 采集数据到Elasticsearch

安装Filebeat,注意版本尽可能要和Elasticsearch 的版本一致

javascript 复制代码
wget https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-7.12.1-linux-x86_64.tar.gz

tar -xzvf filebeat-7.12.1-linux-x86_64.tar.gz

mv filebeat-7.12.1-linux-x86_64/   filebeat-7.12.1

修改配置文件

1.开启输入

2.指定输出ES

ES多节点配置

javascript 复制代码
output.elasticsearch:
  hosts: ["192.169.208.111:9200", "192.169.208.112:9200", "192.169.208.113:9200"]
  loadbalance: true   # ← 默认就是 true,可省略

查看配置是否正常

javascript 复制代码
./filebeat test output

补充:filebeat.yml 生产级配置

javascript 复制代码
filebeat.inputs:
- type: log
  enabled: true
  paths:
    - /opt/module/log/1.log
    # - /path/to/your/other/*.log  <-- 可以在这里加更多文件

  # --- 核心:多行合并 (Multiline) ---
  
  # 1. 正则:匹配 Logback/Spring Boot 的标准时间头
  # 格式:2026-04-22 16:02:06
  # 解释:^表示行首,\d{4}表示年份,确保只有新的一行日志才会被识别为"开始"
  multiline.pattern: '^\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2}'
  
  # 2. 策略:negate (取反)
  # 解释:如果一行 **不符合** 上面的时间格式(比如它是 "at com..." 或者 "Caused by..."),
  # 那么它就不是新日志,而是旧日志的一部分。
  multiline.negate: true
  
  # 3. 方向:after
  # 解释:把那些"不是新日志"的行,追加到上一行的末尾。
  multiline.match: after
  
  # 4. 兜底保护
  # 防止某个异常堆栈有几万行导致内存溢出,生产环境建议设置上限
  multiline.max_lines: 500

  # --- 额外优化:处理容器日志换行 (可选) ---
  # 如果你的日志是 Docker/K8s 打印出来的,有时候会被截断成很长的行,
  # 可以开启这个来合并被物理截断的行(通常以空格结尾)。
  # multiline2.pattern: '.*\s$'
  # multiline2.negate: true
  # multiline2.match: after
相关推荐
Elasticsearch5 小时前
你的日志早已写好告警:在 Elasticsearch 中生成 ES|QL 检测查询
elasticsearch
垚垚学技术_聚焦云原生6 小时前
Ansible Vault 安全实践:敏感密码、密钥加密存储方案
安全·elasticsearch·ansible
Flynn Liang1 天前
内存/Redis/PGVector/Milvus/ES 怎么选?Spring AI VectorStore 抽象与向量库选型对照表
redis·elasticsearch·milvus·rag·springai·pgvector·向量库
Elastic 中国社区官方博客1 天前
基于 Jina OCR v1 与 Elasticsearch 的 PDF 智能混合检索与 RAG 系统实战指南
大数据·数据库·elasticsearch·搜索引擎·ocr·jina
Eloudy2 天前
Qwen2.5-14B-Instruct-AWQ 模型文件结构分析
大数据·elasticsearch·搜索引擎
YIN_尹2 天前
【git原理与使用】git初识与安装
大数据·git·elasticsearch
Elastic 中国社区官方博客2 天前
Elastic 在《Forrester Wave™:2026 年第四季度智能运维平台》报告中被评为强劲表现者
大数据·运维·数据库·elasticsearch·搜索引擎·全文检索
Elasticsearch2 天前
Elastic Cloud 无服务器服务审计日志:将审计记录发送到可观测性或安全解决方案
elasticsearch
zwjapple3 天前
skill总结
大数据·elasticsearch·搜索引擎
阿里云大数据AI技术3 天前
云栖实录|从代码上下文到千亿级文档:Qoder × 阿里云 Elasticsearch 落地生产级Agent向量检索
人工智能·elasticsearch