的值设置为空XML字段我得到logstash一些XML消息,我才能分析得到相关信息我怎样才能在logstash
if ([message] =~ /^</) {
xml {
source => "message"
store_xml => false
xpath => [
"name(/APIOS_MOM_EVENT/DATA/APIOS_EXPORT/*[not(self::METADATA)])","MESSAGE_TYPE",
]
target => "xml"
}
if ([MESSAGE_TYPE] == "") {
mutate {
update => { "MESSAGE_TYPE" => "EDITO" }
}
}
}
我的目标是让所有MESSAGE_TYPE,如果它是空的,将其设置为EDITO。 现在我可以用(MESSAGE_TYPE.raw:“”)看到kibana中的空信息,但是我没有看到任何EDITO MESSAGE_TYPE。
我有一些MESSAGE_TYPE:文本,资料,照片,但没有EDITO(只空消息)
所以总结起来,空字符串应该EDITO
我已经读一些文档(https://www.elastic.co/guide/en/logstash/current/plugins-filters-mutate.html#plugins-filters-mutate-replacehttps://groups.google.com/forum/#!msg/logstash-users/mKJVO6yAmSc/on9mLRtLgTYJ)但仍然没有运气
我也检查http://stackoverflow.com/questions/4489976/xpath-to-return-default-value-if-node-not-present但我不知道如何处理它 – glmrenard
试试的东西,不应该既成事实'''如果[MESSAGE_TYPE] { 如果([MESSAGE_TYPE] == “”){ 发生变异{ 更新=> { “MESSAGE_TYPE”=> “EDITO”}} } } 否则{ 发生变异{ add_field => { “MESSAGE_TYPE”=> “EDITO”}} } '''但仍然是空的,而不是EDITO – glmrenard
也许诀窍是使用'alter'插件(https://www.elastic.co/guide/en/logstash/current/plugins-filters-alter.html)'''alter condrewrite => [ “MESSAGE_TYPE”,“”, “EDITO” ] } ''' – glmrenard