logstash-input-azureeventhub 0.9.5-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +6 -0
- data/Gemfile +2 -0
- data/LICENSE +17 -0
- data/README.md +80 -0
- data/lib/logstash/inputs/azureeventhub.rb +159 -0
- data/logstash-input-azureeventhub.gemspec +32 -0
- data/spec/inputs/azureeventhub_spec.rb +1 -0
- metadata +113 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 28e1da54f720c2d11303e4a4c28dcec2332814bc
|
4
|
+
data.tar.gz: 3e43bdce6632c8b822b556b166f7558bbabaaccc
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 27c5b6bd3740836cabeecac6e9ba9eaf240f83ca17e11ac2fda95b65839a48737a71b4ce6e4a37eef854066ccfad6ba59310255ec63e23fc9db27b15427548f8
|
7
|
+
data.tar.gz: 9d187d4ba4cdd1579cd80fafac81cf6df45b7f6295276946702652ade9619dc2db07ebdc24438a3b50309c615497b723b12cd1c67dad0853c75c8bdba6466b07
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,6 @@
|
|
1
|
+
## 2016.05.03
|
2
|
+
* Fixed the jar dependency problem. Now installing the plugin by using the "plugin" or "logstash-plugin" (for newer versions of Logstash) should automatically download and jar files needed.
|
3
|
+
* Fixed the default value of *time_since_epoch_millis* to use UTC time to match the SelectorFilter.
|
4
|
+
* Made the plugin to respect Logstash shutdown signal.
|
5
|
+
* Updated the *logstash-core* runtime dependency requirement to '~> 2.0'.
|
6
|
+
* Updated the *logstash-devutils* development dependency requirement to '>= 0.0.16'
|
data/Gemfile
ADDED
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
|
+
|
data/README.md
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
# Logstash input plugin for data from Event Hubs
|
2
|
+
|
3
|
+
## Summary
|
4
|
+
This plugin reads data from specified Azure Event Hubs.
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
You can install this plugin using the Logstash "plugin" or "logstash-plugin" (for newer versions of Logstash) command:
|
8
|
+
```sh
|
9
|
+
logstash-plugin install logstash-input-azureeventhub
|
10
|
+
```
|
11
|
+
For more information, see Logstash reference [Working with plugins](https://www.elastic.co/guide/en/logstash/current/working-with-plugins.html).
|
12
|
+
|
13
|
+
## Configuration
|
14
|
+
### Required Parameters
|
15
|
+
__*key*__
|
16
|
+
|
17
|
+
The shared access key to the target event hub.
|
18
|
+
|
19
|
+
__*username*__
|
20
|
+
|
21
|
+
The name of the shared access policy.
|
22
|
+
|
23
|
+
__*namespace*__
|
24
|
+
|
25
|
+
Event Hub namespace.
|
26
|
+
|
27
|
+
__*eventhub*__
|
28
|
+
|
29
|
+
Event Hub name.
|
30
|
+
|
31
|
+
__*partitions*__
|
32
|
+
|
33
|
+
Partition count of the target event hub.
|
34
|
+
|
35
|
+
### Optional Parameters
|
36
|
+
__*domain*__
|
37
|
+
|
38
|
+
Domain of the target Event Hub. Default value is "servicebus.windows.net".
|
39
|
+
|
40
|
+
__*port*__
|
41
|
+
|
42
|
+
Port of the target Event Hub. Default value is 5671.
|
43
|
+
|
44
|
+
__*receive_credits*__
|
45
|
+
|
46
|
+
The credit number to limit the number of messages to receive in a processing cycle. Default value is 1000.
|
47
|
+
|
48
|
+
__*consumer_group*__
|
49
|
+
|
50
|
+
Name of the consumer group. Default value is "$default".
|
51
|
+
|
52
|
+
__*time_since_epoch_millis*__
|
53
|
+
|
54
|
+
Specifies the point of time after which the messages are received. Default value is the time when this plugin is initialized:
|
55
|
+
```ruby
|
56
|
+
Time.now.utc.to_i * 1000
|
57
|
+
```
|
58
|
+
__*thread_wait_sec*__
|
59
|
+
|
60
|
+
Specifies the time (in seconds) to wait before another try if no message was received.
|
61
|
+
|
62
|
+
### Examples
|
63
|
+
```
|
64
|
+
input
|
65
|
+
{
|
66
|
+
azurewadeventhub
|
67
|
+
{
|
68
|
+
key => "VGhpcyBpcyBhIGZha2Uga2V5Lg=="
|
69
|
+
username => "receivepolicy"
|
70
|
+
namespace => "mysbns"
|
71
|
+
eventhub => "myeventhub"
|
72
|
+
partitions => 4
|
73
|
+
}
|
74
|
+
}
|
75
|
+
```
|
76
|
+
|
77
|
+
## More information
|
78
|
+
The source code of this plugin is hosted in GitHub repo [Microsoft Azure Diagnostics with ELK](https://github.com/Azure/azure-diagnostics-tools). We welcome you to provide feedback and/or contribute to the project.
|
79
|
+
|
80
|
+
Please also see [Analyze Diagnostics Data with ELK template](https://github.com/Azure/azure-quickstart-templates/tree/master/diagnostics-with-elk) for quick deployment of ELK to Azure.
|
@@ -0,0 +1,159 @@
|
|
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 Dir[ File.dirname(__FILE__) + "/../../*_jars.rb" ].first
|
10
|
+
|
11
|
+
# Reads events from Azure event-hub
|
12
|
+
class LogStash::Inputs::Azureeventhub < LogStash::Inputs::Base
|
13
|
+
|
14
|
+
config_name "azureeventhub"
|
15
|
+
milestone 1
|
16
|
+
|
17
|
+
default :codec, "json"
|
18
|
+
|
19
|
+
config :key, :validate => :string
|
20
|
+
config :username, :validate => :string
|
21
|
+
config :namespace, :validate => :string
|
22
|
+
config :domain, :validate => :string, :default => "servicebus.windows.net"
|
23
|
+
config :port, :validate => :number, :default => 5671
|
24
|
+
config :receive_credits, :validate => :number, :default => 1000
|
25
|
+
|
26
|
+
config :eventhub, :validate => :string
|
27
|
+
config :partitions, :validate => :number
|
28
|
+
config :consumer_group, :validate => :string, :default => "$default"
|
29
|
+
|
30
|
+
config :time_since_epoch_millis, :validate => :number, :default => Time.now.utc.to_i * 1000
|
31
|
+
config :thread_wait_sec, :validate => :number, :default => 5
|
32
|
+
|
33
|
+
|
34
|
+
def initialize(*args)
|
35
|
+
super(*args)
|
36
|
+
end # def initialize
|
37
|
+
|
38
|
+
public
|
39
|
+
def register
|
40
|
+
end # def register
|
41
|
+
|
42
|
+
def get_pay_load(message)
|
43
|
+
return nil if not message
|
44
|
+
message.getPayload().each do |section|
|
45
|
+
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
|
46
|
+
return section.getValue().to_s
|
47
|
+
end
|
48
|
+
end
|
49
|
+
return nil
|
50
|
+
end
|
51
|
+
|
52
|
+
def process(output_queue, receiver, partition)
|
53
|
+
while !stop?
|
54
|
+
begin
|
55
|
+
msg = receiver.receive(10)
|
56
|
+
if msg
|
57
|
+
codec.decode(get_pay_load(msg)) do |event|
|
58
|
+
output_queue << event
|
59
|
+
end
|
60
|
+
receiver.acknowledge(msg)
|
61
|
+
else
|
62
|
+
@logger.debug(" " + partition.to_s.rjust(2,"0") + " --- " + "No message")
|
63
|
+
sleep(@thread_wait_sec)
|
64
|
+
end
|
65
|
+
rescue LogStash::ShutdownSignal => e
|
66
|
+
raise e
|
67
|
+
rescue org::apache::qpid::amqp_1_0::client::ConnectionErrorException => e
|
68
|
+
raise e
|
69
|
+
rescue => e
|
70
|
+
@logger.error(" " + partition.to_s.rjust(2,"0") + " --- " + "Oh My, An error occurred.", :exception => e)
|
71
|
+
end
|
72
|
+
end # process
|
73
|
+
end # process
|
74
|
+
|
75
|
+
def process_partition(output_queue, partition)
|
76
|
+
while !stop?
|
77
|
+
begin
|
78
|
+
filter = SelectorFilter.new "amqp.annotation.x-opt-enqueuedtimeutc > '" + @time_since_epoch_millis.to_s + "'"
|
79
|
+
filters = { org::apache::qpid::amqp_1_0::type::Symbol.valueOf("apache.org:selector-filter:string") => filter }
|
80
|
+
|
81
|
+
host = @namespace + "." + @domain
|
82
|
+
connection = org::apache::qpid::amqp_1_0::client::Connection.new(host, @port, @username, @key, host, true)
|
83
|
+
connection.getEndpoint().getDescribedTypeRegistry().register(filter.java_class, WriterFactory.new)
|
84
|
+
receiveSession = connection.createSession()
|
85
|
+
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)
|
86
|
+
receiver.setCredit(org::apache::qpid::amqp_1_0::type::UnsignedInteger.valueOf(@receive_credits), true)
|
87
|
+
process(output_queue,receiver,partition)
|
88
|
+
rescue org::apache::qpid::amqp_1_0::client::ConnectionErrorException => e
|
89
|
+
@logger.debug(" " + partition.to_s.rjust(2,"0") + " --- " + "resetting connection")
|
90
|
+
@time_since_epoch_millis = Time.now.utc.to_i * 1000
|
91
|
+
end
|
92
|
+
end
|
93
|
+
rescue LogStash::ShutdownSignal => e
|
94
|
+
receiver.close()
|
95
|
+
raise e
|
96
|
+
rescue => e
|
97
|
+
@logger.error(" " + partition.to_s.rjust(2,"0") + " --- Oh My, An error occurred.", :exception => e)
|
98
|
+
end # process
|
99
|
+
|
100
|
+
public
|
101
|
+
def run(output_queue)
|
102
|
+
threads = []
|
103
|
+
(0..(@partitions-1)).each do |p_id|
|
104
|
+
threads << Thread.new { process_partition(output_queue, p_id) }
|
105
|
+
end
|
106
|
+
threads.each { |thr| thr.join }
|
107
|
+
end # def run
|
108
|
+
|
109
|
+
public
|
110
|
+
def teardown
|
111
|
+
end # def teardown
|
112
|
+
end # class LogStash::Inputs::Azureeventhub
|
113
|
+
|
114
|
+
|
115
|
+
class SelectorFilter
|
116
|
+
include org::apache::qpid::amqp_1_0::type::messaging::Filter
|
117
|
+
|
118
|
+
def initialize(value)
|
119
|
+
@value = value
|
120
|
+
end
|
121
|
+
|
122
|
+
def getValue
|
123
|
+
return @value
|
124
|
+
end
|
125
|
+
|
126
|
+
def toString
|
127
|
+
return @value
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
class SelectorFilterWriter < org::apache::qpid::amqp_1_0::codec::AbstractDescribedTypeWriter
|
132
|
+
def initialize(registry)
|
133
|
+
super(registry)
|
134
|
+
end
|
135
|
+
|
136
|
+
def onSetValue(value)
|
137
|
+
@value = value
|
138
|
+
end
|
139
|
+
|
140
|
+
def clear
|
141
|
+
@value = nil
|
142
|
+
end
|
143
|
+
|
144
|
+
def getDescriptor
|
145
|
+
return org::apache::qpid::amqp_1_0::type::UnsignedLong.valueOf(83483426826);
|
146
|
+
end
|
147
|
+
|
148
|
+
def createDescribedWriter
|
149
|
+
return getRegistry().getValueWriter(@value.getValue());
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
class WriterFactory
|
154
|
+
include org::apache::qpid::amqp_1_0::codec::ValueWriter::Factory
|
155
|
+
|
156
|
+
def newInstance(registry)
|
157
|
+
return SelectorFilterWriter.new registry
|
158
|
+
end
|
159
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = 'logstash-input-azureeventhub'
|
3
|
+
s.version = '0.9.5'
|
4
|
+
s.platform = "java"
|
5
|
+
s.licenses = ['Apache License (2.0)']
|
6
|
+
s.summary = "This plugin collects data from Azure Event Hubs."
|
7
|
+
s.description = "This gem is a Logstash plugin. It reads data from Azure Event Hubs."
|
8
|
+
s.authors = ["Microsoft Corporation"]
|
9
|
+
s.email = 'azdiag@microsoft.com'
|
10
|
+
s.homepage = "https://github.com/Azure/azure-diagnostics-tools"
|
11
|
+
s.require_paths = ["lib"]
|
12
|
+
|
13
|
+
# Files
|
14
|
+
s.files = Dir['lib/**/*','spec/**/*','vendor/**/*','*.gemspec','*.md','Gemfile','LICENSE']
|
15
|
+
# Tests
|
16
|
+
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
17
|
+
|
18
|
+
# Special flag to let us know this is actually a logstash plugin
|
19
|
+
s.metadata = { "logstash_plugin" => "true", "logstash_group" => "input" }
|
20
|
+
|
21
|
+
# Gem dependencies
|
22
|
+
s.add_runtime_dependency 'logstash-core', '~> 2.0'
|
23
|
+
s.add_runtime_dependency 'azure', '~> 0.7.1'
|
24
|
+
s.add_development_dependency 'logstash-devutils', '>= 0.0.16'
|
25
|
+
|
26
|
+
#Jar dependencies
|
27
|
+
s.requirements << "jar 'org.apache.qpid:qpid-amqp-1-0-common', '0.32'"
|
28
|
+
s.requirements << "jar 'org.apache.qpid:qpid-amqp-1-0-client-jms', '0.32'"
|
29
|
+
s.requirements << "jar 'org.apache.qpid:qpid-client', '0.32'"
|
30
|
+
s.requirements << "jar 'org.apache.geronimo.specs:geronimo-jms_1.1_spec', '1.1.1'"
|
31
|
+
s.add_runtime_dependency 'jar-dependencies', '~> 0.3.2'
|
32
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require "logstash/devutils/rspec/spec_helper"
|
metadata
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: logstash-input-azureeventhub
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.9.5
|
5
|
+
platform: java
|
6
|
+
authors:
|
7
|
+
- Microsoft Corporation
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-05-03 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: logstash-core
|
15
|
+
version_requirements: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.0'
|
20
|
+
requirement: !ruby/object:Gem::Requirement
|
21
|
+
requirements:
|
22
|
+
- - "~>"
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: '2.0'
|
25
|
+
prerelease: false
|
26
|
+
type: :runtime
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: azure
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.7.1
|
34
|
+
requirement: !ruby/object:Gem::Requirement
|
35
|
+
requirements:
|
36
|
+
- - "~>"
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: 0.7.1
|
39
|
+
prerelease: false
|
40
|
+
type: :runtime
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: logstash-devutils
|
43
|
+
version_requirements: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.0.16
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: 0.0.16
|
53
|
+
prerelease: false
|
54
|
+
type: :development
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: jar-dependencies
|
57
|
+
version_requirements: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.3.2
|
62
|
+
requirement: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - "~>"
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: 0.3.2
|
67
|
+
prerelease: false
|
68
|
+
type: :runtime
|
69
|
+
description: This gem is a Logstash plugin. It reads data from Azure Event Hubs.
|
70
|
+
email: azdiag@microsoft.com
|
71
|
+
executables: []
|
72
|
+
extensions: []
|
73
|
+
extra_rdoc_files: []
|
74
|
+
files:
|
75
|
+
- CHANGELOG.md
|
76
|
+
- Gemfile
|
77
|
+
- LICENSE
|
78
|
+
- README.md
|
79
|
+
- lib/logstash/inputs/azureeventhub.rb
|
80
|
+
- logstash-input-azureeventhub.gemspec
|
81
|
+
- spec/inputs/azureeventhub_spec.rb
|
82
|
+
homepage: https://github.com/Azure/azure-diagnostics-tools
|
83
|
+
licenses:
|
84
|
+
- Apache License (2.0)
|
85
|
+
metadata:
|
86
|
+
logstash_plugin: 'true'
|
87
|
+
logstash_group: input
|
88
|
+
post_install_message:
|
89
|
+
rdoc_options: []
|
90
|
+
require_paths:
|
91
|
+
- lib
|
92
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
requirements:
|
103
|
+
- jar 'org.apache.qpid:qpid-amqp-1-0-common', '0.32'
|
104
|
+
- jar 'org.apache.qpid:qpid-amqp-1-0-client-jms', '0.32'
|
105
|
+
- jar 'org.apache.qpid:qpid-client', '0.32'
|
106
|
+
- jar 'org.apache.geronimo.specs:geronimo-jms_1.1_spec', '1.1.1'
|
107
|
+
rubyforge_project:
|
108
|
+
rubygems_version: 2.4.8
|
109
|
+
signing_key:
|
110
|
+
specification_version: 4
|
111
|
+
summary: This plugin collects data from Azure Event Hubs.
|
112
|
+
test_files:
|
113
|
+
- spec/inputs/azureeventhub_spec.rb
|