logstash-output-bos 0.2.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 7a6cc81ef9f41fa45fd84e6441d210c21c6bc0b23e3c57908279567e1b39b335
4
+ data.tar.gz: 2e5bac5a2395c19f607ade6a8f5c5fbbaf52d97a4379434f838cc4d9ad5713e8
5
+ SHA512:
6
+ metadata.gz: f75d493d237c4ee9c1993a7faa73dc5cb68f0995dbf30a00c464075a01f820e378de6bf201d2023e346defc64a4ff0823c3c0a714c4f3a7847196252658c607f
7
+ data.tar.gz: 3a8dd197ea2b147dca613fa2fb5b1795b0e4833b83e95f10e63eaee7e11be5848f1d821ba3668c07da13c0c72b20a95eaf3ffb9efcf522531ddda5e2a548e7f5
data/CHANGELOG.md ADDED
@@ -0,0 +1,12 @@
1
+ ## 2.0.3
2
+ - Docs: Set the default_codec doc attribute.
3
+
4
+ ## 2.0.2
5
+ - Docs: Add documentation template
6
+ ## 2.0.1
7
+ - Add encoding: utf-8 to spec files. This can help prevent issues during testing.
8
+ ## 2.0.0
9
+ - Plugins were updated to follow the new shutdown semantic, this mainly allows Logstash to instruct input plugins to terminate gracefully,
10
+ instead of using Thread.raise on the plugins' threads. Ref: https://github.com/elastic/logstash/pull/3895
11
+ - Dependency on logstash-core update to 2.0
12
+
data/CONTRIBUTORS ADDED
@@ -0,0 +1,11 @@
1
+ The following is a list of people who have contributed ideas, code, bug
2
+ reports, or in general have helped logstash along its way.
3
+
4
+ Contributors:
5
+ * Aaron Mildenstein (untergeek)
6
+ * Pier-Hugues Pellerin (ph)
7
+
8
+ Note: If you've sent us patches, bug reports, or otherwise contributed to
9
+ Logstash, and you aren't on the list above and want to be, please let us know
10
+ and we'll make sure you're here. Contributions from folks like you are what make
11
+ open source awesome.
data/DEVELOPER.md ADDED
@@ -0,0 +1,2 @@
1
+ # logstash-output-example
2
+ Example output plugin. This should help bootstrap your effort to write your own output plugin!
data/Gemfile ADDED
@@ -0,0 +1,16 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ logstash_path = ENV["LOGSTASH_PATH"] || "../../logstash"
6
+ use_logstash_source = ENV["LOGSTASH_SOURCE"] && ENV["LOGSTASH_SOURCE"].to_s == "1"
7
+
8
+ if Dir.exist?(logstash_path) && use_logstash_source
9
+ gem 'logstash-core', :path => "#{logstash_path}/logstash-core"
10
+ gem 'logstash-core-plugin-api', :path => "#{logstash_path}/logstash-core-plugin-api"
11
+ end
12
+
13
+ gem "baidubce-sdk"
14
+ gem "mimemagic"
15
+ gem "rest-client"
16
+ gem "rufus-scheduler"
data/LICENSE ADDED
@@ -0,0 +1,13 @@
1
+ Copyright (c) 2012-2018 Elasticsearch <http://www.elastic.co>
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
data/NOTICE.TXT ADDED
@@ -0,0 +1,5 @@
1
+ Elasticsearch
2
+ Copyright 2012-2015 Elasticsearch
3
+
4
+ This product includes software developed by The Apache Software
5
+ Foundation (http://www.apache.org/).
data/README.md ADDED
@@ -0,0 +1,98 @@
1
+ # Logstash Plugin
2
+
3
+ [![Travis Build Status](https://travis-ci.org/logstash-plugins/logstash-output-example.svg)](https://travis-ci.org/logstash-plugins/logstash-output-example)
4
+
5
+ This is a plugin for [Logstash](https://github.com/elastic/logstash).
6
+
7
+ 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.
8
+
9
+ ## Documentation
10
+
11
+ Logstash provides infrastructure to automatically build documentation for this plugin. We provide a template file, index.asciidoc, where you can add documentation. The contents of this file will be converted into html and then placed with other plugin documentation in a [central location](http://www.elastic.co/guide/en/logstash/current/).
12
+
13
+ - For formatting config examples, you can use the asciidoc `[source,json]` directive
14
+ - For more asciidoc formatting tips, see the excellent reference here https://github.com/elastic/docs#asciidoc-guide
15
+
16
+ ## Need Help?
17
+
18
+ Need help? Try #logstash on freenode IRC or the https://discuss.elastic.co/c/logstash discussion forum.
19
+
20
+ ## Developing
21
+
22
+ ### 1. Plugin Developement and Testing
23
+
24
+ #### Code
25
+ - To get started, you'll need JRuby with the Bundler gem installed.
26
+
27
+ - 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).
28
+
29
+ - Install dependencies
30
+ ```sh
31
+ bundle install
32
+ ```
33
+
34
+ #### Test
35
+
36
+ - Update your dependencies
37
+
38
+ ```sh
39
+ bundle install
40
+ ```
41
+
42
+ - Run tests
43
+
44
+ ```sh
45
+ bundle exec rspec
46
+ ```
47
+
48
+ ### 2. Running your unpublished Plugin in Logstash
49
+
50
+ #### 2.1 Run in a local Logstash clone
51
+
52
+ - Edit Logstash `Gemfile` and add the local plugin path, for example:
53
+ ```ruby
54
+ gem "logstash-filter-awesome", :path => "/your/local/logstash-filter-awesome"
55
+ ```
56
+ - Install plugin
57
+ ```sh
58
+ # Logstash 2.3 and higher
59
+ bin/logstash-plugin install --no-verify
60
+
61
+ # Prior to Logstash 2.3
62
+ bin/plugin install --no-verify
63
+
64
+ ```
65
+ - Run Logstash with your plugin
66
+ ```sh
67
+ bin/logstash -e 'filter {awesome {}}'
68
+ ```
69
+ At this point any modifications to the plugin code will be applied to this local Logstash setup. After modifying the plugin, simply rerun Logstash.
70
+
71
+ #### 2.2 Run in an installed Logstash
72
+
73
+ 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:
74
+
75
+ - Build your plugin gem
76
+ ```sh
77
+ gem build logstash-filter-awesome.gemspec
78
+ ```
79
+ - Install the plugin from the Logstash home
80
+ ```sh
81
+ # Logstash 2.3 and higher
82
+ bin/logstash-plugin install --no-verify
83
+
84
+ # Prior to Logstash 2.3
85
+ bin/plugin install --no-verify
86
+
87
+ ```
88
+ - Start Logstash and proceed to test the plugin
89
+
90
+ ## Contributing
91
+
92
+ All contributions are welcome: ideas, patches, documentation, bug reports, complaints, and even something you drew up on a napkin.
93
+
94
+ 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.
95
+
96
+ It is more important to the community that you are able to contribute.
97
+
98
+ For more information about contributing, see the [CONTRIBUTING](https://github.com/elastic/logstash/blob/master/CONTRIBUTING.md) file.
@@ -0,0 +1,71 @@
1
+ # Logfile created on 2018-07-16 19:29:19 +0800 by logger.rb/61378
2
+ I, [2018-07-16T19:29:19.568134 #29235] INFO -- : url: http://bj.bcebos.com//, params: {}
3
+ I, [2018-07-17T11:50:27.981548 #55036] INFO -- : url: http://bj.bcebos.com//, params: {}
4
+ I, [2018-07-17T11:51:54.049430 #55173] INFO -- : url: http://bj.bcebos.com/testLogStash/, params: {}
5
+ I, [2018-07-17T11:51:54.133378 #55173] INFO -- : url: http://bj.bcebos.com//, params: {}
6
+ I, [2018-07-17T11:52:21.804757 #55210] INFO -- : url: http://bj.bcebos.com//, params: {}
7
+ I, [2018-07-17T11:53:02.315680 #55277] INFO -- : url: http://bj.bcebos.com/hubble/?maxKeys=1000, params: {:maxKeys=>1000}
8
+ I, [2018-07-17T14:36:50.113842 #65041] INFO -- : url: http://bj.bcebos.com/hubble/?maxKeys=1000, params: {:maxKeys=>1000}
9
+ I, [2018-07-17T14:37:02.880997 #65078] INFO -- : url: http://bj.bcebos.com/hubble/?maxKeys=1000&prefix=testRuby, params: {:maxKeys=>1000, :prefix=>"testRuby"}
10
+ I, [2018-07-17T14:45:13.102576 #65963] INFO -- : url: http://bj.bcebos.com/hubble/testRuby/test1, params: {}
11
+ I, [2018-07-17T14:45:13.359318 #65963] INFO -- : url: http://bj.bcebos.com/hubble/?maxKeys=1000&prefix=testRuby, params: {:maxKeys=>1000, :prefix=>"testRuby"}
12
+ I, [2018-07-17T14:46:08.416940 #66052] INFO -- : url: http://bj.bcebos.com/hubble/testRuby/test1, params: {}
13
+ I, [2018-07-17T14:46:15.401718 #66053] INFO -- : url: http://bj.bcebos.com/hubble/testRuby/test1, params: {}
14
+ I, [2018-07-17T14:46:44.911391 #66105] INFO -- : url: http://bj.bcebos.com/hubble/testRuby/test1, params: {}
15
+ I, [2018-07-17T14:46:51.309309 #66121] INFO -- : url: http://bj.bcebos.com/hubble/testRuby/test1, params: {}
16
+ I, [2018-07-17T16:47:19.419575 #82715] INFO -- : url: http://bj.bcebos.com/hubble/?maxKeys=1000&prefix=testRuby, params: {:maxKeys=>1000, :prefix=>"testRuby"}
17
+ I, [2018-07-17T16:48:45.846830 #82913] INFO -- : url: http://bj.bcebos.com/hubble/?maxKeys=1000, params: {:maxKeys=>1000}
18
+ I, [2018-07-17T16:52:59.499108 #83364] INFO -- : url: http://bj.bcebos.com/hubble/?maxKeys=1000&prefix=testRuby, params: {:maxKeys=>1000, :prefix=>"testRuby"}
19
+ I, [2018-07-17T17:17:17.977105 #85959] INFO -- : url: http://bj.bcebos.com/hubble/?maxKeys=1000&prefix=testRuby, params: {:maxKeys=>1000, :prefix=>"testRuby"}
20
+ I, [2018-07-17T17:17:20.501648 #85960] INFO -- : url: http://bj.bcebos.com/hubble/?maxKeys=1000&prefix=testRuby, params: {:maxKeys=>1000, :prefix=>"testRuby"}
21
+ I, [2018-07-17T17:17:36.649071 #85976] INFO -- : url: http://bj.bcebos.com/hubble/?maxKeys=1000&prefix=Logstash, params: {:maxKeys=>1000, :prefix=>"Logstash"}
22
+ I, [2018-07-17T17:17:36.781701 #85976] INFO -- : url: http://bj.bcebos.com/hubble/Logstash/PluginTest, params: {}
23
+ I, [2018-07-17T17:18:00.034224 #86022] INFO -- : url: http://bj.bcebos.com/hubble/?maxKeys=1000&prefix=Logstash, params: {:maxKeys=>1000, :prefix=>"Logstash"}
24
+ I, [2018-07-17T17:18:00.183661 #86022] INFO -- : url: http://bj.bcebos.com/hubble/Logstash/PluginTest, params: {}
25
+ I, [2018-07-17T17:18:00.324864 #86022] INFO -- : url: http://bj.bcebos.com/hubble/Logstash/PluginTest, params: {}
26
+ I, [2018-07-17T17:18:01.801560 #86032] INFO -- : url: http://bj.bcebos.com/hubble/?maxKeys=1000&prefix=Logstash, params: {:maxKeys=>1000, :prefix=>"Logstash"}
27
+ I, [2018-07-17T17:18:01.941337 #86032] INFO -- : url: http://bj.bcebos.com/hubble/Logstash/PluginTest, params: {}
28
+ I, [2018-07-17T17:18:08.570041 #86033] INFO -- : url: http://bj.bcebos.com/hubble/?maxKeys=1000&prefix=Logstash, params: {:maxKeys=>1000, :prefix=>"Logstash"}
29
+ I, [2018-07-17T17:18:16.345537 #86056] INFO -- : url: http://bj.bcebos.com/hubble/?maxKeys=1000&prefix=Logstash, params: {:maxKeys=>1000, :prefix=>"Logstash"}
30
+ I, [2018-07-17T17:18:16.499875 #86056] INFO -- : url: http://bj.bcebos.com/hubble/Logstash/PluginTest, params: {}
31
+ I, [2018-07-17T17:18:25.892169 #86072] INFO -- : url: http://bj.bcebos.com/hubble/?maxKeys=1000&prefix=Logstash, params: {:maxKeys=>1000, :prefix=>"Logstash"}
32
+ I, [2018-07-17T17:18:26.021939 #86072] INFO -- : url: http://bj.bcebos.com/hubble/Logstash/PluginTest, params: {}
33
+ I, [2018-07-17T17:18:30.887206 #86074] INFO -- : url: http://bj.bcebos.com/hubble/?maxKeys=1000&prefix=Logstash, params: {:maxKeys=>1000, :prefix=>"Logstash"}
34
+ I, [2018-07-17T17:18:31.011935 #86074] INFO -- : url: http://bj.bcebos.com/hubble/Logstash/PluginTest, params: {}
35
+ I, [2018-07-18T14:45:39.377263 #9073] INFO -- : url: http://bj.bcebos.com//, params: {}
36
+ I, [2018-07-18T14:46:21.275336 #9149] INFO -- : url: http://bj.bcebos.com//, params: {}
37
+ I, [2018-07-18T14:47:32.344747 #9281] INFO -- : url: http://bj.bcebos.com//, params: {}
38
+ I, [2018-07-18T14:47:37.591110 #9289] INFO -- : url: http://bj.bcebos.com//, params: {}
39
+ I, [2018-07-18T14:47:40.721758 #9312] INFO -- : url: http://bj.bcebos.com//, params: {}
40
+ I, [2018-07-18T14:48:06.173293 #9358] INFO -- : url: http://bj.bcebos.com//, params: {}
41
+ I, [2018-07-18T14:48:08.181829 #9366] INFO -- : url: http://bj.bcebos.com//, params: {}
42
+ I, [2018-07-18T14:48:38.407382 #9427] INFO -- : url: http://bj.bcebos.com//, params: {}
43
+ I, [2018-07-18T14:48:42.746513 #9441] INFO -- : url: http://bj.bcebos.com//, params: {}
44
+ I, [2018-07-18T14:49:22.340804 #9525] INFO -- : url: http://bj.bcebos.com//, params: {}
45
+ I, [2018-07-18T14:49:49.068901 #9586] INFO -- : url: http://bj.bcebos.com//, params: {}
46
+ I, [2018-07-18T14:50:03.143733 #9616] INFO -- : url: http://bj.bcebos.com//, params: {}
47
+ I, [2018-07-18T14:51:31.971977 #9755] INFO -- : url: http://bj.bcebos.com/logstash/, params: {}
48
+ I, [2018-07-18T14:51:32.056725 #9755] INFO -- : url: http://bj.bcebos.com/logstash/, params: {}
49
+ I, [2018-07-18T14:52:21.863201 #9856] INFO -- : url: http://bj.bcebos.com/testyyj/?maxKeys=1000, params: {:maxKeys=>1000}
50
+ I, [2018-07-18T14:52:35.373447 #9892] INFO -- : url: http://bj.bcebos.com//, params: {}
51
+ I, [2018-07-18T14:53:00.234736 #9944] INFO -- : url: http://bj.bcebos.com/testyyj/?maxKeys=1000, params: {:maxKeys=>1000}
52
+ I, [2018-07-18T14:53:20.660033 #9990] INFO -- : url: http://bj.bcebos.com/test123321/?maxKeys=1000, params: {:maxKeys=>1000}
53
+ I, [2018-07-18T14:53:22.568450 #9991] INFO -- : url: http://bj.bcebos.com/test123321/?maxKeys=1000, params: {:maxKeys=>1000}
54
+ I, [2018-07-18T14:54:03.586978 #10060] INFO -- : url: http://bj.bcebos.com/luguo/?maxKeys=1000, params: {:maxKeys=>1000}
55
+ I, [2018-07-18T14:54:06.325689 #10084] INFO -- : url: http://bj.bcebos.com/luguo/?maxKeys=1000, params: {:maxKeys=>1000}
56
+ I, [2018-07-18T14:54:22.893265 #10107] INFO -- : url: http://bj.bcebos.com/iot2test/?maxKeys=1000, params: {:maxKeys=>1000}
57
+ I, [2018-07-18T14:54:24.498791 #10108] INFO -- : url: http://bj.bcebos.com/iot2test/?maxKeys=1000, params: {:maxKeys=>1000}
58
+ I, [2018-07-18T14:54:40.968935 #10154] INFO -- : url: http://bj.bcebos.com/12dffvsa/?maxKeys=1000, params: {:maxKeys=>1000}
59
+ I, [2018-07-18T14:55:15.203592 #10223] INFO -- : url: http://bj.bcebos.com/multitest/?maxKeys=1000, params: {:maxKeys=>1000}
60
+ I, [2018-07-18T14:55:54.537358 #10314] INFO -- : url: http://bj.bcebos.com/multitest/test/Bos, params: {}
61
+ I, [2018-07-18T14:55:54.733656 #10314] INFO -- : url: http://bj.bcebos.com/multitest/?maxKeys=1000, params: {:maxKeys=>1000}
62
+ I, [2018-07-18T14:56:06.874685 #10345] INFO -- : url: http://bj.bcebos.com/multitest/?maxKeys=1000, params: {:maxKeys=>1000}
63
+ I, [2018-07-18T14:56:08.445478 #10346] INFO -- : url: http://bj.bcebos.com/multitest/?maxKeys=1000, params: {:maxKeys=>1000}
64
+ I, [2018-07-18T14:56:47.661725 #10424] INFO -- : url: http://bj.bcebos.com/multitest/?maxKeys=1000, params: {:maxKeys=>1000}
65
+ I, [2018-07-18T14:57:34.442253 #10507] INFO -- : url: http://bj.bcebos.com/multitest/test/Bos, params: {}
66
+ I, [2018-07-18T14:57:34.723687 #10507] INFO -- : url: http://bj.bcebos.com/multitest/?maxKeys=1000, params: {:maxKeys=>1000}
67
+ I, [2018-07-18T14:57:42.101877 #10531] INFO -- : url: http://bj.bcebos.com/multitest/test/Bos, params: {}
68
+ I, [2018-07-18T14:57:42.454883 #10531] INFO -- : url: http://bj.bcebos.com/multitest/?maxKeys=1000, params: {:maxKeys=>1000}
69
+ I, [2018-07-18T14:58:54.857076 #10632] INFO -- : url: http://bj.bcebos.com/multitest/?maxKeys=1000, params: {:maxKeys=>1000}
70
+ I, [2018-07-18T14:59:19.260529 #10693] INFO -- : url: http://bj.bcebos.com/multitest/test/Bos, params: {}
71
+ I, [2018-07-18T14:59:19.414703 #10693] INFO -- : url: http://bj.bcebos.com/multitest/?maxKeys=1000, params: {:maxKeys=>1000}
@@ -0,0 +1,62 @@
1
+ # encoding: utf-8
2
+ require "logstash/outputs/base"
3
+ require "logstash/namespace"
4
+ require "baidubce/services/bos/bos_client"
5
+ require "rufus-scheduler"
6
+ include Baidubce
7
+
8
+ # Upload the log string into specified bos
9
+ class LogStash::Outputs::Bos < LogStash::Outputs::Base
10
+ config_name "bos"
11
+
12
+ # The log string to be stored in bos
13
+ # config :log, :validate => :string, :required => true
14
+
15
+ # Destination bucket name
16
+ config :bucket, :validate => :string, :required => true
17
+
18
+ # Object Name
19
+ config :object, :validate => :string, :required => true
20
+
21
+ # Path of the file to upload
22
+ config :file_path, :validate => :string, :required => true
23
+
24
+ # Endpoint of BOS
25
+ config :endpoint, :validate => :string, :required => true
26
+
27
+ # Access Key of BOS
28
+ config :ak, :validate => :string, :required => true
29
+
30
+ # Secret Key of BOS
31
+ config :sk, :validate => :string, :required => true
32
+
33
+ public
34
+ def register
35
+ credentials = Auth::BceCredentials.new(@ak, @sk)
36
+ conf = BceClientConfiguration.new(credentials, @endpoint)
37
+ @client = Services::BosClient.new(conf)
38
+ @@scheduledTasks = {}
39
+ # 时区设置
40
+ ENV['TZ'] = 'Asia/Shanghai'
41
+ end # def register
42
+
43
+ public
44
+ def receive(event)
45
+ if @@scheduledTasks["#{@bucket} - #{@object}"].nil?
46
+ # 上传任务未计划,增加新的任务
47
+ scheduler = Rufus::Scheduler.new
48
+ scheduler.at "#{Date.today.next_day.strftime('%Y-%m-%d')} 00:10" do
49
+ # 在第二天0点10分上传前一天的csv文件
50
+ begin
51
+ @client.put_object_from_file(@bucket, @object, @file_path)
52
+ @@scheduledTasks["#{@bucket} - #{@object}"] = nil
53
+ rescue BceServerException => e
54
+ puts "Error: #{e}"
55
+ end
56
+ end
57
+ @@scheduledTasks["#{@bucket} - #{@object}"] = scheduler
58
+ scheduler.join
59
+ end
60
+ end # def receive
61
+
62
+ end # class LogStash::Outputs::Bos
@@ -0,0 +1,20 @@
1
+ require "rufus-scheduler"
2
+ require "baidubce/services/bos/bos_client"
3
+ include Baidubce
4
+ credentials = Auth::BceCredentials.new(
5
+ "a85ed2d7649141e08bf79fbbd88edc12",
6
+ "08b3c29a36df4d0c8f98f093c62661ed"
7
+ )
8
+ conf = BceClientConfiguration.new(credentials, "bj.bcebos.com")
9
+ client = Services::BosClient.new(conf)
10
+ # client.put_object_from_string("multitest", "test/Bos", "string")
11
+ # client.delete_object("multitest", "test/Bos")
12
+ # data = client.list_objects("multitest")
13
+ # objects = data["contents"]
14
+ # objects.each do |object|
15
+ # print("#{object["key"]}\n")
16
+ # end
17
+ scheduler = Rufus::Scheduler.new
18
+ scheduler.at "#{Date.today.strftime('%Y-%m-%d')} 15:43" do
19
+ # do something at a given point in time
20
+ client.put_object_from_string(@bucket, @object, @log)
@@ -0,0 +1,28 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'logstash-output-bos'
3
+ s.version = '0.2.0'
4
+ s.licenses = ['Apache License (2.0)']
5
+ s.summary = "Store a string (mostly log) to specified bos"
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 = ["Yucheng Qin"]
8
+ s.email = "qinyucheng@baidu.com"
9
+ s.homepage = "http://www.baidu.com"
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" => "output" }
19
+
20
+ # Gem dependencies
21
+ #
22
+ s.add_runtime_dependency "mimemagic"
23
+ s.add_runtime_dependency "baidubce-sdk"
24
+ s.add_runtime_dependency "rest-client"
25
+ s.add_runtime_dependency "logstash-core-plugin-api", ">= 1.60", "<= 2.99"
26
+ s.add_runtime_dependency "logstash-codec-plain"
27
+ s.add_development_dependency 'logstash-devutils'
28
+ end
@@ -0,0 +1,47 @@
1
+ # encoding: utf-8
2
+ require "logstash/devutils/rspec/spec_helper"
3
+ require "logstash/outputs/bos"
4
+ require "logstash/codecs/plain"
5
+ require "logstash/event"
6
+ require "baidubce/services/bos/bos_client"
7
+
8
+ describe LogStash::Outputs::Bos do
9
+ let(:logEvent) { LogStash::Event.new }
10
+ let(:output) { LogStash::Outputs::Bos.new }
11
+
12
+ before do
13
+ logEvent.set("log", "Logstash Plugin Test String")
14
+ logEvent.set("bucket", "hubble")
15
+ logEvent.set("object", "Logstash/PluginTest")
16
+ logEvent.set("ak", "be80026973e14e2783bd37670c9bff5d")
17
+ logEvent.set("sk", "ed5f08fe9e374fb48fb9d4d1b6d83491")
18
+ logEvent.set("endpoint", "http://bj.bcebos.com")
19
+ output.register
20
+ end
21
+
22
+ describe "receive message" do
23
+ output.receive(logEvent)
24
+
25
+ it "returns a string" do
26
+ bos = {
27
+ "endpoint" => "http://bj.bcebos.com",
28
+ "ak" => "be80026973e14e2783bd37670c9bff5d",
29
+ "sk" => "ed5f08fe9e374fb48fb9d4d1b6d83491"
30
+ }
31
+
32
+ credentials = Auth::BceCredentials.new(
33
+ bos['ak'],
34
+ bos['sk']
35
+ )
36
+
37
+ conf = BceClientConfiguration.new(
38
+ credentials,
39
+ bos['endpoint']
40
+ )
41
+ client = Services::BosClient.new(conf)
42
+ result = client.get_object_as_string("hubble", "Logstash/PluginTest")
43
+ expect(result).to eq("Logstash Plugin Test String")
44
+ client.delete_object("hubble", "Logstash/PluginTest")
45
+ end
46
+ end
47
+ end
metadata ADDED
@@ -0,0 +1,151 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: logstash-output-bos
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ platform: ruby
6
+ authors:
7
+ - Yucheng Qin
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-07-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: mimemagic
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: baidubce-sdk
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rest-client
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: logstash-core-plugin-api
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '1.60'
62
+ - - "<="
63
+ - !ruby/object:Gem::Version
64
+ version: '2.99'
65
+ type: :runtime
66
+ prerelease: false
67
+ version_requirements: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ version: '1.60'
72
+ - - "<="
73
+ - !ruby/object:Gem::Version
74
+ version: '2.99'
75
+ - !ruby/object:Gem::Dependency
76
+ name: logstash-codec-plain
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ type: :runtime
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ - !ruby/object:Gem::Dependency
90
+ name: logstash-devutils
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ type: :development
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ description: This gem is a Logstash plugin required to be installed on top of the
104
+ Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This
105
+ gem is not a stand-alone program
106
+ email: qinyucheng@baidu.com
107
+ executables: []
108
+ extensions: []
109
+ extra_rdoc_files: []
110
+ files:
111
+ - CHANGELOG.md
112
+ - CONTRIBUTORS
113
+ - DEVELOPER.md
114
+ - Gemfile
115
+ - LICENSE
116
+ - NOTICE.TXT
117
+ - README.md
118
+ - lib/logstash/outputs/baidubce-sdk.log
119
+ - lib/logstash/outputs/bos.rb
120
+ - lib/logstash/outputs/logstash-output-bos-0.4.0.gem
121
+ - lib/logstash/outputs/test.rb
122
+ - logstash-output-bos.gemspec
123
+ - spec/outputs/bos_spec.rb
124
+ homepage: http://www.baidu.com
125
+ licenses:
126
+ - Apache License (2.0)
127
+ metadata:
128
+ logstash_plugin: 'true'
129
+ logstash_group: output
130
+ post_install_message:
131
+ rdoc_options: []
132
+ require_paths:
133
+ - lib
134
+ required_ruby_version: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ required_rubygems_version: !ruby/object:Gem::Requirement
140
+ requirements:
141
+ - - ">="
142
+ - !ruby/object:Gem::Version
143
+ version: '0'
144
+ requirements: []
145
+ rubyforge_project:
146
+ rubygems_version: 2.7.6
147
+ signing_key:
148
+ specification_version: 4
149
+ summary: Store a string (mostly log) to specified bos
150
+ test_files:
151
+ - spec/outputs/bos_spec.rb