logstash-input-azureeventhub 0.9.7-java → 0.9.8-java
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 +5 -5
- data/README.md +6 -1
- data/lib/com/microsoft/azure/azure-eventhubs/0.15.0/azure-eventhubs-0.15.0.jar +0 -0
- data/lib/logstash-input-azureeventhub_jars.rb +14 -0
- data/lib/logstash/inputs/azureeventhub.rb +74 -97
- data/lib/org/apache/qpid/proton-j/0.22.0/proton-j-0.22.0.jar +0 -0
- data/lib/org/slf4j/slf4j-api/1.7.25/slf4j-api-1.7.25.jar +0 -0
- data/logstash-input-azureeventhub.gemspec +2 -5
- metadata +27 -26
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 924c45dec9708f85316b26facc34c9308f73f0773bbc056703fb4816ae1d72a1
|
4
|
+
data.tar.gz: 6a0eed913702d19b82d1f1fc8deb7036202f1f941bc30d3d0bff66ad5e722426
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b3462e2f63501a9183916ba6f366205c73bf2dd671686747b0b77f0a37d6b086706123c40c6bfb6638e35fa435312fd847cfba25833e3a445b3f6e72ae81fa39
|
7
|
+
data.tar.gz: 35bdb5244ba4abaacba931d8960d056198a6f37770d8d84c449fdaa9b77257b7f3e2c433b1d42ac699db7abe53edf3e22f85b5e5a35c21ee088d6230ec5251bd
|
data/README.md
CHANGED
@@ -43,7 +43,7 @@ Port of the target Event Hub. Default value is 5671.
|
|
43
43
|
|
44
44
|
__*receive_credits*__
|
45
45
|
|
46
|
-
The credit number to limit the number of messages to receive in a processing cycle. Default
|
46
|
+
The credit number to limit the number of messages to receive in a processing cycle. Value must be between 10 and 999. Default is 999.
|
47
47
|
|
48
48
|
__*consumer_group*__
|
49
49
|
|
@@ -59,6 +59,10 @@ __*thread_wait_sec*__
|
|
59
59
|
|
60
60
|
Specifies the time (in seconds) to wait before another try if no message was received.
|
61
61
|
|
62
|
+
__*partition_receiver_epochs*__
|
63
|
+
|
64
|
+
A map from partition (string) to epoch (integer). By default each partition doesn't have an epoch defined. For more information read https://blogs.msdn.microsoft.com/gyan/2014/09/02/event-hubs-receiver-epoch/ .
|
65
|
+
|
62
66
|
### Examples
|
63
67
|
```
|
64
68
|
input
|
@@ -70,6 +74,7 @@ input
|
|
70
74
|
namespace => "mysbns"
|
71
75
|
eventhub => "myeventhub"
|
72
76
|
partitions => 4
|
77
|
+
partition_receiver_epochs => { '2' => 42 '0' => 15 }
|
73
78
|
}
|
74
79
|
}
|
75
80
|
```
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# this is a generated file, to avoid over-writing it just delete this comment
|
2
|
+
begin
|
3
|
+
require 'jar_dependencies'
|
4
|
+
rescue LoadError
|
5
|
+
require 'org/slf4j/slf4j-api/1.7.25/slf4j-api-1.7.25.jar'
|
6
|
+
require 'com/microsoft/azure/azure-eventhubs/0.15.0/azure-eventhubs-0.15.0.jar'
|
7
|
+
require 'org/apache/qpid/proton-j/0.22.0/proton-j-0.22.0.jar'
|
8
|
+
end
|
9
|
+
|
10
|
+
if defined? Jars
|
11
|
+
require_jar( 'org.slf4j', 'slf4j-api', '1.7.25' )
|
12
|
+
require_jar( 'com.microsoft.azure', 'azure-eventhubs', '0.15.0' )
|
13
|
+
require_jar( 'org.apache.qpid', 'proton-j', '0.22.0' )
|
14
|
+
end
|
@@ -16,19 +16,21 @@ class LogStash::Inputs::Azureeventhub < LogStash::Inputs::Base
|
|
16
16
|
|
17
17
|
default :codec, "json"
|
18
18
|
|
19
|
-
config :key, :validate => :string
|
20
|
-
config :username, :validate => :string
|
21
|
-
config :namespace, :validate => :string
|
19
|
+
config :key, :validate => :string, :required => true
|
20
|
+
config :username, :validate => :string, :required => true
|
21
|
+
config :namespace, :validate => :string, :required => true
|
22
22
|
config :domain, :validate => :string, :default => "servicebus.windows.net"
|
23
23
|
config :port, :validate => :number, :default => 5671
|
24
|
-
config :receive_credits, :validate => :number, :default =>
|
24
|
+
config :receive_credits, :validate => :number, :default => 999
|
25
25
|
|
26
|
-
config :eventhub, :validate => :string
|
27
|
-
config :partitions, :validate => :number
|
26
|
+
config :eventhub, :validate => :string, :required => true
|
27
|
+
config :partitions, :validate => :number, :required => true
|
28
28
|
config :consumer_group, :validate => :string, :default => "$default"
|
29
29
|
|
30
30
|
config :time_since_epoch_millis, :validate => :number, :default => Time.now.utc.to_i * 1000
|
31
31
|
config :thread_wait_sec, :validate => :number, :default => 5
|
32
|
+
|
33
|
+
config :partition_receiver_epochs, :validate => :hash, :default => {}
|
32
34
|
|
33
35
|
|
34
36
|
def initialize(*args)
|
@@ -37,72 +39,94 @@ class LogStash::Inputs::Azureeventhub < LogStash::Inputs::Base
|
|
37
39
|
|
38
40
|
public
|
39
41
|
def register
|
42
|
+
user_agent = "logstash-input-azureeventhub"
|
43
|
+
user_agent << "/" << Gem.latest_spec_for("logstash-input-azureeventhub").version.to_s
|
44
|
+
com::microsoft::azure::eventhubs::EventHubClient.userAgent = user_agent
|
40
45
|
end # def register
|
41
46
|
|
42
|
-
def
|
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.gsub("\\x5c", "\\")
|
47
|
-
end
|
48
|
-
end
|
49
|
-
return nil
|
50
|
-
end
|
51
|
-
|
52
|
-
def process(output_queue, receiver, partition)
|
47
|
+
def process(output_queue, receiver, partition, last_event_offset)
|
53
48
|
while !stop?
|
54
49
|
begin
|
55
|
-
|
56
|
-
if
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
50
|
+
events = receiver.receiveSync(10)
|
51
|
+
if events
|
52
|
+
events.each{ |msg|
|
53
|
+
body = msg.getBytes().to_s.gsub("\\x5c", "\\")
|
54
|
+
props = msg.getSystemProperties()
|
55
|
+
|
56
|
+
last_event_offset = props.getOffset()
|
57
|
+
|
58
|
+
@logger.debug("[#{partition.to_s.rjust(2,"0")}] Event: #{body[0..50] unless body.nil?}... " <<
|
59
|
+
"Offset: #{props.getOffset()} " <<
|
60
|
+
"Time: #{props.getEnqueuedTime()} " <<
|
61
|
+
"Sequence: #{props.getSequenceNumber()}")
|
62
|
+
|
63
|
+
codec.decode(body) do |event|
|
64
|
+
decorate(event)
|
65
|
+
output_queue << event
|
66
|
+
end
|
67
|
+
}
|
62
68
|
else
|
63
|
-
@logger.debug("
|
64
|
-
sleep(@thread_wait_sec)
|
69
|
+
@logger.debug("[#{partition.to_s.rjust(2,"0")}] No message")
|
65
70
|
end
|
66
|
-
rescue LogStash::ShutdownSignal => e
|
67
|
-
raise e
|
68
|
-
rescue org::apache::qpid::amqp_1_0::client::ConnectionErrorException => e
|
69
|
-
raise e
|
70
|
-
rescue => e
|
71
|
-
@logger.error(" " + partition.to_s.rjust(2,"0") + " --- " + "Oh My, An error occurred.", :exception => e)
|
72
71
|
end
|
73
|
-
end
|
72
|
+
end
|
73
|
+
rescue LogStash::ShutdownSignal => e
|
74
|
+
@logger.debug("[#{partition.to_s.rjust(2,"0")}] ShutdownSignal received")
|
75
|
+
raise e
|
76
|
+
rescue => e
|
77
|
+
@logger.error("[#{partition.to_s.rjust(2,"0")}] Oh My, An error occurred. Error:#{e}: Trace: #{e.backtrace}", :exception => e)
|
78
|
+
raise e
|
79
|
+
ensure
|
80
|
+
return last_event_offset
|
74
81
|
end # process
|
75
82
|
|
76
|
-
def process_partition(output_queue, partition)
|
83
|
+
def process_partition(output_queue, partition, epoch)
|
84
|
+
last_event_offset = nil
|
77
85
|
while !stop?
|
78
86
|
begin
|
79
|
-
|
80
|
-
|
87
|
+
host = java::net::URI.new("amqps://" << @namespace << "." << @domain)
|
88
|
+
connStr = com::microsoft::azure::eventhubs::ConnectionStringBuilder.new(host, @eventhub, @username, @key).toString()
|
89
|
+
ehClient = com::microsoft::azure::eventhubs::EventHubClient.createFromConnectionStringSync(connStr)
|
90
|
+
|
91
|
+
if !epoch.nil?
|
92
|
+
if !last_event_offset.nil?
|
93
|
+
@logger.debug("[#{partition.to_s.rjust(2,"0")}] Create receiver with epoch=#{epoch} & offset > #{last_event_offset}")
|
94
|
+
receiver = ehClient.createEpochReceiverSync(@consumer_group, partition.to_s, last_event_offset, false, epoch)
|
95
|
+
else
|
96
|
+
@logger.debug("[#{partition.to_s.rjust(2,"0")}] Create receiver with epoch=#{epoch} & timestamp > #{@time_since_epoch_millis}")
|
97
|
+
receiver = ehClient.createEpochReceiverSync(@consumer_group, partition.to_s, java::time::Instant::ofEpochMilli(@time_since_epoch_millis), epoch)
|
98
|
+
end
|
99
|
+
else
|
100
|
+
if !last_event_offset.nil?
|
101
|
+
@logger.debug("[#{partition.to_s.rjust(2,"0")}] Create receiver with offset > #{last_event_offset}")
|
102
|
+
receiver = ehClient.createReceiverSync(@consumer_group, partition.to_s, last_event_offset, false)
|
103
|
+
else
|
104
|
+
@logger.debug("[#{partition.to_s.rjust(2,"0")}] Create receiver with timestamp > #{@time_since_epoch_millis}")
|
105
|
+
receiver = ehClient.createReceiverSync(@consumer_group, partition.to_s, java::time::Instant::ofEpochMilli(@time_since_epoch_millis))
|
106
|
+
end
|
107
|
+
end
|
108
|
+
receiver.setReceiveTimeout(java::time::Duration::ofSeconds(@thread_wait_sec));
|
109
|
+
receiver.setPrefetchCount(@receive_credits)
|
81
110
|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
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)
|
87
|
-
receiver.setCredit(org::apache::qpid::amqp_1_0::type::UnsignedInteger.valueOf(@receive_credits), true)
|
88
|
-
process(output_queue,receiver,partition)
|
89
|
-
rescue org::apache::qpid::amqp_1_0::client::ConnectionErrorException => e
|
90
|
-
@logger.debug(" " + partition.to_s.rjust(2,"0") + " --- " + "resetting connection")
|
91
|
-
@time_since_epoch_millis = Time.now.utc.to_i * 1000
|
111
|
+
last_event_offset = process(output_queue, receiver, partition, last_event_offset)
|
112
|
+
rescue com::microsoft::azure::eventhubs::EventHubException => e
|
113
|
+
sleep(@thread_wait_sec)
|
114
|
+
@logger.debug("[#{partition.to_s.rjust(2,"0")}] resetting connection. Error:#{e}: Trace: #{e.backtrace}", :exception => e)
|
92
115
|
end
|
93
116
|
end
|
94
117
|
rescue LogStash::ShutdownSignal => e
|
95
118
|
receiver.close()
|
96
119
|
raise e
|
97
120
|
rescue => e
|
98
|
-
@logger.error("
|
99
|
-
end #
|
121
|
+
@logger.error("[#{partition.to_s.rjust(2,"0")}] Oh My, An error occurred. Error:#{e}: Trace: #{e.backtrace}", :exception => e)
|
122
|
+
end # process_partition
|
100
123
|
|
101
124
|
public
|
102
125
|
def run(output_queue)
|
103
126
|
threads = []
|
104
127
|
(0..(@partitions-1)).each do |p_id|
|
105
|
-
|
128
|
+
epoch = partition_receiver_epochs[p_id.to_s] if @partition_receiver_epochs.key?(p_id.to_s)
|
129
|
+
threads << Thread.new { process_partition(output_queue, p_id, epoch) }
|
106
130
|
end
|
107
131
|
threads.each { |thr| thr.join }
|
108
132
|
end # def run
|
@@ -110,51 +134,4 @@ class LogStash::Inputs::Azureeventhub < LogStash::Inputs::Base
|
|
110
134
|
public
|
111
135
|
def teardown
|
112
136
|
end # def teardown
|
113
|
-
end # class LogStash::Inputs::Azureeventhub
|
114
|
-
|
115
|
-
|
116
|
-
class SelectorFilter
|
117
|
-
include org::apache::qpid::amqp_1_0::type::messaging::Filter
|
118
|
-
|
119
|
-
def initialize(value)
|
120
|
-
@value = value
|
121
|
-
end
|
122
|
-
|
123
|
-
def getValue
|
124
|
-
return @value
|
125
|
-
end
|
126
|
-
|
127
|
-
def toString
|
128
|
-
return @value
|
129
|
-
end
|
130
|
-
end
|
131
|
-
|
132
|
-
class SelectorFilterWriter < org::apache::qpid::amqp_1_0::codec::AbstractDescribedTypeWriter
|
133
|
-
def initialize(registry)
|
134
|
-
super(registry)
|
135
|
-
end
|
136
|
-
|
137
|
-
def onSetValue(value)
|
138
|
-
@value = value
|
139
|
-
end
|
140
|
-
|
141
|
-
def clear
|
142
|
-
@value = nil
|
143
|
-
end
|
144
|
-
|
145
|
-
def getDescriptor
|
146
|
-
return org::apache::qpid::amqp_1_0::type::UnsignedLong.valueOf(83483426826);
|
147
|
-
end
|
148
|
-
|
149
|
-
def createDescribedWriter
|
150
|
-
return getRegistry().getValueWriter(@value.getValue());
|
151
|
-
end
|
152
|
-
end
|
153
|
-
|
154
|
-
class WriterFactory
|
155
|
-
include org::apache::qpid::amqp_1_0::codec::ValueWriter::Factory
|
156
|
-
|
157
|
-
def newInstance(registry)
|
158
|
-
return SelectorFilterWriter.new registry
|
159
|
-
end
|
160
|
-
end
|
137
|
+
end # class LogStash::Inputs::Azureeventhub
|
Binary file
|
Binary file
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'logstash-input-azureeventhub'
|
3
|
-
s.version = '0.9.
|
3
|
+
s.version = '0.9.8'
|
4
4
|
s.platform = "java"
|
5
5
|
s.licenses = ['Apache License (2.0)']
|
6
6
|
s.summary = "This plugin collects data from Azure Event Hubs."
|
@@ -24,9 +24,6 @@ Gem::Specification.new do |s|
|
|
24
24
|
s.add_development_dependency 'logstash-devutils'
|
25
25
|
|
26
26
|
#Jar dependencies
|
27
|
-
s.requirements << "jar '
|
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'"
|
27
|
+
s.requirements << "jar 'com.microsoft.azure:azure-eventhubs', '0.15.0'"
|
31
28
|
s.add_runtime_dependency 'jar-dependencies', '~> 0.3.2'
|
32
29
|
end
|
metadata
CHANGED
@@ -1,18 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-input-azureeventhub
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.8
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- Microsoft Corporation
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-10-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
|
15
|
-
version_requirements: !ruby/object:Gem::Requirement
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
16
15
|
requirements:
|
17
16
|
- - ">="
|
18
17
|
- !ruby/object:Gem::Version
|
@@ -20,7 +19,10 @@ dependencies:
|
|
20
19
|
- - "<="
|
21
20
|
- !ruby/object:Gem::Version
|
22
21
|
version: '2.99'
|
23
|
-
|
22
|
+
name: logstash-core-plugin-api
|
23
|
+
prerelease: false
|
24
|
+
type: :runtime
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
26
|
requirements:
|
25
27
|
- - ">="
|
26
28
|
- !ruby/object:Gem::Version
|
@@ -28,50 +30,48 @@ dependencies:
|
|
28
30
|
- - "<="
|
29
31
|
- !ruby/object:Gem::Version
|
30
32
|
version: '2.99'
|
31
|
-
prerelease: false
|
32
|
-
type: :runtime
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
|
-
name: azure
|
35
|
-
version_requirements: !ruby/object:Gem::Requirement
|
36
|
-
requirements:
|
37
|
-
- - "~>"
|
38
|
-
- !ruby/object:Gem::Version
|
39
|
-
version: 0.7.1
|
40
34
|
requirement: !ruby/object:Gem::Requirement
|
41
35
|
requirements:
|
42
36
|
- - "~>"
|
43
37
|
- !ruby/object:Gem::Version
|
44
38
|
version: 0.7.1
|
39
|
+
name: azure
|
45
40
|
prerelease: false
|
46
41
|
type: :runtime
|
47
|
-
- !ruby/object:Gem::Dependency
|
48
|
-
name: logstash-devutils
|
49
42
|
version_requirements: !ruby/object:Gem::Requirement
|
50
43
|
requirements:
|
51
|
-
- - "
|
44
|
+
- - "~>"
|
52
45
|
- !ruby/object:Gem::Version
|
53
|
-
version:
|
46
|
+
version: 0.7.1
|
47
|
+
- !ruby/object:Gem::Dependency
|
54
48
|
requirement: !ruby/object:Gem::Requirement
|
55
49
|
requirements:
|
56
50
|
- - ">="
|
57
51
|
- !ruby/object:Gem::Version
|
58
52
|
version: '0'
|
53
|
+
name: logstash-devutils
|
59
54
|
prerelease: false
|
60
55
|
type: :development
|
61
|
-
- !ruby/object:Gem::Dependency
|
62
|
-
name: jar-dependencies
|
63
56
|
version_requirements: !ruby/object:Gem::Requirement
|
64
57
|
requirements:
|
65
|
-
- - "
|
58
|
+
- - ">="
|
66
59
|
- !ruby/object:Gem::Version
|
67
|
-
version: 0
|
60
|
+
version: '0'
|
61
|
+
- !ruby/object:Gem::Dependency
|
68
62
|
requirement: !ruby/object:Gem::Requirement
|
69
63
|
requirements:
|
70
64
|
- - "~>"
|
71
65
|
- !ruby/object:Gem::Version
|
72
66
|
version: 0.3.2
|
67
|
+
name: jar-dependencies
|
73
68
|
prerelease: false
|
74
69
|
type: :runtime
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - "~>"
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: 0.3.2
|
75
75
|
description: This gem is a Logstash plugin. It reads data from Azure Event Hubs.
|
76
76
|
email: azdiag@microsoft.com
|
77
77
|
executables: []
|
@@ -82,7 +82,11 @@ files:
|
|
82
82
|
- Gemfile
|
83
83
|
- LICENSE
|
84
84
|
- README.md
|
85
|
+
- lib/com/microsoft/azure/azure-eventhubs/0.15.0/azure-eventhubs-0.15.0.jar
|
86
|
+
- lib/logstash-input-azureeventhub_jars.rb
|
85
87
|
- lib/logstash/inputs/azureeventhub.rb
|
88
|
+
- lib/org/apache/qpid/proton-j/0.22.0/proton-j-0.22.0.jar
|
89
|
+
- lib/org/slf4j/slf4j-api/1.7.25/slf4j-api-1.7.25.jar
|
86
90
|
- logstash-input-azureeventhub.gemspec
|
87
91
|
- spec/inputs/azureeventhub_spec.rb
|
88
92
|
homepage: https://github.com/Azure/azure-diagnostics-tools
|
@@ -106,12 +110,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
106
110
|
- !ruby/object:Gem::Version
|
107
111
|
version: '0'
|
108
112
|
requirements:
|
109
|
-
- jar '
|
110
|
-
- jar 'org.apache.qpid:qpid-amqp-1-0-client-jms', '0.32'
|
111
|
-
- jar 'org.apache.qpid:qpid-client', '0.32'
|
112
|
-
- jar 'org.apache.geronimo.specs:geronimo-jms_1.1_spec', '1.1.1'
|
113
|
+
- jar 'com.microsoft.azure:azure-eventhubs', '0.15.0'
|
113
114
|
rubyforge_project:
|
114
|
-
rubygems_version: 2.
|
115
|
+
rubygems_version: 2.6.13
|
115
116
|
signing_key:
|
116
117
|
specification_version: 4
|
117
118
|
summary: This plugin collects data from Azure Event Hubs.
|