fluent-plugin-logentries 0.0.1 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/fluent-plugin-logentries.gemspec +1 -1
- data/lib/fluent/plugin/out_logentries.rb +26 -22
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a5f759b0770dd1199f13f790a4126cc58122da38
|
4
|
+
data.tar.gz: aa0ae2f4c53dcff7689f088740a8dc20f8398e64
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7ed23880d05afe47319e0efb17c75b4056402deb337d7c6be210692a97a06a9fcdaf01dbf7b1fac90be0f28c6131001d5a55d3fb11fdb319769b60b5d3c811cc
|
7
|
+
data.tar.gz: 01f32fef24d176376ab066149f7ceaae00829ee60fa0ffa686693b61fe2718354363af32fc01f23f83a2c4bdddf7c0ebf8c5a77016198f84574b9a001b9eb56c
|
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = "fluent-plugin-logentries"
|
7
|
-
spec.version = "0.0.
|
7
|
+
spec.version = "0.0.4"
|
8
8
|
spec.authors = ["Woorank"]
|
9
9
|
spec.email = ["dev@woorank.com"]
|
10
10
|
spec.summary = "Logentries output plugin for Fluent event collector"
|
@@ -8,24 +8,13 @@ class LogentriesOutput < Fluent::BufferedOutput
|
|
8
8
|
|
9
9
|
config_param :host, :string
|
10
10
|
config_param :port, :integer, :default => 80
|
11
|
-
config_param :
|
11
|
+
config_param :path, :string
|
12
12
|
|
13
13
|
def configure(conf)
|
14
14
|
super
|
15
15
|
@port = conf['port']
|
16
16
|
@host = conf['host']
|
17
|
-
@
|
18
|
-
end
|
19
|
-
|
20
|
-
def parse_tokens(list)
|
21
|
-
tokens_list = {}
|
22
|
-
|
23
|
-
list.split(',').each do |host|
|
24
|
-
key, token = host.split(':');
|
25
|
-
tokens_list[key] = token
|
26
|
-
end
|
27
|
-
|
28
|
-
tokens_list
|
17
|
+
@path = conf['path']
|
29
18
|
end
|
30
19
|
|
31
20
|
def start
|
@@ -42,8 +31,25 @@ class LogentriesOutput < Fluent::BufferedOutput
|
|
42
31
|
@_socket ||= TCPSocket.new @host, @port
|
43
32
|
end
|
44
33
|
|
45
|
-
|
46
|
-
|
34
|
+
# This method is called when an event reaches to Fluentd.
|
35
|
+
def format(tag, time, record)
|
36
|
+
return [tag, record].to_msgpack
|
37
|
+
end
|
38
|
+
|
39
|
+
# Scan a given directory for host tokens
|
40
|
+
def generate_token(path)
|
41
|
+
tokens = {}
|
42
|
+
|
43
|
+
Dir[path << "*.token"].each do |file|
|
44
|
+
key = File.basename(file, ".token") #remove path/extension from filename
|
45
|
+
tokens[key] = File.open(file, &:readline).gsub(/\r\n|\r|\n/, '') #read the first line and close it
|
46
|
+
end
|
47
|
+
tokens
|
48
|
+
end
|
49
|
+
|
50
|
+
# returns the correct token to use for a given tag
|
51
|
+
def get_token(tag, tokens)
|
52
|
+
tokens.each do |key, value|
|
47
53
|
if tag.index(key) != nil then
|
48
54
|
return value
|
49
55
|
end
|
@@ -52,16 +58,14 @@ class LogentriesOutput < Fluent::BufferedOutput
|
|
52
58
|
return nil
|
53
59
|
end
|
54
60
|
|
55
|
-
# This method is called when an event reaches to Fluentd.
|
56
|
-
def format(tag, time, record)
|
57
|
-
token = get_token(tag)
|
58
|
-
return [token, record].to_msgpack
|
59
|
-
end
|
60
|
-
|
61
61
|
# NOTE! This method is called by internal thread, not Fluentd's main thread. So IO wait doesn't affect other plugins.
|
62
62
|
def write(chunk)
|
63
|
-
|
63
|
+
tokens = generate_token(@path)
|
64
|
+
|
65
|
+
chunk.msgpack_each do |tag, record|
|
64
66
|
next unless record.is_a? Hash
|
67
|
+
|
68
|
+
token = get_token(tag, tokens)
|
65
69
|
next if token.nil?
|
66
70
|
|
67
71
|
if record.has_key?("message")
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-logentries
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Woorank
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-10-
|
11
|
+
date: 2014-10-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|