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
[META] Native support for Java plugins #9215
Comments
Hi, I will need it to production in 4-5 months. Where can I find documentation about this new java plugin? When it should be in production ready stage? Thanks a lot! In addition I would to contribute from my knowledge to convert some of the plugin from ruby to java. Thanks Ziv |
@zivziv77, the current plan for this work is to release the Java Plugin API in a series of phases. The first phase is the experimental phase in which we'll solicit feedback on its basic functionality. After that, it would progress to the beta phase where we'd evaluate its stability and then it would be released as GA. I would hope that we would have something within your target timeframe, but I cannot commit to any specific release date. Right now, that work is happening in the It may also be worth mentioning that we do already have a number of hybrid Ruby/Java plugins in which the bulk of the code is Java using Ruby shims to interface with the Ruby plugin API in Logstash. The TCP, date, and DLQ plugins are examples of hybrid Ruby/Java plugins if you'd like some examples of how those work. |
@zivziv77, I should also add that we'd be happy to have any contributions you might make in converting plugins from Ruby to Java! |
Hi Thanks for your detailed answer. Where can I find documentation about how the java api works? I just think it doesn’t make sense writing hybrid plugin java and ruby if there’s going to be support for full java plugin without ruby. Thanks |
@zivziv77, we don't have docs for the Java API, yet. It's pretty simple, so perhaps a brief explanation will provide what you need. (Note that these APIs are subject to change, though it is unlikely that they will change significantly.) Your Redis input will need to implement the You will also need to provide a constructor that takes two parameters of type Let me know if that helps or if you have additional questions. |
Thank you! |
Oh, right. You'll need to add the |
I wanted to try to create a filter for two of my (Java) projects (Yauaa and Logparser) so I decided to start by simply trying to build the java filter example.
So I download logstash 6.6.0 and hardcoded the path into the build.gradle file.
It would really help me if you can point me a bit more into the right direction (preferably by updating the readme in the example project). Thanks. |
@nielsbasjes, thank you for experimenting with the Java plugin API. You have noted some deficiencies in the existing documentation which have also been reported here: logstash-plugins/logstash-filter-java_filter_example#1 I am working on improving that documentation. Let me know if my explanation in that issue doesn't get you back up and running. |
Ok, So as a first step I tried to simply "get the example running". In an empty working directory: First get a really clean logstash
Then get the filter example
I had to create this (documented but missing) file: lib/logstash-filter-java_filter_example_jars.rb
Then build the filter gem
Install the filter
Create test input file
Test config file run-test.conf
When I run this using
I get
|
@nielsbasjes, thank you for trying out the Java plugin API and leaving feedback on your experience. The problem you encountered when attempting to run Logstash with the example filter is that you were not running Logstash with the Java execution engine (with the The rest of the steps you took look good. In the beta version of the Java plugin API that will be released with Logstash 6.7.0, many of the manual steps and all of the boilerplate Ruby source files will be automated. |
Yes, that does the trick!!
|
FYI: I have been playing around with the example filter and now I have it working being built fully by Maven |
I wanted to create a first 'real' filter and ran into something I do not understand. My starting point (This tag in my git repo) works on my machine. using this filter config
The output I get on a file containing "Niels Basjes" is
which is what I expected. Now I change this code in only 1 single aspect: The javacode no longer lives under That is the only change! (Tag in my git repo) When I repeat the same steps I now get this output:
So to me the underlying error seems to be this:
The place where I find this is in the just about the only piece of Ruby code:
Where the working variant only has one line different: The one near the end
|
For now I'm using an ugly workaround. |
@nielsbasjes, congrats on the first working third-party Java filter! As for the change to the package of the filter, that does have to be updated in some of the Ruby source files as you noted above. I wasn't sure if that resolved your problem or if you needed something else. Also, in the beta release of this API which will land in Logstash 6.7.0, all the Ruby source files will be auto-generated so no manual editing of them will be required. |
The example filter clearly states (as expected):
The question I have: What is the proper way of failing in case of bad configuration so that a descriptive error message is passed on to the user? I have tried throwing an IllegalArgumentException but that wasn't shown in the console. |
@nielsbasjes, I typically throw an |
Thanks. |
I tried to compile a new codec plugin, but failed getting the execution right [2019-04-11T14:23:35,906][ERROR][logstash.plugins.registry] Problems loading a plugin with {:type=>"codec", :name=>"asc_codec", :path=>"logstash/codecs/asc_codec", :error_message=>"\n\n\tyou might need to reinstall the gem which depends on the missing jar or in case there is Jars.lock then resolve the jars with require'", "C:/es7/logstash/vendor/bundle/jruby/2.5.0/gems/polyglot-0.3.5/lib/polyglot.rb:65:in require'", "C:/es7/logstash/logstash-core/lib/logstash/codecs/asc_codec.rb:1:in <main>'", "org/jruby/RubyKernel.java:984:in require'", "C:/es7/logstash/vendor/bundle/jruby/2.5.0/gems/polyglot-0.3.5/lib/polyglot.rb:65:in require'", "C:/es7/logstash/logstash-core/lib/logstash/plugins/registry.rb:181:in legacy_lookup'", "C:/es7/logstash/logstash-core/lib/logstash/plugins/registry.rb:156:in block in lookup'", "org/jruby/ext/thread/Mutex.java:165:in synchronize'", "C:/es7/logstash/logstash-core/lib/logstash/plugins/registry.rb:152:in lookup'", "C:/es7/logstash/logstash-core/lib/logstash/plugins/registry.rb:206:in lookup_pipeline_plugin'", "C:/es7/logstash/logstash-core/lib/logstash/plugin.rb:137:in lookup'", "org/logstash/plugins/PluginFactoryExt.java:200:in plugin'", "org/logstash/plugins/PluginFactoryExt.java:308:in plugin'", "org/logstash/plugins/PluginFactoryExt.java:117:in buildInput'", "org/logstash/execution/JavaBasePipelineExt.java:50:in initialize'", "C:/es7/logstash/logstash-core/lib/logstash/java_pipeline.rb:23:in initialize'", "C:/es7/logstash/logstash-core/lib/logstash/pipeline_action/create.rb:36:in execute'", "C:/es7/logstash/logstash-core/lib/logstash/agent.rb:325:in block in converge_state'"]}
Example encoding: utf-8require "logstash/codecs/base" class LogStash::Codecs::AsnCodec < LogStash::Codecs::Base def self.javaClass() org.logstash.javaapi.AsnCodec.java_class; end require 'jar_dependencies' |
@synapticiel can you please move this comment to a new issue? there is no need to add debugging discussions to this one as it was created to track the progress of implementation. If necessary you can always link that new issue to this one. |
The beta support for this was released with version 6.7 several weeks ago. So far the dependencies needed to build a plugin haven't been released to maven central yet. Can you indicate when this will be done? Right now I'm unable to automate my plugin build. |
@nielsbasjes, we would like to get to the point where we are publishing a minimal jar containing the Java plugin API to Maven, but that involves some non-trivial refactoring of dependencies in Logstash core and changes to our build and deployment processes. We will be releasing the Java plugin API as GA in the upcoming 7.2.0 release of Logstash without publishing those artifacts because we did not want to hold up the overall effort for that. Until we are able to complete that work, plugin builds can be automated with the new |
Thanks for the update. |
@nielsbasjes, that was an option but a big part of the reason we did not do that is that not all of the public classes in the logstash-core jar are part of the plugin API and are therefore not subject to the backward compatibility guarantees within major versions that we make for the plugin API itself. We did not want to give that impression by publishing a jar that contains nearly all of the Java source code for Logstash. |
I want to use third-party jars in the java-plugins, I want to know if java-plugins supports this feature.Can you give me some help? |
@YSZYCF, yes, third-party jars are definitely supported. The example Java plugins use those in several places. For example, see the Apache Commons and Log4j2 dependencies in the Java filter: https://github.com/logstash-plugins/logstash-filter-java_filter_example/blob/master/build.gradle |
@danhermann OK |
@danhermann hi.. i am working on a filter plugin in java. I chose to write some part of it in scala classes(for ease of coding) and used that code in java code. Unit tests works fine..configured gradle to compile scala first and then java code.. gem file generated has only one single jar. I was able to install the gem successfully into logstash 7.2 locally. |
nevermind, I figured out the issue, it needed scala library packaged into the jar as well, once that included, it worked fine. |
@danhermann ,hello,I used the example you supplyed in “https://www.elastic.co/guide/en/logstash/current/java-codec-plugin.html”,and success get the result by the java_stdin。However,when i set input from kafka,I got the error: Need your help, thank you very much~ |
@damozhizhou, if you'll post your question in the Logstash forums and tag me ( |
Closing this as Java plugins went GA in Logstash 7.2.0. Any additional work on Java plugins will be tracked in new issues. For help with developing your own Java plugins for Logstash, please post in the Logstash forums. You may tag me ( |
@danhermann The current process cannot be ran in a CI environment because of this missing jar. |
@nielsbasjes, could you open an issue here so we can track that effort separately? |
Hi, I built a custom JAVA Input plugin using the example JAVA plugin. I am able to install the GEM in the Logstash in my local. When I tried to install the custom plugin -the generated GEM file in my Dev server, getting the below exception, Received fatal alert: handshake_failure Could anyone brief on the process of installing the plugin developed in one machine in another Logstash instance. Thanks, |
Have a look at how I did it here https://www.github.com/nielsbasjes/yauaa/tree/master/udfs/logstash/logstash-filter/src/test/docker I simply install everything in a docker image and check if the output meets my expectations. |
This tracks the phases of the Native support for Java plugins Project.
Experimental phase:
Beta phase (#10232):
encode
anddecode
methods?flush
method for Java filtersco.elastic.logstash.api
GA (#10620):
Beyond GA?
The text was updated successfully, but these errors were encountered: