fluent-plugin-norikra 0.0.9 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +174 -125
- data/example/blank.conf +2 -3
- data/example/blank.rb +15 -0
- data/example/blank2.conf +1 -1
- data/example/example1.conf +6 -7
- data/example/test1.conf +4 -5
- data/example/test1.rb +40 -0
- data/example/test2.conf +5 -6
- data/example/test_in_out.rb +48 -0
- data/fluent-plugin-norikra.gemspec +1 -1
- data/lib/fluent/plugin/in_norikra.rb +75 -0
- data/lib/fluent/plugin/norikra/config_section.rb +67 -0
- data/lib/fluent/plugin/norikra/fetch_request.rb +72 -0
- data/lib/fluent/plugin/norikra/input.rb +109 -0
- data/lib/fluent/plugin/norikra/output.rb +213 -0
- data/lib/fluent/plugin/norikra/query.rb +13 -0
- data/lib/fluent/plugin/norikra/query_generator.rb +61 -0
- data/lib/fluent/plugin/norikra/record_filter.rb +62 -0
- data/lib/fluent/plugin/norikra/target.rb +47 -0
- data/lib/fluent/plugin/norikra_target.rb +0 -246
- data/lib/fluent/plugin/out_norikra.rb +15 -364
- data/lib/fluent/plugin/out_norikra_filter.rb +172 -0
- data/test/helper.rb +2 -0
- data/test/plugin/test_in_norikra.rb +14 -0
- data/test/plugin/test_out_norikra.rb +5 -1
- data/test/plugin/test_out_norikra_filter.rb +15 -0
- data/test/test_config_section.rb +80 -25
- data/test/test_query.rb +6 -2
- data/test/test_query_generator.rb +9 -4
- data/test/test_record_filter.rb +2 -2
- data/test/test_target.rb +11 -13
- metadata +19 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fb3d07d2f2997aa968bdeb9a2c9b367d11b8402d
|
4
|
+
data.tar.gz: ba678530347bc93801c557d70eaf5bda2aec33e5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 06681dafb3386c4773dd557b801103c0d73f9880607d9521abc860b17272b129f612a83217fa305254fa19de569b426e02fa49056fac962525ab9035b1b32ab9
|
7
|
+
data.tar.gz: bab9693ba1db4ca31416bde2dc4d6b1ca91b388562c7364d362adf8916902aa509cb5f42f4729f935813f9f1a22882f28d5a77102a954c257ceb53309167f159
|
data/README.md
CHANGED
@@ -1,31 +1,35 @@
|
|
1
1
|
# fluent-plugin-norikra
|
2
2
|
|
3
|
-
Fluentd
|
3
|
+
Fluentd plugins to send/receive events to/from Norikra server.
|
4
4
|
|
5
|
-
|
5
|
+
Norikra is an open source server software provides "Stream Processing" with SQL, written in JRuby, runs on JVM, licensed under GPLv2.
|
6
|
+
For more details, see: http://norikra.github.io/ .
|
6
7
|
|
7
|
-
|
8
|
-
*
|
9
|
-
|
10
|
-
*
|
8
|
+
fluent-plugin-norikra has 3 plugins: in\_norikra, out\_norikra and out\_norikra\_filter.
|
9
|
+
* in\_norikra
|
10
|
+
* fetch events of query results from Norikra server
|
11
|
+
* out\_norikra
|
12
|
+
* send events to Norikra server
|
13
|
+
* out\_norikra\_filter
|
14
|
+
* launch Norikra server as child process dynamically, as needed
|
15
|
+
* use Norikra server as event filter (like out\_exec\_filter)
|
16
|
+
* register/execute queries for targets newly incoming
|
11
17
|
|
12
18
|
# Setup
|
13
19
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
5. configure Fluentd, and execute.
|
28
|
-
* and write `path` configuration of `<server>` section (if you want)
|
20
|
+
`fluent-plugin-norikra` works with Norikra server, on same server with Fluentd, or anywhere reachable over network from Fluentd.
|
21
|
+
For Norikra server setup, see: http://norikra.github.io/ .
|
22
|
+
|
23
|
+
NOTES:
|
24
|
+
* Fluentd and fluent-plugin-norikra requires CRuby (MatzRuby).
|
25
|
+
* Norikra requires JRuby.
|
26
|
+
|
27
|
+
To use out\_norikra\_filter with dynamic Norikra server launching, check actual path of command `norikra` under installed JRuby tree. (ex: `$HOME/.rbenv/versions/jruby-1.7.8/bin/norikra`)
|
28
|
+
|
29
|
+
To use this plugin:
|
30
|
+
1. run `gem install fluent-plugin-norikra` or `fluent-gem install fluent-plugin-norikra` to install plugin
|
31
|
+
1. edit configuration files
|
32
|
+
1. execute fluentd
|
29
33
|
|
30
34
|
# Configuration
|
31
35
|
|
@@ -33,87 +37,156 @@ For variations, see `example` directory.
|
|
33
37
|
|
34
38
|
## NorikraOutput
|
35
39
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
</query>
|
92
|
-
</default>
|
93
|
-
</match>
|
94
|
-
|
95
|
-
Additional field definitions and query registrations should be written in `<target TARGET_NAME>` sections. In each sections (or also in 'default'), you can specify `auto_field false` to suppress field number which increasing infinitely.
|
96
|
-
|
97
|
-
<default>
|
98
|
-
... # for all of access logs
|
99
|
-
</default>
|
100
|
-
<target login>
|
101
|
-
field_string protocol # like 'oauth', 'openid', ...
|
102
|
-
field_int proto_num # integer means internal id of protocols
|
103
|
-
<query>
|
104
|
-
name protocol
|
105
|
-
expression SELECT protocol, count(*) AS cnt FROM ${target}.win:time_batch(1 hour) WHERE proto_num != 0 GROUP BY protocol
|
106
|
-
tag login.counts
|
107
|
-
</query>
|
108
|
-
</target>
|
109
|
-
<target other_action>
|
110
|
-
auto_field false
|
111
|
-
...
|
112
|
-
</target>
|
113
|
-
# ...
|
40
|
+
Sends events to remote Norikra server. Minimal configurations are:
|
41
|
+
```apache
|
42
|
+
<match data.*>
|
43
|
+
type norikra
|
44
|
+
norikra norikra.server.local:26571
|
45
|
+
|
46
|
+
remove_tag_prefix data
|
47
|
+
target_map_tag true # fluentd's tag 'data.event' -> norikra's target 'event'
|
48
|
+
</match>
|
49
|
+
```
|
50
|
+
|
51
|
+
NorikraOutput plugin opens Norikra's target for newly incoming tags. You can specify fields to include/exclude, and specify types of each fields, for each targets (and all targets by `default`). Definitions in `<target TARGET_NAME>` overwrites `<default>` specifications.
|
52
|
+
```apache
|
53
|
+
<match data.*>
|
54
|
+
type norikra
|
55
|
+
norikra norikra.server.local:26571
|
56
|
+
|
57
|
+
target_map_tag true # fluentd's tag -> norikra's target
|
58
|
+
remove_tag_prefix data
|
59
|
+
# other options:
|
60
|
+
# target_map_key KEY_NAME # use specified key's value as target in fluentd event
|
61
|
+
# target_string STRING # use fixed target name specified
|
62
|
+
|
63
|
+
<default>
|
64
|
+
include * # send all fields values to norikra
|
65
|
+
exclude time # exclude 'time' field from sending event values
|
66
|
+
# AND/OR 'include_regexp' and 'exclude_regexp' available
|
67
|
+
field_integer seq # field 'seq' defined as integer for all targets
|
68
|
+
</default>
|
69
|
+
|
70
|
+
<target users>
|
71
|
+
field_string name,address
|
72
|
+
field_integer age
|
73
|
+
field_float height,weight
|
74
|
+
field_boolean superuser
|
75
|
+
</target>
|
76
|
+
</match>
|
77
|
+
```
|
78
|
+
|
79
|
+
With default setting, all fields are defined as 'string', so you must use `field_xxxx` parameters for numerical processing in query (For more details, see Norikra and Esper's documents).
|
80
|
+
|
81
|
+
If fluentd's events has so many variations of sets of fields, you can specify not to include fields automatically, with `auto_field` option:
|
82
|
+
```apache
|
83
|
+
<match data.*>
|
84
|
+
type norikra
|
85
|
+
norikra norikra.server.local:26571
|
86
|
+
|
87
|
+
target_map_tag true # fluentd's tag 'data.event' -> norikra's target 'event'
|
88
|
+
remove_tag_prefix data
|
89
|
+
|
90
|
+
<default>
|
91
|
+
auto_field false # norikra includes fields only used in queries.
|
92
|
+
</default>
|
93
|
+
</match>
|
94
|
+
```
|
114
95
|
|
115
96
|
Fields which are referred in queries are automatically registered on norikra server in spite of `auto_field false`.
|
116
97
|
|
98
|
+
** NOTE: <default> and <target> sections in NorikraOutput ignores <query> sections. see NorikraFilterOutput **
|
99
|
+
|
100
|
+
## NorikraInput
|
101
|
+
|
102
|
+
Fetch events from Norikra server, and emits these into Fluentd itself. NorikraInput uses Norikra's API `event` (for queries), and `sweep` (for query groups).
|
103
|
+
|
104
|
+
Minimal configurations:
|
105
|
+
```apache
|
106
|
+
<source>
|
107
|
+
type norikra
|
108
|
+
norikra norikra.server.local:26571
|
109
|
+
<fetch>
|
110
|
+
method sweep
|
111
|
+
# target QUERY_GROUP_NAME # not specified => default query group
|
112
|
+
tag query_name
|
113
|
+
tag_prefix norikra.query
|
114
|
+
# other options:
|
115
|
+
# tag field FIELDNAME : tag by value with specified field name in output event
|
116
|
+
# tag string STRING : fixed string specified
|
117
|
+
interval 3s # interval to call api
|
118
|
+
</fetch>
|
119
|
+
</source>
|
120
|
+
```
|
121
|
+
|
122
|
+
Available `<fetch>` methods are `event` and `sweep`. `target` parameter is handled as query name for `event`, and as query group name for `sweep`.
|
123
|
+
```apache
|
124
|
+
<source>
|
125
|
+
type norikra
|
126
|
+
norikra norikra.server.local:26571
|
127
|
+
<fetch>
|
128
|
+
method event
|
129
|
+
target data_count_1hour
|
130
|
+
tag string data.count.1hour
|
131
|
+
interval 60m
|
132
|
+
</fetch>
|
133
|
+
<fetch>
|
134
|
+
method event
|
135
|
+
target data_count_5min
|
136
|
+
tag string data.count.5min
|
137
|
+
interval 5m
|
138
|
+
</fetch>
|
139
|
+
<fetch>
|
140
|
+
method sweep
|
141
|
+
target count_queries
|
142
|
+
tag field target_name
|
143
|
+
tag_prefix data.count.all
|
144
|
+
interval 15s
|
145
|
+
</fetch>
|
146
|
+
</source>
|
147
|
+
```
|
148
|
+
|
149
|
+
## NorikraFilterOutput
|
150
|
+
|
151
|
+
NorikraFilterOutput has all features of both of NorikraInput and NorikraOutput, and also has additional features:
|
152
|
+
* execute Norikra server
|
153
|
+
* runs queries for newly incoming targets.
|
154
|
+
|
155
|
+
If you runs Norikra as standalone process, better configurations are to use NorikraInput and NorikraOutput separately. NorikraFilterOutput is for simple aggregations and filterings.
|
156
|
+
|
157
|
+
Configuration example to receive tags like `event.foo` and send norikra's target `foo`, and get count of its records per minute, and per hour with built-in Norikra server:
|
158
|
+
```apache
|
159
|
+
<match event.*>
|
160
|
+
type norikra_filter
|
161
|
+
<server>
|
162
|
+
path /home/username/.rbenv/versions/jruby-1.7.4/bin/norikra
|
163
|
+
# opts -Xmx2g # options of 'norikra start'
|
164
|
+
</server>
|
165
|
+
|
166
|
+
remove_tag_prefix event
|
167
|
+
target_map_tag yes
|
168
|
+
|
169
|
+
<default>
|
170
|
+
<query>
|
171
|
+
name count_min_${target}
|
172
|
+
group count_query_group # or default when omitted
|
173
|
+
expression SELECT count(*) AS cnt FROM ${target}.win:time_batch(1 minute)
|
174
|
+
tag count.min.${target}
|
175
|
+
</query>
|
176
|
+
<query>
|
177
|
+
name count_hour_${target}
|
178
|
+
group count_query_group
|
179
|
+
expression SELECT count(*) AS cnt FROM ${target}.win:time_batch(1 hour)
|
180
|
+
tag count.hour.${target}
|
181
|
+
</query>
|
182
|
+
</default>
|
183
|
+
</match>
|
184
|
+
```
|
185
|
+
|
186
|
+
Results of queries automatically registered by NorikraFilterOutput with `tag` parameter, will be fetched automatically by this plugin, and re-emitted into Fluentd itself.
|
187
|
+
|
188
|
+
Other all options are available as same as NorikraInput and NorikraOutput. `<default>`, `<target>` and `<fetch>` sections, `auto_field`, `include|exclude` and `field_xxxx` specifiers for targets and parameters for `<fetch>` sections.
|
189
|
+
|
117
190
|
### Input event data filtering
|
118
191
|
|
119
192
|
If you want send known fields only, specify `exclude *` and `include` or `include_regexp` like this:
|
@@ -152,34 +225,10 @@ Norikra's target (like table name) can be generated from:
|
|
152
225
|
* all records are sent in single target
|
153
226
|
* `target_string from_fluentd`
|
154
227
|
|
155
|
-
### Event sweeping
|
156
|
-
|
157
|
-
Norikra server accepts queries and events from everywhere other than Fluentd. This plugin can get events from these queries/events.
|
158
|
-
|
159
|
-
To gather all events of Norikra server, including queries from outside of Fluentd configurations, write `<event>` section.
|
160
|
-
|
161
|
-
<events>
|
162
|
-
method sweep
|
163
|
-
tag query_name
|
164
|
-
# tag field FIELDNAME
|
165
|
-
# tag string FIXED_STRING
|
166
|
-
tag_prefix norikra.event # actual tag: norikra.event.QUERYNAME
|
167
|
-
sweep_interval 5s
|
168
|
-
</events>
|
169
|
-
|
170
|
-
NOTE: 'sweep' get all events from Norikra, and other clients cannot get these events. Take care for other clients.
|
171
|
-
|
172
|
-
# FAQ
|
173
|
-
|
174
|
-
* TODO: write this section
|
175
|
-
* `fetch_interval`
|
176
|
-
* error logs for new target, success logs of retry
|
177
|
-
* input/output plugin
|
178
|
-
* output plugin with active-standby servers
|
179
|
-
|
180
228
|
# TODO
|
181
229
|
|
182
|
-
*
|
230
|
+
* write abou these topics
|
231
|
+
* error logs for new target, success logs of retry
|
183
232
|
|
184
233
|
# Copyright
|
185
234
|
|
data/example/blank.conf
CHANGED
@@ -3,11 +3,10 @@
|
|
3
3
|
</source>
|
4
4
|
|
5
5
|
<match event.*>
|
6
|
-
type
|
6
|
+
type norikra_filter
|
7
7
|
norikra localhost:26571 # this is default
|
8
8
|
<server>
|
9
|
-
|
10
|
-
path /Users/tagomoris/.rbenv/versions/jruby-1.7.3/bin/norikra
|
9
|
+
path /Users/tagomoris/.rbenv/versions/jruby-1.7.8/bin/norikra # $HOME
|
11
10
|
</server>
|
12
11
|
|
13
12
|
remove_tag_prefix event
|
data/example/blank.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
source {
|
2
|
+
type "forward"
|
3
|
+
}
|
4
|
+
|
5
|
+
home_dir = ::Object::ENV['HOME']
|
6
|
+
|
7
|
+
match('event.*') {
|
8
|
+
type "norikra_filter"
|
9
|
+
norikra "localhost:26571"
|
10
|
+
server {
|
11
|
+
path "#{home_dir}/.rbenv/versions/jruby-1.7.8/bin/norikra"
|
12
|
+
}
|
13
|
+
remove_tag_prefix "event"
|
14
|
+
target_map_tag true
|
15
|
+
}
|
data/example/blank2.conf
CHANGED
data/example/example1.conf
CHANGED
@@ -1,9 +1,8 @@
|
|
1
1
|
<match event.*>
|
2
|
-
type
|
2
|
+
type norikra_filter
|
3
3
|
norikra localhost:26571
|
4
4
|
|
5
5
|
<server>
|
6
|
-
execute yes # (default)no
|
7
6
|
path /home/user/.rbenv/versions/jruby-1.7.4/bin/norikra
|
8
7
|
</server>
|
9
8
|
|
@@ -24,13 +23,13 @@
|
|
24
23
|
# include foo,bar,baz
|
25
24
|
# include_regexp status.*
|
26
25
|
field_boolean flag
|
27
|
-
|
28
|
-
field_long duration,bytes
|
26
|
+
field_integer status,duration,bytes
|
29
27
|
|
30
28
|
<query>
|
31
29
|
name pv_${target}
|
32
30
|
expression SELECT count(*) AS cnt FROM ${target}.win:time_batch(1 minutes) WHERE not flag
|
33
31
|
tag pv.${target}
|
32
|
+
# group pv_query_group # default: nil (default group)
|
34
33
|
fetch_interval 15s # default -> time_batch / 4 ? -> (none) -> 60s
|
35
34
|
# fetch_interval is ignored when <events> section specified
|
36
35
|
</query>
|
@@ -57,12 +56,12 @@
|
|
57
56
|
</query>
|
58
57
|
</target>
|
59
58
|
|
60
|
-
<
|
59
|
+
<fetch>
|
61
60
|
method sweep # listen(not implemented)
|
62
61
|
tag query_name
|
63
62
|
# tag field FIELDNAME
|
64
63
|
# tag string TAG_STRING
|
65
64
|
tag_prefix cep
|
66
|
-
|
67
|
-
</
|
65
|
+
interval 5s
|
66
|
+
</fetch>
|
68
67
|
</match>
|
data/example/test1.conf
CHANGED
@@ -3,11 +3,10 @@
|
|
3
3
|
</source>
|
4
4
|
|
5
5
|
<match test.*>
|
6
|
-
type
|
6
|
+
type norikra_filter
|
7
7
|
norikra localhost:26571
|
8
8
|
<server>
|
9
|
-
|
10
|
-
path /Users/tagomoris/.rbenv/versions/jruby-1.7.3/bin/norikra
|
9
|
+
path /Users/tagomoris/.rbenv/versions/jruby-1.7.8/bin/norikra # $HOME
|
11
10
|
</server>
|
12
11
|
|
13
12
|
remove_tag_prefix test
|
@@ -19,11 +18,11 @@
|
|
19
18
|
expression SELECT '${target}' as target,count(*) AS cnt FROM ${target}.win:time_batch(30 sec)
|
20
19
|
</query>
|
21
20
|
</default>
|
22
|
-
<
|
21
|
+
<fetch>
|
23
22
|
method sweep
|
24
23
|
tag field target
|
25
24
|
tag_prefix count
|
26
|
-
|
25
|
+
interval 5s
|
27
26
|
</event>
|
28
27
|
</match>
|
29
28
|
|
data/example/test1.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
source {
|
2
|
+
type :forward
|
3
|
+
}
|
4
|
+
|
5
|
+
home_dir = ::Object::ENV['HOME']
|
6
|
+
|
7
|
+
match('test.*') {
|
8
|
+
type :norikra_filter
|
9
|
+
norikra 'localhost:26571'
|
10
|
+
server {
|
11
|
+
path "#{home_dir}/.rbenv/versions/jruby-1.7.8/bin/norikra"
|
12
|
+
}
|
13
|
+
|
14
|
+
remove_tag_prefix 'test'
|
15
|
+
target_map_tag true
|
16
|
+
|
17
|
+
default {
|
18
|
+
query {
|
19
|
+
name "count_${target}"
|
20
|
+
expression "SELECT '${target}' as target,count(*) AS cnt FROM ${target}.win:time_batch(30 sec)"
|
21
|
+
group "testing"
|
22
|
+
tag "count.x.${target}"
|
23
|
+
}
|
24
|
+
}
|
25
|
+
|
26
|
+
fetch {
|
27
|
+
method :sweep
|
28
|
+
tag 'field target'
|
29
|
+
tag_prefix 'count'
|
30
|
+
interval 5
|
31
|
+
}
|
32
|
+
}
|
33
|
+
|
34
|
+
match('fluent.*') {
|
35
|
+
type :null
|
36
|
+
}
|
37
|
+
|
38
|
+
match('**') {
|
39
|
+
type :stdout
|
40
|
+
}
|
data/example/test2.conf
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
</source>
|
4
4
|
|
5
5
|
<match {accesslog,applog}.**>
|
6
|
-
type
|
6
|
+
type norikra_filter
|
7
7
|
norikra localhost:26571
|
8
8
|
target_map_tag yes
|
9
9
|
|
@@ -14,16 +14,15 @@
|
|
14
14
|
|
15
15
|
<target accesslog.**>
|
16
16
|
field_string vhost,path,method,referer,rhost,userlabel,agent,ua_name,ua_category,ua_os,ua_version,ua_vendor
|
17
|
-
|
18
|
-
field_long bytes,duration
|
17
|
+
field_integer status,bytes,duration
|
19
18
|
field_boolean FLAG,status_redirection,status_errors,rhost_internal,suffix_miscfile,suffix_imagefile,agent_bot
|
20
19
|
</target>
|
21
20
|
|
22
|
-
<
|
21
|
+
<fetch>
|
23
22
|
method sweep
|
24
23
|
tag query_name
|
25
24
|
tag_prefix norikra.event
|
26
|
-
|
27
|
-
</
|
25
|
+
interval 5s
|
26
|
+
</fetch>
|
28
27
|
</match>
|
29
28
|
|
@@ -0,0 +1,48 @@
|
|
1
|
+
source {
|
2
|
+
type :forward
|
3
|
+
}
|
4
|
+
|
5
|
+
match('test.*') {
|
6
|
+
type :norikra
|
7
|
+
norikra 'localhost:26571'
|
8
|
+
|
9
|
+
remove_tag_prefix 'test'
|
10
|
+
target_map_tag true
|
11
|
+
|
12
|
+
default {
|
13
|
+
include '*'
|
14
|
+
exclude 'hhmmss'
|
15
|
+
}
|
16
|
+
|
17
|
+
target('data') {
|
18
|
+
field_string 'name'
|
19
|
+
field_integer 'age'
|
20
|
+
}
|
21
|
+
}
|
22
|
+
|
23
|
+
source {
|
24
|
+
type :norikra
|
25
|
+
|
26
|
+
fetch {
|
27
|
+
method :sweep
|
28
|
+
# target => nil (group: default)
|
29
|
+
tag 'field target'
|
30
|
+
tag_prefix 'norikra.query'
|
31
|
+
interval 3
|
32
|
+
}
|
33
|
+
|
34
|
+
fetch {
|
35
|
+
method :event
|
36
|
+
target 'data_count'
|
37
|
+
tag 'string norikra.count.data'
|
38
|
+
interval 5
|
39
|
+
}
|
40
|
+
}
|
41
|
+
|
42
|
+
match('fluent.**') {
|
43
|
+
type :null
|
44
|
+
}
|
45
|
+
|
46
|
+
match('**') {
|
47
|
+
type :stdout
|
48
|
+
}
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |spec|
|
4
4
|
spec.name = "fluent-plugin-norikra"
|
5
|
-
spec.version = "0.0
|
5
|
+
spec.version = "0.1.0"
|
6
6
|
spec.authors = ["TAGOMORI Satoshi"]
|
7
7
|
spec.email = ["tagomoris@gmail.com"]
|
8
8
|
spec.description = %q{process events on fluentd with SQL like query, with built-in Norikra server if needed.}
|
@@ -0,0 +1,75 @@
|
|
1
|
+
require_relative 'norikra/input'
|
2
|
+
|
3
|
+
require 'norikra-client'
|
4
|
+
|
5
|
+
module Fluent
|
6
|
+
class NorikraInput < Fluent::Input
|
7
|
+
include Fluent::NorikraPlugin::InputMixin
|
8
|
+
|
9
|
+
Fluent::Plugin.register_input('norikra', self)
|
10
|
+
|
11
|
+
config_param :norikra, :string, :default => 'localhost:26571'
|
12
|
+
|
13
|
+
config_param :connect_timeout, :integer, :default => nil
|
14
|
+
config_param :send_timeout, :integer, :default => nil
|
15
|
+
config_param :receive_timeout, :integer, :default => nil
|
16
|
+
|
17
|
+
# <fetch> tags
|
18
|
+
# <fetch>
|
19
|
+
# method event
|
20
|
+
# target QUERY_NAME
|
21
|
+
# interval 5s
|
22
|
+
# tag query_name
|
23
|
+
# # tag field FIELDNAME
|
24
|
+
# # tag string FIXED_STRING
|
25
|
+
# tag_prefix norikra.event # actual tag: norikra.event.QUERYNAME
|
26
|
+
# </fetch>
|
27
|
+
# <fetch>
|
28
|
+
# method sweep
|
29
|
+
# target QUERY_GROUP # or unspecified => default
|
30
|
+
# interval 60s
|
31
|
+
# tag field group_by_key
|
32
|
+
# tag_prefix norikra.query
|
33
|
+
# </fetch>
|
34
|
+
|
35
|
+
def configure(conf)
|
36
|
+
super
|
37
|
+
|
38
|
+
@host,@port = @norikra.split(':', 2)
|
39
|
+
@port = @port.to_i
|
40
|
+
|
41
|
+
conf.elements.each do |element|
|
42
|
+
case element.name
|
43
|
+
when 'fetch'
|
44
|
+
# ignore: processed in InputMixin, and set @fetch_queue
|
45
|
+
else
|
46
|
+
raise Fluent::ConfigError, "unknown configuration section name for this plugin: #{element.name}"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
setup_input(conf)
|
51
|
+
end
|
52
|
+
|
53
|
+
def client(opts={})
|
54
|
+
Norikra::Client.new(@host, @port, {
|
55
|
+
:connect_timeout => opts[:connect_timeout] || @connect_timeout,
|
56
|
+
:send_timeout => opts[:send_timeout] || @send_timeout,
|
57
|
+
:receive_timeout => opts[:receive_timeout] || @receive_timeout,
|
58
|
+
})
|
59
|
+
end
|
60
|
+
|
61
|
+
def start
|
62
|
+
super
|
63
|
+
start_input
|
64
|
+
end
|
65
|
+
|
66
|
+
def shutdown
|
67
|
+
stop_input
|
68
|
+
shutdown_input
|
69
|
+
end
|
70
|
+
|
71
|
+
def fetchable?
|
72
|
+
true
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|