不为失败找理由,要为成功找方法。

filebeat每次有新事件会将上一次的事件重新发送,该如何避免?

Beats | 作者 levey | 发布于2017年10月08日 | 阅读数:11162

这是第一次事件offset为58​



2017/10/08 15:17:12.134290 client.go:214: DBG  Publish: {
  "@timestamp": "2017-10-08T15:17:02.134Z",
  "beat": {
    "hostname": "izuf6f8i2ttdohwal5u4pzz",
    "name": "izuf6f8i2ttdohwal5u4pzz",
    "version": "5.6.2"
  },
  "input_type": "log",
  "message": "23:53:18.061 [main] ERROR - Context initialization failed",
  "offset": 58,
  "source": "/mnt/data/usr/elasticsearch-5.x/beats/simple-logs/hello.txt",
  "tags": [
    "datalake-log"
  ],
  "type": "log"
}


 
接下来第二次事件offset为116,但是会将上一次发送时的offset读取重新发送上一次的事件,推送两次Event,以此类推


Publish: {
  "@timestamp": "2017-10-08T15:22:24.665Z",
  "beat": {
    "hostname": "izuf6f8i2ttdohwal5u4pzz",
    "name": "izuf6f8i2ttdohwal5u4pzz",
    "version": "5.6.2"
  },
  "input_type": "log",
  "message": "23:53:18.061 [main] ERROR - Context initialization failed",
  "offset": 58,
  "source": "/mnt/data/usr/elasticsearch-5.x/beats/simple-logs/hello.txt",
  "tags": [
    "datalake-log"
  ],
  "type": "log"
}

 
Publish: {
  "@timestamp": "2017-10-08T15:22:24.665Z",
  "beat": {
    "hostname": "izuf6f8i2ttdohwal5u4pzz",
    "name": "izuf6f8i2ttdohwal5u4pzz",
    "version": "5.6.2"
  },
  "input_type": "log",
  "message": "23:53:18.061 [main] ERROR - Context initialization failed",
  "offset": 116,
  "source": "/mnt/data/usr/elasticsearch-5.x/beats/simple-logs/hello.txt",
  "tags": [
    "datalake-log"
  ],
  "type": "log"
}


 
导致logstash重复消费数据,我不知道是我的问题还是beats内部机制本来就这样,有办法避免这个情况吗?
 
filebeat.yml配置:

filebeat.config.prospectors:
  path: /etc/filebeat/filebeat.yml
  reload.enabled: false
  reload.period: 10s

filebeat.prospectors:
 - input_type: log
  paths:
    - /mnt/data/usr/elasticsearch-5.x/beats/simple-logs/*
  include_lines: ["^.*] ERROR.*", "^.*] WARN.*"]
  multiline.pattern: ^(?:[01]\d|2[0-3])(?::[0-5]\d){2}\.(\d){3} \[
  multiline.negate: true
  multiline.match: after
  tags: ["datalake-log"]

output.logstash:
  hosts: ["localhost:5044"]

logging.level: debug
logging.to_files: true
logging.to_syslog: false
logging.files:
  path: /mnt/data/usr/elasticsearch-5.x/beats/logs
  name: mybeat.log
  keepfiles: 7
logging.selectors: ["*"]

 
 
 
 
已邀请:

juneryang

赞同来自:

我的版本是5.1.2,曾经碰到过filebeat重启后重新发送数据的情况,就跟data/registry文件失效的效果一样。话说reload.enabled和reload.period参数是干什么用的?

medcl - 今晚打老虎。

赞同来自:

可以看看 logstash 和 Filebeat 的日志,有没有链接超时或者网络断开的异常,如果 Filebeat 日志发给 logstash,但是没有收到 ack 确认消息,Filebeat 会重试的。超时时间或可调大点。

Ohhhhhhhhhhhh!

赞同来自:

请问您解决这个问题了吗? 我也遇到了,求解~

zdy

赞同来自:

vi指令保存后,会重复发送,用echo写东西测试没问题,类似vi估计都会有问题。官方论坛翻译内容如下:
 
你怎么修改文件。你试过了$ echo 'new line' >> /usr/src/app/log.log吗?filebeat试图根据元数据来检测文件是否是新的。一些工具/编辑器创建一个全新的文件保存并取消旧链接。这被filebeat检测为新文件,迫使它重新发送所有内容。
 
 
 

要回复问题请先登录注册