【问题标题】:How do I get the filename from the source value supplied by filebeat in logstash?如何从 logstash 中 filebeat 提供的源值获取文件名?
【发布时间】:2017-04-22 06:18:22
【问题描述】:

我想从 filebeat 提供的源值中获取文件名。

output {
  if [type] == "wxnumber" {
    elasticsearch {
        hosts => "localhost:9200"
        sniffing => false
        manage_template => false
        index => "%{[source]}"
        document_type => "%{[@metadata][type]}"
    }
  }
}

%{[source]} 通常类似于/aaa/bbb/ccc.log。如何将索引设置为ccc.log

【问题讨论】:

  • 从上面的配置中你得到了什么结果?
  • @Kulasangar,谢谢你的回复。 %{[source]} 的结果类似于 /aaa/bbb/ccc.log。我只想获取此变量的 ccc.log。
  • 我已经更新了答案!检查它是否有效。
  • 非常感谢。但我不知道文件名。也许会是 ddd.log、eee.log、fff.log 等等。
  • 如果您使用正则表达式来修剪路径并仅获得提到的特定值here

标签: elasticsearch logstash elastic-stack filebeat


【解决方案1】:

也许您可以使用mutate 将其替换为您的日志文件的命名方式:

if [%{[source]}] =~ /aaa/bbb/ccc.log {
  mutate {
     replace => ["%{[source]}]", "ccc.log"]
  }
}

这个SO 可能会有所帮助!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-12-09
    • 2015-12-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多