logstash-input-azureeventhub 0.9.3 → 0.9.4

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: 232cebdc693dc57bc9a195394f87ceb386634158
4
- data.tar.gz: 8504b6dadea7e61dd5b40ca44ec16bc2b3eed5b2
3
+ metadata.gz: 2924490058a3734f84e3b19c7d79052b75dc14da
4
+ data.tar.gz: d6cbf8697ab3cd2d9a9833bd418034f10daf893b
5
5
  SHA512:
6
- metadata.gz: c219b85abccc9cc4b383108f48b6980ef1635c39dac39434c76e18072f1c57ae021ad39f73d0b7f8c63323a142a8e4e69f73300125a8d5a1a4e573c44cfb8a02
7
- data.tar.gz: 13eb990e3f67b16f3b09de36d4ae1041ee1447257c758d75656f73d5bc082d90adec964a2f0da8b82cf6b734875a2534a1e5fd32b126672d7ef9c5f05765d896
6
+ metadata.gz: 9f54390e4614abae268c78b62299de3f1fefaf030927636b6a361dd42b025a1e7178b557eba4ce67812935ccd45b7e2fdc929f1403ecde1ae02a498bb75396bc
7
+ data.tar.gz: e9919670be6b516fe82a75ff42ce7127393ffcb8ac48609e5289cb3dfefa5705bbbdd047b7ef4970adf0e10360447a73139cf994ba059e142a43947659fed9c0
File without changes
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
3
+ gem 'azure', '~> 0.7.1'
data/LICENSE ADDED
@@ -0,0 +1,17 @@
1
+
2
+ Copyright (c) Microsoft. All rights reserved.
3
+ Microsoft would like to thank its contributors, a list
4
+ of whom are at http://aka.ms/entlib-contributors
5
+
6
+ Licensed under the Apache License, Version 2.0 (the "License"); you
7
+ may not use this file except in compliance with the License. You may
8
+ obtain a copy of the License at
9
+
10
+ http://www.apache.org/licenses/LICENSE-2.0
11
+
12
+ Unless required by applicable law or agreed to in writing, software
13
+ distributed under the License is distributed on an "AS IS" BASIS,
14
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
15
+ implied. See the License for the specific language governing permissions
16
+ and limitations under the License.
17
+
@@ -0,0 +1,91 @@
1
+ # Notice
2
+ This plugin is a part of [Microsoft Azure Diagnostics with ELK](https://github.com/mspnp/semantic-logging/tree/v3/ELK).
3
+
4
+ [See more documentation.](https://github.com/mspnp/semantic-logging/blob/v3/ELK/md/LogstashExtensions.md#azure-wad-table)
5
+
6
+ # Logstash Plugin
7
+
8
+ This is a plugin for [Logstash](https://github.com/elasticsearch/logstash).
9
+
10
+ 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.
11
+
12
+ ## Documentation
13
+
14
+ Logstash provides infrastructure to automatically generate documentation for this plugin. We use the asciidoc format to write documentation so any comments in the source code will be first converted into asciidoc and then into html. All plugin documentation are placed under one [central location](http://www.elasticsearch.org/guide/en/logstash/current/).
15
+
16
+ - For formatting code or config example, you can use the asciidoc `[source,ruby]` directive
17
+ - For more asciidoc formatting tips, see the excellent reference here https://github.com/elasticsearch/docs#asciidoc-guide
18
+
19
+ ## Need Help?
20
+
21
+ Need help? Try #logstash on freenode IRC or the https://discuss.elastic.co/c/logstash discussion forum.
22
+
23
+ ## Developing
24
+
25
+ ### 1. Plugin Developement and Testing
26
+
27
+ #### Code
28
+ - To get started, you'll need JRuby with the Bundler gem installed.
29
+
30
+ - 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).
31
+
32
+ - Install dependencies
33
+ ```sh
34
+ bundle install
35
+ ```
36
+
37
+ #### Test
38
+
39
+ - Update your dependencies
40
+
41
+ ```sh
42
+ bundle install
43
+ ```
44
+
45
+ - Run tests
46
+
47
+ ```sh
48
+ bundle exec rspec
49
+ ```
50
+
51
+ ### 2. Running your unpublished Plugin in Logstash
52
+
53
+ #### 2.1 Run in a local Logstash clone
54
+
55
+ - Edit Logstash `Gemfile` and add the local plugin path, for example:
56
+ ```ruby
57
+ gem "logstash-filter-awesome", :path => "/your/local/logstash-filter-awesome"
58
+ ```
59
+ - Install plugin
60
+ ```sh
61
+ bin/plugin install --no-verify
62
+ ```
63
+ - Run Logstash with your plugin
64
+ ```sh
65
+ bin/logstash -e 'filter {awesome {}}'
66
+ ```
67
+ At this point any modifications to the plugin code will be applied to this local Logstash setup. After modifying the plugin, simply rerun Logstash.
68
+
69
+ #### 2.2 Run in an installed Logstash
70
+
71
+ 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:
72
+
73
+ - Build your plugin gem
74
+ ```sh
75
+ gem build logstash-filter-awesome.gemspec
76
+ ```
77
+ - Install the plugin from the Logstash home
78
+ ```sh
79
+ bin/plugin install /your/local/plugin/logstash-filter-awesome.gem
80
+ ```
81
+ - Start Logstash and proceed to test the plugin
82
+
83
+ ## Contributing
84
+
85
+ All contributions are welcome: ideas, patches, documentation, bug reports, complaints, and even something you drew up on a napkin.
86
+
87
+ 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.
88
+
89
+ It is more important to the community that you are able to contribute.
90
+
91
+ For more information about contributing, see the [CONTRIBUTING](https://github.com/elasticsearch/logstash/blob/master/CONTRIBUTING.md) file.
@@ -0,0 +1 @@
1
+ require "logstash/devutils/rake"
@@ -0,0 +1,163 @@
1
+ # encoding: utf-8
2
+ require "logstash/inputs/base"
3
+ require "logstash/namespace"
4
+
5
+ require "securerandom"
6
+ require "open-uri"
7
+ require "thread"
8
+
9
+ require "geronimo-jms_1.1_spec-1.1.jar"
10
+ require "qpid-amqp-1-0-client-0.22.jar"
11
+ require "qpid-amqp-1-0-client-jms-0.22.jar"
12
+ require "qpid-amqp-1-0-common-0.22.jar"
13
+
14
+
15
+ # Reads events from Azure event-hub
16
+ class LogStash::Inputs::Azureeventhub < LogStash::Inputs::Base
17
+
18
+ config_name "azureeventhub"
19
+ milestone 0
20
+
21
+ default :codec, "json"
22
+
23
+ config :key, :validate => :string
24
+ config :username, :validate => :string
25
+ config :namespace, :validate => :string
26
+ config :domain, :validate => :string, :default => "servicebus.windows.net"
27
+ config :port, :validate => :number, :default => 5671
28
+ config :receive_credits, :validate => :number, :default => 1000
29
+
30
+ config :eventhub, :validate => :string
31
+ config :partitions, :validate => :number
32
+ config :consumer_group, :validate => :string, :default => "$default"
33
+
34
+ config :time_since_epoch_millis, :validate => :number, :default => Time.now.to_i * 1000
35
+ config :thread_wait_sec, :validate => :number, :default => 5
36
+
37
+
38
+ def initialize(*args)
39
+ super(*args)
40
+ end # def initialize
41
+
42
+ public
43
+ def register
44
+ end # def register
45
+
46
+ def get_pay_load(message)
47
+ return nil if not message
48
+ message.getPayload().each do |section|
49
+ if section.java_kind_of? org::apache::qpid::amqp_1_0::type::messaging::Data or section.java_kind_of? org::apache::qpid::amqp_1_0::type::messaging::AmqpValue
50
+ return section.getValue().to_s
51
+ end
52
+ end
53
+ return nil
54
+ end
55
+
56
+ def process(output_queue, receiver, partition)
57
+ while true
58
+ begin
59
+ msg = receiver.receive(10)
60
+ if msg
61
+ codec.decode(get_pay_load(msg)) do |event|
62
+ output_queue << event
63
+ end
64
+ receiver.acknowledge(msg)
65
+ else
66
+ @logger.debug(" " + partition.to_s.rjust(2,"0") + " --- " + "No message")
67
+ sleep(@thread_wait_sec)
68
+ end
69
+ rescue LogStash::ShutdownSignal => e
70
+ raise e
71
+ rescue org::apache::qpid::amqp_1_0::client::ConnectionErrorException => e
72
+ raise e
73
+ rescue => e
74
+ @logger.error(" " + partition.to_s.rjust(2,"0") + " --- " + "Oh My, An error occurred.", :exception => e)
75
+ end
76
+ end # process
77
+ end # process
78
+
79
+ def process_partition(output_queue, partition)
80
+ while true
81
+ begin
82
+ filter = SelectorFilter.new "amqp.annotation.x-opt-enqueuedtimeutc > '" + @time_since_epoch_millis.to_s + "'"
83
+ filters = { org::apache::qpid::amqp_1_0::type::Symbol.valueOf("apache.org:selector-filter:string") => filter }
84
+
85
+ host = @namespace + "." + @domain
86
+ connection = org::apache::qpid::amqp_1_0::client::Connection.new(host, @port, @username, @key, host, true)
87
+ connection.getEndpoint().getDescribedTypeRegistry().register(filter.java_class, WriterFactory.new)
88
+ receiveSession = connection.createSession()
89
+ receiver = receiveSession.createReceiver(@eventhub + "/ConsumerGroups/" + @consumer_group + "/Partitions/" + partition.to_s, org::apache::qpid::amqp_1_0::client::AcknowledgeMode::ALO, "eventhubs-receiver-link-" + partition.to_s, false, filters, nil)
90
+ receiver.setCredit(org::apache::qpid::amqp_1_0::type::UnsignedInteger.valueOf(@receive_credits), true)
91
+ process(output_queue,receiver,partition)
92
+ rescue org::apache::qpid::amqp_1_0::client::ConnectionErrorException => e
93
+ @logger.debug(" " + partition.to_s.rjust(2,"0") + " --- " + "resetting connection")
94
+ @time_since_epoch_millis = Time.now.to_i * 1000
95
+ end
96
+ end
97
+ rescue LogStash::ShutdownSignal => e
98
+ receiver.close()
99
+ raise e
100
+ rescue => e
101
+ @logger.error(" " + partition.to_s.rjust(2,"0") + " --- Oh My, An error occurred.", :exception => e)
102
+ end # process
103
+
104
+ public
105
+ def run(output_queue)
106
+ threads = []
107
+ (0..(@partitions-1)).each do |p_id|
108
+ threads << Thread.new { process_partition(output_queue, p_id) }
109
+ end
110
+ threads.each { |thr| thr.join }
111
+ end # def run
112
+
113
+ public
114
+ def teardown
115
+ end # def teardown
116
+ end # class LogStash::Inputs::Azureeventhub
117
+
118
+
119
+ class SelectorFilter
120
+ include org::apache::qpid::amqp_1_0::type::messaging::Filter
121
+
122
+ def initialize(value)
123
+ @value = value
124
+ end
125
+
126
+ def getValue
127
+ return @value
128
+ end
129
+
130
+ def toString
131
+ return @value
132
+ end
133
+ end
134
+
135
+ class SelectorFilterWriter < org::apache::qpid::amqp_1_0::codec::AbstractDescribedTypeWriter
136
+ def initialize(registry)
137
+ super(registry)
138
+ end
139
+
140
+ def onSetValue(value)
141
+ @value = value
142
+ end
143
+
144
+ def clear
145
+ @value = nil
146
+ end
147
+
148
+ def getDescriptor
149
+ return org::apache::qpid::amqp_1_0::type::UnsignedLong.valueOf(83483426826);
150
+ end
151
+
152
+ def createDescribedWriter
153
+ return getRegistry().getValueWriter(@value.getValue());
154
+ end
155
+ end
156
+
157
+ class WriterFactory
158
+ include org::apache::qpid::amqp_1_0::codec::ValueWriter::Factory
159
+
160
+ def newInstance(registry)
161
+ return SelectorFilterWriter.new registry
162
+ end
163
+ end
@@ -0,0 +1,31 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'logstash-input-azureeventhub'
3
+ s.version = '0.9.4'
4
+ s.licenses = ['Apache License (2.0)']
5
+ s.summary = "This plugin will collect Microsoft Azure Diagnostics data from Azure Event Hubs."
6
+ s.description = "This gem is a logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/plugin install gemname. This gem is not a stand-alone program."
7
+ s.authors = ["Microsoft Corporation"]
8
+ s.email = 'azdiag@microsoft.com'
9
+ s.homepage = "https://github.com/Azure/azure-diagnostics-tools"
10
+ s.require_paths = ["lib"]
11
+
12
+ # Files
13
+ s.files = `git ls-files`.split($\)
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', '>= 1.4.0', '< 2.0.0'
22
+ s.add_runtime_dependency 'azure', '~> 0.7.1'
23
+ s.add_development_dependency 'logstash-devutils'
24
+
25
+ #Jar dependencies
26
+ s.requirements << "jar 'org.apache.qpid:qpid-amqp-1-0-common', '0.32'"
27
+ s.requirements << "jar 'org.apache.qpid:qpid-amqp-1-0-client-jms', '0.32'"
28
+ s.requirements << "jar 'org.apache.qpid:qpid-client', '0.32'"
29
+ s.requirements << "jar 'org.apache.geronimo.specs:geronimo-jms_1.1_spec', '1.1.1'"
30
+ s.add_runtime_dependency 'jar-dependencies'
31
+ end
@@ -0,0 +1 @@
1
+ require "logstash/devutils/rspec/spec_helper"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-input-azureeventhub
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.3
4
+ version: 0.9.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Microsoft Corporation
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-12 00:00:00.000000000 Z
11
+ date: 2016-03-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -77,8 +77,16 @@ email: azdiag@microsoft.com
77
77
  executables: []
78
78
  extensions: []
79
79
  extra_rdoc_files: []
80
- files: []
81
- homepage: https://github.com/juliusl/logstash-input-azurewadtable
80
+ files:
81
+ - CHANGELOG.md
82
+ - Gemfile
83
+ - LICENSE
84
+ - README.md
85
+ - Rakefile
86
+ - lib/logstash/inputs/azureeventhub.rb
87
+ - logstash-input-azureeventhub.gemspec
88
+ - spec/inputs/azureeventhub_spec.rb
89
+ homepage: https://github.com/Azure/azure-diagnostics-tools
82
90
  licenses:
83
91
  - Apache License (2.0)
84
92
  metadata:
@@ -108,4 +116,5 @@ rubygems_version: 2.4.8
108
116
  signing_key:
109
117
  specification_version: 4
110
118
  summary: This plugin will collect Microsoft Azure Diagnostics data from Azure Event Hubs.
111
- test_files: []
119
+ test_files:
120
+ - spec/inputs/azureeventhub_spec.rb