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

相关推荐
Up九五小庞28 分钟前
jenkins从入门到精通-P1—九五小庞
运维·jenkins
乐维_lwops43 分钟前
运维端口管理闭环:从暴露面测绘到自动化封禁!
运维·自动化·php
Cyber4K1 小时前
MySQL--组从复制的详解及功能演练
运维·数据库·mysql·云原生
wyjcxyyy2 小时前
打靶日记-RCE-labs(续)
linux·运维·服务器
六点半8883 小时前
【Linux】Linux编译器-gcc/g++使用
linux·运维·服务器
我才是一卓3 小时前
排查解决 nvidia-suspend 导致的 linux 系统无响应/死机问题
linux·运维·服务器
Tipriest_4 小时前
linux eval命令的使用方法介绍
linux·运维·bash
laoma-cloud5 小时前
网络基础实操篇-05-路由基础-最佳实践
运维·网络·智能路由器
孟婆来包棒棒糖~5 小时前
Docker快速入门
运维·spring boot·docker·容器·tomcat
IT成长日记5 小时前
【自动化运维神器Ansible】Ansible常用模块之setup模块详解
运维·自动化·ansible·setup·常用模块