使用 shuf 来打乱一个文件中的行或是选择文件中一个随机的行。

logstash kv插件解析日志时,日志value中包含field_split切割字符,导致value截取不完整。

Logstash | 作者 sun_changlong | 发布于2018年09月04日 | 阅读数:6269

我的数据格式是:
evel="2" treatment="3" cmd="\"D:\Program Files (x86)\360\360safe\modules\setup.exe\" /s /smartsilence" type="sys"

使用kv插件,使用 " " 进行剪切,然后使用“=”进行解析,但cmd字段的值包含转义字符和切割字符。

预期结果:
key = cmd
value = "D:\Program Files (x86)\360\360safe\modules\setup.exe" /s /smartsilence

 
但是,结果是:

key = cmd 
value =“D:\ Program
 
或者

key = cmd 
value =“D:\ Program Files(x86)\ 360 \ 360safe \ modules \ setup.exe
 
配置为:
kv {
source => "message"
field_split => " ?"
value_split => "="
}



kv {
source => "message"
field_split => " ?"
value_split => "="
trim_value => "\" "
}

应该如何正确解析出cmd 部分,并且不影响其余的key-value 解析?
 
已邀请:

medcl - 今晚打老虎。

赞同来自:

第一步用“ ”来切肯定是不行的,换用正则来做没问题的。

qw8613243

赞同来自:

你这数据格不支持“ ”来切分呀 建议数据格式重新整理

要回复问题请先登录注册