XML file
<?xml version="1.0" encoding="UTF-8"?>
-<Documents xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://localhost/request">
-<Document>
<Status>Зарегистрировано</Status>
<Number>000000001</Number>
<Tip>Внутренняя</Tip>
</Document>
-<Document>
<Status>Исполнено</Status>
<Number>000000002</Number>
<Tip>Внешняя</Tip>
</Document>
-<Document>
<Status>Зарегистрировано</Status>
<Number>000000003</Number>
<Tip>Внешняя</Tip>
</Document>
-<Document>
<Status>Исполнено</Status>
<Number>000000004</Number>
<Tip>Внутренняя</Tip>
</Document>
Logstash config
input {
file {
path =>"D:/ElasticMain/1C/servicesdeskxml.xml"
start_position => beginning
type => "document"
codec => multiline
{
pattern => "^<\?Document .*\>"
negate => true
what => "previous"
}
}
}
filter {
xml {
source => "document"
xpath =>
[
"/documents/document/status/text()", "document_status",
"/documents/document/number/text()", "document_number",
"/documents/document/tip/text()", "document_tip"
]
store_xml => true
target => "doc"
}
}
output {
stdout { codec => rubydebug }
elasticsearch {
index => "logstash-xml"
hosts => ["localhost:9200"]
document_type => "document"
}
}
logstash log
[2019-08-28T10:10:24,995][INFO ][filewatch.observingtail ] START, creating Discoverer, Watch with file and sincedb collections
[2019-08-28T10:10:25,339][INFO ][logstash.agent ] Successfully started Logstash API endpoint {:port=>9600}