logstash-input-sls 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
 - data/Gemfile +2 -0
 - data/LICENSE +21 -0
 - data/README.md +90 -0
 - data/README_CN.md +135 -0
 - data/lib/logstash/inputs/logservice.rb +71 -0
 - data/lib/logstash/vendor/jar-dependencies/runtime-jars/logstash-input-sls-1.0-SNAPSHOT.jar +0 -0
 - data/logstash-input-sls.gemspec +25 -0
 - metadata +116 -0
 
    
        checksums.yaml
    ADDED
    
    | 
         @@ -0,0 +1,7 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            ---
         
     | 
| 
      
 2 
     | 
    
         
            +
            SHA256:
         
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 9d5043bd9ad3a1cc123d446408dda36912b2dddd57b385c1c759923d66ee60ef
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: d721fa819bda7140a27c5ca9971058060591d7f497b6319b274500b7796377d2
         
     | 
| 
      
 5 
     | 
    
         
            +
            SHA512:
         
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: ea69bedf30527c0bc0e7eb39fe9fd6539759429564563ae4eb645c81f046644371d244356c2ef3ac93aca476a0462cb09a8d12f3a34e7aea2c31a70bfa2aff6e
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 5be4fdf65df4f3bc48a0b2216f57a1d6a046e33819c0127a2e4695192b2bd36a855e0a881a679eec4e9f1880a5f00e25ce078ec052f1b91ae56b8b02ee4708ff
         
     | 
    
        data/Gemfile
    ADDED
    
    
    
        data/LICENSE
    ADDED
    
    | 
         @@ -0,0 +1,21 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            The MIT License (MIT)
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            Copyright (c) 2019 Aliyun
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            Permission is hereby granted, free of charge, to any person obtaining a copy
         
     | 
| 
      
 6 
     | 
    
         
            +
            of this software and associated documentation files (the "Software"), to deal
         
     | 
| 
      
 7 
     | 
    
         
            +
            in the Software without restriction, including without limitation the rights
         
     | 
| 
      
 8 
     | 
    
         
            +
            to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
         
     | 
| 
      
 9 
     | 
    
         
            +
            copies of the Software, and to permit persons to whom the Software is
         
     | 
| 
      
 10 
     | 
    
         
            +
            furnished to do so, subject to the following conditions:
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
            The above copyright notice and this permission notice shall be included in all
         
     | 
| 
      
 13 
     | 
    
         
            +
            copies or substantial portions of the Software.
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
            THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
         
     | 
| 
      
 16 
     | 
    
         
            +
            IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
         
     | 
| 
      
 17 
     | 
    
         
            +
            FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
         
     | 
| 
      
 18 
     | 
    
         
            +
            AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
         
     | 
| 
      
 19 
     | 
    
         
            +
            LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
         
     | 
| 
      
 20 
     | 
    
         
            +
            OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
         
     | 
| 
      
 21 
     | 
    
         
            +
            SOFTWARE.
         
     | 
    
        data/README.md
    ADDED
    
    | 
         @@ -0,0 +1,90 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # Logstash Logservice Input Plugin
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            This is a plugin for [Logstash](https://github.com/elastic/logstash).
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            ## Documentation
         
     | 
| 
      
 6 
     | 
    
         
            +
            This plugin provides infrastructure to automatically consume logs from Aliyun Log Service .
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
            ### Usage:
         
     | 
| 
      
 10 
     | 
    
         
            +
            This is an example of logstash config:
         
     | 
| 
      
 11 
     | 
    
         
            +
            ```
         
     | 
| 
      
 12 
     | 
    
         
            +
            input {
         
     | 
| 
      
 13 
     | 
    
         
            +
              logservice{
         
     | 
| 
      
 14 
     | 
    
         
            +
              endpoint => "your project endpoint"
         
     | 
| 
      
 15 
     | 
    
         
            +
              access_id => "your access id"
         
     | 
| 
      
 16 
     | 
    
         
            +
              access_key => "your access key"
         
     | 
| 
      
 17 
     | 
    
         
            +
              project => "your project name"
         
     | 
| 
      
 18 
     | 
    
         
            +
              logstore => "your logstore name"
         
     | 
| 
      
 19 
     | 
    
         
            +
              consumer_group => "consumer group name"
         
     | 
| 
      
 20 
     | 
    
         
            +
              consumer_name => "consumer name"
         
     | 
| 
      
 21 
     | 
    
         
            +
              position => "end"
         
     | 
| 
      
 22 
     | 
    
         
            +
              checkpoint_second => 30
         
     | 
| 
      
 23 
     | 
    
         
            +
              include_meta => true
         
     | 
| 
      
 24 
     | 
    
         
            +
              consumer_name_with_ip => true
         
     | 
| 
      
 25 
     | 
    
         
            +
              }
         
     | 
| 
      
 26 
     | 
    
         
            +
            }
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
            output {
         
     | 
| 
      
 29 
     | 
    
         
            +
              stdout {}
         
     | 
| 
      
 30 
     | 
    
         
            +
            }
         
     | 
| 
      
 31 
     | 
    
         
            +
            ```
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
            ### Logstash Logservice Input Configuration Options
         
     | 
| 
      
 34 
     | 
    
         
            +
            This plugin supports the following configuration options
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
            |Configuration|Type|Required|Comments|
         
     | 
| 
      
 37 
     | 
    
         
            +
            |:---:|:---:|:---:|:---|
         
     | 
| 
      
 38 
     | 
    
         
            +
            |endpoint|string|true|Your project endpoint|
         
     | 
| 
      
 39 
     | 
    
         
            +
            |access_id|string|true|Your access id|
         
     | 
| 
      
 40 
     | 
    
         
            +
            |access_key|string|true|Your access key|
         
     | 
| 
      
 41 
     | 
    
         
            +
            |project|string|true|Your project name|
         
     | 
| 
      
 42 
     | 
    
         
            +
            |logstore|string|true|Your consumer_name name|
         
     | 
| 
      
 43 
     | 
    
         
            +
            |consumer_group|string|true|Consumer group name|
         
     | 
| 
      
 44 
     | 
    
         
            +
            |consumer_name|string|true|Consumer name,The consumer name in the same consumer group must not be repeated, otherwise undefined behavior will occur.|
         
     | 
| 
      
 45 
     | 
    
         
            +
            |position|string|true|Position to consume. Options are `begin`, `end` and `yyyy-MM-dd HH:mm:ss`|
         
     | 
| 
      
 46 
     | 
    
         
            +
            |checkpoint_second|number| false|Time to checkpoint,default is 30|
         
     | 
| 
      
 47 
     | 
    
         
            +
            |include_meta|boolean| false|Whether the meta is included,default is true|
         
     | 
| 
      
 48 
     | 
    
         
            +
            |consumer_name_with_ip|boolean| false|Whether the consumer name has ip,default is true,Must be set to true under distributed collaborative consumption|
         
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
      
 50 
     | 
    
         
            +
             
     | 
| 
      
 51 
     | 
    
         
            +
            ## Install the plugin
         
     | 
| 
      
 52 
     | 
    
         
            +
             
     | 
| 
      
 53 
     | 
    
         
            +
            [logstash-input-sls-0.0.1.gem](https://github.com/aliyun/logstash-input-logservice/raw/master/logstash-input-sls-0.0.1.gem)
         
     | 
| 
      
 54 
     | 
    
         
            +
             
     | 
| 
      
 55 
     | 
    
         
            +
            you can build the gem and install it using:
         
     | 
| 
      
 56 
     | 
    
         
            +
             
     | 
| 
      
 57 
     | 
    
         
            +
            - Build your plugin gem
         
     | 
| 
      
 58 
     | 
    
         
            +
             
     | 
| 
      
 59 
     | 
    
         
            +
            ```sh
         
     | 
| 
      
 60 
     | 
    
         
            +
            gem build logstash-input-sls.gemspec
         
     | 
| 
      
 61 
     | 
    
         
            +
            ```
         
     | 
| 
      
 62 
     | 
    
         
            +
             
     | 
| 
      
 63 
     | 
    
         
            +
            - Install the plugin from the Logstash home
         
     | 
| 
      
 64 
     | 
    
         
            +
             
     | 
| 
      
 65 
     | 
    
         
            +
            ```sh
         
     | 
| 
      
 66 
     | 
    
         
            +
            logstash-plugin install --local logstash-input-sls-0.0.1.gem
         
     | 
| 
      
 67 
     | 
    
         
            +
            ```
         
     | 
| 
      
 68 
     | 
    
         
            +
             
     | 
| 
      
 69 
     | 
    
         
            +
            - Start Logstash
         
     | 
| 
      
 70 
     | 
    
         
            +
             
     | 
| 
      
 71 
     | 
    
         
            +
            ```bash
         
     | 
| 
      
 72 
     | 
    
         
            +
            logstash -f logstash-sample.conf
         
     | 
| 
      
 73 
     | 
    
         
            +
            ```
         
     | 
| 
      
 74 
     | 
    
         
            +
             
     | 
| 
      
 75 
     | 
    
         
            +
            ## The performance test
         
     | 
| 
      
 76 
     | 
    
         
            +
             
     | 
| 
      
 77 
     | 
    
         
            +
            ### The test environment
         
     | 
| 
      
 78 
     | 
    
         
            +
             
     | 
| 
      
 79 
     | 
    
         
            +
            - cpu : Intel(R) Xeon(R) Platinum 8163 CPU @ 2.50GHz,4 Core
         
     | 
| 
      
 80 
     | 
    
         
            +
            - memory : 8GB 
         
     | 
| 
      
 81 
     | 
    
         
            +
            - env : Linux
         
     | 
| 
      
 82 
     | 
    
         
            +
             
     | 
| 
      
 83 
     | 
    
         
            +
            ### Test result
         
     | 
| 
      
 84 
     | 
    
         
            +
            | Data flow(MB/S) |CPU(%) | MEM(GB) |
         
     | 
| 
      
 85 
     | 
    
         
            +
            | :---: | :---: | :---: |
         
     | 
| 
      
 86 
     | 
    
         
            +
            |32|170.3|1.3|
         
     | 
| 
      
 87 
     | 
    
         
            +
            |16|83.3|1.3|
         
     | 
| 
      
 88 
     | 
    
         
            +
            |8|41.5|1.3|
         
     | 
| 
      
 89 
     | 
    
         
            +
            |4|21.0|1.3|
         
     | 
| 
      
 90 
     | 
    
         
            +
            |2|11.3|1.3|
         
     | 
    
        data/README_CN.md
    ADDED
    
    | 
         @@ -0,0 +1,135 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # Logstash 日志服务 Input 插件
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            本插件作为[Logstash](https://github.com/elastic/logstash)的input插件,提供从日志服务拉取(消费)日志的功能。
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            ### 功能特性
         
     | 
| 
      
 6 
     | 
    
         
            +
            * 支持分布式协同消费:可配置多台服务器同时消费某一Logstore。
         
     | 
| 
      
 7 
     | 
    
         
            +
            * 高性能:基于Java ConsumerGroup实现,单核消费速度可达20MB/s。
         
     | 
| 
      
 8 
     | 
    
         
            +
            * 高可靠:消费进度保存到服务端,宕机恢复后会从上一次checkpoint处自动恢复。
         
     | 
| 
      
 9 
     | 
    
         
            +
            * 自动负载均衡:根据消费者数量自动分配Shard,消费者增加/退出后会自动Rebalance。
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
            ### 使用方式:
         
     | 
| 
      
 13 
     | 
    
         
            +
            以下示例为配置Logstash消费某一个Logstore并将日志打印到标准输出:
         
     | 
| 
      
 14 
     | 
    
         
            +
            ```
         
     | 
| 
      
 15 
     | 
    
         
            +
            input {
         
     | 
| 
      
 16 
     | 
    
         
            +
              logservice{
         
     | 
| 
      
 17 
     | 
    
         
            +
              endpoint => "your project endpoint"
         
     | 
| 
      
 18 
     | 
    
         
            +
              access_id => "your access id"
         
     | 
| 
      
 19 
     | 
    
         
            +
              access_key => "your access key"
         
     | 
| 
      
 20 
     | 
    
         
            +
              project => "your project name"
         
     | 
| 
      
 21 
     | 
    
         
            +
              logstore => "your logstore name"
         
     | 
| 
      
 22 
     | 
    
         
            +
              consumer_group => "consumer group name"
         
     | 
| 
      
 23 
     | 
    
         
            +
              consumer_name => "consumer name"
         
     | 
| 
      
 24 
     | 
    
         
            +
              position => "end"
         
     | 
| 
      
 25 
     | 
    
         
            +
              checkpoint_second => 30
         
     | 
| 
      
 26 
     | 
    
         
            +
              include_meta => true
         
     | 
| 
      
 27 
     | 
    
         
            +
              consumer_name_with_ip => true
         
     | 
| 
      
 28 
     | 
    
         
            +
              }
         
     | 
| 
      
 29 
     | 
    
         
            +
            }
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
            output {
         
     | 
| 
      
 32 
     | 
    
         
            +
              stdout {}
         
     | 
| 
      
 33 
     | 
    
         
            +
            }
         
     | 
| 
      
 34 
     | 
    
         
            +
            ```
         
     | 
| 
      
 35 
     | 
    
         
            +
            分布式并发消费的配置:
         
     | 
| 
      
 36 
     | 
    
         
            +
            ````
         
     | 
| 
      
 37 
     | 
    
         
            +
            例如某Logstore有10个shard,
         
     | 
| 
      
 38 
     | 
    
         
            +
            每个shard数据流量1M/s,
         
     | 
| 
      
 39 
     | 
    
         
            +
            每台机器处理的能力为3M/s,
         
     | 
| 
      
 40 
     | 
    
         
            +
            可分配5台服务器,
         
     | 
| 
      
 41 
     | 
    
         
            +
            每个服务器设置相同的consumer_group和consumer_name,consumer_name_with_ip字段设置为true。
         
     | 
| 
      
 42 
     | 
    
         
            +
            这种情况每台服务器会分配到2个Shard,分别处理2M/s的数据。
         
     | 
| 
      
 43 
     | 
    
         
            +
            ````
         
     | 
| 
      
 44 
     | 
    
         
            +
             
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
      
 46 
     | 
    
         
            +
            ### Logstash 日志服务 Input 配置参数
         
     | 
| 
      
 47 
     | 
    
         
            +
            本插件提供以下配置参数
         
     | 
| 
      
 48 
     | 
    
         
            +
             
     | 
| 
      
 49 
     | 
    
         
            +
            |参数名|参数类型|是否必填|备注|
         
     | 
| 
      
 50 
     | 
    
         
            +
            |:---:|:---:|:---:|:---|
         
     | 
| 
      
 51 
     | 
    
         
            +
            |endpoint|string|是|日志服务项目所在的endpoint,详情请参考[endpoint列表](https://help.aliyun.com/document_detail/29008.html)|
         
     | 
| 
      
 52 
     | 
    
         
            +
            |access_id|string|是|阿里云Access Key ID,需要具备ConsumerGroup相关权限,详情请参考[consumer group](https://help.aliyun.com/document_detail/28998.html)|
         
     | 
| 
      
 53 
     | 
    
         
            +
            |access_key|string|是|阿里云Access Key Secret,需要具备ConsumerGroup相关权限,详情请参考[consumer group](https://help.aliyun.com/document_detail/28998.html)|
         
     | 
| 
      
 54 
     | 
    
         
            +
            |project|string|是|日志服务项目名|
         
     | 
| 
      
 55 
     | 
    
         
            +
            |logstore|string|是|日志服务日志库名|
         
     | 
| 
      
 56 
     | 
    
         
            +
            |consumer_group|string|是|消费组名|
         
     | 
| 
      
 57 
     | 
    
         
            +
            |consumer_name|string|是|消费者名,同一个消费组内消费者名,必须不能重复,否则会出现未定义行为|
         
     | 
| 
      
 58 
     | 
    
         
            +
            |position|string|是|消费位置,可选项为 `begin`(从日志库写入的第一条数据开始消费)、`end`(从当前时间点开始消费) 和 `yyyy-MM-dd HH:mm:ss`(从指定时间点开始消费)|
         
     | 
| 
      
 59 
     | 
    
         
            +
            |checkpoint_second|number| 否|每隔几秒 checkpoint 一次,建议10-60秒,不能低于10秒,默认30秒|
         
     | 
| 
      
 60 
     | 
    
         
            +
            |include_meta|boolean| 否|传入日志是否包含meta,Meta包括日志source、time、tag、topic,默认为 true|
         
     | 
| 
      
 61 
     | 
    
         
            +
            |consumer_name_with_ip|boolean| 否|消费者名是否包含ip地址,默认为 true,分布式协同消费下必须设置为true|
         
     | 
| 
      
 62 
     | 
    
         
            +
             
     | 
| 
      
 63 
     | 
    
         
            +
             
     | 
| 
      
 64 
     | 
    
         
            +
            ## 安装插件
         
     | 
| 
      
 65 
     | 
    
         
            +
             
     | 
| 
      
 66 
     | 
    
         
            +
            * 注意:如果没有修改源码可直接安装
         
     | 
| 
      
 67 
     | 
    
         
            +
             
     | 
| 
      
 68 
     | 
    
         
            +
            下载地址:[logstash-input-sls-0.0.1.gem](https://github.com/aliyun/logstash-input-logservice/raw/master/logstash-input-sls-0.0.1.gem)
         
     | 
| 
      
 69 
     | 
    
         
            +
             
     | 
| 
      
 70 
     | 
    
         
            +
            - 构建 插件
         
     | 
| 
      
 71 
     | 
    
         
            +
             
     | 
| 
      
 72 
     | 
    
         
            +
            ```sh
         
     | 
| 
      
 73 
     | 
    
         
            +
            gem build logstash-input-sls.gemspec
         
     | 
| 
      
 74 
     | 
    
         
            +
            ```
         
     | 
| 
      
 75 
     | 
    
         
            +
             
     | 
| 
      
 76 
     | 
    
         
            +
            - 安装 日志服务 input 插件
         
     | 
| 
      
 77 
     | 
    
         
            +
             
     | 
| 
      
 78 
     | 
    
         
            +
            ```sh
         
     | 
| 
      
 79 
     | 
    
         
            +
            logstash-plugin install --local logstash-input-sls-0.0.1.gem
         
     | 
| 
      
 80 
     | 
    
         
            +
            ```
         
     | 
| 
      
 81 
     | 
    
         
            +
             
     | 
| 
      
 82 
     | 
    
         
            +
            - 启动 Logstash
         
     | 
| 
      
 83 
     | 
    
         
            +
             
     | 
| 
      
 84 
     | 
    
         
            +
            ```bash
         
     | 
| 
      
 85 
     | 
    
         
            +
            logstash -f logstash.conf
         
     | 
| 
      
 86 
     | 
    
         
            +
            ```
         
     | 
| 
      
 87 
     | 
    
         
            +
             
     | 
| 
      
 88 
     | 
    
         
            +
            ## 性能基准测试
         
     | 
| 
      
 89 
     | 
    
         
            +
             
     | 
| 
      
 90 
     | 
    
         
            +
            ### 测试环境
         
     | 
| 
      
 91 
     | 
    
         
            +
             
     | 
| 
      
 92 
     | 
    
         
            +
            - 处理器 : Intel(R) Xeon(R) Platinum 8163 CPU @ 2.50GHz,4 Core
         
     | 
| 
      
 93 
     | 
    
         
            +
            - 内存 : 8GB 
         
     | 
| 
      
 94 
     | 
    
         
            +
            - 环境 : Linux
         
     | 
| 
      
 95 
     | 
    
         
            +
             
     | 
| 
      
 96 
     | 
    
         
            +
            ### Logstash配置
         
     | 
| 
      
 97 
     | 
    
         
            +
             
     | 
| 
      
 98 
     | 
    
         
            +
            ```
         
     | 
| 
      
 99 
     | 
    
         
            +
            input {
         
     | 
| 
      
 100 
     | 
    
         
            +
              logservice{
         
     | 
| 
      
 101 
     | 
    
         
            +
              endpoint => "cn-hangzhou.log.aliyuncs.com"
         
     | 
| 
      
 102 
     | 
    
         
            +
              access_id => "***"
         
     | 
| 
      
 103 
     | 
    
         
            +
              access_key => "***"
         
     | 
| 
      
 104 
     | 
    
         
            +
              project => "test-project"
         
     | 
| 
      
 105 
     | 
    
         
            +
              logstore => "logstore1"
         
     | 
| 
      
 106 
     | 
    
         
            +
              consumer_group => "consumer_group1"
         
     | 
| 
      
 107 
     | 
    
         
            +
              consumer => "consumer1"
         
     | 
| 
      
 108 
     | 
    
         
            +
              position => "end"
         
     | 
| 
      
 109 
     | 
    
         
            +
              checkpoint_second => 30
         
     | 
| 
      
 110 
     | 
    
         
            +
              include_meta => true
         
     | 
| 
      
 111 
     | 
    
         
            +
              consumer_name_with_ip => true
         
     | 
| 
      
 112 
     | 
    
         
            +
              }
         
     | 
| 
      
 113 
     | 
    
         
            +
            }
         
     | 
| 
      
 114 
     | 
    
         
            +
             
     | 
| 
      
 115 
     | 
    
         
            +
            output {
         
     | 
| 
      
 116 
     | 
    
         
            +
              file {
         
     | 
| 
      
 117 
     | 
    
         
            +
              path => "/dev/null"
         
     | 
| 
      
 118 
     | 
    
         
            +
              }
         
     | 
| 
      
 119 
     | 
    
         
            +
            }
         
     | 
| 
      
 120 
     | 
    
         
            +
            ```
         
     | 
| 
      
 121 
     | 
    
         
            +
             
     | 
| 
      
 122 
     | 
    
         
            +
            ### 测试过程
         
     | 
| 
      
 123 
     | 
    
         
            +
             
     | 
| 
      
 124 
     | 
    
         
            +
            - 使用Java Producer向logstore发送数据,分别达到每秒发送2MB、4MB、8MB、16MB、32MB数据。
         
     | 
| 
      
 125 
     | 
    
         
            +
            - 每条日志约500字节,包括10个Key&Value对。
         
     | 
| 
      
 126 
     | 
    
         
            +
            - 启动Logstash,消费logstore中的数据并确保消费延迟没有上涨(消费速度能够跟上生产的速度)。
         
     | 
| 
      
 127 
     | 
    
         
            +
             
     | 
| 
      
 128 
     | 
    
         
            +
            ### 测试结果
         
     | 
| 
      
 129 
     | 
    
         
            +
            | 流量(MB/S) |处理器占用(%) | 内存占用(GB) |
         
     | 
| 
      
 130 
     | 
    
         
            +
            | :---: | :---: | :---: |
         
     | 
| 
      
 131 
     | 
    
         
            +
            |32|170.3|1.3|
         
     | 
| 
      
 132 
     | 
    
         
            +
            |16|83.3|1.3|
         
     | 
| 
      
 133 
     | 
    
         
            +
            |8|41.5|1.3|
         
     | 
| 
      
 134 
     | 
    
         
            +
            |4|21.0|1.3|
         
     | 
| 
      
 135 
     | 
    
         
            +
            |2|11.3|1.3|
         
     | 
| 
         @@ -0,0 +1,71 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'java'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require "logstash/namespace"
         
     | 
| 
      
 3 
     | 
    
         
            +
            require "logstash/event"
         
     | 
| 
      
 4 
     | 
    
         
            +
            require "logstash/environment"
         
     | 
| 
      
 5 
     | 
    
         
            +
            require "logstash/inputs/base"
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            root_dir = File.expand_path(File.join(File.dirname(__FILE__), ".."))
         
     | 
| 
      
 8 
     | 
    
         
            +
            LogStash::Environment.load_runtime_jars! File.join(root_dir, "vendor")
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
            java_import 'com.aliyun.log.logstash.LogHubStarter'
         
     | 
| 
      
 11 
     | 
    
         
            +
            java_import 'com.aliyun.log.logstash.LogstashLogHubProcessor'
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
            class LogStash::Inputs::LogService < LogStash::Inputs::Base
         
     | 
| 
      
 14 
     | 
    
         
            +
              attr_accessor :worker
         
     | 
| 
      
 15 
     | 
    
         
            +
              def initialize(*args)
         
     | 
| 
      
 16 
     | 
    
         
            +
                super(*args)
         
     | 
| 
      
 17 
     | 
    
         
            +
              end
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
              class LogHubProcessor < LogstashLogHubProcessor
         
     | 
| 
      
 20 
     | 
    
         
            +
                attr_accessor :queue
         
     | 
| 
      
 21 
     | 
    
         
            +
                def showContent(logmap)
         
     | 
| 
      
 22 
     | 
    
         
            +
                    event = LogStash::Event.new(logmap)
         
     | 
| 
      
 23 
     | 
    
         
            +
                    # this will block if output_queue is full. output_queue size is 20
         
     | 
| 
      
 24 
     | 
    
         
            +
                    @queue << event
         
     | 
| 
      
 25 
     | 
    
         
            +
                end
         
     | 
| 
      
 26 
     | 
    
         
            +
              end
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
              config_name "logservice"
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
              config :endpoint, :validate => :string, :required => true
         
     | 
| 
      
 31 
     | 
    
         
            +
              config :access_id, :validate => :string, :required => true
         
     | 
| 
      
 32 
     | 
    
         
            +
              config :access_key, :validate => :string, :required => true
         
     | 
| 
      
 33 
     | 
    
         
            +
              config :project, :validate => :string, :required => true
         
     | 
| 
      
 34 
     | 
    
         
            +
              config :logstore, :validate => :string, :required => true
         
     | 
| 
      
 35 
     | 
    
         
            +
              config :consumer_group, :validate => :string, :required => true
         
     | 
| 
      
 36 
     | 
    
         
            +
              config :consumer_name, :validate => :string, :required => true
         
     | 
| 
      
 37 
     | 
    
         
            +
              config :position, :validate => :string, :required => true
         
     | 
| 
      
 38 
     | 
    
         
            +
              config :checkpoint_second, :validate => :number, :default => 30
         
     | 
| 
      
 39 
     | 
    
         
            +
              config :include_meta, :validate => :boolean, :default => true
         
     | 
| 
      
 40 
     | 
    
         
            +
              config :consumer_name_with_ip, :validate => :boolean, :default => true
         
     | 
| 
      
 41 
     | 
    
         
            +
              public
         
     | 
| 
      
 42 
     | 
    
         
            +
              def register
         
     | 
| 
      
 43 
     | 
    
         
            +
                @logger.info("Init logstash-input-logservice", :endpoint => @endpoint, :project => @project, :logstore => @logstore,
         
     | 
| 
      
 44 
     | 
    
         
            +
                    :consumer_group => @consumer_group, :consumer_name => @consumer_name, :position => @position,
         
     | 
| 
      
 45 
     | 
    
         
            +
                    :checkpoint_second => @checkpoint_second, :include_meta => @include_meta ,:consumer_name_with_ip => @consumer_name_with_ip)
         
     | 
| 
      
 46 
     | 
    
         
            +
              end
         
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
      
 48 
     | 
    
         
            +
              def run(queue)
         
     | 
| 
      
 49 
     | 
    
         
            +
                @local_address = java.net.InetAddress.getLocalHost().getHostAddress();
         
     | 
| 
      
 50 
     | 
    
         
            +
                @ip_suffix = ''
         
     | 
| 
      
 51 
     | 
    
         
            +
                if @consumer_name_with_ip
         
     | 
| 
      
 52 
     | 
    
         
            +
                    @ip_suffix = '_' + @local_address
         
     | 
| 
      
 53 
     | 
    
         
            +
                end
         
     | 
| 
      
 54 
     | 
    
         
            +
                @logger.info("Running logstash-input-logservice",:local_address => @local_address)
         
     | 
| 
      
 55 
     | 
    
         
            +
                @handler = LogHubProcessor.new()
         
     | 
| 
      
 56 
     | 
    
         
            +
                @handler.setCheckpointSecond(@checkpoint_second)
         
     | 
| 
      
 57 
     | 
    
         
            +
                @handler.setIncludeMeta(@include_meta)
         
     | 
| 
      
 58 
     | 
    
         
            +
                @handler.queue = queue
         
     | 
| 
      
 59 
     | 
    
         
            +
                LogHubStarter.startWorker(@handler, @endpoint, @access_id, @access_key, @project, @logstore, @consumer_group, @consumer_name + @ip_suffix, @position)
         
     | 
| 
      
 60 
     | 
    
         
            +
                rescue Exception => e
         
     | 
| 
      
 61 
     | 
    
         
            +
                    @logger.error("Start logstash-input-logservice", :endpoint => @endpoint, :project => @project, :logstore => @logstore,
         
     | 
| 
      
 62 
     | 
    
         
            +
                        :consumer_group => @consumer_group, :consumer_name => @consumer_name, :position => @position,
         
     | 
| 
      
 63 
     | 
    
         
            +
                        :checkpoint_second => @checkpoint_second, :include_meta => @include_meta, :consumer_name_with_ip => @consumer_name_with_ip, :exception => e)
         
     | 
| 
      
 64 
     | 
    
         
            +
              end
         
     | 
| 
      
 65 
     | 
    
         
            +
             
     | 
| 
      
 66 
     | 
    
         
            +
              def teardown
         
     | 
| 
      
 67 
     | 
    
         
            +
                @interrupted = true
         
     | 
| 
      
 68 
     | 
    
         
            +
                finished
         
     | 
| 
      
 69 
     | 
    
         
            +
              end # def teardown
         
     | 
| 
      
 70 
     | 
    
         
            +
            end 
         
     | 
| 
      
 71 
     | 
    
         
            +
             
     | 
| 
         Binary file 
     | 
| 
         @@ -0,0 +1,25 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            Gem::Specification.new do |s|
         
     | 
| 
      
 2 
     | 
    
         
            +
              s.name = 'logstash-input-sls'
         
     | 
| 
      
 3 
     | 
    
         
            +
              s.version         = '0.0.2'
         
     | 
| 
      
 4 
     | 
    
         
            +
              s.licenses = ['MIT']
         
     | 
| 
      
 5 
     | 
    
         
            +
              s.summary = "This sls input streams a string at a definable interval."
         
     | 
| 
      
 6 
     | 
    
         
            +
              s.description     = "This gem is a Logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This gem is not a stand-alone program"
         
     | 
| 
      
 7 
     | 
    
         
            +
              s.authors = ["lichao"]
         
     | 
| 
      
 8 
     | 
    
         
            +
              s.email = 'info@elastic.co'
         
     | 
| 
      
 9 
     | 
    
         
            +
              s.homepage = "https://www.aliyun.com/product/sls"
         
     | 
| 
      
 10 
     | 
    
         
            +
              s.require_paths = ["lib"]
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
              # Files
         
     | 
| 
      
 13 
     | 
    
         
            +
              s.files = Dir['lib/**/*','spec/**/*','vendor/**/*','*.gemspec','*.md','CONTRIBUTORS','Gemfile','LICENSE','NOTICE.TXT']
         
     | 
| 
      
 14 
     | 
    
         
            +
               # Tests
         
     | 
| 
      
 15 
     | 
    
         
            +
              s.test_files = s.files.grep(%r{^(test|spec|features)/})
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
              # Special flag to let us know this is actually a logstash plugin
         
     | 
| 
      
 18 
     | 
    
         
            +
              s.metadata = { "logstash_plugin" => "true", "logstash_group" => "input" }
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
              # Gem dependencies
         
     | 
| 
      
 21 
     | 
    
         
            +
              s.add_runtime_dependency "logstash-core-plugin-api", ">= 1.60", "<= 2.99"
         
     | 
| 
      
 22 
     | 
    
         
            +
              s.add_runtime_dependency 'logstash-codec-plain'
         
     | 
| 
      
 23 
     | 
    
         
            +
              s.add_runtime_dependency 'stud', '>= 0.0.22'
         
     | 
| 
      
 24 
     | 
    
         
            +
              s.add_development_dependency 'logstash-devutils'
         
     | 
| 
      
 25 
     | 
    
         
            +
            end
         
     | 
    
        metadata
    ADDED
    
    | 
         @@ -0,0 +1,116 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            --- !ruby/object:Gem::Specification
         
     | 
| 
      
 2 
     | 
    
         
            +
            name: logstash-input-sls
         
     | 
| 
      
 3 
     | 
    
         
            +
            version: !ruby/object:Gem::Version
         
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.0.2
         
     | 
| 
      
 5 
     | 
    
         
            +
            platform: ruby
         
     | 
| 
      
 6 
     | 
    
         
            +
            authors:
         
     | 
| 
      
 7 
     | 
    
         
            +
            - lichao
         
     | 
| 
      
 8 
     | 
    
         
            +
            autorequire:
         
     | 
| 
      
 9 
     | 
    
         
            +
            bindir: bin
         
     | 
| 
      
 10 
     | 
    
         
            +
            cert_chain: []
         
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2019-07-25 00:00:00.000000000 Z
         
     | 
| 
      
 12 
     | 
    
         
            +
            dependencies:
         
     | 
| 
      
 13 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 14 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 15 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 16 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 17 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 18 
     | 
    
         
            +
                    version: '1.60'
         
     | 
| 
      
 19 
     | 
    
         
            +
                - - "<="
         
     | 
| 
      
 20 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 21 
     | 
    
         
            +
                    version: '2.99'
         
     | 
| 
      
 22 
     | 
    
         
            +
              name: logstash-core-plugin-api
         
     | 
| 
      
 23 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 24 
     | 
    
         
            +
              type: :runtime
         
     | 
| 
      
 25 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 26 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 27 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 28 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 29 
     | 
    
         
            +
                    version: '1.60'
         
     | 
| 
      
 30 
     | 
    
         
            +
                - - "<="
         
     | 
| 
      
 31 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 32 
     | 
    
         
            +
                    version: '2.99'
         
     | 
| 
      
 33 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 34 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 35 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 36 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 37 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 38 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 39 
     | 
    
         
            +
              name: logstash-codec-plain
         
     | 
| 
      
 40 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 41 
     | 
    
         
            +
              type: :runtime
         
     | 
| 
      
 42 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 43 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 44 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 45 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 46 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 47 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 48 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 49 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 50 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 51 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 52 
     | 
    
         
            +
                    version: 0.0.22
         
     | 
| 
      
 53 
     | 
    
         
            +
              name: stud
         
     | 
| 
      
 54 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 55 
     | 
    
         
            +
              type: :runtime
         
     | 
| 
      
 56 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 57 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 58 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 59 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 60 
     | 
    
         
            +
                    version: 0.0.22
         
     | 
| 
      
 61 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 62 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 63 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 64 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 65 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 66 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 67 
     | 
    
         
            +
              name: logstash-devutils
         
     | 
| 
      
 68 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 69 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 70 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 71 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 72 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 73 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 74 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 75 
     | 
    
         
            +
            description: This gem is a Logstash plugin required to be installed on top of the
         
     | 
| 
      
 76 
     | 
    
         
            +
              Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This
         
     | 
| 
      
 77 
     | 
    
         
            +
              gem is not a stand-alone program
         
     | 
| 
      
 78 
     | 
    
         
            +
            email: info@elastic.co
         
     | 
| 
      
 79 
     | 
    
         
            +
            executables: []
         
     | 
| 
      
 80 
     | 
    
         
            +
            extensions: []
         
     | 
| 
      
 81 
     | 
    
         
            +
            extra_rdoc_files: []
         
     | 
| 
      
 82 
     | 
    
         
            +
            files:
         
     | 
| 
      
 83 
     | 
    
         
            +
            - Gemfile
         
     | 
| 
      
 84 
     | 
    
         
            +
            - LICENSE
         
     | 
| 
      
 85 
     | 
    
         
            +
            - README.md
         
     | 
| 
      
 86 
     | 
    
         
            +
            - README_CN.md
         
     | 
| 
      
 87 
     | 
    
         
            +
            - lib/logstash/inputs/logservice.rb
         
     | 
| 
      
 88 
     | 
    
         
            +
            - lib/logstash/vendor/jar-dependencies/runtime-jars/logstash-input-sls-1.0-SNAPSHOT.jar
         
     | 
| 
      
 89 
     | 
    
         
            +
            - logstash-input-sls.gemspec
         
     | 
| 
      
 90 
     | 
    
         
            +
            homepage: https://www.aliyun.com/product/sls
         
     | 
| 
      
 91 
     | 
    
         
            +
            licenses:
         
     | 
| 
      
 92 
     | 
    
         
            +
            - MIT
         
     | 
| 
      
 93 
     | 
    
         
            +
            metadata:
         
     | 
| 
      
 94 
     | 
    
         
            +
              logstash_plugin: 'true'
         
     | 
| 
      
 95 
     | 
    
         
            +
              logstash_group: input
         
     | 
| 
      
 96 
     | 
    
         
            +
            post_install_message:
         
     | 
| 
      
 97 
     | 
    
         
            +
            rdoc_options: []
         
     | 
| 
      
 98 
     | 
    
         
            +
            require_paths:
         
     | 
| 
      
 99 
     | 
    
         
            +
            - lib
         
     | 
| 
      
 100 
     | 
    
         
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 101 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 102 
     | 
    
         
            +
              - - ">="
         
     | 
| 
      
 103 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 104 
     | 
    
         
            +
                  version: '0'
         
     | 
| 
      
 105 
     | 
    
         
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 106 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 107 
     | 
    
         
            +
              - - ">="
         
     | 
| 
      
 108 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 109 
     | 
    
         
            +
                  version: '0'
         
     | 
| 
      
 110 
     | 
    
         
            +
            requirements: []
         
     | 
| 
      
 111 
     | 
    
         
            +
            rubyforge_project:
         
     | 
| 
      
 112 
     | 
    
         
            +
            rubygems_version: 2.7.6
         
     | 
| 
      
 113 
     | 
    
         
            +
            signing_key:
         
     | 
| 
      
 114 
     | 
    
         
            +
            specification_version: 4
         
     | 
| 
      
 115 
     | 
    
         
            +
            summary: This sls input streams a string at a definable interval.
         
     | 
| 
      
 116 
     | 
    
         
            +
            test_files: []
         
     |