我正在尝试解析 Logstash 中的 XML 文件。我想使用 XPath 来解析 XML 中的文档。所以当我运行我的配置文件时,数据加载到elasticsearch但它不是我想要加载数据的方式。加载进来的数据elasticsearch是xml文档中的每一行
我的 XML 文件的结构
我想要达到的目标:
在弹性搜索中创建存储以下内容的字段
ID =1
Name = "Finch"
Run Code Online (Sandbox Code Playgroud)
我的配置文件:
input{
file{
path => "C:\Users\186181152\Downloads\stations.xml"
start_position => "beginning"
sincedb_path => "/dev/null"
exclude => "*.gz"
type => "xml"
}
}
filter{
xml{
source => "message"
store_xml => false
target => "stations"
xpath => [
"/stations/station/id/text()", "station_id",
"/stations/station/name/text()", "station_name"
]
}
}
output{
elasticsearch{
codec => json
hosts => "localhost"
index => "xmlns"
}
stdout{
codec => rubydebug …Run Code Online (Sandbox Code Playgroud)