sk-fluent-plugin-azureeventhubs 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: b96f55f410eaa0d94d998a8754dee8d0124c67b4ab1a7df8ac5ca4ca149ffc1b
4
+ data.tar.gz: c9f51c4245d8c6e58ad124d9cb6b43ebaa2b05505297c2fbb705e492b46d422e
5
+ SHA512:
6
+ metadata.gz: 5deef053c1a69ed9f79b0d7416160b1b37ffceea78c1362932bd3e4c32ac94c830891c29acc0086deeeb43882367a18ff10fb2b829977172a3e66217d407af9f
7
+ data.tar.gz: e32589b83cd7e4fee2fe642a4e57ea9699e64ae749d5d4ac7e746949cc2337afd16471e0d04f1db3cda4073e16e855d1288be37004e31838b92ba1b7200065ab
data/.gitignore ADDED
@@ -0,0 +1,15 @@
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
15
+ *.gem
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in fluent-plugin-azureeventhubs.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +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.
data/README.md ADDED
@@ -0,0 +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
+ 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 ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,23 @@
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 = "sk-fluent-plugin-azureeventhubs"
7
+ spec.version = "0.0.1"
8
+ spec.authors = ["Hidemasa Togashi", "Toddy Mladenov", "Justin Seely"]
9
+ spec.email = ["togachiro@gmail.com", "toddysm@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
+ spec.add_dependency "fluentd", [">= 0.14.15", "< 2"]
23
+ end
@@ -0,0 +1,60 @@
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 'unirest'
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
+ Unirest.post @uri.request_uri,
53
+ headers:{ 'Content-Type' => 'application/atom+xml;type=entry;charset=utf-8',
54
+ 'Authorization' => token
55
+ },
56
+ parameters:payload {|response|
57
+ response.code
58
+ }
59
+ end
60
+ end
@@ -0,0 +1,63 @@
1
+ module Fluent::Plugin
2
+
3
+ class AzureEventHubsOutputBuffered < Output
4
+ Fluent::Plugin.register_output('azureeventhubs_buffered', self)
5
+
6
+ helpers :compat_parameters, :inject
7
+
8
+ DEFAULT_BUFFER_TYPE = "memory"
9
+
10
+ config_param :connection_string, :string
11
+ config_param :hub_name, :string
12
+ config_param :include_tag, :bool, :default => false
13
+ config_param :include_time, :bool, :default => false
14
+ config_param :tag_time_name, :string, :default => 'time'
15
+ config_param :expiry_interval, :integer, :default => 3600 # 60min
16
+ config_param :type, :string, :default => 'https' # https / amqps (Not Implemented)
17
+ config_param :proxy_addr, :string, :default => ''
18
+ config_param :proxy_port, :integer,:default => 3128
19
+ config_param :open_timeout, :integer,:default => 60
20
+ config_param :read_timeout, :integer,:default => 60
21
+ config_param :message_properties, :hash, :default => nil
22
+
23
+ config_section :buffer do
24
+ config_set_default :@type, DEFAULT_BUFFER_TYPE
25
+ config_set_default :chunk_keys, ['tag']
26
+ end
27
+
28
+ def configure(conf)
29
+ compat_parameters_convert(conf, :buffer, :inject)
30
+ super
31
+ case @type
32
+ when 'amqps'
33
+ raise NotImplementedError
34
+ else
35
+ require_relative 'azureeventhubs/http'
36
+ @sender = AzureEventHubsHttpSender.new(@connection_string, @hub_name, @expiry_interval,@proxy_addr,@proxy_port,@open_timeout,@read_timeout)
37
+ end
38
+ raise Fluent::ConfigError, "'tag' in chunk_keys is required." if not @chunk_key_tag
39
+ end
40
+
41
+ def format(tag, time, record)
42
+ record = inject_values_to_record(tag, time, record)
43
+ [tag, time, record].to_msgpack
44
+ end
45
+
46
+ def formatted_to_msgpack_binary?
47
+ true
48
+ end
49
+
50
+ def write(chunk)
51
+ chunk.msgpack_each { |tag, time, record|
52
+ p record.to_s
53
+ if @include_tag
54
+ record['tag'] = tag
55
+ end
56
+ if @include_time
57
+ record[@tag_time_name] = time
58
+ end
59
+ @sender.send_w_properties(record, @message_properties)
60
+ }
61
+ end
62
+ end
63
+ end
metadata ADDED
@@ -0,0 +1,103 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sk-fluent-plugin-azureeventhubs
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Hidemasa Togashi
8
+ - Toddy Mladenov
9
+ - Justin Seely
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2018-10-31 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: bundler
17
+ requirement: !ruby/object:Gem::Requirement
18
+ requirements:
19
+ - - "~>"
20
+ - !ruby/object:Gem::Version
21
+ version: '1.7'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - "~>"
27
+ - !ruby/object:Gem::Version
28
+ version: '1.7'
29
+ - !ruby/object:Gem::Dependency
30
+ name: rake
31
+ requirement: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - "~>"
34
+ - !ruby/object:Gem::Version
35
+ version: '10.0'
36
+ type: :development
37
+ prerelease: false
38
+ version_requirements: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - "~>"
41
+ - !ruby/object:Gem::Version
42
+ version: '10.0'
43
+ - !ruby/object:Gem::Dependency
44
+ name: fluentd
45
+ requirement: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: 0.14.15
50
+ - - "<"
51
+ - !ruby/object:Gem::Version
52
+ version: '2'
53
+ type: :runtime
54
+ prerelease: false
55
+ version_requirements: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: 0.14.15
60
+ - - "<"
61
+ - !ruby/object:Gem::Version
62
+ version: '2'
63
+ description: Fluentd output plugin for Azure Event Hubs
64
+ email:
65
+ - togachiro@gmail.com
66
+ - toddysm@gmail.com
67
+ executables: []
68
+ extensions: []
69
+ extra_rdoc_files: []
70
+ files:
71
+ - ".gitignore"
72
+ - Gemfile
73
+ - LICENSE.txt
74
+ - README.md
75
+ - Rakefile
76
+ - fluent-plugin-azureeventhubs.gemspec
77
+ - lib/fluent/plugin/azureeventhubs/http.rb
78
+ - lib/fluent/plugin/out_azureeventhubs_buffered.rb
79
+ homepage: https://github.com/htgc/fluent-plugin-azureeventhubs
80
+ licenses:
81
+ - MIT
82
+ metadata: {}
83
+ post_install_message:
84
+ rdoc_options: []
85
+ require_paths:
86
+ - lib
87
+ required_ruby_version: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ required_rubygems_version: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ requirements: []
98
+ rubyforge_project:
99
+ rubygems_version: 2.7.7
100
+ signing_key:
101
+ specification_version: 4
102
+ summary: Fluentd output plugin for Azure Event Hubs
103
+ test_files: []