将多个字段值输入一个新字段

问题描述 投票:0回答:2

我正在尝试在搜索中创建一个从其他字段中提取的新字段,以便自动为另一个应用程序编写搜索查询。

基本思路:

eval PCAP_Search=(( ipv4_initiator="src_ip" and port_initiator="src_port" and ipv4_responder="dest_ip" and port_responder="dest_port"))

src_ip
src_port
dest_ip
dest_port
是我试图从中提取的其他领域。

我知道我将不得不转义特殊字符和 AND,但一直无法弄清楚如何。该字段的输出理想情况下如下所示:

(ipv4_initiator="172.168.0.1" and port_initiator="1234" and ipv4_responder="8.8.8.8" and port_responder="80")

我尝试使用

\
单独转义字符,并转义不是我试图从中提取的字段的所有内容 ' ',但遇到了表达式格式错误或我正在创建的字段没有的问题里面有什么吗?

更新 第一个答案不正确,我不是要创建多个新字段,只是一个包含从其他 4 个字段中提取数据的字符串

splunk splunk-query splunk-dashboard splunk-formula
2个回答
1
投票

format
命令会为你做到这一点。只需填充字段(或从搜索中提取它们)并调用
|format
.

| makeresults 
| eval ipv4_initiator="src_ip", port_initiator="src_port", ipv4_responder="dest_ip", port_responder="dest_port" 
| format 
| rename search as PCAP_Search

您也可以使用连接运算符手动完成,就像这样(记住,“AND”必须大写)。

| makeresults 
| eval ipv4_initiator="src_ip", port_initiator="src_port", ipv4_responder="dest_ip", port_responder="dest_port" 
| eval PCAP_Search="(( ipv4_initiator=\"" . ipv4_initiator . "\" AND port_initiator=\"" . port_initiator . "\" AND ipv4_responder=\"" . ipv4_responder . "\" AND port_responder=\"" . port_responder . "\"))"

0
投票

RichG 确实帮助解决了它,我不知道使用“.FIELD_NAME.”会调用该字段的数据。这是有效的灵魂:

eval PCAP_Search="( ipv4_initiator="".src_ip."" and port_initiator="".src_port."" and ipv4_responder="".dest_ip."" and port_responder="".dest_port."")"

© www.soinside.com 2019 - 2024. All rights reserved.