Как исправить ошибку «попытка добавления второго корневого элемента в документ» в logstash? - PullRequest
0 голосов
/ 06 ноября 2019

У меня есть следующий xml из API:

<Journey id=1 fpTime="12:33"></Journey>
<Journey id=2 fpTime="14:33"></Journey>

Я хочу разобрать каждое «Путешествие» отдельно и отправить его вasticsearch. Это моя конфигурация logstash:

input {
  http_poller {
    urls => {

      test2 => {
        method => get
         url => "https://reiseauskunft.bahn.de/bin/stboard.exe/dn?rt=1&input=Stuttgart%20Hauptbahnhof&boardType=dep&L=vs_java3&productsFilter=111110111&start=yes&maxJourneys=20"

     }

    }
     codec => multiline
        {
            pattern => "<Journey"
            negate => true
            what => "previous"
            charset => "ISO-8859-1"
            auto_flush_interval => 1
        }

    request_timeout => 20
    schedule => { cron => "* * * * * UTC"}
    metadata_target => "http_poller_metadata"
  }
}

    filter {
     xml {
        remove_namespaces => true
        source => "message"
        force_array => false
        target => "msg"
        xpath => ["/Journey/@fpTime", "jTime"]
      }
    }

Когда я запускаю logstash, я получаю следующую ошибку xmlParse:

:exception=>#<REXML::ParseException: #<RuntimeError: attempted adding second root element to document>Line: 1 Position: 6218
...