【问题标题】:Logstash filename as ElasticSearch indexLogstash 文件名作为 ElasticSearch 索引
【发布时间】:2018-05-22 17:10:00
【问题描述】:

我使用文件夹作为输入:

input {
  file {
    path => "C:/ProjectName/Uploads/*"
    start_position => "beginning"
    sincedb_path => "dev/null"
  }
}

作为输出:

output {
  elasticsearch {
    hosts => "localhost"
    index => "manual_index_name" # want filename here
    document_type => "_doc"
  }     
}

我希望 elasticsearch 中的索引是被索引的文件的名称。 我尝试了这个答案的变体但没有成功,因为我不清楚它在做什么:https://stackoverflow.com/a/40156466/6483906

【问题讨论】:

    标签: elasticsearch logstash


    【解决方案1】:

    您需要使用grok 过滤器来查找文件名的最后一部分:

    filter {
      grok {
         match => ["path", "Uploads/%{GREEDYDATA:index_name}" ]
      }
    }
    

    然后只需使用索引名称中的部分index => "%{index_name}"

    【讨论】:

    • 我遵循相同的模式,但我得到的索引只是 %{index_name} 作为纯字符串。能否指点一下如何解决?
    • 同样的事情发生在我身上
    猜你喜欢
    • 1970-01-01
    • 2020-09-27
    • 1970-01-01
    • 1970-01-01
    • 2018-10-02
    • 1970-01-01
    • 2021-01-16
    • 1970-01-01
    • 2015-05-27
    相关资源
    最近更新 更多