Hi All,
I need help for parsing my xml file
My xml file look like this:
<UserList>
<User statefile='10'>
<UserAt atName='NUMBER'>3312348555</UserAt>
<UserAt atName='ID'>308014204145695</UserAt>
<UserAt atName='segTo'>X5XXX</UserAt>
<UserAt atName='descriptionSegTo'>XXX 10Ci 4C XX XXX</UserAt >
<UserAt atName='payMode'>yes</UserAt >
</User>
<User statefile='60'>
<UserAt atName='NUMBER'>3312348555</UserAt>
<UserAt atName='ID'>308014204145695</UserAt>
<UserAt atName='segTo'>X5XXX</UserAt>
<UserAt atName='descriptionSegTo'>XXX 10Ci 4C XX XXX</UserAt >
<UserAt atName='payMode'>yes</UserAt>
<ServPrest hash='TTGHB' date=''/>
</User>
.....
</UserList>
I want my output in this format:
"NUMBER" => 3312348555
"ID" => 308014204145695
"segTo" => X5XXX
"descriptionSegTo" => XXX 10Ci 4C XX XXX
"payMode" => yes
"NUMBER" => 3312348555
"ID" => 308014204145695
"segTo" => X5XXX
"descriptionSegTo" => XXX 10Ci 4C XX XXX
"payMode" => yes
"hash" => TTGHB
.....
My logstash configuration:
input {
file {
path => "/home/osad/fichierxml"
sincedb_path => "/dev/null"
start_position => "beginning"
codec => multiline {
pattern => "<User>"
negate => true
what => "previous"
}
}
}
filter {
xml{
source => "message"
store_xml => false
# target => "doc"
xpath =>
[
"/User/UserAt/@atName='NUMBER'","NUMBER",
"/User/UserAt/@atName='ID'","ID",
"/User/UserAt/@atName='segTo'","SEGTO",
]
}
}
output {
elasticsearch {
hosts => ["http://localhost:9200"]
index => "test_xml"
}
stdout {
codec => rubydebug
}
}
But I have any results when I run logstash. it stays stuck on:
[2019-08-23T09:29:17,519][INFO ][logstash.javapipeline ] Pipeline started {"pipeline.id"=>"main"}
[2019-08-23T09:29:17,812][INFO ][logstash.agent ] Pipelines running {:count=>1, :running_pipelines=>[:main], :non_running_pipelines=>[]}
[2019-08-23T09:29:17,910][INFO ][filewatch.observingtail ] START, creating Discoverer, Watch with file and sincedb collections
[2019-08-23T09:29:19,373][INFO ][logstash.agent ] Successfully started Logstash API endpoint {:port=>9600}
Thank you in advance !