fluent-plugin-udp 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +32 -0
- data/fluent-plugin-udp.gemspec +19 -0
- data/lib/fluent/plugin/in_udp.rb +61 -0
- metadata +82 -0
data/README.rdoc
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
= UDP input plugin for Fluent event collector
|
2
|
+
|
3
|
+
== Overview
|
4
|
+
|
5
|
+
*This input plugin allows you to collect incoming events over UDP instead of TCP. It is useful because UDP does not require ACK hence the transaction is completed fasted than TCP
|
6
|
+
|
7
|
+
== Installation
|
8
|
+
|
9
|
+
gem install fluent-plugin-udp
|
10
|
+
|
11
|
+
== Configuration
|
12
|
+
|
13
|
+
<source>
|
14
|
+
type udp
|
15
|
+
bind <bind_ip>
|
16
|
+
port <binding_udp_port>
|
17
|
+
</source>
|
18
|
+
|
19
|
+
|
20
|
+
For submitting events, if you are using Ruby then you could use this:
|
21
|
+
<pre>
|
22
|
+
require "socket"
|
23
|
+
UDPSocket.new.send("{\"tag\":\"tagname\",\"key\":\"value\"}", 0, 'hostname', 1234)
|
24
|
+
</pre>
|
25
|
+
== Copyright
|
26
|
+
|
27
|
+
Copyright:: Copyright (c) 2012 Abhishek Parolkar
|
28
|
+
License:: MIT License
|
29
|
+
|
30
|
+
|
31
|
+
|
32
|
+
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
Gem::Specification.new do |gem|
|
4
|
+
gem.name = "fluent-plugin-udp"
|
5
|
+
gem.description = "This input plugin allows you to collect incoming events over UDP instead of TCP"
|
6
|
+
gem.homepage = "https://github.com/parolkar/fluent-plugin-udp"
|
7
|
+
gem.summary = gem.description
|
8
|
+
gem.version = "0.0.1"
|
9
|
+
gem.authors = ["Abhishek Parolkar"]
|
10
|
+
gem.email = "abhishek@parolkar.com"
|
11
|
+
gem.has_rdoc = false
|
12
|
+
gem.files = `git ls-files`.split("\n")
|
13
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
14
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
15
|
+
gem.require_paths = ['lib']
|
16
|
+
gem.add_dependency "fluentd", "~> 0.10.7"
|
17
|
+
end
|
18
|
+
|
19
|
+
|
@@ -0,0 +1,61 @@
|
|
1
|
+
module Fluent
|
2
|
+
class UDPInput < Fluent::Input
|
3
|
+
Plugin.register_input('udp', self)
|
4
|
+
include DetachMultiProcessMixin
|
5
|
+
require 'socket'
|
6
|
+
require 'json'
|
7
|
+
def initialize
|
8
|
+
super
|
9
|
+
end
|
10
|
+
|
11
|
+
config_param :port, :integer, :default => 8765
|
12
|
+
config_param :bind, :string, :default => '0.0.0.0'
|
13
|
+
|
14
|
+
|
15
|
+
def configure(conf)
|
16
|
+
super
|
17
|
+
end
|
18
|
+
|
19
|
+
def start
|
20
|
+
|
21
|
+
@udp_s = UDPSocket.new
|
22
|
+
|
23
|
+
|
24
|
+
detach_multi_process do
|
25
|
+
super
|
26
|
+
@udp_s.bind(@bind, @port)
|
27
|
+
$log.debug "listening UDP on #{@bind}:#{@port}"
|
28
|
+
@thread = Thread.new(&method(:run))
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def shutdown
|
33
|
+
@udp_s.close
|
34
|
+
@thread.join
|
35
|
+
end
|
36
|
+
|
37
|
+
def run
|
38
|
+
loop do
|
39
|
+
text, sender = @udp_s.recvfrom(1024)
|
40
|
+
begin
|
41
|
+
j_obj = JSON.parse(text)
|
42
|
+
rescue
|
43
|
+
$log.debug "Parse error : #{text} \n #{$!.to_s}"
|
44
|
+
j_obj = {}
|
45
|
+
end
|
46
|
+
time = j_obj['t']
|
47
|
+
time = time.to_i
|
48
|
+
if time == 0
|
49
|
+
time = Engine.now
|
50
|
+
end
|
51
|
+
|
52
|
+
tag = j_obj['tag'] || "unknown"
|
53
|
+
|
54
|
+
Engine.emit(tag, time, j_obj)
|
55
|
+
end
|
56
|
+
rescue
|
57
|
+
$log.error "unexpected error", :error=>$!.to_s
|
58
|
+
$log.error_backtrace
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
metadata
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fluent-plugin-udp
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Abhishek Parolkar
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2012-05-10 00:00:00 Z
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: fluentd
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ~>
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 57
|
29
|
+
segments:
|
30
|
+
- 0
|
31
|
+
- 10
|
32
|
+
- 7
|
33
|
+
version: 0.10.7
|
34
|
+
type: :runtime
|
35
|
+
version_requirements: *id001
|
36
|
+
description: This input plugin allows you to collect incoming events over UDP instead of TCP
|
37
|
+
email: abhishek@parolkar.com
|
38
|
+
executables: []
|
39
|
+
|
40
|
+
extensions: []
|
41
|
+
|
42
|
+
extra_rdoc_files: []
|
43
|
+
|
44
|
+
files:
|
45
|
+
- README.rdoc
|
46
|
+
- fluent-plugin-udp.gemspec
|
47
|
+
- lib/fluent/plugin/in_udp.rb
|
48
|
+
homepage: https://github.com/parolkar/fluent-plugin-udp
|
49
|
+
licenses: []
|
50
|
+
|
51
|
+
post_install_message:
|
52
|
+
rdoc_options: []
|
53
|
+
|
54
|
+
require_paths:
|
55
|
+
- lib
|
56
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
hash: 3
|
62
|
+
segments:
|
63
|
+
- 0
|
64
|
+
version: "0"
|
65
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
66
|
+
none: false
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
hash: 3
|
71
|
+
segments:
|
72
|
+
- 0
|
73
|
+
version: "0"
|
74
|
+
requirements: []
|
75
|
+
|
76
|
+
rubyforge_project:
|
77
|
+
rubygems_version: 1.8.12
|
78
|
+
signing_key:
|
79
|
+
specification_version: 3
|
80
|
+
summary: This input plugin allows you to collect incoming events over UDP instead of TCP
|
81
|
+
test_files: []
|
82
|
+
|