用Filebeat OSS 7.10.2将收集日志到Easysearch

Filebeat OSS (Open Source Software) 7.10.2版本是Elastic公司提供的开源版本。移除了一些Elasticsearch商业化的功能插件(但是没移出去干净)

https://www.elastic.co/cn/downloads/past-releases/filebeat-oss-7-10-2。

这主要还是AWS和Elastic公司之间的矛盾,AWS托管的ES会和Elastic抢客户。所以Elastic搞了一个不能商业化的协议,影响了这个生态圈,也给开发者造成了很多不方便。

还记得这个非常戏剧性的Issue:

https://github.com/elastic/beats/issues/8086

下面将介绍如何配置该版本Filebeat将日志发送到Easysearch。

以下是完整的filebeat.yml配置示例:

yaml 复制代码
filebeat.inputs:
- type: log
  enabled: true
  paths:
    - /var/log/messages
    - /var/log/httpd/*.log

output.elasticsearch:
  hosts: ["yourEasysearchEndpoint:443"]
  protocol: "https"
  username: "username"
  password: "password"
  ssl.verification_mode: none

# 以下配置用于处理xpack相关兼容性问题
setup.template.name: "filebeat"
setup.template.pattern: "filebeat-*"
setup.template.enabled: true
setup.ilm.enabled: false

setup.template和setup.ilm相关的操作就是和没移除干净的xpack有关系,所以得再配置文件加上这些东西。

同时也得在Easysearch里面开启兼容ES的API,不然会遇到这个报错。

在我的MBP上是这样:(config/easysearch.yml)

yml 复制代码
discovery.type: single-node
network.host: 0.0.0.0
elasticsearch.api_compatibility: true
  1. 启动并测试Filebeat
bash 复制代码
sudo systemctl start filebeat
sudo filebeat test output
  1. 检查服务状态
bash 复制代码
sudo systemctl status filebeat
  1. 生成测试日志
bash 复制代码
echo "test log $(date)" | sudo tee -a /var/log/messages
  1. 在Easysearch中查询日志
    使用Dev Tools执行以下查询:
json 复制代码
GET filebeat-*/_search
{
  "query": {
    "match_all": {}
  },
  "sort": [
    {
      "@timestamp": {
        "order": "desc"
      }
    }
  ]
}

成功响应示例如下:

json 复制代码
{
  "took": 5,
  "timed_out": false,
  "_shards": {
    "total": 5,
    "successful": 5,
    "skipped": 0,
    "failed": 0
  },
  "hits": {
    "total": {
      "value": 1,
      "relation": "eq"
    },
    "max_score": null,
    "hits": [
      {
        "_index": "filebeat-7.10.2-2025.04.18",
        "_id": "XXXXXXX",
        "_score": null,
        "_source": {
          "@timestamp": "2025-04-29T09:04:09.566Z",
          "log": {
            "file": {
              "path": "/var/log/messages"
            },
            "offset": 0
          },
          "message": "test log Fri Apr 29 09:04:00 UTC 2025",
          "input": {
            "type": "log"
          },
          "ecs": {
            "version": "1.6.0"
          }
        }
      }
    ]
  }
}

曾经在ubuntu上遇到过只要启动filebeat就报错一堆内存的信息:

这个文章给了一个解决办法:

https://infinilabs.cn/blog/2025/ubuntu_run_filebeat/通过以上配置和步骤,您应该能够成功使用Filebeat OSS 7.10.2版本将日志收集到Easysearch中。

相关推荐
小白银子2 小时前
零基础从头教学Linux(Day 45)
linux·运维·junit·openresty
半梦半醒*3 小时前
nginx反向代理和负载均衡
linux·运维·nginx·centos·tomcat·负载均衡
喜欢你,还有大家3 小时前
集群的概述和分类和负载均衡集群
运维·负载均衡
liu****3 小时前
负载均衡式的在线OJ项目编写(六)
运维·c++·负载均衡·个人开发
Elastic 中国社区官方博客5 小时前
CI/CD 流水线与 agentic AI:如何创建自我纠正的 monorepos
大数据·运维·数据库·人工智能·搜索引擎·ci/cd·全文检索
A-刘晨阳5 小时前
Linux安装centos8及基础配置
linux·运维·服务器·操作系统·centos8
恒雨田5 小时前
解决 jenkins 用户 SSH 连接目标服务器时的 Permission denied 问题
运维·ssh·jenkins
迎風吹頭髮6 小时前
UNIX下C语言编程与实践14-UNIX 文件系统格式化:磁盘分区与文件系统创建原理
运维·c语言·unix
Saniffer_SH6 小时前
【高清视频】CXL 2.0 over Fibre演示和答疑 - 将内存拉到服务器10米之外
运维·服务器·网络·人工智能·驱动开发·计算机外设·硬件工程
野熊佩骑6 小时前
一文读懂Redis之数据持久化
linux·运维·数据库·redis·缓存·中间件·centos