logstash-filter-device_detector

说明

这是一个基于ruby语言的logstash filter插件,用来解析http_user_agent,调用了外部库。

开发环境测试

1. 插件开发环境和测试

Code

  • 首先,您需要安装了Bundler gem的JRuby。
  • 执行下面的命令安装依赖 sh bundle install

Test

  • Update your dependencies
bundle install
  • Run tests
bundle exec rspec

这里在windows可能执行失败,暂时没研究什么原因。

2. 在logstash中运行未发布的插件

2.1 直接在logstash使用克隆下来的插件代码

进入logstash安装目录,一般是/usr/share/logstash

  • 编辑 Gemfile ,添加本地插件路径,如下所示: ruby gem "logstash-filter-device_detector", :path => "/path/to/logstash-filter-device-detector"
  • 安装插件 sh bin/logstash-plugin install --no-verify
  • 运行logstash测试此插件 sh cd /etc/logstash/conf.d vim test.conf # 添加如下内容 input { stdin {} } filter { device_detector { source => "message" } } output { stdout { codec => rubydebug } } # 运行logstash /usr/share/logstash/bin/logstash -f test.conf 然后在屏幕输入useragent就可以看到效果了。

2.2 在logstash使用gem安装插件

You can use the same 2.1 method to run your plugin in an installed Logstash by editing its Gemfile and pointing the :path to your local plugin development directory or you can build the gem and install it using:

  • 构建gem sh gem build logstash-filter-device-detector.gemspec
  • 进入logstash安装目录,安装gem插件 sh bin/logstash-plugin install /your/local/plugin/logstash-filter-awesome.gem
  • Start Logstash and proceed to test the plugin

Contributing

All contributions are welcome: ideas, patches, documentation, bug reports, complaints, and even something you drew up on a napkin.

Programming is not a required skill. Whatever you've seen about open source and maintainers or community members saying "send patches or die" - you will not see that here.

It is more important to the community that you are able to contribute.

For more information about contributing, see the CONTRIBUTING file.