fluent-plugin-record-reformer 0.0.1 → 0.0.2
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/.gitignore +1 -0
- data/CHANGELOG.md +6 -0
- data/README.md +12 -4
- data/fluent-plugin-record-reformer.gemspec +2 -2
- data/lib/fluent/plugin/out_record_reformer.rb +21 -6
- data/spec/spec_helper.rb +0 -3
- metadata +5 -19
- data/.coveralls.yml +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c27a9bd39e4b37a91f5cfaa52afa8fe63b759cd4
|
4
|
+
data.tar.gz: f7847b8ad017df0871c32dc82ca5a87949080bc6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7ad34f1d7fa04e2393c5513bf1821c53572eb4d5de13635bdb00d0aea408996301c59e19ecdb48f0d1640c421d2c88c0b378ba997ce641f0d5feaced6e05cae6
|
7
|
+
data.tar.gz: 3ec3479c687ad1fadb9a0f08ac67225a2c4668440b8b647f3e60a6edb10d44b39a2e5f4a2bf85724a93cfc08642da798a5fe911ed7b10f384fa34460a99f4be2
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
-
# fluent-plugin-record-reformer
|
1
|
+
# fluent-plugin-record-reformer
|
2
2
|
|
3
|
-
|
3
|
+
[](http://travis-ci.org/sonots/fluent-plugin-record-reformer) [](https://gemnasium.com/sonots/fluent-plugin-record-reformer)
|
4
|
+
|
5
|
+
Fluentd pluging to add or replace fields of a event record
|
4
6
|
|
5
7
|
## Installation
|
6
8
|
|
@@ -10,6 +12,8 @@ Use RubyGems:
|
|
10
12
|
|
11
13
|
## Configuration
|
12
14
|
|
15
|
+
Example:
|
16
|
+
|
13
17
|
<match foo.**>
|
14
18
|
type record_reformer
|
15
19
|
output_tag reformed
|
@@ -35,7 +39,7 @@ reformed {
|
|
35
39
|
"time":"2013-05-01T01:13:14Z",
|
36
40
|
"message":"your_hostname bar hello world!",
|
37
41
|
"foo":"bar"
|
38
|
-
|
42
|
+
}
|
39
43
|
```
|
40
44
|
|
41
45
|
### Placeholders
|
@@ -57,9 +61,13 @@ It is also possible to write a ruby code in placeholders, so you may write some
|
|
57
61
|
* ${time.strftime('%Y-%m-%dT%H:%M:%S%z')}
|
58
62
|
* ${tags.last}
|
59
63
|
|
64
|
+
## Notice
|
65
|
+
|
66
|
+
Please note that this plugin enables to execute any ruby codes. Do not allow anyone to write fluentd configuration from outside of your system by security reasons.
|
67
|
+
|
60
68
|
## Relatives
|
61
69
|
|
62
|
-
* [fluent-plugin-record-modifier](https://github.com/repeatedly/fluent-plugin-record-modifier)
|
70
|
+
* inspired by [fluent-plugin-record-modifier](https://github.com/repeatedly/fluent-plugin-record-modifier)
|
63
71
|
|
64
72
|
## ChangeLog
|
65
73
|
|
@@ -3,12 +3,13 @@ $:.push File.expand_path('../lib', __FILE__)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |gem|
|
5
5
|
gem.name = "fluent-plugin-record-reformer"
|
6
|
-
gem.version = "0.0.
|
6
|
+
gem.version = "0.0.2"
|
7
7
|
gem.authors = ["Naotoshi Seo"]
|
8
8
|
gem.email = "sonots@gmail.com"
|
9
9
|
gem.homepage = "https://github.com/sonots/fluent-plugin-record-reformer"
|
10
10
|
gem.description = "Output filter plugin for reforming each event record"
|
11
11
|
gem.summary = gem.description
|
12
|
+
gem.licenses = ["MIT"]
|
12
13
|
gem.has_rdoc = false
|
13
14
|
|
14
15
|
gem.files = `git ls-files`.split("\n")
|
@@ -20,5 +21,4 @@ Gem::Specification.new do |gem|
|
|
20
21
|
gem.add_development_dependency "rake"
|
21
22
|
gem.add_development_dependency "rspec"
|
22
23
|
gem.add_development_dependency "pry"
|
23
|
-
gem.add_development_dependency 'coveralls'
|
24
24
|
end
|
@@ -24,23 +24,32 @@ module Fluent
|
|
24
24
|
def emit(tag, es, chain)
|
25
25
|
tags = tag.split('.')
|
26
26
|
es.each { |time, record|
|
27
|
-
Engine.emit(@output_tag, time,
|
27
|
+
Engine.emit(@output_tag, time, replace_record(record, tag, tags, Time.at(time)))
|
28
28
|
}
|
29
29
|
chain.next
|
30
|
+
rescue => e
|
31
|
+
$log.warn e.message
|
32
|
+
$log.warn e.backtrace.join(', ')
|
30
33
|
end
|
31
34
|
|
32
35
|
private
|
33
36
|
|
34
|
-
def
|
35
|
-
time = Time.at(time)
|
37
|
+
def replace_record(record, tag, tags, time)
|
36
38
|
@map.each_pair { |k, v|
|
37
|
-
record[k] =
|
39
|
+
record[k] = expand_placeholder(v, record, tag, tags, time)
|
38
40
|
}
|
39
41
|
record
|
40
42
|
end
|
41
43
|
|
42
|
-
|
43
|
-
|
44
|
+
# Replace placeholders in a string
|
45
|
+
#
|
46
|
+
# @param [String] str the string to be replaced
|
47
|
+
# @param [Hash] record the record, one of information
|
48
|
+
# @param [String] tag one of information
|
49
|
+
# @param [Array] tags one of information
|
50
|
+
# @param [Time] time one of information
|
51
|
+
def expand_placeholder(str, record, tag, tags, time)
|
52
|
+
struct = UndefOpenStruct.new(record)
|
44
53
|
struct.tag = tag
|
45
54
|
struct.tags = tags
|
46
55
|
struct.time = time
|
@@ -48,5 +57,11 @@ module Fluent
|
|
48
57
|
str = str.gsub(/\$\{([^}]+)\}/, '#{\1}') # ${..} => #{..}
|
49
58
|
eval "\"#{str}\"", struct.instance_eval { binding }
|
50
59
|
end
|
60
|
+
|
61
|
+
class UndefOpenStruct < OpenStruct
|
62
|
+
(Object.instance_methods).each do |m|
|
63
|
+
undef_method m unless m.to_s =~ /^__|respond_to_missing\?|object_id|public_methods|instance_eval|method_missing|define_singleton_method|respond_to\?|new_ostruct_member/
|
64
|
+
end
|
65
|
+
end
|
51
66
|
end
|
52
67
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-record-reformer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Naotoshi Seo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-08-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fluentd
|
@@ -66,27 +66,12 @@ dependencies:
|
|
66
66
|
- - '>='
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: coveralls
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - '>='
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '0'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - '>='
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '0'
|
83
69
|
description: Output filter plugin for reforming each event record
|
84
70
|
email: sonots@gmail.com
|
85
71
|
executables: []
|
86
72
|
extensions: []
|
87
73
|
extra_rdoc_files: []
|
88
74
|
files:
|
89
|
-
- .coveralls.yml
|
90
75
|
- .gitignore
|
91
76
|
- .rspec
|
92
77
|
- .travis.yml
|
@@ -100,7 +85,8 @@ files:
|
|
100
85
|
- spec/out_record_expander_spec.rb
|
101
86
|
- spec/spec_helper.rb
|
102
87
|
homepage: https://github.com/sonots/fluent-plugin-record-reformer
|
103
|
-
licenses:
|
88
|
+
licenses:
|
89
|
+
- MIT
|
104
90
|
metadata: {}
|
105
91
|
post_install_message:
|
106
92
|
rdoc_options: []
|
@@ -118,7 +104,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
118
104
|
version: '0'
|
119
105
|
requirements: []
|
120
106
|
rubyforge_project:
|
121
|
-
rubygems_version: 2.0.
|
107
|
+
rubygems_version: 2.0.2
|
122
108
|
signing_key:
|
123
109
|
specification_version: 4
|
124
110
|
summary: Output filter plugin for reforming each event record
|
data/.coveralls.yml
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
repo_token: i4DJCtdksuIwhBck1tukIjzKoMCxWIIvQ
|