fluent-plugin-logentries 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ede9927a84f4346ffdf4298c2c4613a66a96a855
4
- data.tar.gz: 7b4572090c1ef0d26a02518700859a0bc508f349
3
+ metadata.gz: 8c4b26041239f1c2c5dd795d1f4aadf4dd0241a5
4
+ data.tar.gz: 9616321ac7d35964d5ec8517203eb37c7a25ba5e
5
5
  SHA512:
6
- metadata.gz: 5ad38d2ba03195a7a557075e113476314739e4625a1b140ed1bb320d3c75c5d1174ed7c4c9ea3c983f21406d3624627e0025d5aa7dbdc1b57d45180f93fb334e
7
- data.tar.gz: ae09d8debfaabb0db41fde0bb5cdb479d2db14be08ee69ef6938009bd54155b51fb2776de050458281cdf49551eee8eae0ca11692a2050a5521cab96489bb3ac
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
- /opt/td-agent/embedded/bin/fluent-gem install fluent-plugin-logentries
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.0"
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
- # Create tokens hash
48
- def generate_token
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
- YAML::load_file(@config_path)
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, tokens)
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 then
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
- tokens = generate_token()
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, tokens)
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.0
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-03 00:00:00.000000000 Z
11
+ date: 2015-01-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler