ELK 线上事故处理:Filebeat 如何跳过积压日志
引言在维护 ELK (Elasticsearch, Logstash, Kibana) 日志系统时,一个常见的线上事故是下游的 Elasticsearch 因磁盘空间耗尽而无法接收新的日志。这会导致上游的 Filebeat 和 Logstash 出现数据积压。当磁盘问题解决后,我们通常不希望重新处理这些积压的、可能已经失去时效性的日志,而是希望从当前时间点开始恢复日志采集。本文将详细介绍如何处理此类事故,核心在于让 Filebeat 跳过积压的日志。 事故场景:Elasticsearch 磁盘写满导致日志积压问题描述: 日志系统链路为 Filebeat -> Logstash -> Elasticsearch。Elasticsearch 因磁盘满了,导致服务中断两小时。现在磁盘空间已清理,服务恢复,但 Filebeat 开始从两小时前中断的位置重新发送日志。我们希望丢弃这两个小时的积压日志,直接从当前时间开始采集。 核心解决方案:重置 Filebeat 的读取位置问题的关键在于 Filebeat 会持久化记录每个日志文件的读取进度(offset)。即使下游服务中断,F...
利用 pprof 分析 Filebeat 的 CPU 使用率过高
通过 pprof 调试 Filebeat因为 Filebeat 是用 Go 语言实现的,而 Go 语言本身的基础库里面就包含 pprof 这个功能极其强大的性能分析工具,因此,在 7.x 版本中,Beats 家族的工具,都提供了以下参数,方便用户在出现问题的时候,对应用进行调试: 12345678--cpuprofile FILE Writes CPU profile data to the specified file. This option is useful for troubleshooting Filebeat.-h, --help Shows help for the run command.--httpprof [HOST]:PORT Starts an http server for profiling. This option is useful for troubleshooting and profiling Filebeat.--memprofile FILE Writes memory profile data to the s...
Filebeat 多实例部署(守护进程方式 systemd)
安装好 Filebeat1站内搜索:记录日志系统的安装-部署-配置-使用文档(1) 复制两个子文件夹12cp -r /etc/filebeat{,1}cp -r /etc/filebeat{,2} 修改各自的 filebeat.yml1234...(省略 inputs 之类的)logging.files: # 这里修改文件夹路径 path: /var/log/filebeat1/2 查看机器 systemd 的 path 我这里是 /usr/lib/systemd/system 添加两份配置文件 vi /usr/lib/systemd/system/filebeat1.service 1234567891011121314151617[Unit]Description=Filebeat sends log files to Logstash or directly to Elasticsearch.Documentation=https://www.elastic.co/bea...
Kibana Dashboard 结合 Filebeat 的使用
利用 Filebeat Module 监听/传输数据到 ES 并通过 Kibana 的面板显示要记得将 modules 功能打开 filebeat 安装完默认会在 /etc/filebeat/modules.d 下放着许多模块的 yml,需要哪个,就执行 filebeat modules enable xxx filebeat.yml 配置: 1234567891011121314151617181920212223filebeat.config: modules: enabled: true path: modules.d/*.yml reload.enabled: true reload.period: 10s# ------------------------------ Kibana Output -------------------------------output.elasticsearch: hosts: ["10.0.2.15:9200"] username: "elastic"...
Filebeat 采集 JSON 日志到 ES
需求描述使用 Filebeat 从 log 文件中采集 JSON 格式的日志,发送到 ES 中,并在 ES 中显示 JSON 日志的各字段和数据。 问题一:如何采集 JSON 格式的日志在 filebeat.yml 文件中进行相应的配置: 12345678910111213141516171819202122232425262728293031323334- type: log enabled: true paths: - E:\testjson.log processors: - script: lang: javascript source: > function process(event) { var message = event.Get("message"); message = message.replace(/\\x22/g,'"'); message = message.replace...
