用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中。

相关推荐
荣--21 小时前
一键部署不是为了省时间 —— 它是把"买来的 PaaS"变成"自己的平台"的拐点
运维·zabbix·工程化·一键部署·平台化·边界设计
江华森1 天前
动手实战学 Docker — 从零到集群编排完全指南
运维
Avan_菜菜2 天前
FRP 内网穿透完整实战:从 HTTP 映射到 HTTPS 自签代理
运维·nginx·https
SelectDB3 天前
Litefuse 开源并推出单进程轻量模式,25 秒就能跑起来的 Agent 可观测与评估平台
运维·后端·自动化运维
XIAOHEZIcode4 天前
Linux系统鼠标偏移常见原因以及修复方案
linux·运维·游戏
用户0328472220705 天前
如何搭建本地yum源(上)
运维
大树888 天前
金刚石散热越强,管路越先见顶
大数据·运维·服务器·人工智能·ai
摇滚侠8 天前
Linux CentOS7 rpm 安装 MySQL 5.7
linux·运维·mysql
霸道流氓气质8 天前
领域驱动设计(DDD)在 Spring Boot 微服务中的实践指南
运维·spring boot·微服务
Inhand陈工8 天前
基于台达PLC与映翰通IG502的智慧水产养殖精准投喂与远程运维解决方案
运维·人工智能·物联网·阿里云·信息与通信