# logstash-filter-restful **Repository Path**: dayu/logstash-filter-restful ## Basic Information - **Project Name**: logstash-filter-restful - **Description**: 从一个restful接口获得需要查询的数据,并将结果加入到当前的event中。需要为当前event中任何字段值添加额外的数据,都可以用这个插件,只要你提供一个restful接口就可以。 - **Primary Language**: Ruby - **License**: GPL-3.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 2 - **Forks**: 1 - **Created**: 2016-12-28 - **Last Updated**: 2021-02-05 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README [logstash插件安装-Restful](https://app.yinxiang.com/shard/s47/nl/12894664/46d00467-2b6e-4080-b6f4-66b2b3189d5f) [插件的gem](https://git.oschina.net/dayu/logstash-filter-restful/raw/master/logstash-filter-restful-1.0.0.gem) ``` $cd $LOGSTASH_HOME $makedir plugin ``` 将附件gem文件拷贝到文件夹plugin中 ``` $cd bin $ ./plugin install ../plugin/logstash-filter-restful-1.0.0.gem ``` > Validating ../plugin/logstash-filter-restful-1.0.0.gem > Installing logstash-filter-restful > Installation successful > 有上述提示表示安装成功 ``` $./plugin list ``` 查看是否存在于插件列表中 LOGSTASH配置示例: ``` filter{ //restful是一个过滤器插件,所有必须配置在filter之中 restful { source => "poorIP1" //source必须有,值为事件中的某个存在的字段名;被指定的字段的值为Restful接口的参数 uri => "http://192.168.0.152:53833/ipi/" //被调用Restful接口的URI,加上source所指定的参数,组合成Restful接口的调用URL。注:最后一个斜杠/不可缺少。 target => "taobaoip" //调用返回之后,将写入事件中这个字段名之下。 } restful //此过滤器可对同一事件使用多次 { source => "badIP1" uri => "http://192.168.0.152:53833/ipi/" target => "taobaoip" } } ``` _____________________________________________________________________________________________________________________________________ ### 附录: # [Logstash Plugin](https://www.elastic.co/guide/en/logstash/current/_how_to_write_a_logstash_filter_plugin.html) [![Travis Build Status](https://travis-ci.org/logstash-plugins/logstash-filter-example.svg)](https://travis-ci.org/logstash-plugins/logstash-filter-example) This is a plugin for [Logstash](https://github.com/elastic/logstash). It is fully free and fully open source. The license is Apache 2.0, meaning you are pretty much free to use it however you want in whatever way. ## Documentation Logstash provides infrastructure to automatically generate documentation for this plugin. We use the asciidoc format to write documentation so any comments in the source code will be first converted into asciidoc and then into html. All plugin documentation are placed under one [central location](http://www.elastic.co/guide/en/logstash/current/). - For formatting code or config example, you can use the asciidoc `[source,ruby]` directive - For more asciidoc formatting tips, see the excellent reference here https://github.com/elastic/docs#asciidoc-guide ## Need Help? Need help? Try #logstash on freenode IRC or the https://discuss.elastic.co/c/logstash discussion forum. ## Developing ### 1. Plugin Developement and Testing #### Code - To get started, you'll need JRuby with the Bundler gem installed. - Create a new plugin or clone and existing from the GitHub [logstash-plugins](https://github.com/logstash-plugins) organization. We also provide [example plugins](https://github.com/logstash-plugins?query=example). - Install dependencies ```sh bundle install ``` #### Test - Update your dependencies ```sh bundle install ``` - Run tests ```sh bundle exec rspec ``` ### 2. Running your unpublished Plugin in Logstash #### 2.1 Run in a local Logstash clone - Edit Logstash `Gemfile` and add the local plugin path, for example: ```ruby gem "logstash-filter-awesome", :path => "/your/local/logstash-filter-awesome" ``` - Install plugin ```sh # Logstash 2.3 and higher bin/logstash-plugin install --no-verify # Prior to Logstash 2.3 bin/plugin install --no-verify ``` - Run Logstash with your plugin ```sh bin/logstash -e 'filter {awesome {}}' ``` At this point any modifications to the plugin code will be applied to this local Logstash setup. After modifying the plugin, simply rerun Logstash. #### 2.2 Run in an installed Logstash 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: - Build your plugin gem ```sh gem build logstash-filter-awesome.gemspec ``` - Install the plugin from the Logstash home ```sh # Logstash 2.3 and higher bin/logstash-plugin install --no-verify # Prior to Logstash 2.3 bin/plugin install --no-verify ``` - 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](https://github.com/elastic/logstash/blob/master/CONTRIBUTING.md) file.