我是Elasticsearch和Logstash的新手,我想为Logstash创建配置文件,该文件可以加载XML文件数据,因此我可以使用kibana在elasticsearch中进行搜索。如何创建此配置?
XML文件结构为:
make
答案 0 :(得分:0)
以下是logstash中xml conf的示例:
input {
file
{
path => "/home/Test_xml.xml"
start_position => "beginning"
codec => multiline
{
pattern => "^<\?book .*\>"
negate => true
what => "previous"
}
sincedb_path => "/dev/null"
}
}
filter
{
xml {
source => "message"
target => "parsed"
}
split {
field => "[parsed][book]"
add_field => {
bookAuthor => "%{[parsed][book][author]}"
title => "%{[parsed][book][title]}"
genre => "%{[parsed][book][genre]}"
price => "%{[parsed][book][price]}"
publish_date => "%{[parsed][book][publish_date]}"
description => "%{[parsed][book][description]}"
}
}
}
output
{
elasticsearch {
hosts => "localhost:9200"
index => "xml_test"
}
stdout
{
codec => rubydebug
}
}
xml file的链接
我试图用logstash将数据插入elasticsearh中。 希望这会成功。