elasticsearch - 仅将一定百分比的日志发送到logstash

标签 elasticsearch logstash elastic-stack filebeat nxlog

如何配置filebeat仅将一定百分比的日志(如果可以的话,将其发送到Logstash)?

在我的应用程序的日志文件夹中,每个日志被分块成大约20兆。我希望filebeat仅将该日志量的约1/300发送到logstash。

我需要先减少日志量,然后再通过电线将其发送到Logstash,以便无法从Logstash中进行过滤,因为它需要在离开服务器之前在端点上进行。

我在ES论坛上问了这个问题,有人说filebeat无法实现:https://discuss.elastic.co/t/ship-only-a-percentage-of-logs-to-logstash/77393/2

真的没有办法可以扩展filebeat来做到这一点吗? nxlog或其他产品可以吗?

最佳答案

无法将Filebeat配置为根据概率删除任意事件。但是Filebeat确实具有根据条件删除事件的能力。有两种过滤事件的方法。

Filebeat可以指定读取文件时要包括或排除的行。这是应用过滤最有效的地方,因为它发生得较早。这是通过在配置文件中使用include_lines exclude_lines 完成的。

filebeat.prospectors:
- paths:
  - /var/log/myapp/*.log
  exclude_lines: ['^DEBUG']

所有Beats都有"processors",可让您根据条件应用 Action 。一种 Action 是drop_events,条件是regexpcontainsequalsrange
processors:
- drop_event:
    when:
      regexp:
        message: '^DEBUG'

关于elasticsearch - 仅将一定百分比的日志发送到logstash,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42728441/

相关文章:

docker - LogStash 无法从许可证中检索许可证信息。响应代码 '401' 通过 URL 'http://elasticsearch:9200/_xpack' 联系 Elasticsearch

logging - 使用Filebeat将Docker GELF日志转发到Logstash(或替代方法?)

elasticsearch - 过滤查询在 Elasticsearch 中不起作用

elasticsearch - 获取此根映射定义具有不受支持的参数:在Kibana控制台中的查询下方运行时,mapper_parsing_exception

amazon-web-services - 作为服务运行时如何指定logstash配置文件

elasticsearch - 编辑 ElasticSearch 7.3 的状态文件

ruby - 如何在 ruby​​ 中将 timeuuid 转换为时间戳

elasticsearch - geoip查找失败弹性堆栈logstash

elasticsearch - 如何找到距输入位置一定范围内的位置?

amazon-web-services - Kinesis编写ElasticSearch和S3