github.com/yankunsam/loki/v2@v2.6.3-0.20220817130409-389df5235c27/clients/cmd/logstash/README.md (about)

     1  # Contributing to Loki Logstash Output Plugin
     2  
     3  For information about how to use this plugin see this [documentation](../../docs/sources/clients/logstash/_index.md).
     4  
     5  ## Install dependencies
     6  
     7  First, make sure you have JDK version `8` or `11` installed and you have set the `JAVA_HOME` environment variable.
     8  
     9  You need to setup JRuby environment to build this plugin. Refer https://github.com/rbenv/rbenv for setting up your rbenv environment.
    10  
    11  After setting up `rbenv`. Install JRuby
    12  
    13  ```bash
    14  rbenv install jruby-9.2.10.0
    15  rbenv local jruby-9.2.10.0
    16  ```
    17  
    18  Check that the environment is configured
    19  
    20  ```bash
    21  ruby --version
    22  jruby 9.2.10
    23  ```
    24  
    25  You should make sure you are running `jruby` and not `ruby`. If the command `ruby --version` still shows `ruby` and not `jruby`, check that PATH contains `$HOME/.rbenv/shims` and `$HOME/.rbenv/bin`. Also verify that you have this in your bash profile:
    26  
    27  ```bash
    28  export PATH="$HOME/.rbenv/bin:$PATH"
    29  eval "$(rbenv init -)"
    30  ```
    31  
    32  Then install bundler:
    33  
    34  ```bash
    35  gem install bundler:2.1.4
    36  ```
    37  
    38  Follow those instructions to [install logstash](https://www.elastic.co/guide/en/logstash/current/installing-logstash.html) before moving to the next section.
    39  
    40  ## Build and test the plugin
    41  
    42  ### Install required packages
    43  
    44  ```bash
    45  git clone git@github.com:elastic/logstash.git
    46  cd logstash
    47  git checkout tags/v7.16.1
    48  export LOGSTASH_PATH="$(pwd)"
    49  export GEM_PATH="$LOGSTASH_PATH/vendor/bundle/jruby/2.5.0"
    50  export GEM_HOME="$LOGSTASH_PATH/vendor/bundle/jruby/2.5.0"
    51  ./gradlew assemble
    52  cd ..
    53  ruby -S bundle config set --local path "$LOGSTASH_PATH/vendor/bundle"
    54  ruby -S bundle install
    55  ruby -S bundle exec rake vendor
    56  ```
    57  
    58  ### Build the plugin
    59  
    60  ```bash
    61  gem build logstash-output-loki.gemspec
    62  ```
    63  
    64  ### Test
    65  
    66  ```bash
    67  ruby -S bundle exec rspec
    68  ```
    69  
    70  Alternatively if you don't want to install JRuby. Enter inside logstash-loki container.
    71  
    72  ```bash
    73  docker build -t logstash-loki ./
    74  docker run -v  $(pwd)/spec:/home/logstash/spec -it --rm --entrypoint /bin/sh logstash-loki
    75  bundle exec rspec
    76  ```
    77  
    78  ## Install plugin to local logstash
    79  
    80  ```bash
    81  bin/logstash-plugin install --no-verify --local logstash-output-loki-1.0.0.gem
    82  ```
    83  
    84  ## Send sample event and check plugin is working
    85  
    86  ```bash
    87  bin/logstash -f loki.conf
    88  ```