fluent-plugin-udp_forward 1.0.0
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/.gitignore +50 -0
- data/LICENSE +21 -0
- data/README.md +65 -0
- data/fluent-plugin-udp_forward.gemspec +17 -0
- data/lib/fluent/plugin/in_udp_forward.rb +63 -0
- metadata +68 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 6712b538bab4274a78fb6dda8de7ca69f9fa3786
|
4
|
+
data.tar.gz: 20f6a4db51b0a3b3df6bbf6afb8669ba1d70dc0b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 15cef4c875d09bc4b760c67009d0b752d2172cbbfcb4d664ab27cf3f555321520e67d4af709ce24e6a85f036f2af2d76515daab24346b48022f88ad4b4fb33a8
|
7
|
+
data.tar.gz: 0a55125635b44f18caef78a914ad236a556938f7b59968d88b8a6d195b33de7534c303c552e115b9b31a3099dacc85207a9dfb95cc8a18c75d681f3df9306b2c
|
data/.gitignore
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/spec/examples.txt
|
9
|
+
/test/tmp/
|
10
|
+
/test/version_tmp/
|
11
|
+
/tmp/
|
12
|
+
|
13
|
+
# Used by dotenv library to load environment variables.
|
14
|
+
# .env
|
15
|
+
|
16
|
+
## Specific to RubyMotion:
|
17
|
+
.dat*
|
18
|
+
.repl_history
|
19
|
+
build/
|
20
|
+
*.bridgesupport
|
21
|
+
build-iPhoneOS/
|
22
|
+
build-iPhoneSimulator/
|
23
|
+
|
24
|
+
## Specific to RubyMotion (use of CocoaPods):
|
25
|
+
#
|
26
|
+
# We recommend against adding the Pods directory to your .gitignore. However
|
27
|
+
# you should judge for yourself, the pros and cons are mentioned at:
|
28
|
+
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
29
|
+
#
|
30
|
+
# vendor/Pods/
|
31
|
+
|
32
|
+
## Documentation cache and generated files:
|
33
|
+
/.yardoc/
|
34
|
+
/_yardoc/
|
35
|
+
/doc/
|
36
|
+
/rdoc/
|
37
|
+
|
38
|
+
## Environment normalization:
|
39
|
+
/.bundle/
|
40
|
+
/vendor/bundle
|
41
|
+
/lib/bundler/man/
|
42
|
+
|
43
|
+
# for a library or gem, you might want to ignore these files since the code is
|
44
|
+
# intended to run in multiple environments; otherwise, check them in:
|
45
|
+
# Gemfile.lock
|
46
|
+
# .ruby-version
|
47
|
+
# .ruby-gemset
|
48
|
+
|
49
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
50
|
+
.rvmrc
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2019 tombola Ltd
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
# fluent-plugin-udp_forward
|
2
|
+
|
3
|
+
#### Overview
|
4
|
+
|
5
|
+
This fluent input plugin allows you to collect incoming events over UDP.
|
6
|
+
While fluentd's default UDP Input plugin supports adding a tag to the received message statically by configuration,
|
7
|
+
it does not support extracting a tag from the received message.
|
8
|
+
This plugin supports extracting the tag from incoming events over UDP. UDP events should be in JSON format.
|
9
|
+
|
10
|
+
#### Installation
|
11
|
+
|
12
|
+
gem install fluent-plugin-udp_forward
|
13
|
+
|
14
|
+
#### Configuration
|
15
|
+
|
16
|
+
<source>
|
17
|
+
@type udp_forward
|
18
|
+
bind "localhost"
|
19
|
+
port 5160
|
20
|
+
tag_key "tag"
|
21
|
+
message_key "data"
|
22
|
+
</source>
|
23
|
+
|
24
|
+
Optional parameters are as follows:
|
25
|
+
|
26
|
+
- bind: The bind address to listen to. Default is "0.0.0.0
|
27
|
+
- port: The port to listen to. Default is 5160
|
28
|
+
- tag_key: Name of tag key. Default is "tag"
|
29
|
+
- message_key: Name of message key. Default is "data"
|
30
|
+
|
31
|
+
#### Example
|
32
|
+
If your fluentd source configuration is the same as above and you submitting an event like this:
|
33
|
+
|
34
|
+
require "socket"
|
35
|
+
require 'json'
|
36
|
+
|
37
|
+
my_hash = {tag: 'my_tag', data:{ "level": "INFO", "time": Time.now, "message": "Yayyy!!" }}
|
38
|
+
UDPSocket.new.send(JSON.generate(my_hash), 0, 'localhost', 5160)
|
39
|
+
|
40
|
+
The output will be:
|
41
|
+
|
42
|
+
2019-02-26 11:11:03.499991000 +0000 my_tag: {"level":"INFO","time":"2019-02-26 11:11:03 +0000","message":"Yayyy!!"}
|
43
|
+
|
44
|
+
|
45
|
+
## Requirements
|
46
|
+
|
47
|
+
| fluent-plugin-udp_forward | fluentd |
|
48
|
+
|-------------------|---------|
|
49
|
+
| >= 1.0.0 | >= v0.12.0 < 2 |
|
50
|
+
|
51
|
+
#### Contributing
|
52
|
+
|
53
|
+
1. Fork it ( http://github.com/tombolaltd/fluent-plugin-udp_forward/fork )
|
54
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
55
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
56
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
57
|
+
5. Create a new Pull Request
|
58
|
+
|
59
|
+
#### Copyright
|
60
|
+
|
61
|
+
Copyright (c) 2019 - [tombola](https://www.tombolaarcade.co.uk).
|
62
|
+
|
63
|
+
#### License
|
64
|
+
|
65
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
Gem::Specification.new do |gem|
|
3
|
+
gem.name = "fluent-plugin-udp_forward"
|
4
|
+
gem.description = "This input plugin allows you to collect incoming events over UDP"
|
5
|
+
gem.homepage = "https://github.com/fluent-plugin-udp_forward"
|
6
|
+
gem.summary = gem.description
|
7
|
+
gem.version = "1.0.0"
|
8
|
+
gem.license = 'MIT'
|
9
|
+
gem.authors = ["Sohaib Maroof"]
|
10
|
+
gem.email = "sohaib.maroof@tombola.com"
|
11
|
+
gem.has_rdoc = false
|
12
|
+
gem.files = `git ls-files`.split("\n")
|
13
|
+
gem.require_paths = ['lib']
|
14
|
+
gem.add_runtime_dependency "fluentd", [">= 0.14.0", "< 2"]
|
15
|
+
end
|
16
|
+
|
17
|
+
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'fluent/input'
|
2
|
+
module Fluent
|
3
|
+
class UDPForwardInput < Input
|
4
|
+
|
5
|
+
Fluent::Plugin.register_input('udp_forward', self)
|
6
|
+
require 'socket'
|
7
|
+
|
8
|
+
config_param :port, :integer, :default => 5160
|
9
|
+
config_param :bind, :string, :default => '0.0.0.0'
|
10
|
+
config_param :tag_key, :string, :default => 'tag'
|
11
|
+
config_param :message_key, :string, :default => 'data'
|
12
|
+
|
13
|
+
def configure(conf)
|
14
|
+
super
|
15
|
+
end
|
16
|
+
|
17
|
+
def start
|
18
|
+
super
|
19
|
+
|
20
|
+
$log.info("udp_forward listening on #{@bind}:#{@port}")
|
21
|
+
|
22
|
+
@thread = Thread.new(Thread.current) do |parent|
|
23
|
+
while (true)
|
24
|
+
begin
|
25
|
+
Socket.udp_server_loop(@bind, @port) do |msg, msg_src|
|
26
|
+
tag, time, record = parse(msg)
|
27
|
+
router.emit(tag, time, record)
|
28
|
+
end
|
29
|
+
rescue
|
30
|
+
$log.error("unexpected error in udp_server_loop", :error=>$!.to_s)
|
31
|
+
$log.error_backtrace
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def shutdown
|
38
|
+
super
|
39
|
+
@thread.kill
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def parse(message)
|
45
|
+
begin
|
46
|
+
parsed = JSON.parse(message)
|
47
|
+
rescue
|
48
|
+
$log.warn("Parse error : #{message} \n #{$!.to_s}")
|
49
|
+
parsed = {}
|
50
|
+
end
|
51
|
+
|
52
|
+
time = Engine.now
|
53
|
+
tag = parsed[@tag_key]
|
54
|
+
record = parsed[@message_key]
|
55
|
+
|
56
|
+
if(tag.nil? || record.nil?)
|
57
|
+
$log.warn("invalid message supplied: #{message}")
|
58
|
+
end
|
59
|
+
|
60
|
+
return [tag, time, record]
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
metadata
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fluent-plugin-udp_forward
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Sohaib Maroof
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-03-01 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: fluentd
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.14.0
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '2'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 0.14.0
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '2'
|
33
|
+
description: This input plugin allows you to collect incoming events over UDP
|
34
|
+
email: sohaib.maroof@tombola.com
|
35
|
+
executables: []
|
36
|
+
extensions: []
|
37
|
+
extra_rdoc_files: []
|
38
|
+
files:
|
39
|
+
- ".gitignore"
|
40
|
+
- LICENSE
|
41
|
+
- README.md
|
42
|
+
- fluent-plugin-udp_forward.gemspec
|
43
|
+
- lib/fluent/plugin/in_udp_forward.rb
|
44
|
+
homepage: https://github.com/fluent-plugin-udp_forward
|
45
|
+
licenses:
|
46
|
+
- MIT
|
47
|
+
metadata: {}
|
48
|
+
post_install_message:
|
49
|
+
rdoc_options: []
|
50
|
+
require_paths:
|
51
|
+
- lib
|
52
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '0'
|
57
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
requirements: []
|
63
|
+
rubyforge_project:
|
64
|
+
rubygems_version: 2.5.2.3
|
65
|
+
signing_key:
|
66
|
+
specification_version: 4
|
67
|
+
summary: This input plugin allows you to collect incoming events over UDP
|
68
|
+
test_files: []
|