fluent-plugin-azureeventhubs 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c0e21c7faa856d74f4f8f195b71e065525213a47
4
- data.tar.gz: 79c2b13e680d28b268003b6013c5769d295f082e
3
+ metadata.gz: 6ede9600a7b9c4e5982441557ec61f97184f92b5
4
+ data.tar.gz: ed8de13ef5ec60d62c3355c7e6303011c251a679
5
5
  SHA512:
6
- metadata.gz: f50fd3712de1735926668d0f957d46104730d7789b35f7e23928db89385c6a2881c960649129c45d2dfa7f5b2461a517e951d464bd6b6e6c9394f9a07819a7ae
7
- data.tar.gz: b67f030f8d6827bcc51e89853e06db30e61f8f4f220ca9ffe076094474ff332e8ffd4f86e173fb834e353ab2357e7e2ccb9e76fb9fc95517a0eedf5a8b3be8e9
6
+ metadata.gz: c96be30e30758af12ada78679b11f8f5376b9c17b6de0412c717f231f593b56ee7ebe502bc3434e5e9cd3301c4e72fd4974d8f852ea9da4a91cada829136a7b1
7
+ data.tar.gz: 418e833fff7d3ccc05c4e33b395f02edc4fa3bb81f0e0b80157e3f21c4d0cb68bc6613e338715cf3ae52e547bb55234fde7507c54cc3d974ebe64476f08a6f63
data/.gitignore CHANGED
@@ -1,14 +1,14 @@
1
- /.bundle/
2
- /.yardoc
3
- /Gemfile.lock
4
- /_yardoc/
5
- /coverage/
6
- /doc/
7
- /pkg/
8
- /spec/reports/
9
- /tmp/
10
- *.bundle
11
- *.so
12
- *.o
13
- *.a
14
- mkmf.log
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in fluent-plugin-azureeventhubs.gemspec
4
- gemspec
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in fluent-plugin-azureeventhubs.gemspec
4
+ gemspec
data/LICENSE.txt CHANGED
@@ -1,22 +1,22 @@
1
- Copyright (c) 2014 Hidemasa Togashi
2
-
3
- MIT License
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining
6
- a copy of this software and associated documentation files (the
7
- "Software"), to deal in the Software without restriction, including
8
- without limitation the rights to use, copy, modify, merge, publish,
9
- distribute, sublicense, and/or sell copies of the Software, and to
10
- permit persons to whom the Software is furnished to do so, subject to
11
- the following conditions:
12
-
13
- The above copyright notice and this permission notice shall be
14
- included in all copies or substantial portions of the Software.
15
-
16
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1
+ Copyright (c) 2014 Hidemasa Togashi
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -1,47 +1,48 @@
1
- # Fluent::Plugin::Azureeventhubs
2
-
3
- Azure Event Hubs buffered output plugin for Fluentd.
4
-
5
- ## Installation
6
-
7
- Add this line to your application's Gemfile:
8
-
9
- ```ruby
10
- gem 'fluent-plugin-azureeventhubs'
11
- ```
12
-
13
- And then execute:
14
-
15
- $ bundle
16
-
17
- Or install it yourself as:
18
-
19
- $ gem install fluent-plugin-azureeventhubs
20
-
21
- ## Configuration
22
-
23
- ```
24
- <match pattern>
25
- type azureeventhubs_buffered
26
-
27
- connection_string <Paste SAS connection string from Azure Management Potal>
28
- hub_name <Name of Event Hubs>
29
- include_tag (true|false) # true: Include tag into record [Optional: default => false]
30
- include_time (true|false) # true: Include time into record [Optional: default => false]
31
- tag_time_name record_time # record tag for time when include_time sets true. [Optional: default => 'time']
32
- type (https|amqps) # Connection type. [Optional: default => https]. Note that amqps is not implementated.
33
- expiry_interval <Integer number> # Signature expiration time interval in seconds. [Optional: default => 3600 (60min)]
34
- proxy_addr <Host or IP> # Address of the proxy [Optional]
35
- proxy_port <Integer> # Proxy port. [Optional: default => 3128]
36
- read_timeout <Integer> # HTTP Read timeout in seconds[Optional: default => 60]
37
- open_timeout <Integer> # HTTP Open timeout in seconds[Optional: default => 60]
38
- </match>
39
- ```
40
-
41
- ## Contributing
42
-
43
- 1. Fork it ( https://github.com/[my-github-username]/fluent-plugin-azureeventhubs/fork )
44
- 2. Create your feature branch (`git checkout -b my-new-feature`)
45
- 3. Commit your changes (`git commit -am 'Add some feature'`)
46
- 4. Push to the branch (`git push origin my-new-feature`)
47
- 5. Create a new Pull Request
1
+ # Fluent::Plugin::Azureeventhubs
2
+
3
+ Azure Event Hubs buffered output plugin for Fluentd.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'fluent-plugin-azureeventhubs'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install fluent-plugin-azureeventhubs
20
+
21
+ ## Configuration
22
+
23
+ ```
24
+ <match pattern>
25
+ type azureeventhubs_buffered
26
+
27
+ connection_string <Paste SAS connection string from Azure Management Potal>
28
+ hub_name <Name of Event Hubs>
29
+ include_tag (true|false) # true: Include tag into record [Optional: default => false]
30
+ include_time (true|false) # true: Include time into record [Optional: default => false]
31
+ tag_time_name record_time # record tag for time when include_time sets true. [Optional: default => 'time']
32
+ type (https|amqps) # Connection type. [Optional: default => https]. Note that amqps is not implementated.
33
+ expiry_interval <Integer number> # Signature expiration time interval in seconds. [Optional: default => 3600 (60min)]
34
+ proxy_addr <Host or IP> # Address of the proxy [Optional]
35
+ proxy_port <Integer> # Proxy port. [Optional: default => 3128]
36
+ read_timeout <Integer> # HTTP Read timeout in seconds[Optional: default => 60]
37
+ open_timeout <Integer> # HTTP Open timeout in seconds[Optional: default => 60]
38
+ message_properties <Json Object> # A json object of key/value pairs to add Properties to the events being sent to EventHubs [Optional: default => nil]
39
+ </match>
40
+ ```
41
+
42
+ ## Contributing
43
+
44
+ 1. Fork it ( https://github.com/[my-github-username]/fluent-plugin-azureeventhubs/fork )
45
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
46
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
47
+ 4. Push to the branch (`git push origin my-new-feature`)
48
+ 5. Create a new Pull Request
data/Rakefile CHANGED
@@ -1,2 +1,2 @@
1
- require "bundler/gem_tasks"
2
-
1
+ require "bundler/gem_tasks"
2
+
@@ -1,22 +1,22 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
-
5
- Gem::Specification.new do |spec|
6
- spec.name = "fluent-plugin-azureeventhubs"
7
- spec.version = "0.0.4"
8
- spec.authors = ["Hidemasa Togashi"]
9
- spec.email = ["togachiro@gmail.com"]
10
- spec.summary = "Fluentd output plugin for Azure Event Hubs"
11
- spec.description = "Fluentd output plugin for Azure Event Hubs"
12
- spec.homepage = "https://github.com/htgc/fluent-plugin-azureeventhubs"
13
- spec.license = "MIT"
14
-
15
- spec.files = `git ls-files -z`.split("\x0")
16
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
- spec.require_paths = ["lib"]
19
-
20
- spec.add_development_dependency "bundler", "~> 1.7"
21
- spec.add_development_dependency "rake", "~> 10.0"
22
- end
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "fluent-plugin-azureeventhubs"
7
+ spec.version = "0.0.5"
8
+ spec.authors = ["Hidemasa Togashi", "Justin Seely"]
9
+ spec.email = ["togachiro@gmail.com"]
10
+ spec.summary = "Fluentd output plugin for Azure Event Hubs"
11
+ spec.description = "Fluentd output plugin for Azure Event Hubs"
12
+ spec.homepage = "https://github.com/htgc/fluent-plugin-azureeventhubs"
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files -z`.split("\x0")
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_development_dependency "bundler", "~> 1.7"
21
+ spec.add_development_dependency "rake", "~> 10.0"
22
+ end
@@ -1,67 +1,74 @@
1
-
2
- class AzureEventHubsHttpSender
3
- def initialize(connection_string, hub_name, expiry=3600,proxy_addr='',proxy_port=3128,open_timeout=60,read_timeout=60)
4
- require 'openssl'
5
- require 'base64'
6
- require 'net/http'
7
- require 'json'
8
- require 'cgi'
9
- require 'time'
10
- @connection_string = connection_string
11
- @hub_name = hub_name
12
- @expiry_interval = expiry
13
- @proxy_addr = proxy_addr
14
- @proxy_port = proxy_port
15
- @open_timeout = open_timeout
16
- @read_timeout = read_timeout
17
-
18
- if @connection_string.count(';') != 2
19
- raise "Connection String format is not correct"
20
- end
21
-
22
- @connection_string.split(';').each do |part|
23
- if ( part.index('Endpoint') == 0 )
24
- @endpoint = 'https' + part[11..-1]
25
- elsif ( part.index('SharedAccessKeyName') == 0 )
26
- @sas_key_name = part[20..-1]
27
- elsif ( part.index('SharedAccessKey') == 0 )
28
- @sas_key_value = part[16..-1]
29
- end
30
- end
31
- @uri = URI.parse("#{@endpoint}#{@hub_name}/messages")
32
- end
33
-
34
- def generate_sas_token(uri)
35
- target_uri = CGI.escape(uri.downcase).downcase
36
- expiry = Time.now.to_i + @expiry_interval
37
- to_sign = "#{target_uri}\n#{expiry}";
38
- signature = CGI.escape(Base64.encode64(OpenSSL::HMAC.digest(OpenSSL::Digest.new('sha256'), @sas_key_value, to_sign)).strip())
39
-
40
- token = "SharedAccessSignature sr=#{target_uri}&sig=#{signature}&se=#{expiry}&skn=#{@sas_key_name}"
41
- return token
42
- end
43
-
44
- private :generate_sas_token
45
-
46
- def send(payload)
47
- token = generate_sas_token(@uri.to_s)
48
- headers = {
49
- 'Content-Type' => 'application/atom+xml;type=entry;charset=utf-8',
50
- 'Authorization' => token
51
- }
52
- if (@proxy_addr.to_s.empty?)
53
- https = Net::HTTP.new(@uri.host, @uri.port)
54
- https.open_timeout = @open_timeout
55
- https.read_timeout = @read_timeout
56
- else
57
- https = Net::HTTP.new(@uri.host, @uri.port,@proxy_addr,@proxy_port)
58
- https.open_timeout = @open_timeout
59
- https.read_timeout = @read_timeout
60
- end
61
- https.use_ssl = true
62
- req = Net::HTTP::Post.new(@uri.request_uri, headers)
63
- req.body = payload.to_json
64
- res = https.request(req)
65
- rescue Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, EOFError, Errno::ETIMEDOUT, Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError => e
66
- end
67
- end
1
+
2
+ class AzureEventHubsHttpSender
3
+ def initialize(connection_string, hub_name, expiry=3600,proxy_addr='',proxy_port=3128,open_timeout=60,read_timeout=60)
4
+ require 'openssl'
5
+ require 'base64'
6
+ require 'net/http'
7
+ require 'json'
8
+ require 'cgi'
9
+ require 'time'
10
+ @connection_string = connection_string
11
+ @hub_name = hub_name
12
+ @expiry_interval = expiry
13
+ @proxy_addr = proxy_addr
14
+ @proxy_port = proxy_port
15
+ @open_timeout = open_timeout
16
+ @read_timeout = read_timeout
17
+
18
+ if @connection_string.count(';') != 2
19
+ raise "Connection String format is not correct"
20
+ end
21
+
22
+ @connection_string.split(';').each do |part|
23
+ if ( part.index('Endpoint') == 0 )
24
+ @endpoint = 'https' + part[11..-1]
25
+ elsif ( part.index('SharedAccessKeyName') == 0 )
26
+ @sas_key_name = part[20..-1]
27
+ elsif ( part.index('SharedAccessKey') == 0 )
28
+ @sas_key_value = part[16..-1]
29
+ end
30
+ end
31
+ @uri = URI.parse("#{@endpoint}#{@hub_name}/messages")
32
+ end
33
+
34
+ def generate_sas_token(uri)
35
+ target_uri = CGI.escape(uri.downcase).downcase
36
+ expiry = Time.now.to_i + @expiry_interval
37
+ to_sign = "#{target_uri}\n#{expiry}";
38
+ signature = CGI.escape(Base64.encode64(OpenSSL::HMAC.digest(OpenSSL::Digest.new('sha256'), @sas_key_value, to_sign)).strip())
39
+
40
+ token = "SharedAccessSignature sr=#{target_uri}&sig=#{signature}&se=#{expiry}&skn=#{@sas_key_name}"
41
+ return token
42
+ end
43
+
44
+ private :generate_sas_token
45
+
46
+ def send(payload)
47
+ send_w_properties(payload, nil)
48
+ end
49
+
50
+ def send_w_properties(payload, properties)
51
+ token = generate_sas_token(@uri.to_s)
52
+ headers = {
53
+ 'Content-Type' => 'application/atom+xml;type=entry;charset=utf-8',
54
+ 'Authorization' => token
55
+ }
56
+ if not properties.nil?
57
+ headers = headers.merge(properties)
58
+ end
59
+ if (@proxy_addr.to_s.empty?)
60
+ https = Net::HTTP.new(@uri.host, @uri.port)
61
+ https.open_timeout = @open_timeout
62
+ https.read_timeout = @read_timeout
63
+ else
64
+ https = Net::HTTP.new(@uri.host, @uri.port,@proxy_addr,@proxy_port)
65
+ https.open_timeout = @open_timeout
66
+ https.read_timeout = @read_timeout
67
+ end
68
+ https.use_ssl = true
69
+ req = Net::HTTP::Post.new(@uri.request_uri, headers)
70
+ req.body = payload.to_json
71
+ res = https.request(req)
72
+ rescue Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, EOFError, Errno::ETIMEDOUT, Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError => e
73
+ end
74
+ end
@@ -1,47 +1,48 @@
1
- #module Fluent
2
-
3
- class AzureEventHubsOutputBuffered < Fluent::BufferedOutput
4
- Fluent::Plugin.register_output('azureeventhubs_buffered', self)
5
-
6
- config_param :connection_string, :string
7
- config_param :hub_name, :string
8
- config_param :include_tag, :bool, :default => false
9
- config_param :include_time, :bool, :default => false
10
- config_param :tag_time_name, :string, :default => 'time'
11
- config_param :expiry_interval, :integer, :default => 3600 # 60min
12
- config_param :type, :string, :default => 'https' # https / amqps (Not Implemented)
13
- config_param :proxy_addr, :string, :default => ''
14
- config_param :proxy_port, :integer,:default => 3128
15
- config_param :open_timeout, :integer,:default => 60
16
- config_param :read_timeout, :integer,:default => 60
17
-
18
- def configure(conf)
19
- super
20
- case @type
21
- when 'amqps'
22
- raise NotImplementedError
23
- else
24
- require_relative 'azureeventhubs/http'
25
- @sender = AzureEventHubsHttpSender.new(@connection_string, @hub_name, @expiry_interval,@proxy_addr,@proxy_port,@open_timeout,@read_timeout)
26
- end
27
- end
28
-
29
- def format(tag, time, record)
30
- [tag, time, record].to_msgpack
31
- end
32
-
33
- def write(chunk)
34
- chunk.msgpack_each { |tag, time, record|
35
- p record.to_s
36
- if @include_tag
37
- record['tag'] = tag
38
- end
39
- if @include_time
40
- record[@tag_time_name] = time
41
- end
42
- @sender.send(record)
43
- }
44
- end
45
- end
46
- #end
47
-
1
+ #module Fluent
2
+
3
+ class AzureEventHubsOutputBuffered < Fluent::BufferedOutput
4
+ Fluent::Plugin.register_output('azureeventhubs_buffered', self)
5
+
6
+ config_param :connection_string, :string
7
+ config_param :hub_name, :string
8
+ config_param :include_tag, :bool, :default => false
9
+ config_param :include_time, :bool, :default => false
10
+ config_param :tag_time_name, :string, :default => 'time'
11
+ config_param :expiry_interval, :integer, :default => 3600 # 60min
12
+ config_param :type, :string, :default => 'https' # https / amqps (Not Implemented)
13
+ config_param :proxy_addr, :string, :default => ''
14
+ config_param :proxy_port, :integer,:default => 3128
15
+ config_param :open_timeout, :integer,:default => 60
16
+ config_param :read_timeout, :integer,:default => 60
17
+ config_param :message_properties, :hash, :default => nil
18
+
19
+ def configure(conf)
20
+ super
21
+ case @type
22
+ when 'amqps'
23
+ raise NotImplementedError
24
+ else
25
+ require_relative 'azureeventhubs/http'
26
+ @sender = AzureEventHubsHttpSender.new(@connection_string, @hub_name, @expiry_interval,@proxy_addr,@proxy_port,@open_timeout,@read_timeout)
27
+ end
28
+ end
29
+
30
+ def format(tag, time, record)
31
+ [tag, time, record].to_msgpack
32
+ end
33
+
34
+ def write(chunk)
35
+ chunk.msgpack_each { |tag, time, record|
36
+ p record.to_s
37
+ if @include_tag
38
+ record['tag'] = tag
39
+ end
40
+ if @include_time
41
+ record[@tag_time_name] = time
42
+ end
43
+ @sender.send_w_properties(record, @message_properties)
44
+ }
45
+ end
46
+ end
47
+ #end
48
+
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-azureeventhubs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hidemasa Togashi
8
+ - Justin Seely
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2016-09-01 00:00:00.000000000 Z
12
+ date: 2017-05-15 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: bundler
@@ -73,7 +74,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
73
74
  version: '0'
74
75
  requirements: []
75
76
  rubyforge_project:
76
- rubygems_version: 2.4.8
77
+ rubygems_version: 2.5.2
77
78
  signing_key:
78
79
  specification_version: 4
79
80
  summary: Fluentd output plugin for Azure Event Hubs