logstash-output-iothub 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +2 -0
- data/CONTRIBUTORS +10 -0
- data/DEVELOPER.md +2 -0
- data/Gemfile +3 -0
- data/LICENSE +11 -0
- data/README.md +115 -0
- data/lib/com/google/code/gson/gson/2.8.0/gson-2.8.0.jar +0 -0
- data/lib/com/microsoft/azure/sdk/iot/deps/websocket-transport-layer/0.1.2/websocket-transport-layer-0.1.2.jar +0 -0
- data/lib/com/microsoft/azure/sdk/iot/iot-device-client/1.0.17/iot-device-client-1.0.17.jar +0 -0
- data/lib/commons-codec/commons-codec/1.10/commons-codec-1.10.jar +0 -0
- data/lib/logstash-output-iothub_jars.rb +5 -0
- data/lib/logstash/outputs/iothub.rb +75 -0
- data/lib/org/apache/qpid/proton-j/0.15.0/proton-j-0.15.0.jar +0 -0
- data/lib/org/bouncycastle/bcpkix-jdk15on/1.47/bcpkix-jdk15on-1.47.jar +0 -0
- data/lib/org/bouncycastle/bcprov-jdk15on/1.47/bcprov-jdk15on-1.47.jar +0 -0
- data/lib/org/eclipse/paho/org.eclipse.paho.client.mqttv3/1.0.2/org.eclipse.paho.client.mqttv3-1.0.2.jar +0 -0
- data/logstash-output-iothub.gemspec +29 -0
- data/spec/outputs/iothub_spec.rb +29 -0
- data/vendor/jar-dependencies/runtime-jars/bcpkix-jdk15on-1.47.jar +0 -0
- data/vendor/jar-dependencies/runtime-jars/bcprov-jdk15on-1.47.jar +0 -0
- data/vendor/jar-dependencies/runtime-jars/commons-codec-1.10.jar +0 -0
- data/vendor/jar-dependencies/runtime-jars/gson-2.8.0.jar +0 -0
- data/vendor/jar-dependencies/runtime-jars/iot-device-client-1.0.17.jar +0 -0
- data/vendor/jar-dependencies/runtime-jars/org.eclipse.paho.client.mqttv3-1.0.2.jar +0 -0
- data/vendor/jar-dependencies/runtime-jars/proton-j-0.15.0.jar +0 -0
- data/vendor/jar-dependencies/runtime-jars/websocket-transport-layer-0.1.2.jar +0 -0
- metadata +143 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 0c592be7c0a660e5b5982aed7e14607c203ac54b
|
4
|
+
data.tar.gz: 70af8dfb0928e7d14c066061f88cf02880b82fc4
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: dd997fd82bab1e475d4cd608374dd46e50a8a80128ac80ffed9b509b3ec01da7b29da026717bd476e551f214c89bc683b2b65f7524bfa544c67343ba671b0071
|
7
|
+
data.tar.gz: 2234c5c9a59d27c86b485629a4e5048f74c3c4d84ef7cd8db93b8c6e5568266eb0268aeabf5a1abfcf9b6f02a61c379ca337701efb412d18a5f39a8d34d0cf58
|
data/CHANGELOG.md
ADDED
data/CONTRIBUTORS
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
The following is a list of people who have contributed ideas, code, bug
|
2
|
+
reports, or in general have helped logstash along its way.
|
3
|
+
|
4
|
+
Contributors:
|
5
|
+
* TAC - tac@tac42.net
|
6
|
+
|
7
|
+
Note: If you've sent us patches, bug reports, or otherwise contributed to
|
8
|
+
Logstash, and you aren't on the list above and want to be, please let us know
|
9
|
+
and we'll make sure you're here. Contributions from folks like you are what make
|
10
|
+
open source awesome.
|
data/DEVELOPER.md
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
2
|
+
you may not use this file except in compliance with the License.
|
3
|
+
You may obtain a copy of the License at
|
4
|
+
|
5
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
6
|
+
|
7
|
+
Unless required by applicable law or agreed to in writing, software
|
8
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
9
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
10
|
+
See the License for the specific language governing permissions and
|
11
|
+
limitations under the License.
|
data/README.md
ADDED
@@ -0,0 +1,115 @@
|
|
1
|
+
# logstash-output-iothub
|
2
|
+
|
3
|
+
This is a plugin for [Logstash](https://github.com/elastic/logstash).
|
4
|
+
|
5
|
+
This plugin provide sending messages to [Microsoft Azure IoTHub](https://azure.microsoft.com/en-us/services/iot-hub/).
|
6
|
+
|
7
|
+
|
8
|
+
# How to use
|
9
|
+
## Install
|
10
|
+
In your logstash home dir,
|
11
|
+
```
|
12
|
+
|
13
|
+
```
|
14
|
+
|
15
|
+
More details, please look [here](https://www.elastic.co/guide/en/logstash/current/working-with-plugins.html).
|
16
|
+
|
17
|
+
|
18
|
+
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.
|
19
|
+
|
20
|
+
## How to build
|
21
|
+
```
|
22
|
+
% bundle install
|
23
|
+
% rake install_jars
|
24
|
+
```
|
25
|
+
|
26
|
+
## Run spec
|
27
|
+
```
|
28
|
+
$ rspec
|
29
|
+
```
|
30
|
+
|
31
|
+
## Publish Gem
|
32
|
+
```
|
33
|
+
$ bundle exec rake publish_gem
|
34
|
+
```
|
35
|
+
|
36
|
+
## Documentation
|
37
|
+
|
38
|
+
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.elastic.co/guide/en/logstash/current/).
|
39
|
+
|
40
|
+
- For formatting code or config example, you can use the asciidoc `[source,ruby]` directive
|
41
|
+
- For more asciidoc formatting tips, see the excellent reference here https://github.com/elastic/docs#asciidoc-guide
|
42
|
+
|
43
|
+
## Need Help?
|
44
|
+
|
45
|
+
Need help? Try #logstash on freenode IRC or the https://discuss.elastic.co/c/logstash discussion forum.
|
46
|
+
|
47
|
+
## Developing
|
48
|
+
|
49
|
+
### 1. Plugin Developement and Testing
|
50
|
+
|
51
|
+
#### Code
|
52
|
+
- To get started, you'll need JRuby with the Bundler gem installed.
|
53
|
+
|
54
|
+
- 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).
|
55
|
+
|
56
|
+
- Install dependencies
|
57
|
+
```sh
|
58
|
+
bundle install
|
59
|
+
```
|
60
|
+
|
61
|
+
#### Test
|
62
|
+
|
63
|
+
- Update your dependencies
|
64
|
+
|
65
|
+
```sh
|
66
|
+
bundle install
|
67
|
+
```
|
68
|
+
|
69
|
+
- Run tests
|
70
|
+
|
71
|
+
```sh
|
72
|
+
bundle exec rspec
|
73
|
+
```
|
74
|
+
|
75
|
+
### 2. Running your unpublished Plugin in Logstash
|
76
|
+
|
77
|
+
#### 2.1 Run in a local Logstash clone
|
78
|
+
|
79
|
+
- Edit Logstash `Gemfile` and add the local plugin path, for example:
|
80
|
+
```ruby
|
81
|
+
gem "logstash-filter-awesome", :path => "/your/local/logstash-filter-awesome"
|
82
|
+
```
|
83
|
+
- Install plugin
|
84
|
+
```sh
|
85
|
+
bin/logstash-plugin install --no-verify
|
86
|
+
```
|
87
|
+
- Run Logstash with your plugin
|
88
|
+
```sh
|
89
|
+
bin/logstash -e 'filter {awesome {}}'
|
90
|
+
```
|
91
|
+
At this point any modifications to the plugin code will be applied to this local Logstash setup. After modifying the plugin, simply rerun Logstash.
|
92
|
+
|
93
|
+
#### 2.2 Run in an installed Logstash
|
94
|
+
|
95
|
+
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:
|
96
|
+
|
97
|
+
- Build your plugin gem
|
98
|
+
```sh
|
99
|
+
gem build logstash-filter-awesome.gemspec
|
100
|
+
```
|
101
|
+
- Install the plugin from the Logstash home
|
102
|
+
```sh
|
103
|
+
bin/logstash-plugin install /your/local/plugin/logstash-filter-awesome.gem
|
104
|
+
```
|
105
|
+
- Start Logstash and proceed to test the plugin
|
106
|
+
|
107
|
+
## Contributing
|
108
|
+
|
109
|
+
All contributions are welcome: ideas, patches, documentation, bug reports, complaints, and even something you drew up on a napkin.
|
110
|
+
|
111
|
+
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.
|
112
|
+
|
113
|
+
It is more important to the community that you are able to contribute.
|
114
|
+
|
115
|
+
For more information about contributing, see the [CONTRIBUTING](https://github.com/elastic/logstash/blob/master/CONTRIBUTING.md) file.
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,75 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require "logstash/outputs/base"
|
3
|
+
require "logstash/namespace"
|
4
|
+
require 'java'
|
5
|
+
require 'logstash-output-iothub_jars.rb'
|
6
|
+
|
7
|
+
java_import "com.microsoft.azure.sdk.iot.device.DeviceClient"
|
8
|
+
java_import "com.microsoft.azure.sdk.iot.device.IotHubClientProtocol"
|
9
|
+
java_import "com.microsoft.azure.sdk.iot.device.Message"
|
10
|
+
java_import "com.microsoft.azure.sdk.iot.device.IotHubEventCallback"
|
11
|
+
|
12
|
+
$wait_queue = {}
|
13
|
+
|
14
|
+
class EventCallback
|
15
|
+
include IotHubEventCallback
|
16
|
+
def execute(status, context)
|
17
|
+
$wait_queue.delete(context) if $wait_queue[context]
|
18
|
+
# puts("Callback #{context} : #{status.to_s}")
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
class LogStash::Outputs::Iothub < LogStash::Outputs::Base
|
23
|
+
config_name "iothub"
|
24
|
+
|
25
|
+
config :connection_string, :validate => :string, :required => true
|
26
|
+
|
27
|
+
# Todo: support for AMQPS.
|
28
|
+
# config :sas_token_expiry_time_sec, :validte => :number, :default => 2400
|
29
|
+
|
30
|
+
public
|
31
|
+
def register
|
32
|
+
# Todo: Get hang in an open with AMQPS.
|
33
|
+
#protocol = IotHubClientProtocol::AMQPS
|
34
|
+
|
35
|
+
protocol = IotHubClientProtocol::MQTT
|
36
|
+
|
37
|
+
@client = DeviceClient.new(@connection_string, protocol)
|
38
|
+
|
39
|
+
# Todo: use params for AMQPS protocol.
|
40
|
+
# @client.setOption(
|
41
|
+
# "SetCertificatePath",
|
42
|
+
# "/Users/tac/Desktop/logstash-output-iothub/cert.crt")
|
43
|
+
|
44
|
+
# @client.setOption(
|
45
|
+
# "SetSASTokenExpiryTime",
|
46
|
+
# @sas_token_expiry_time_sec)
|
47
|
+
|
48
|
+
@client.open()
|
49
|
+
end # def register
|
50
|
+
|
51
|
+
|
52
|
+
public
|
53
|
+
def receive(event)
|
54
|
+
m = event.to_json
|
55
|
+
$wait_queue[m] = true
|
56
|
+
msg = Message.new(m)
|
57
|
+
msg.setExpiryTime(3000)
|
58
|
+
@client.sendEventAsync(
|
59
|
+
msg,
|
60
|
+
EventCallback.new, m)
|
61
|
+
|
62
|
+
return "Event received"
|
63
|
+
end # def receive
|
64
|
+
|
65
|
+
public
|
66
|
+
def close()
|
67
|
+
begin
|
68
|
+
# waiting callbacks for all sent messages.
|
69
|
+
sleep 1 unless $wait_queue.empty?
|
70
|
+
|
71
|
+
@client.close() if @client
|
72
|
+
rescue => e
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end # class LogStash::Outputs::Iothub
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,29 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = 'logstash-output-iothub'
|
3
|
+
s.version = '1.1.0'
|
4
|
+
s.licenses = ['Apache-2.0']
|
5
|
+
s.summary = 'Output plugin for Logstash for sending Azure IoTHub'
|
6
|
+
s.description = 'Output plugin for Logstash for sending Azure IoTHub'
|
7
|
+
s.homepage = 'https://github.com/tac0x2a/logstash-output-iothub'
|
8
|
+
s.authors = ['TAC']
|
9
|
+
s.email = 'tac@tac42.net'
|
10
|
+
s.require_paths = ['lib']
|
11
|
+
|
12
|
+
# Files
|
13
|
+
s.files = Dir['lib/**/*','spec/**/*','vendor/**/*','*.gemspec','*.md','CONTRIBUTORS','Gemfile','LICENSE','NOTICE.TXT']
|
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" => "output" }
|
19
|
+
|
20
|
+
s.requirements << "jar 'com.microsoft.azure.sdk.iot:iot-device-client', '1.0.17'"
|
21
|
+
s.add_development_dependency 'jar-dependencies'
|
22
|
+
|
23
|
+
# Gem dependencies
|
24
|
+
s.add_runtime_dependency "logstash-core-plugin-api", "~> 2.0"
|
25
|
+
s.add_runtime_dependency "logstash-codec-plain"
|
26
|
+
s.add_development_dependency "logstash-devutils"
|
27
|
+
s.add_development_dependency "fuubar"
|
28
|
+
|
29
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require "logstash/devutils/rspec/spec_helper"
|
3
|
+
require "logstash/outputs/iothub"
|
4
|
+
require "logstash/codecs/plain"
|
5
|
+
require "logstash/event"
|
6
|
+
|
7
|
+
describe LogStash::Outputs::Iothub do
|
8
|
+
#let(:settings)
|
9
|
+
let(:sample_event) { LogStash::Event.new }
|
10
|
+
let(:output) { LogStash::Outputs::Iothub.new({
|
11
|
+
"connection_string" => "{set your iot hub connection string}",
|
12
|
+
}) }
|
13
|
+
|
14
|
+
before do
|
15
|
+
output.register
|
16
|
+
end
|
17
|
+
|
18
|
+
after do
|
19
|
+
output.close
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "receive message" do
|
23
|
+
subject { output.receive(sample_event) }
|
24
|
+
|
25
|
+
it "returns a string" do
|
26
|
+
expect(subject).to eq("Event received")
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
metadata
ADDED
@@ -0,0 +1,143 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: logstash-output-iothub
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- TAC
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-01-22 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
15
|
+
requirements:
|
16
|
+
- - ">="
|
17
|
+
- !ruby/object:Gem::Version
|
18
|
+
version: '0'
|
19
|
+
name: jar-dependencies
|
20
|
+
prerelease: false
|
21
|
+
type: :development
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - "~>"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '2.0'
|
33
|
+
name: logstash-core-plugin-api
|
34
|
+
prerelease: false
|
35
|
+
type: :runtime
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
requirement: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
name: logstash-codec-plain
|
48
|
+
prerelease: false
|
49
|
+
type: :runtime
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
requirement: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
name: logstash-devutils
|
62
|
+
prerelease: false
|
63
|
+
type: :development
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
requirement: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
name: fuubar
|
76
|
+
prerelease: false
|
77
|
+
type: :development
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: Output plugin for Logstash for sending Azure IoTHub
|
84
|
+
email: tac@tac42.net
|
85
|
+
executables: []
|
86
|
+
extensions: []
|
87
|
+
extra_rdoc_files: []
|
88
|
+
files:
|
89
|
+
- CHANGELOG.md
|
90
|
+
- CONTRIBUTORS
|
91
|
+
- DEVELOPER.md
|
92
|
+
- Gemfile
|
93
|
+
- LICENSE
|
94
|
+
- README.md
|
95
|
+
- lib/com/google/code/gson/gson/2.8.0/gson-2.8.0.jar
|
96
|
+
- lib/com/microsoft/azure/sdk/iot/deps/websocket-transport-layer/0.1.2/websocket-transport-layer-0.1.2.jar
|
97
|
+
- lib/com/microsoft/azure/sdk/iot/iot-device-client/1.0.17/iot-device-client-1.0.17.jar
|
98
|
+
- lib/commons-codec/commons-codec/1.10/commons-codec-1.10.jar
|
99
|
+
- lib/logstash-output-iothub_jars.rb
|
100
|
+
- lib/logstash/outputs/iothub.rb
|
101
|
+
- lib/org/apache/qpid/proton-j/0.15.0/proton-j-0.15.0.jar
|
102
|
+
- lib/org/bouncycastle/bcpkix-jdk15on/1.47/bcpkix-jdk15on-1.47.jar
|
103
|
+
- lib/org/bouncycastle/bcprov-jdk15on/1.47/bcprov-jdk15on-1.47.jar
|
104
|
+
- lib/org/eclipse/paho/org.eclipse.paho.client.mqttv3/1.0.2/org.eclipse.paho.client.mqttv3-1.0.2.jar
|
105
|
+
- logstash-output-iothub.gemspec
|
106
|
+
- spec/outputs/iothub_spec.rb
|
107
|
+
- vendor/jar-dependencies/runtime-jars/bcpkix-jdk15on-1.47.jar
|
108
|
+
- vendor/jar-dependencies/runtime-jars/bcprov-jdk15on-1.47.jar
|
109
|
+
- vendor/jar-dependencies/runtime-jars/commons-codec-1.10.jar
|
110
|
+
- vendor/jar-dependencies/runtime-jars/gson-2.8.0.jar
|
111
|
+
- vendor/jar-dependencies/runtime-jars/iot-device-client-1.0.17.jar
|
112
|
+
- vendor/jar-dependencies/runtime-jars/org.eclipse.paho.client.mqttv3-1.0.2.jar
|
113
|
+
- vendor/jar-dependencies/runtime-jars/proton-j-0.15.0.jar
|
114
|
+
- vendor/jar-dependencies/runtime-jars/websocket-transport-layer-0.1.2.jar
|
115
|
+
homepage: https://github.com/tac0x2a/logstash-output-iothub
|
116
|
+
licenses:
|
117
|
+
- Apache-2.0
|
118
|
+
metadata:
|
119
|
+
logstash_plugin: 'true'
|
120
|
+
logstash_group: output
|
121
|
+
post_install_message:
|
122
|
+
rdoc_options: []
|
123
|
+
require_paths:
|
124
|
+
- lib
|
125
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
126
|
+
requirements:
|
127
|
+
- - ">="
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
version: '0'
|
130
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
131
|
+
requirements:
|
132
|
+
- - ">="
|
133
|
+
- !ruby/object:Gem::Version
|
134
|
+
version: '0'
|
135
|
+
requirements:
|
136
|
+
- jar 'com.microsoft.azure.sdk.iot:iot-device-client', '1.0.17'
|
137
|
+
rubyforge_project:
|
138
|
+
rubygems_version: 2.6.8
|
139
|
+
signing_key:
|
140
|
+
specification_version: 4
|
141
|
+
summary: Output plugin for Logstash for sending Azure IoTHub
|
142
|
+
test_files:
|
143
|
+
- spec/outputs/iothub_spec.rb
|