Developing a Logstash plugin within Docker

Hi, I'm more of a Python and C developer than a Ruby a Java developer, but I have a need to make my first real logstash plugin for some work I'm doing with Elastic.

My development environment is Windows 10 Enterprise with Docker Desktop, so while I intend to do all my code editing in Visual Studio Code, I want to do all my building and testing inside Docker containers. I realise I could just fire up a Linux VM at have at it, but I want to practice some useful DevOps style of skills that would be useful to spread around the rest of my team.

What I intend to do is the following:

  • fork logstash-filter-geoip
  • make it more generic to handle any (custom-made) MMDB datafile (that's another story :slight_smile:)
  • build / test / run my plugin using the logstash container image

What I'm need help with:

  • can someone verify if this is feasible?
  • or is there an image that someone has already made that is suitable for such development?
  • or should I create my own container image for building my plugin?

If I need to create my own custom container image, then I would suspect it would look something like https://github.com/elastic/logstash/blob/master/Dockerfile....
actually no, as it would seem that https://github.com/elastic/logstash/blob/master/docker/templates/Dockerfile.j2 is the real Dockerfile that is used.

Comparing with the logstash filter development documentation https://www.elastic.co/guide/en/logstash/current/filter-new-plugin.html, I would need:

  • rake (noting /usr/share/logstash/vendor/jruby/bin/ is not in the PATH)
  • bundle command is not found, which is needed for running tests. I saw one in /usr/share/logstash/vendor/bundle/jruby/2.5.0/bin/, but it has a shebang that points to a non-installed version of Java 8

I see that https://github.com/elastic/logstash#prerequisites says that you should 'gem install rake' and 'gem install bundler', which I've done inside the container using the 'gem' from the vendored Jruby.

Ideally what I'm aiming for is a container image that will take a directory containing my logstash-filter-mmdb directory, build it and run tests, and emit the compiled plugin ready for running inside a logstash instance.

Cheers,
Cameron

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.