Splunk搜索一串字符串和_raw的显示表

时间:2016-11-16 19:44:35

标签: search field splunk

我想使用OR搜索一组字符串(感谢任何更好的方式)。有没有办法为字符串分配名称。

  

index = blah host = 123“ERROR”(“FILE1”或“FILE2”或“FILE3”)|雷克斯   field = _raw“。 errorDesc \”:\“(?。)\”,\“errorCode。*”|表   _time RESP_JSON

现在,我想将Filename添加为表中的另一列。如果File不存在则显示其余列的空值

注意: fileName不是字段,它只是_raw字段中的字符串

Splunk ::

  处理 FILE1 时出现

[12/12/2015:12:12:12.123] 错误。 errorDesc “:”{字段:123,代码:124} “” 的errorCode
  [12/12/2015:13:13:12.123]处理 FILE3 时出现错误。 errorDesc “:”{字段:125,代码:124} “” 的errorCode

例如输出:

档案-------------------_ time ----------------------- RESP_JSON

FILE1 ----- 12/12/2015:12:12:12.123 ----- {field:123,code:124}

FILE2

FILE3 ----- 12/12/2015:13:13:12.123 ----- {field:125,code:124}

没有File2的日志条目,因此显示只有文件名的空行

2 个答案:

答案 0 :(得分:0)

您是否尝试过提取文件名?

index=blah host=123 "ERROR" ("FILE1" OR "FILE2" OR "FILE3" ) | rex field=_raw "(?<filename>). errorDesc" | table _time RESP_JSON filename

关于命名搜索术语的第一个问题,您是否查看了宏或使用带有查找的子搜索?

答案 1 :(得分:0)

试一试:

index=blah host=123 "ERROR" ("FILE1" OR "FILE2" OR "FILE3" ) | rex "processing\s+(?<filename>[^\.]+)\.\s+" | table _time RESP_JSON filename

它与上面的搜索相同,只是一个不同的正则表达式提取。