fluent-plugin-azureeventhubs 0.0.1

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
+ SHA1:
3
+ metadata.gz: 5491857b05bcfb6db0fb36515adefd80e69b4fdc
4
+ data.tar.gz: 8a189efccb6bdaff99fd1ce52f1a85a4b0cdc7e5
5
+ SHA512:
6
+ metadata.gz: 6b1b7c7719bb7836a62bbc7c291b1fc5713772d7d436856592f7d5272eee013dc7632baecea48c534fd3a336928c2dcec1099c6b55fc6cc810746030beaad48d
7
+ data.tar.gz: 4372244363879f01275cbb6e59caf532170c270c4609b3f2fe086b9c9bab422359bb2e39e23cf6b607632022bac897fcae1e8a1e269a8ac94beaa8960a5cccba
data/.gitignore ADDED
@@ -0,0 +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
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,42 @@
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
+ </match>
34
+ ```
35
+
36
+ ## Contributing
37
+
38
+ 1. Fork it ( https://github.com/[my-github-username]/fluent-plugin-azureeventhubs/fork )
39
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
40
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
41
+ 4. Push to the branch (`git push origin my-new-feature`)
42
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +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.1"
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
@@ -0,0 +1,54 @@
1
+
2
+ class AzureEventHubsHttpSender
3
+ def initialize(connection_string, hub_name)
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
+ @expires_in_mins = 3600
13
+
14
+ if @connection_string.count(';') != 2
15
+ raise "Connection String format is not correct"
16
+ end
17
+
18
+ @connection_string.split(';').each do |part|
19
+ if ( part.index('Endpoint') == 0 )
20
+ @endpoint = 'https' + part[11..-1]
21
+ elsif ( part.index('SharedAccessKeyName') == 0 )
22
+ @sas_key_name = part[20..-1]
23
+ elsif ( part.index('SharedAccessKey') == 0 )
24
+ @sas_key_value = part[16..-1]
25
+ end
26
+ end
27
+ @uri = URI.parse("#{@endpoint}#{@hub_name}/messages")
28
+ end
29
+
30
+ def generate_sas_token(uri)
31
+ target_uri = CGI.escape(uri.downcase).downcase
32
+ expires = Time.now.to_i + @expires_in_mins
33
+ to_sign = "#{target_uri}\n#{expires}";
34
+ signature = CGI.escape(Base64.encode64(OpenSSL::HMAC.digest(OpenSSL::Digest.new('sha256'), @sas_key_value, to_sign)).strip())
35
+
36
+ token = "SharedAccessSignature sr=#{target_uri}&sig=#{signature}&se=#{expires}&skn=#{@sas_key_name}"
37
+ return token
38
+ end
39
+
40
+ private :generate_sas_token
41
+
42
+ def send(payload)
43
+ token = generate_sas_token(@uri.to_s)
44
+ headers = {
45
+ 'Content-Type' => 'application/atom+xml;type=entry;charset=utf-8',
46
+ 'Authorization' => token
47
+ }
48
+ https = Net::HTTP.new(@uri.host, @uri.port)
49
+ https.use_ssl = true
50
+ req = Net::HTTP::Post.new(@uri.request_uri, headers)
51
+ req.body = payload.to_json
52
+ res = https.request(req)
53
+ end
54
+ end
@@ -0,0 +1,43 @@
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 :expires_mins, :integer, :default => 3600 # 60min
12
+ config_param :type, :string, :default => 'https' # https / amqps (Not Implemented)
13
+
14
+ def configure(conf)
15
+ super
16
+ case @type
17
+ when 'amqps'
18
+ raise NotImplementedError
19
+ else
20
+ require_relative 'azureeventhubs/http'
21
+ @sender = AzureEventHubsHttpSender.new(@connection_string, @hub_name)
22
+ end
23
+ end
24
+
25
+ def format(tag, time, record)
26
+ [tag, time, record].to_msgpack
27
+ end
28
+
29
+ def write(chunk)
30
+ chunk.msgpack_each { |tag, time, record|
31
+ p record.to_s
32
+ if @include_tag
33
+ record['tag'] = tag
34
+ end
35
+ if @include_time
36
+ record[@tag_time_name] = time
37
+ end
38
+ @sender.send(record)
39
+ }
40
+ end
41
+ end
42
+ #end
43
+
metadata ADDED
@@ -0,0 +1,80 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fluent-plugin-azureeventhubs
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Hidemasa Togashi
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-01-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ description: Fluentd output plugin for Azure Event Hubs
42
+ email:
43
+ - togachiro@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - Gemfile
50
+ - LICENSE.txt
51
+ - README.md
52
+ - Rakefile
53
+ - fluent-plugin-azureeventhubs.gemspec
54
+ - lib/fluent/plugin/azureeventhubs/http.rb
55
+ - lib/fluent/plugin/out_azureeventhubs_buffered.rb
56
+ homepage: https://github.com/htgc/fluent-plugin-azureeventhubs
57
+ licenses:
58
+ - MIT
59
+ metadata: {}
60
+ post_install_message:
61
+ rdoc_options: []
62
+ require_paths:
63
+ - lib
64
+ required_ruby_version: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ required_rubygems_version: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ requirements: []
75
+ rubyforge_project:
76
+ rubygems_version: 2.2.2
77
+ signing_key:
78
+ specification_version: 4
79
+ summary: Fluentd output plugin for Azure Event Hubs
80
+ test_files: []