fluent-plugin-replace 0.0.1 → 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 +16 -3
- data/lib/fluent/plugin/out_replace.rb +10 -3
- data/lib/fluent/plugin/replace/version.rb +1 -1
- 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: 075291576f6796e35260172cc9fc7c6ddefa7bef
|
4
|
+
data.tar.gz: ec0e00fff4f88c632da5cd148f069e8b5c2c85b1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ea8f93f547c4b53b0372c802db9e8526890f3c1a60ba8e236af99916cc4c9197c2bce0884ad0fbf7793fe0ba8d6c2a1c96d9b2cecc1c13a77cf634430484e95d
|
7
|
+
data.tar.gz: b7d47b0067f12fe99a9149b94fd0c1d67a9919d06c9a727d134d7e5ab9ca7d597bbd87bb460322f7c930cb3dab924c777d886d4e339ec8c1515082fe6b5480cf
|
data/README.md
CHANGED
@@ -26,10 +26,23 @@ $ gem install fluent-plugin-replace
|
|
26
26
|
# test_rules.yml
|
27
27
|
|
28
28
|
ip:
|
29
|
-
|
29
|
+
127.0.0.1: 'localhost'
|
30
|
+
/^192\.168.*$/: 'private network'
|
31
|
+
|
32
|
+
host:
|
33
|
+
/.*\.sakigakeweb\.com$/: 'Old Domain'
|
34
|
+
|
35
|
+
status:
|
36
|
+
200: 'OK'
|
37
|
+
|
38
|
+
referer:
|
39
|
+
/http:\/\/kaihar4\.com/: ''
|
30
40
|
```
|
31
41
|
|
32
42
|
```
|
33
|
-
$ echo '{"ip":"127.0.0.1","host":"
|
34
|
-
{"ip":"localhost","host":"
|
43
|
+
$ echo '{"ip":"127.0.0.1","host":"kaihar4.com","status":200,"referer":"http://kaihar4.com/about.html"}' | fluent-cat test
|
44
|
+
{"ip":"localhost","host":"kaihar4.com","status","OK","referer":"/about.html"}
|
45
|
+
|
46
|
+
$ echo '{"ip":"192.168.1.2","host":"foo.sakigakeweb.com","status":404,"referer":"https://www.google.co.jp/"}' | fluent-cat test
|
47
|
+
{"ip":"private network","host":"Old Domain","status":404,"referer":"https://www.google.co.jp/"}
|
35
48
|
```
|
@@ -18,9 +18,16 @@ class Fluent::ReplaceOutput < Fluent::Output
|
|
18
18
|
|
19
19
|
es.each do |time, record|
|
20
20
|
begin
|
21
|
-
@rules.each do |key,
|
22
|
-
|
23
|
-
|
21
|
+
@rules.each do |key, rule|
|
22
|
+
target = record[key].to_s
|
23
|
+
|
24
|
+
rule.each do |from, to|
|
25
|
+
if match_data = from.to_s.match(/\/(?<pattern>.+)\//)
|
26
|
+
pattern = Regexp.new(match_data[:pattern])
|
27
|
+
record[key] = target.gsub(pattern, to) if target.match(pattern)
|
28
|
+
else
|
29
|
+
record[key] = to if from.to_s == target
|
30
|
+
end
|
24
31
|
end
|
25
32
|
end
|
26
33
|
rescue
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-replace
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kaihar4
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-02-
|
11
|
+
date: 2015-02-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|