fluent-plugin-logentries 0.2.0 → 0.2.1
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 +4 -4
- data/README.md +7 -1
- data/fluent-plugin-logentries.gemspec +1 -1
- data/lib/fluent/plugin/out_logentries.rb +20 -9
- 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: 8c4b26041239f1c2c5dd795d1f4aadf4dd0241a5
|
4
|
+
data.tar.gz: 9616321ac7d35964d5ec8517203eb37c7a25ba5e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aa0e5144b3e4a0008e5a7fb2ebc8eee91f0e3a1641a708b9a48276bb73b1c9e0db7884a79a30834e6c86ab64e80493167d86cd58f0b17b91510bf0b2d9464464
|
7
|
+
data.tar.gz: 1cf6a1107c9ce8329151a852a1087477ca04e615e45f335e095319fc42d494a91c7c22af0b838fd6b658943ca911d49349065f5d5bdd58a5c41bcadce813af0f
|
data/README.md
CHANGED
@@ -5,7 +5,13 @@ Looks at the tag/message to find out where the log should go.
|
|
5
5
|
|
6
6
|
## Installation
|
7
7
|
|
8
|
-
|
8
|
+
install with gem or fluent-gem command as:
|
9
|
+
|
10
|
+
### native gem
|
11
|
+
$ gem install fluent-plugin-logentries
|
12
|
+
|
13
|
+
### fluentd gem
|
14
|
+
$ /opt/td-agent/embedded/bin/fluent-gem install fluent-plugin-logentries
|
9
15
|
|
10
16
|
## Configruation file (YML)
|
11
17
|
|
@@ -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.2.
|
7
|
+
spec.version = "0.2.1"
|
8
8
|
spec.authors = ["Woorank"]
|
9
9
|
spec.email = ["dev@woorank.com"]
|
10
10
|
spec.summary = "Logentries output plugin for Fluent event collector"
|
@@ -17,6 +17,9 @@ class LogentriesOutput < Fluent::BufferedOutput
|
|
17
17
|
|
18
18
|
def configure(conf)
|
19
19
|
super
|
20
|
+
|
21
|
+
@tokens = nil
|
22
|
+
@last_edit = Time.at(0)
|
20
23
|
end
|
21
24
|
|
22
25
|
def start
|
@@ -44,17 +47,25 @@ class LogentriesOutput < Fluent::BufferedOutput
|
|
44
47
|
return [tag, record].to_msgpack
|
45
48
|
end
|
46
49
|
|
47
|
-
#
|
48
|
-
|
50
|
+
# Parse an YML file and generate a list of tokens.
|
51
|
+
# It will only re-generate the list on changes.
|
52
|
+
def generate_tokens_list
|
49
53
|
begin
|
50
|
-
|
54
|
+
edit_time = File.mtime(@config_path)
|
55
|
+
|
56
|
+
if edit_time > @last_edit
|
57
|
+
@tokens = YAML::load_file(@config_path)
|
58
|
+
@last_edit = edit_time
|
59
|
+
|
60
|
+
log.info "Token(s) list updated."
|
61
|
+
end
|
51
62
|
rescue Exception => e
|
52
63
|
log.warn "Could not load configuration. #{e.message}"
|
53
64
|
end
|
54
65
|
end
|
55
66
|
|
56
67
|
# Returns the correct token to use for a given tag / records
|
57
|
-
def get_token(tag, record
|
68
|
+
def get_token(tag, record)
|
58
69
|
tag ||= ""
|
59
70
|
message = record["message"]
|
60
71
|
|
@@ -64,8 +75,8 @@ class LogentriesOutput < Fluent::BufferedOutput
|
|
64
75
|
# app: TOKEN
|
65
76
|
# access: TOKEN (optional)
|
66
77
|
# error: TOKEN (optional)
|
67
|
-
tokens.each do |key, value|
|
68
|
-
if tag.index(key) != nil || message.index(key) != nil
|
78
|
+
@tokens.each do |key, value|
|
79
|
+
if tag.index(key) != nil || message.index(key) != nil
|
69
80
|
default = value['app']
|
70
81
|
|
71
82
|
case tag
|
@@ -85,14 +96,14 @@ class LogentriesOutput < Fluent::BufferedOutput
|
|
85
96
|
|
86
97
|
# NOTE! This method is called by internal thread, not Fluentd's main thread. So IO wait doesn't affect other plugins.
|
87
98
|
def write(chunk)
|
88
|
-
|
89
|
-
return unless tokens.is_a? Hash
|
99
|
+
generate_tokens_list()
|
100
|
+
return unless @tokens.is_a? Hash
|
90
101
|
|
91
102
|
chunk.msgpack_each do |tag, record|
|
92
103
|
next unless record.is_a? Hash
|
93
104
|
next unless record.has_key? "message"
|
94
105
|
|
95
|
-
token = get_token(tag, record
|
106
|
+
token = get_token(tag, record)
|
96
107
|
next if token.nil?
|
97
108
|
|
98
109
|
send_logentries(token + ' ' + record["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.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Woorank
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-01-
|
11
|
+
date: 2015-01-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|