Помогите извлечь поли из xml в message

input дает мне xml в message
Хочу из message извлечь поля status, number, tip, Data

xml отчет такой

<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
   <soap:Body>
      <m:GetDocumentsResponse xmlns:m="http://localhost/request">
         <m:return xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <m:Document>
               <m:Status>Зарегистрировано</m:Status>
               <m:Number>000000001</m:Number>
               <m:Tip>Внутренняя</m:Tip>
               <m:DataDoc>2019-08-01T14:43:21</m:DataDoc>
            </m:Document>
            <m:Document>
               <m:Status>Исполнено</m:Status>
               <m:Number>000000002</m:Number>
               <m:Tip>Внешняя</m:Tip>
               <m:DataDoc>2019-08-05T17:17:00</m:DataDoc>
            </m:Document>
            <m:Document>
               <m:Status>Зарегистрировано</m:Status>
               <m:Number>000000003</m:Number>
               <m:Tip>Внешняя</m:Tip>
               <m:DataDoc>2019-08-08T12:47:17</m:DataDoc>
            </m:Document>
            <m:Document>
               <m:Status>Исполнено</m:Status>
               <m:Number>000000004</m:Number>
               <m:Tip>Внутренняя</m:Tip>
               <m:DataDoc>2019-08-15T10:47:53</m:DataDoc>
            </m:Document>
            <m:Document>
               <m:Status>Зарегистрировано</m:Status>
               <m:Number>000000005</m:Number>
               <m:Tip>Внешняя</m:Tip>
               <m:DataDoc>2019-08-19T10:32:35</m:DataDoc>
            </m:Document>
            <m:Document>
               <m:Status>Зарегистрировано</m:Status>
               <m:Number>000000006</m:Number>
               <m:Tip>Внутренняя</m:Tip>
               <m:DataDoc>2019-08-19T10:47:28</m:DataDoc>
            </m:Document>
            <m:Document>
               <m:Status>Зарегистрировано</m:Status>
               <m:Number>000000007</m:Number>
               <m:Tip>Внутренняя</m:Tip>
               <m:DataDoc>2019-08-20T15:28:57</m:DataDoc>
            </m:Document>
            <m:Document>
               <m:Status>Зарегистрировано</m:Status>
               <m:Number>000000008</m:Number>
               <m:Tip>Внешняя</m:Tip>
               <m:DataDoc>2019-08-21T15:25:06</m:DataDoc>
            </m:Document>
            <m:Document>
               <m:Status>Зарегистрировано</m:Status>
               <m:Number>000000009</m:Number>
               <m:Tip>Внешняя</m:Tip>
               <m:DataDoc>2019-08-27T16:54:25</m:DataDoc>
            </m:Document>
            <m:Document>
               <m:Status>Зарегистрировано</m:Status>
               <m:Number>000000010</m:Number>
               <m:Tip>Внешняя</m:Tip>
               <m:DataDoc>2019-08-29T17:06:39</m:DataDoc>
            </m:Document>
         </m:return>
      </m:GetDocumentsResponse>
   </soap:Body>
</soap:Envelope>

мой logstsh config

input {
      http_poller {
        urls => {
          soap_request => {
    					method => post
    					url => "???"
    		headers => {
    					"Content-Type" => "text/xml; charset=utf-8"
    					"SOAPAction" => "???"
    					}
            body => '<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:req="http://localhost/request">
    					   <soap:Header/>
    					   <soap:Body>
    						  <req:GetDocuments>
    							 <req:Date1>2019-08-01</req:Date1>
    							 <req:Date2>2019-08-31</req:Date2>
    						  </req:GetDocuments>
    					   </soap:Body>
    					</soap:Envelope>'
    		auth => {
    				user => "1"
    				password => "1"
    				}
    			  }
    			}
    		schedule => { cron => "* * * * * UTC"}
    			request_timeout => 60
    			 codec => "plain"
    		}			
    		}
    		filter {
         xml {
    	 source => "message"
    	    store_xml => false
             xpath => [
                "soap:Envelope/soap:Body/m:GetDocumentsResponse/m:return/m:Document/m:Status/text()", "Status",
    			"soap:Envelope/soap:Body/m:GetDocumentsResponse/m:return/m:Document/m:Number/text()", "Number",
    			"soap:Envelope/soap:Body/m:GetDocumentsResponse/m:return/m:Document/m:Tip/text()", "Tip",
    			"soap:Envelope/soap:Body/m:GetDocumentsResponse/m:return/m:Document/m:DataDoc/text()", "Data" ]
        }
    }
    	         

    		
    output {
        elasticsearch {
            hosts => ['localhost:9200']
            index => "xml222"
        }
        stdout {
            codec => rubydebug
        }
    } 

Делаю через filter xml не получается выдает ошибку конфига... Есть какие то решение на счет этого

Какую ошибку?

Выдает такую ошибку

 [2019-09-09T16:27:03,272][ERROR][logstash.pipeline        ] Exception in pipelineworker, the pipeline stopped processing new events, please check your filter configuration and restart Logstash. {:pipeline_id=>"xml", "exception"=>"//m:Document/m:Status/text()", "backtrace"=>["nokogiri/XmlXpathContext.java:128:in `evaluate'", "C:/Elastic/logstash-6.6.0/vendor/bundle/jruby/2.3.0/gems/nokogiri-1.10.0-java/lib/nokogiri/xml/searchable.rb:198:in `xpath_impl'", "C:/Elastic/logstash-6.6.0/vendor/bundle/jruby/2.3.0/gems/nokogiri-1.10.0-java/lib/nokogiri/xml/searchable.rb:179:in `xpath_internal'", "C:/Elastic/logstash-6.6.0/vendor/bundle/jruby/2.3.0/gems/nokogiri-1.10.0-java/lib/nokogiri/xml/searchable.rb:154:in `xpath'", "C:/Elastic/logstash-6.6.0/vendor/bundle/jruby/2.3.0/gems/logstash-filter-xml-4.0.6/lib/logstash/filters/xml.rb:153:in `block in filter'", "org/jruby/RubyHash.java:1343:in `each'", "C:/Elastic/logstash-6.6.0/vendor/bundle/jruby/2.3.0/gems/logstash-filter-xml-4.0.6/lib/logstash/filters/xml.rb:152:in `filter'", "C:/Elastic/logstash-6.6.0/logstash-core/lib/logstash/filters/base.rb:143:in `do_filter'", "C:/Elastic/logstash-6.6.0/logstash-core/lib/logstash/filters/base.rb:162:in `block in multi_filter'", "org/jruby/RubyArray.java:1734:in `each'", "C:/Elastic/logstash-6.6.0/logstash-core/lib/logstash/filters/base.rb:159:in `multi_filter'", "org/logstash/config/ir/compiler/AbstractFilterDelegatorExt.java:115:in `multi_filter'", "(eval):46:in `block in filter_func'", "C:/Elastic/logstash-6.6.0/logstash-core/lib/logstash/pipeline.rb:341:in `filter_batch'", "C:/Elastic/logstash-6.6.0/logstash-core/lib/logstash/pipeline.rb:320:in `worker_loop'", "C:/Elastic/logstash-6.6.0/logstash-core/lib/logstash/pipeline.rb:287:in `block in start_workers'"], :thread=>"#<Thread:0x57aed2f3 sleep>"}
[2019-09-09T16:27:03,481][FATAL][logstash.runner          ] An unexpected error occurred! {:error=>#<Nokogiri::XML::XPath::SyntaxError: //m:Document/m:Status/text()>, :backtrace=>["nokogiri/XmlXpathContext.java:128:in `evaluate'", "C:/Elastic/logstash-6.6.0/vendor/bundle/jruby/2.3.0/gems/nokogiri-1.10.0-java/lib/nokogiri/xml/searchable.rb:198:in `xpath_impl'", "C:/Elastic/logstash-6.6.0/vendor/bundle/jruby/2.3.0/gems/nokogiri-1.10.0-java/lib/nokogiri/xml/searchable.rb:179:in `xpath_internal'", "C:/Elastic/logstash-6.6.0/vendor/bundle/jruby/2.3.0/gems/nokogiri-1.10.0-java/lib/nokogiri/xml/searchable.rb:154:in `xpath'", "C:/Elastic/logstash-6.6.0/vendor/bundle/jruby/2.3.0/gems/logstash-filter-xml-4.0.6/lib/logstash/filters/xml.rb:153:in `block in filter'", "org/jruby/RubyHash.java:1343:in `each'", "C:/Elastic/logstash-6.6.0/vendor/bundle/jruby/2.3.0/gems/logstash-filter-xml-4.0.6/lib/logstash/filters/xml.rb:152:in `filter'", "C:/Elastic/logstash-6.6.0/logstash-core/lib/logstash/filters/base.rb:143:in `do_filter'", "C:/Elastic/logstash-6.6.0/logstash-core/lib/logstash/filters/base.rb:162:in `block in multi_filter'", "org/jruby/RubyArray.java:1734:in `each'", "C:/Elastic/logstash-6.6.0/logstash-core/lib/logstash/filters/base.rb:159:in `multi_filter'", "org/logstash/config/ir/compiler/AbstractFilterDelegatorExt.java:115:in `multi_filter'", "(eval):46:in `block in filter_func'", "C:/Elastic/logstash-6.6.0/logstash-core/lib/logstash/pipeline.rb:341:in `filter_batch'", "C:/Elastic/logstash-6.6.0/logstash-core/lib/logstash/pipeline.rb:320:in `worker_loop'", "C:/Elastic/logstash-6.6.0/logstash-core/lib/logstash/pipeline.rb:287:in `block in start_workers'"]}

А namespace для m в фильтре logstash задавать не пробовали?

Спасибо работает!

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.