簡體   English   中英

使用 logstash conf 文件從字段中提取值

[英]Extracting value from field with logstash conf file

我有一個類似的日志:

id:0422 time:[2013-11-19 02:34:58] level:INFO text:(Lorem Ipsum只是印刷排版行業的dummy text) 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)

先進入elasticsearch output。

& params=query:google$some value$dummy data$lorem Ipsum到第二個彈性索引。

我只想提取query:google以存儲到第二個彈性索引中。
我怎樣才能做到這一點?

您可以使用克隆過濾器克隆事件

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

只需為其添加一個標簽並使用 in tags 功能來確保您只在操作您想要操作的事件,並使用它來決定您想要寫入哪個索引。

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}\$

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM