【问题标题】:Extracting value from field with logstash conf file使用 logstash conf 文件从字段中提取值
【发布时间】:2021-04-21 09:30:12
【问题描述】:

我有一个类似的日志:

id:0422 time:[2013-11-19 02:34:58] level:INFO text:(Lorem Ipsum is 印刷和排版行业的简单虚拟文本) params:query:google$some value$dummy data$lorem Ipsum

使用 logstash 处理后,我得到的字段的值如下:

ID=0422
Timestamp=[2013-11-19 02:34:58]
loglevel=INFO  
params=query:google$some value$dummy data$lorem Ipsum
text=(Lorem Ipsum is simply dummy text of the printing and typesetting industry)

进入弹性搜索先输出。

& params=query:google$some value$dummy data$lorem Ipsum 变成第二个弹性索引。

我只想提取 query:google 以存储到第二个弹性索引中。
我怎样才能做到这一点??

【问题讨论】:

    标签: elasticsearch logstash elastic-stack logstash-grok logstash-configuration


    【解决方案1】:

    您可以使用克隆过滤器克隆事件

    https://www.elastic.co/guide/en/logstash/current/plugins-filters-clone.html

    只需为其添加一个标签并使用标签内功能来确保您只是在操作您想要操作的事件,并使用它来决定您想要写入哪个索引。

    clone {
      clones => ["params"]
      add_tag => ["sendtoindex2"]
    }
    ...
    #use the structure below when you want to know which flow to take (you can also use not in [tags])
    if ("sendtoindex2" in [tags]) {
      ...
    else {
      ...
    }
    

    为确保您只有感兴趣的部分,请使用 grok 过滤器

    https://www.elastic.co/guide/en/logstash/current/plugins-filters-grok.html

    对于您的示例,它将类似于:

    ^%{DATA:name_of_variable_you_want_to_use}\$
    

    【讨论】:

      猜你喜欢
      • 2014-07-26
      • 1970-01-01
      • 2021-01-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-08-31
      • 1970-01-01
      • 2015-06-30
      相关资源
      最近更新 更多