Logstash 插件開發

Logstash

背景

Logstash 是一個用於日誌收集、處理、轉發的軟件,對應 input/filter/output 三個階段,能夠配置多個插件實現流式處理javascript

咱們能夠自定義開發插件,實現豐富的日誌處理功能java

參考文檔 www.elastic.co/products/lo…linux

安裝 jruby

  1. Download JRuby from jruby.org/
  2. Extract JRuby into a directory.
  3. Add that directory's bin subdirectory to the end of your path.
    PATH=$PATH:/path/to/jruby-version/bin/複製代碼
  4. Test it: jruby -v
    jruby 9.1.6.0 (2.3.1) 2016-11-09 0150a76 Java HotSpot(TM) 64-Bit Server VM 25.45-b02 on 1.8.0_45-b14 +jit [linux-x86_64]複製代碼

安裝 Bundler

  1. 參考文檔 bundler.io/
    /path/to/jruby-veriosn/bin/jgem install bundler複製代碼
  2. 修改 bundle 下載源
bundle config mirror.https://rubygems.org https://gems.ruby-china.org複製代碼

換成國內的下載源後,能夠加速依賴安裝過程,參考文檔 gems.ruby-china.org/ios

使用 Logstash plugin 腳本生成插件模板

/path/to/logstash-version/bin/logstash-plugin generate --type input --name demo --path /path/to/plugins複製代碼

安裝 Logstash plugin 須要的依賴

cd /path/to/plugins/logstash-input-demo複製代碼

修改 logstash-input-demo.gemspec 文件中 TODO 相關的內容,而後執行安裝依賴:ruby

bundle install複製代碼

測試插件

bundle exec rspec複製代碼

參考文檔 [rspec.info/](http://rs…微信

生成 gem 包

/path/to/jruby-veriosn/bin/gem build {logstash-filter-example}.gemspec複製代碼

安裝&查看插件

/path/to/logstash-version/bin/logstash-plugin install /path/to/gemfile複製代碼
/path/to/logstash-version/bin/logstash-plugin list複製代碼

總結

若是你的插件成功安裝,那麼就能夠在 Logstash 的配置文件中引用了svg

(還有疑問?聯繫做者微博/微信 @Ceelog)測試

相關文章
相關標籤/搜索