Hello,
I've just started working on a Java binding for Logstash.
My initial goal was to be able to write unit tests in Java but once we have a binding in place we could do so much more.
To give you some context, I'm working on a system where we handle more than 100 different types of events and we want to make sure that everything is working as expected. Currently we are running Rspec tests from a Maven build using Logstash distribution zip. This solution is working but it's not great.
With a Java binding, I could write a simple JUnit tests:
@Test
public void should_lowercase_message() throws IOException {
URL url = Resources.getResource(LogstashFilterTest.class, "filter_config.conf");
String config = Resources.toString(url, Charsets.UTF_8);
Pipeline pipeline = Logstash.Pipeline.create(config);
Event event = pipeline.send("You don't need to YELL!");
assertThat(event.getMessage()).isEqualTo("you don't need to yell!");
}
My main concern is that I have to declare explicitly every dependencies to create the Logstash distribution (default patterns, filters, codecs...).
Also I don't know how I can provide a simple solution if a user want to unit test a custom filter or a use another version for a specific filter.
I'm aware that @colinsurprenant is already working on a project inside Logstash repository to create a Java API around event. As far as I know, the idea is to expose a pure Java API to plugins developers to support Java plugins.
We have different goal but maybe we should work together to avoid doing the same thing twice ?
What do you think ?