fluent-plugin-filter-record-map 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/.rspec +3 -0
- data/.travis.yml +7 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +75 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/fluent-plugin-filter-record-map.gemspec +27 -0
- data/lib/fluent/plugin/filter_record_map.rb +38 -0
- data/lib/fluent_plugin_filter_record_map/version.rb +3 -0
- metadata +114 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 0cb7b8c69d6c985a33f5d9fbec04c755f2d711ca
|
4
|
+
data.tar.gz: c562f157f5a4d8ff2789ccb5b947a9125baa8e54
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 272c1a8f9fe1c1af921d19ccfc4b517e9c16bd1babac6e64233fa87fde3dd8da39ca84dbaa28a09c482ca95ce756cf95da193686ca7b95436cedbb750f42079f
|
7
|
+
data.tar.gz: 462042e80dab6c833805adc4ba7d01d2f06c40f49e8669790547f299217695772e20e90774bf727aed32c4edce6a9e107bc58d0357b4ccec8cdc84aacd7446b8
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Genki Sugawara
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
# fluent-plugin-filter-record-map
|
2
|
+
|
3
|
+
Filter Plugin to create a new record containing the values converted by Ruby script.
|
4
|
+
|
5
|
+
[![Gem Version](https://badge.fury.io/rb/fluent-plugin-filter-record-map.svg)](http://badge.fury.io/rb/fluent-plugin-filter-record-map)
|
6
|
+
[![Build Status](https://travis-ci.org/winebarrel/fluent-plugin-filter-record-map.svg?branch=master)](https://travis-ci.org/winebarrel/fluent-plugin-filter-record-map)
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
Add this line to your application's Gemfile:
|
11
|
+
|
12
|
+
```ruby
|
13
|
+
gem 'fluent-plugin-filter-record-map'
|
14
|
+
```
|
15
|
+
|
16
|
+
And then execute:
|
17
|
+
|
18
|
+
$ bundle
|
19
|
+
|
20
|
+
Or install it yourself as:
|
21
|
+
|
22
|
+
$ gem install fluent-plugin-filter-record-map
|
23
|
+
|
24
|
+
## Configuration
|
25
|
+
|
26
|
+
```apache
|
27
|
+
<filter>
|
28
|
+
type record_map
|
29
|
+
map new_record["new_foo"] = record["foo"]; new_record["new_bar"] = record["bar"]
|
30
|
+
</filter>
|
31
|
+
```
|
32
|
+
|
33
|
+
## Usage
|
34
|
+
|
35
|
+
### Example1
|
36
|
+
|
37
|
+
```apache
|
38
|
+
<filter>
|
39
|
+
type record_map
|
40
|
+
map new_record["new_foo"] = record["foo"].upcase; new_record["new_bar"] = record["bar"].upcase
|
41
|
+
</filter>
|
42
|
+
```
|
43
|
+
|
44
|
+
```sh
|
45
|
+
$ echo '{"foo":"bar", "bar":"zoo"})' | fluentd test.data
|
46
|
+
#=> 2015-01-01 23:34:45 +0900 test.data: {"new_foo":"BAR","new_bar":"ZOO"}
|
47
|
+
```
|
48
|
+
|
49
|
+
### Example2
|
50
|
+
|
51
|
+
```apache
|
52
|
+
<filter>
|
53
|
+
type record_map
|
54
|
+
map record.each {|k, v| new_record[k] = k + "." + v }
|
55
|
+
</filter>
|
56
|
+
```
|
57
|
+
|
58
|
+
```sh
|
59
|
+
$ echo '{"foo":"bar", "bar":"zoo"}' | fluent-cat test.data
|
60
|
+
#=> 2015-01-01 23:34:45 +0900 test.data: {"foo":"foo.bar","bar":"bar.zoo"}
|
61
|
+
```
|
62
|
+
|
63
|
+
### Use `tag`, `tag_parts`
|
64
|
+
|
65
|
+
```apache
|
66
|
+
<filter>
|
67
|
+
type record_map
|
68
|
+
map new_record["tag"] = tag; new_record["new_foo"] = tag_parts[1] + "." + record["foo"]
|
69
|
+
</filter>
|
70
|
+
```
|
71
|
+
|
72
|
+
```sh
|
73
|
+
$ echo '{"foo":"bar", "bar":"zoo"}' | fluent-cat test.data
|
74
|
+
#=> 2015-01-01 23:34:45 +0900 test.data: {"tag":"test.data","new_foo":"data.foo"}
|
75
|
+
```
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "fluent/plugin/filter/simple/map"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'fluent_plugin_filter_record_map/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'fluent-plugin-filter-record-map'
|
8
|
+
spec.version = FluentPluginFilterSimpleMap::VERSION
|
9
|
+
spec.authors = ['Genki Sugawara']
|
10
|
+
spec.email = ['sgwr_dts@yahoo.co.jp']
|
11
|
+
|
12
|
+
spec.summary = %q{Filter Plugin to create a new record containing the values converted by Ruby script.}
|
13
|
+
spec.description = %q{Filter Plugin to create a new record containing the values converted by Ruby script.}
|
14
|
+
spec.homepage = 'https://github.com/winebarrel/fluent-plugin-filter-record-map'
|
15
|
+
spec.license = 'MIT'
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.bindir = 'exe'
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ['lib']
|
21
|
+
|
22
|
+
spec.add_dependency 'fluentd', '>= 0.12'
|
23
|
+
|
24
|
+
spec.add_development_dependency 'bundler'
|
25
|
+
spec.add_development_dependency 'rake'
|
26
|
+
spec.add_development_dependency 'rspec', '>= 3.0.0'
|
27
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'fluent_plugin_filter_record_map/version'
|
2
|
+
|
3
|
+
module Fluent
|
4
|
+
class RecordMapFilter < Filter
|
5
|
+
class Context
|
6
|
+
def context(tag, record)
|
7
|
+
tag_parts = tag.split('.')
|
8
|
+
new_record = {}
|
9
|
+
binding
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
Plugin.register_filter('record_map', self)
|
14
|
+
|
15
|
+
config_param :map, :string
|
16
|
+
|
17
|
+
def configure(conf)
|
18
|
+
super
|
19
|
+
@context = Context.new
|
20
|
+
end
|
21
|
+
|
22
|
+
def filter_stream(tag, es)
|
23
|
+
result_es = Fluent::MultiEventStream.new
|
24
|
+
|
25
|
+
es.each do |time, record|
|
26
|
+
bind = @context.context(tag, record)
|
27
|
+
eval(@map, bind)
|
28
|
+
new_record = eval('new_record', bind)
|
29
|
+
result_es.add(time, new_record)
|
30
|
+
end
|
31
|
+
|
32
|
+
result_es
|
33
|
+
rescue => e
|
34
|
+
log.warn e.message
|
35
|
+
log.warn e.backtrace.join(', ')
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
metadata
ADDED
@@ -0,0 +1,114 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fluent-plugin-filter-record-map
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Genki Sugawara
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-07-12 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: fluentd
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.12'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.12'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 3.0.0
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 3.0.0
|
69
|
+
description: Filter Plugin to create a new record containing the values converted
|
70
|
+
by Ruby script.
|
71
|
+
email:
|
72
|
+
- sgwr_dts@yahoo.co.jp
|
73
|
+
executables: []
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- .gitignore
|
78
|
+
- .rspec
|
79
|
+
- .travis.yml
|
80
|
+
- Gemfile
|
81
|
+
- LICENSE.txt
|
82
|
+
- README.md
|
83
|
+
- Rakefile
|
84
|
+
- bin/console
|
85
|
+
- bin/setup
|
86
|
+
- fluent-plugin-filter-record-map.gemspec
|
87
|
+
- lib/fluent/plugin/filter_record_map.rb
|
88
|
+
- lib/fluent_plugin_filter_record_map/version.rb
|
89
|
+
homepage: https://github.com/winebarrel/fluent-plugin-filter-record-map
|
90
|
+
licenses:
|
91
|
+
- MIT
|
92
|
+
metadata: {}
|
93
|
+
post_install_message:
|
94
|
+
rdoc_options: []
|
95
|
+
require_paths:
|
96
|
+
- lib
|
97
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
104
|
+
- - '>='
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: '0'
|
107
|
+
requirements: []
|
108
|
+
rubyforge_project:
|
109
|
+
rubygems_version: 2.0.14
|
110
|
+
signing_key:
|
111
|
+
specification_version: 4
|
112
|
+
summary: Filter Plugin to create a new record containing the values converted by Ruby
|
113
|
+
script.
|
114
|
+
test_files: []
|