Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Target is required value as xml_store is default to true #37

Open
purbon opened this issue May 31, 2016 · 3 comments
Open

Target is required value as xml_store is default to true #37

purbon opened this issue May 31, 2016 · 3 comments
Labels

Comments

@purbon
Copy link

purbon commented May 31, 2016

According to documentation:

 # XML in the value of the source field will be expanded into a
  # datastructure in the `target` field.
  # Note: if the `target` field already exists, it will be overridden.
  # Required if `store_xml` is true (which is the default).

https://github.com/logstash-plugins/logstash-filter-xml/blob/master/lib/logstash/filters/xml.rb#L40

what makes this field required, but is not like this in the documentation causing probably many unknown errors until this is discovered.

Easy fix would be to just make the target field required.

@purbon purbon added the bug label May 31, 2016
@magnusbaeck
Copy link
Contributor

Easy fix would be to just make the target field required.

But... then people would have to set the target option even if they disable store_xml and the target option's value is unused. Is that really better than the current situation where users get a concrete and descriptive error message if they screw up the configuration?

@mut3
Copy link

mut3 commented Nov 18, 2016

Just ran into this issue today. Tried to set an xml filter with only a source field. A concrete and descriptive error message seems to be raised here:

def register
    require "nokogiri"
    require "xmlsimple"

    if @store_xml && (!@target || @target.empty?)
      raise LogStash::ConfigurationError, I18n.t(
        "logstash.runner.configuration.invalid_plugin_register",
        :plugin => "filter",
        :type => "xml",
        :error => "When the 'store_xml' configuration option is true, 'target' must also be set"
      )
    end
  end

But this error does not actually make it to the end user, at least in my case, here's what I got:

Pipeline aborted due to error {:exception=>"LogStash::ConfigurationError", :backtrace=>["/opt/logstash/vendor/bundle/jruby/1.9/gems/logstash-filter-xml-2.2.0/lib/logstash/filters/xml.rb:106:in `register'", "/opt/logstash/vendor/bundle/jruby/1.9/gems/logstash-core-2.4.0-java/lib/logstash/pipeline.rb:182:in `start_workers'", "org/jruby/RubyArray.java:1613:in `each'", "/opt/logstash/vendor/bundle/jruby/1.9/gems/logstash-core-2.4.0-java/lib/logstash/pipeline.rb:182:in `start_workers'", "/opt/logstash/vendor/bundle/jruby/1.9/gems/logstash-core-2.4.0-java/lib/logstash/pipeline.rb:136:in `run'", "/opt/logstash/vendor/bundle/jruby/1.9/gems/logstash-core-2.4.0-java/lib/logstash/agent.rb:491:in `start_pipeline'"], :level=>:error}

Actually receiving this error and/or more clearly stated documentation would solve a lot of headaches.

I found this open issue because after some extensive googling I could not find why my XML was failing so I went and looked at the register block in the xml filter code.

@magnusbaeck
Copy link
Contributor

@mut3, your bad experience is due to a bug in Logstash 2.4.0 that was fixed in 2.4.1 and 5.x (although in different ways). See elastic/logstash#6011 for the fix that went into 2.4.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants