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

Accessing event field references with json_batch is causing exception #84

Open
kishoreck opened this issue Mar 12, 2018 · 5 comments
Open
Assignees

Comments

@kishoreck
Copy link

kishoreck commented Mar 12, 2018

  • Version: Logstash 5.5 [with logstash output http patch with json_batch enabled]
  • Operating System: Centos
  • Config File (if you have sensitive info, please remove it):
    if [@metadata][@Index]{
    http {
    format => "json_batch"
    http_method => "post"
    codec => "json"
    url => "https://myendpoint/%{[@metadata][@index]}"
    pool_max_per_route => 2000
    pool_max => 2000
    automatic_retries => 2
    retry_non_idempotent => true
    socket_timeout => 60
    connect_timeout => 60
    }
    }

With json_batch , not able to refer to the event's field references as specified in the logstash config. This is throwing an exception as follows

Exception in thread "[main]>worker1" java.net.URISyntaxException: Malformed escape pair at index 56: https://myendpoint/%{[@metadata][@index]}
at org.apache.http.client.utils.URIBuilder.(org/apache/http/client/utils/URIBuilder.java:82)
at Manticore::Client.uri_from_url_and_options(/usr/share/logstash/vendor/bundle/jruby/1.9/gems/manticore-0.6.1-java/lib/manticore/client.rb:450)
at Manticore::Client.uri_from_url_and_options(/usr/share/logstash/vendor/bundle/jruby/1.9/gems/manticore-0.6.1-java/lib/manticore/client.rb:450)
at Manticore::Client.request_from_options(/usr/share/logstash/vendor/bundle/jruby/1.9/gems/manticore-0.6.1-java/lib/manticore/client.rb:457)
at Manticore::Client.request_from_options(/usr/share/logstash/vendor/bundle/jruby/1.9/gems/manticore-0.6.1-java/lib/manticore/client.rb:457)
at Manticore::Client.request(/usr/share/logstash/vendor/bundle/jruby/1.9/gems/manticore-0.6.1-java/lib/manticore/client.rb:418)
at Manticore::Client.request(/usr/share/logstash/vendor/bundle/jruby/1.9/gems/manticore-0.6.1-java/lib/manticore/client.rb:418)
at Manticore::Client.post(/usr/share/logstash/vendor/bundle/jruby/1.9/gems/manticore-0.6.1-java/lib/manticore/client.rb:265)
at Manticore::Client.post(/usr/share/logstash/vendor/bundle/jruby/1.9/gems/manticore-0.6.1-java/lib/manticore/client.rb:265)
at LogStash::Outputs::Http.send_json_batch(/usr/share/logstash/logstash-output-http/lib/logstash/outputs/http.rb:145)
at LogStash::Outputs::Http.send_json_batch(/usr/share/logstash/logstash-output-http/lib/logstash/outputs/http.rb:145)
at LogStash::Outputs::Http.multi_receive(/usr/share/logstash/logstash-output-http/lib/logstash/outputs/http.rb:121)
at LogStash::Outputs::Http.multi_receive(/usr/share/logstash/logstash-output-http/lib/logstash/outputs/http.rb:121)
at LogStash::OutputDelegatorStrategies::Shared.multi_receive(/usr/share/logstash/logstash-core/lib/logstash/output_delegator_strategies/shared.rb:13)
at LogStash::OutputDelegatorStrategies::Shared.multi_receive(/usr/share/logstash/logstash-core/lib/logstash/output_delegator_strategies/shared.rb:13)
at LogStash::OutputDelegator.multi_receive(/usr/share/logstash/logstash-core/lib/logstash/output_delegator.rb:47)
at LogStash::OutputDelegator.multi_receive(/usr/share/logstash/logstash-core/lib/logstash/output_delegator.rb:47)
at LogStash::Pipeline.output_batch(/usr/share/logstash/logstash-core/lib/logstash/pipeline.rb:420)
at LogStash::Pipeline.output_batch(/usr/share/logstash/logstash-core/lib/logstash/pipeline.rb:420)
at org.jruby.RubyHash.each(org/jruby/RubyHash.java:1342)
at LogStash::Pipeline.output_batch(/usr/share/logstash/logstash-core/lib/logstash/pipeline.rb:419)
at LogStash::Pipeline.output_batch(/usr/share/logstash/logstash-core/lib/logstash/pipeline.rb:419)
at RUBY.worker_loop(/usr/share/logstash/logstash-core/lib/logstash/pipeline.rb:365)
at RUBY.start_workers(/usr/share/logstash/logstash-core/lib/logstash/pipeline.rb:330)

PS: Accessing the event data [for example "Url" in this case] is working with json mode. Is this the expected behavior? Shouldn't "json_batch" also mock the "json" format with respect to accessing the event data?

@jsvd
Copy link
Member

jsvd commented Mar 12, 2018

@andrewvc it seems the new json_batch sender method doesn't perform sprintf on the @url, I don't see a reason not to have it, thoughts?

@jsvd jsvd self-assigned this Mar 13, 2018
@jsvd jsvd added the bug label Mar 13, 2018
@jsvd
Copy link
Member

jsvd commented Mar 14, 2018

@kishoreck what is your expectation for field references in url when using json_batch?
a) given a list of events, each event's url field will be sprinted and multiple sub batches are sent to different urls?
b) you assume all events in a batch will sprintf to the same url?

@andrewvc
Copy link
Contributor

andrewvc commented Mar 14, 2018 via email

@kishoreck
Copy link
Author

@jsvd - We are looking for something similar to option "a", as the events that are coming in will have different values and dynamic in nature and will have to pick/form the appropriate URL based on the input event's fields.

@jsvd
Copy link
Member

jsvd commented Jul 11, 2018

The json_batch mode was made so that the received batch of events could be sent in a single HTTP request. If you need custom/dynamic urls then you can use the normal modes.
We could in the future implement the ability evaluate all elements in the batch and spawn sub batches, but I don't see this coming in the near future (and it slows down the current json_batch format)

@jsvd jsvd added enhancement and removed bug labels Jul 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants