logstash-input-event-hub 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 +7 -0
- data/CHANGELOG.md +6 -0
- data/Gemfile +2 -0
- data/LICENSE +17 -0
- data/README.md +110 -0
- data/lib/logstash/inputs/azureeventhub.rb +137 -0
- data/logstash-input-azureeventhub.gemspec +29 -0
- data/spec/inputs/azureeventhub_spec.rb +1 -0
- metadata +116 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d91c45e960c5cbc93915934fad7f29af488d5fef
|
4
|
+
data.tar.gz: 82fd3dfc287c37cc6f89bbe3ab6a49ac6e6d17ee
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 81344c87d6c3bd82106a6dcab73d18b6bf77829b76ad706566e6f979ebb791ce681b70038292083598b83aa6973629ff6267ccf239a74d37253adc3713eb789e
|
7
|
+
data.tar.gz: 5ee58b5c8d391b881dcda450ff842981e99d28384c7d229421f033ee18dd190fced1fa2778c29371a7d1a64d592ab82eb8df19cf3508fd5226c03665689d069c
|
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,110 @@
|
|
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. Value must be between 10 and 999. Default is 999.
|
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
|
+
__*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
|
+
|
66
|
+
### Examples
|
67
|
+
* Bare-bone settings
|
68
|
+
```
|
69
|
+
input
|
70
|
+
{
|
71
|
+
azureeventhub
|
72
|
+
{
|
73
|
+
key => "VGhpcyBpcyBhIGZha2Uga2V5Lg=="
|
74
|
+
username => "receivepolicy"
|
75
|
+
namespace => "mysbns"
|
76
|
+
eventhub => "myeventhub"
|
77
|
+
partitions => 4
|
78
|
+
partition_receiver_epochs => { '2' => 42 '0' => 15 }
|
79
|
+
}
|
80
|
+
}
|
81
|
+
```
|
82
|
+
|
83
|
+
* Example for WAD (Azure Diagnostics)
|
84
|
+
```
|
85
|
+
input
|
86
|
+
{
|
87
|
+
azureeventhub
|
88
|
+
{
|
89
|
+
key => "VGhpcyBpcyBhIGZha2Uga2V5Lg=="
|
90
|
+
username => "receivepolicy"
|
91
|
+
namespace => "mysbns"
|
92
|
+
eventhub => "myeventhub"
|
93
|
+
partitions => 4
|
94
|
+
partition_receiver_epochs => { '2' => 42 '0' => 15 }
|
95
|
+
}
|
96
|
+
}
|
97
|
+
filter {
|
98
|
+
split {field => 'records'} #split the records array in individual events
|
99
|
+
}
|
100
|
+
output {
|
101
|
+
stdout {
|
102
|
+
codec => rubydebug
|
103
|
+
}
|
104
|
+
}
|
105
|
+
```
|
106
|
+
|
107
|
+
## More information
|
108
|
+
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.
|
109
|
+
|
110
|
+
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,137 @@
|
|
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, :required => true
|
20
|
+
config :username, :validate => :string, :required => true
|
21
|
+
config :namespace, :validate => :string, :required => true
|
22
|
+
config :domain, :validate => :string, :default => "servicebus.windows.net"
|
23
|
+
config :port, :validate => :number, :default => 5671
|
24
|
+
config :receive_credits, :validate => :number, :default => 999
|
25
|
+
|
26
|
+
config :eventhub, :validate => :string, :required => true
|
27
|
+
config :partitions, :validate => :number, :required => true
|
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
|
+
config :partition_receiver_epochs, :validate => :hash, :default => {}
|
34
|
+
|
35
|
+
|
36
|
+
def initialize(*args)
|
37
|
+
super(*args)
|
38
|
+
end # def initialize
|
39
|
+
|
40
|
+
public
|
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
|
45
|
+
end # def register
|
46
|
+
|
47
|
+
def process(output_queue, receiver, partition, last_event_offset)
|
48
|
+
while !stop?
|
49
|
+
begin
|
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
|
+
}
|
68
|
+
else
|
69
|
+
@logger.debug("[#{partition.to_s.rjust(2,"0")}] No message")
|
70
|
+
end
|
71
|
+
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
|
81
|
+
end # process
|
82
|
+
|
83
|
+
def process_partition(output_queue, partition, epoch)
|
84
|
+
last_event_offset = nil
|
85
|
+
while !stop?
|
86
|
+
begin
|
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)
|
110
|
+
|
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)
|
115
|
+
end
|
116
|
+
end
|
117
|
+
rescue LogStash::ShutdownSignal => e
|
118
|
+
receiver.close()
|
119
|
+
raise e
|
120
|
+
rescue => e
|
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
|
123
|
+
|
124
|
+
public
|
125
|
+
def run(output_queue)
|
126
|
+
threads = []
|
127
|
+
(0..(@partitions-1)).each do |p_id|
|
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) }
|
130
|
+
end
|
131
|
+
threads.each { |thr| thr.join }
|
132
|
+
end # def run
|
133
|
+
|
134
|
+
public
|
135
|
+
def teardown
|
136
|
+
end # def teardown
|
137
|
+
end # class LogStash::Inputs::Azureeventhub
|
@@ -0,0 +1,29 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = 'logstash-input-event-hub'
|
3
|
+
s.version = '0.9.8'
|
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 = ["Shailesh Srivastava"]
|
9
|
+
s.email = 'shailesh17mar@gmail.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-plugin-api', '~> 2.1', '>= 2.1.28'
|
23
|
+
s.add_runtime_dependency 'azure', '~> 0.7.1'
|
24
|
+
s.add_development_dependency 'logstash-devutils'
|
25
|
+
|
26
|
+
#Jar dependencies
|
27
|
+
s.requirements << "jar 'com.microsoft.azure:azure-eventhubs', '0.15.0'"
|
28
|
+
s.add_runtime_dependency 'jar-dependencies', '~> 0.3.2'
|
29
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require "logstash/devutils/rspec/spec_helper"
|
metadata
ADDED
@@ -0,0 +1,116 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: logstash-input-event-hub
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.9.8
|
5
|
+
platform: java
|
6
|
+
authors:
|
7
|
+
- Shailesh Srivastava
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-12-27 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: logstash-core-plugin-api
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.1'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 2.1.28
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '2.1'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 2.1.28
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: azure
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: 0.7.1
|
40
|
+
type: :runtime
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - "~>"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 0.7.1
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: logstash-devutils
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: jar-dependencies
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - "~>"
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: 0.3.2
|
68
|
+
type: :runtime
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - "~>"
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: 0.3.2
|
75
|
+
description: This gem is a Logstash plugin. It reads data from Azure Event Hubs.
|
76
|
+
email: shailesh17mar@gmail.com
|
77
|
+
executables: []
|
78
|
+
extensions: []
|
79
|
+
extra_rdoc_files: []
|
80
|
+
files:
|
81
|
+
- CHANGELOG.md
|
82
|
+
- Gemfile
|
83
|
+
- LICENSE
|
84
|
+
- README.md
|
85
|
+
- lib/logstash/inputs/azureeventhub.rb
|
86
|
+
- logstash-input-azureeventhub.gemspec
|
87
|
+
- spec/inputs/azureeventhub_spec.rb
|
88
|
+
homepage: https://github.com/Azure/azure-diagnostics-tools
|
89
|
+
licenses:
|
90
|
+
- Apache License (2.0)
|
91
|
+
metadata:
|
92
|
+
logstash_plugin: 'true'
|
93
|
+
logstash_group: input
|
94
|
+
post_install_message:
|
95
|
+
rdoc_options: []
|
96
|
+
require_paths:
|
97
|
+
- lib
|
98
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
|
+
requirements:
|
105
|
+
- - ">="
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: '0'
|
108
|
+
requirements:
|
109
|
+
- jar 'com.microsoft.azure:azure-eventhubs', '0.15.0'
|
110
|
+
rubyforge_project:
|
111
|
+
rubygems_version: 2.4.5.1
|
112
|
+
signing_key:
|
113
|
+
specification_version: 4
|
114
|
+
summary: This plugin collects data from Azure Event Hubs.
|
115
|
+
test_files:
|
116
|
+
- spec/inputs/azureeventhub_spec.rb
|