我正在尝试解析字段名称并将其发送到 ElasticSearch,但遇到了排列正确字段的问题。
这是一些示例 XML
<products>
<product name="name_1"></product>
<product name="name_2"></product>
<product name="name_3"></product>
</products>
我的logstash配置文件:
input {
file {
path => "sample.xml"
start_position => "beginning"
sincedb_path => "/dev/null"
exclude => "*.gz"
type => "xml"
codec => multiline {
pattern => "<products>"
negate => "true"
what => "previous"
}
}
}
filter {
xml {
source => "message"
store_xml => false
target => "products"
add_field => {
"p_name" => "%{[products][product][name]}"
}
xpath => [
"/products/*/@name", "product_name"
]
}
}
目前,在 ElasticSearch 中:有一个p_name
集合到%{[products][product][name]}
并且product_name
是name_1, name_2, name_3
相反,我想要 3 个不同的记录,每个记录都有自己独特的 product_name
什么是正确的 xml 过滤器?
原来问题(更确切地说,是我认为我正在摄取的)始于错误地读取输入。下面是我的 logstash.config 文件。
<products>
我没有摄取属性,而是直接转到<product>
属性。这意味着每条进线都是一个产品(及其子元素)。
input {
file {
path => /file/example*.xml"
start_position => "beginning"
sincedb_path => "/dev/null"
type => "xml"
codec => multiline {
pattern => "<product>"
negate => "true"
what => "previous"
}
}
}
filter {
xml {
source => "message"
store_xml => false
xpath => [
"/product/@name", "name"
]
}
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句