Splunk 合并函数

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

您好,我正在尝试使用 Splunk 中的 coalesce eval 函数。但是,eval 函数不喜欢其中有空格的字段。

在过去,我通过使用重命名功能将其中有空格的字段更改为没有空格的字段名称来解决这个问题。但是,由于某种原因,这一次不起作用。

除了重命名技巧之外,还有其他方法可以在 eval 语句中使用带空格的字段吗?

例子

base search
|eval test=coalesce(field1,field2)
| rename "space field 1" AS field1, "space field 2" AS field2
| table field1 field2 test
splunk splunk-query
3个回答
1
投票

您分享的 SPL 显示

rename
在您尝试 coalesce()
 之后

base search
| eval test=coalesce(field1,field2)
| rename "space field 1" AS field1, "space field 2" AS field2
| table field1 field2 test

很确定你想要的是这个:

base search
| rename "space field 1" AS field1, "space field 2" AS field2
| eval test=coalesce(field1,field2)
| table field1 field2 test

1
投票

eval
命令中使用单引号将文本指定为字段名称。文本周围的双引号使其成为字符串常量。

base search
| eval test=coalesce('space field 1','space field 2')
| table "space field 1" "space field 2" test

注意

table
命令如何不使用此约定。
table
的所有参数都被视为字段名称。


0
投票

所以我想通了。你必须在带有空格的字段周围使用单引号。

记住 coalesce 在填写非 NULL 值时按提供的顺序使用这些字段。所以在使用这个功能时也要记住这一点!

工作示例:

base search
| eval test=coalesce('space field 1','space field 2')
| rename "space field 1" AS field1, "space field 2" AS field2
| table field1 field2 test
© www.soinside.com 2019 - 2024. All rights reserved.