fluent-plugin-eventcounter 0.0.4.1 → 0.0.5

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.
data/README.md CHANGED
@@ -59,58 +59,65 @@ or
59
59
  #### Basic
60
60
 
61
61
  - **count_key** (**required**)
62
- - The key within the record to count unique instances of
62
+ - The key within the record to count unique instances of
63
63
  - *eg. event*
64
64
 
65
65
  - **input_tag_exclude** (optional)
66
- - A pattern to exclude from the incoming tag
66
+ - A pattern to exclude from the incoming tag
67
67
  - *default: ''*
68
68
 
69
69
  - **emit_only** (optional) - *boolean*
70
- - Skip redis and re-emit using emit_to
70
+ - Skip redis and re-emit using emit_to
71
71
  - *default: false*
72
-
72
+
73
73
  - **emit_to** (optional) - *string*
74
- - Tag to re-emit with
74
+ - Tag to re-emit with
75
75
  - *default: debug.events*
76
76
 
77
77
  #### Extra Capture (optional)
78
78
 
79
79
  - **capture_extra_if** (optional)
80
- - An additional field to attach to the captured key
80
+ - An additional field to attach to the captured key
81
81
  - *default: nil*
82
-
82
+
83
83
  - **capture_extra_replace** (optional)
84
84
  - A regular expression to replace a portion of the extra capture. *(note: this is passed as a string and parsed as a regex so be aware that you may need to escape reserved characters to preserve their meaning.)*
85
85
  - *default: ''*
86
86
 
87
87
  #### Redis Config (optional)
88
-
88
+
89
89
  - **redis_host** (optional) - *string*
90
- - Host address of the redis server
90
+ - Host address of the redis server
91
91
  - *default: localhost*
92
-
92
+
93
93
  - **redis_port** (optional)
94
- - Port of the redis server
94
+ - Port of the redis server ()
95
95
  - *default: 6379*
96
-
96
+
97
97
  - **redis_password** (optional)
98
- - Password for the redis server
98
+ - Password for the redis server
99
99
  - *default: nil*
100
-
100
+
101
+ - **redis_sentinel** (optional) - *boolean*
102
+ - Use `redis_host` and `redis_port` as sentinel
103
+ - *default: false*
104
+
105
+ - **redis_master_group_name** (optional) - *string*
106
+ - Sentinel master group name
107
+ - *default: mymaster*
108
+
101
109
  - **redis_db_number** (optional)
102
- - Redis DB
110
+ - Redis DB (not used if `redis_sentinel` is set)
103
111
  - *default: 0*
104
112
 
105
113
  - **redis_output_key** (optional)
106
- - The key to prefix against the tag
114
+ - The key to prefix against the tag
107
115
  - *default: ''*
108
116
 
109
117
  #### Other
110
118
 
111
119
  - **flush_interval** (optional)
112
- - Provided from **Fluent::BufferedOutput** time in seconds between flushes
120
+ - Provided from **Fluent::BufferedOutput** time in seconds between flushes
113
121
  - *default: 60*
114
122
 
115
123
 
116
-
@@ -1,7 +1,7 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  Gem::Specification.new do |gem|
3
3
  gem.name = "fluent-plugin-eventcounter"
4
- gem.version = "0.0.4.1"
4
+ gem.version = "0.0.5"
5
5
  gem.authors = ["Sean Dick", "Change.org"]
6
6
  gem.email = ["sean@change.org"]
7
7
  gem.homepage = "https://github.com/change/fluent-plugin-eventcounter"
@@ -12,6 +12,8 @@ class Fluent::EventCounterOutput < Fluent::BufferedOutput
12
12
  config_param :redis_port, :integer, :default => 6379
13
13
  config_param :redis_password, :string, :default => nil
14
14
  config_param :redis_db_number, :integer, :default => 0
15
+ config_param :redis_sentinel, :bool, :default => false
16
+ config_param :redis_master_group_name, :string, :default => 'mymaster'
15
17
  config_param :redis_output_key, :string, :default => ''
16
18
 
17
19
  config_param :input_tag_exclude, :string, :default => ''
@@ -19,7 +21,7 @@ class Fluent::EventCounterOutput < Fluent::BufferedOutput
19
21
  config_param :capture_extra_replace, :string, :default => ''
20
22
  config_param :debug_emit, :bool, :default => false
21
23
 
22
- config_param :count_key, :string # REQUIRED
24
+ config_param :count_key, :string # REQUIRED
23
25
 
24
26
  attr_accessor :counts
25
27
 
@@ -30,13 +32,28 @@ class Fluent::EventCounterOutput < Fluent::BufferedOutput
30
32
 
31
33
  def start
32
34
  super
33
- @redis = Redis.new(
34
- host: @redis_host,
35
- port: @redis_port,
36
- password: @redis_password,
37
- thread_safe: true,
38
- db: @redis_db_number
39
- ) unless @emit_only
35
+ unless @emit_only
36
+ @redis = begin
37
+ if @redis_sentinel
38
+ sentinels = [{host: @redis_host, port: @redis_port}]
39
+ Redis.new(
40
+ url: "redis://#{@redis_master_group_name}",
41
+ sentinels: sentinels,
42
+ password: @redis_password,
43
+ thread_safe: true,
44
+ role: :master
45
+ )
46
+ else
47
+ Redis.new(
48
+ host: @redis_host,
49
+ port: @redis_port,
50
+ password: @redis_password,
51
+ thread_safe: true,
52
+ db: @redis_db_number
53
+ )
54
+ end
55
+ end
56
+ end
40
57
  end
41
58
 
42
59
  def format(tag, time, record)
@@ -56,7 +73,7 @@ class Fluent::EventCounterOutput < Fluent::BufferedOutput
56
73
  items = io.read.split("\n")
57
74
  items.each do |item|
58
75
  key, event = JSON.parse(item)
59
- counts[key][event] += 1
76
+ counts[key][event] += 1
60
77
  end
61
78
  end
62
79
 
@@ -65,7 +82,7 @@ class Fluent::EventCounterOutput < Fluent::BufferedOutput
65
82
  events.each do |event, c|
66
83
  redis_key = [@redis_output_key,tag].join(':')
67
84
  @redis.hincrby(redis_key, event, c.to_i)
68
- end
85
+ end
69
86
  end
70
87
  end unless @emit_only
71
88
 
@@ -76,4 +93,4 @@ class Fluent::EventCounterOutput < Fluent::BufferedOutput
76
93
  end
77
94
 
78
95
  end
79
- end
96
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-eventcounter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4.1
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2014-10-21 00:00:00.000000000 Z
13
+ date: 2016-02-11 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: fluentd