如何删除 CSV 文件中为 nil 的字段
How can I remove field which are nil in CSV file
我的 CSV 文件包含像这样的 nil 字段:
{ "message" => [
[0] "m_FRA-LIENSs-R2012-1;\r"
],
"@version" => "1",
"@timestamp" => "2015-05-24T13:51:14.735Z",
"host" => "debian",
"SEXTANT_UUID" => "m_FRA-LIENSs-R2012-1",
"SEXTANT_ALTERNATE_TITLE" => nil
}
How can I remove all : messages and fields
这是我的 CSV 文件
SEXTANT_UUID|SEXTANT_ALTERNATE_TITLE
a1afd680-543c | ZONE_ENJEU
4b80d9ad-e59d | ZICO
800d640f-1f82 |
我想删除最后一行,我使用了过滤器ruby,但它不起作用!它只删除字段而不是整个消息。
如果您像这样配置 Ruby 过滤器,它将起作用:
filter {
# let ruby check all fields of the event and remove any empty ones
ruby {
code => "event.to_hash.delete_if {|field, value| value.blank? }"
}
}
我使用 if ([message]=~ "^;") { drop { } } 及其工作 => 用于 csv 文件
我的 CSV 文件包含像这样的 nil 字段:
{ "message" => [
[0] "m_FRA-LIENSs-R2012-1;\r"
],
"@version" => "1",
"@timestamp" => "2015-05-24T13:51:14.735Z",
"host" => "debian",
"SEXTANT_UUID" => "m_FRA-LIENSs-R2012-1",
"SEXTANT_ALTERNATE_TITLE" => nil
}
How can I remove all : messages and fields
这是我的 CSV 文件
SEXTANT_UUID|SEXTANT_ALTERNATE_TITLE
a1afd680-543c | ZONE_ENJEU
4b80d9ad-e59d | ZICO
800d640f-1f82 |
我想删除最后一行,我使用了过滤器ruby,但它不起作用!它只删除字段而不是整个消息。
如果您像这样配置 Ruby 过滤器,它将起作用:
filter {
# let ruby check all fields of the event and remove any empty ones
ruby {
code => "event.to_hash.delete_if {|field, value| value.blank? }"
}
}
我使用 if ([message]=~ "^;") { drop { } } 及其工作 => 用于 csv 文件