fluent-plugin-yohoushi 0.0.1
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 +7 -0
- data/.gitignore +13 -0
- data/.pryrc +5 -0
- data/.rspec +2 -0
- data/.travis.yml +6 -0
- data/CHANGELOG.md +0 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +104 -0
- data/Rakefile +15 -0
- data/fluent-plugin-yohoushi.gemspec +28 -0
- data/lib/fluent/plugin/out_yohoushi.rb +137 -0
- data/spec/out_yohoushi_spec.rb +140 -0
- data/spec/spec_helper.rb +16 -0
- metadata +157 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ba86fd85bd4b6e256ffb4f1633d8944a274307b8
|
4
|
+
data.tar.gz: 51a4a9f99f7055d49f42e4af253730f4a215560b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: fa06329d4f0d24d58360a874b8346365ceae60c467898c3f9d819b12a6d821591832a39826fc7a50e425716f1d51cae774e0bfb6d495129a50d820b17b71c662
|
7
|
+
data.tar.gz: 5975b9820caef9e28a7cff8fbe17a691ef483011df0f4be7ec6a9e9ade6f6993720d5924f647902cc2f4785dd1c466b4f13697c46a1980a9305873c729914d5d
|
data/.gitignore
ADDED
data/.pryrc
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CHANGELOG.md
ADDED
File without changes
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Naotoshi SEO
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,104 @@
|
|
1
|
+
# fluent-plugin-yohoushi [](http://travis-ci.org/sonots/fluent-plugin-yohoushi) [](https://gemnasium.com/sonots/fluent-plugin-yohoushi)
|
2
|
+
|
3
|
+
Fluentd plugin to post data to yohoushi where [yohoushi](http://yohoushi.github.io/yohoushi/) is a visualization graph tool.
|
4
|
+
|
5
|
+
## Configuration
|
6
|
+
|
7
|
+
<match foo.bar.**>
|
8
|
+
type yohoushi
|
9
|
+
base_uri http://yohoushi.local:4804
|
10
|
+
key1 foo_count /foobar/foo_count
|
11
|
+
key2 bar_count /foobar/bar_count
|
12
|
+
</source>
|
13
|
+
|
14
|
+
Assuming following inputs are coming:
|
15
|
+
|
16
|
+
foo.bar: {"foo_count":1,"bar_count":2}
|
17
|
+
|
18
|
+
then fluent-plugin-yohoushi posts data to yohoshi similarly like
|
19
|
+
|
20
|
+
$ curl -d number=1 http://yohoushi.local:4804/api/graphs/foobar/foo_count
|
21
|
+
$ curl -d number=2 http://yohoushi.local:4804/api/graphs/foobar/bar_count
|
22
|
+
|
23
|
+
## Parameters
|
24
|
+
|
25
|
+
- base\_uri (semi-required)
|
26
|
+
|
27
|
+
The base uri of yohoushi. `mapping1` or `base_uri` is required.
|
28
|
+
|
29
|
+
- mapping\[1-20\] (semi-required)
|
30
|
+
|
31
|
+
This is an option for [multiforecast-client](https://github.com/yohoushi/multiforecast-client). `mapping1` or `base_uri` is required.
|
32
|
+
|
33
|
+
With this option, you can post graph data directly to multiple growthforecasts, not via yohoushi, which is more efficient.
|
34
|
+
|
35
|
+
ex)
|
36
|
+
|
37
|
+
mapping1 /foobar http://growthforecast1.local:5125
|
38
|
+
mapping2 / http://growthforecast2.local:5125
|
39
|
+
|
40
|
+
- key\[1-20\] (semi-required)
|
41
|
+
|
42
|
+
A pair of a field name of the input record, and a graph path to be posted. `key1` or `key_pattern` is required.
|
43
|
+
|
44
|
+
SECRET TRICK: You can use placeholders for the graph path. See Placeholders section.
|
45
|
+
|
46
|
+
- key\_pattern (semi-requierd)
|
47
|
+
|
48
|
+
A pair of a regular expression to specify field names of the input record, and an expression to specify graph paths. `key1` or `key_pattern` is required.
|
49
|
+
|
50
|
+
For example, a configuration like
|
51
|
+
|
52
|
+
key_pattern _count$ /foobar/${key}
|
53
|
+
|
54
|
+
instead of key1, key2 in the above example gives the same effect.
|
55
|
+
|
56
|
+
$ curl -d number=1 http://yohoushi.local:4804/api/graphs/foobar/foo_count
|
57
|
+
$ curl -d number=2 http://yohoushi.local:4804/api/graphs/foobar/bar_count
|
58
|
+
|
59
|
+
See Placeholders section to know more about placeholders such as ${key}.
|
60
|
+
|
61
|
+
- enable\_float\_number
|
62
|
+
|
63
|
+
Set to `true` if you are enabling `--enable_float_number` option of GrowthForecast. Default is `false`
|
64
|
+
|
65
|
+
- mode
|
66
|
+
|
67
|
+
The graph mode (either of gauge, count, or modified). Just same as mode of GrowthForecast POST parameter. Default is gauge.
|
68
|
+
|
69
|
+
### Placeholders
|
70
|
+
|
71
|
+
The keys of input json are available as placeholders. In the above example,
|
72
|
+
|
73
|
+
* ${foo_count}
|
74
|
+
* ${bar_count}
|
75
|
+
|
76
|
+
shall be available. In addition, following placeholders are reserved:
|
77
|
+
|
78
|
+
* ${hostname} hostname
|
79
|
+
* ${tag} input tag
|
80
|
+
* ${tags} input tag splitted by '.'
|
81
|
+
* ${time} time of the event
|
82
|
+
* ${key} the matched key value with `key_pattern` or `key1`, `key2`, ...
|
83
|
+
|
84
|
+
It is also possible to write a ruby code in placeholders, so you may write some codes as
|
85
|
+
|
86
|
+
* ${time.strftime('%Y-%m-%dT%H:%M:%S%z')}
|
87
|
+
* ${tags.last}
|
88
|
+
|
89
|
+
## ChangeLog
|
90
|
+
|
91
|
+
See [CHANGELOG.md](CHANGELOG.md) for details.
|
92
|
+
|
93
|
+
## Contributing
|
94
|
+
|
95
|
+
1. Fork it
|
96
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
97
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
98
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
99
|
+
5. Create new [Pull Request](../../pull/new/master)
|
100
|
+
|
101
|
+
## Copyright
|
102
|
+
|
103
|
+
Copyright (c) 2013 Naotoshi SEO. See [LICENSE](LICENSE) for details.
|
104
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require "bundler/gem_tasks"
|
3
|
+
|
4
|
+
require 'rspec/core'
|
5
|
+
require 'rspec/core/rake_task'
|
6
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
7
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
8
|
+
end
|
9
|
+
task :default => :spec
|
10
|
+
|
11
|
+
desc 'Open an irb session preloaded with the gem library'
|
12
|
+
task :console do
|
13
|
+
sh 'irb -rubygems -I lib'
|
14
|
+
end
|
15
|
+
task :c => :console
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = "fluent-plugin-yohoushi"
|
6
|
+
s.version = "0.0.1"
|
7
|
+
s.authors = ["Naotoshi Seo"]
|
8
|
+
s.email = ["sonots@gmail.com"]
|
9
|
+
s.homepage = "https://github.com/sonots/fluent-plugin-yohoushi"
|
10
|
+
s.summary = "fluentd plugin to post data to yohoushi"
|
11
|
+
s.description = s.summary
|
12
|
+
|
13
|
+
s.rubyforge_project = "fluent-plugin-yohoushi"
|
14
|
+
|
15
|
+
s.files = `git ls-files`.split("\n")
|
16
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
17
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
18
|
+
s.require_paths = ["lib"]
|
19
|
+
|
20
|
+
s.add_runtime_dependency "fluentd"
|
21
|
+
s.add_runtime_dependency "multiforecast-client"
|
22
|
+
s.add_runtime_dependency "yohoushi-client"
|
23
|
+
|
24
|
+
s.add_development_dependency "rake"
|
25
|
+
s.add_development_dependency "rspec"
|
26
|
+
s.add_development_dependency "pry"
|
27
|
+
s.add_development_dependency "pry-nav"
|
28
|
+
end
|
@@ -0,0 +1,137 @@
|
|
1
|
+
class Fluent::YohoushiOutput < Fluent::Output
|
2
|
+
Fluent::Plugin.register_output('yohoushi', self)
|
3
|
+
|
4
|
+
MAPPING_MAX_NUM = 20
|
5
|
+
KEY_MAX_NUM = 20
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
super
|
9
|
+
require 'socket'
|
10
|
+
require 'multiforecast-client'
|
11
|
+
require 'yohoushi-client'
|
12
|
+
end
|
13
|
+
|
14
|
+
config_param :base_uri, :string, :default => nil
|
15
|
+
(1..MAPPING_MAX_NUM).each {|i| config_param "mapping#{i}".to_sym, :string, :default => nil }
|
16
|
+
config_param :key_pattern, :string, :default => nil
|
17
|
+
(1..KEY_MAX_NUM).each {|i| config_param "key#{i}".to_sym, :string, :default => nil }
|
18
|
+
config_param :enable_float_number, :bool, :default => false
|
19
|
+
config_param :mode, :default => :gauge do |val|
|
20
|
+
case val.downcase
|
21
|
+
when 'gauge'
|
22
|
+
:gauge
|
23
|
+
when 'count'
|
24
|
+
:count
|
25
|
+
when 'modified'
|
26
|
+
:modified
|
27
|
+
else
|
28
|
+
raise ConfigError, "stdout output output_type should be `gauge`, `count`, or `modified`"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
# for test
|
33
|
+
attr_reader :client
|
34
|
+
attr_reader :mapping
|
35
|
+
attr_reader :keys
|
36
|
+
attr_reader :key_pattern
|
37
|
+
attr_reader :key_pattern_path
|
38
|
+
|
39
|
+
def configure(conf)
|
40
|
+
super
|
41
|
+
|
42
|
+
if @base_uri
|
43
|
+
@client = Yohoushi::Client.new(@base_uri)
|
44
|
+
else
|
45
|
+
@mapping = {}
|
46
|
+
(1..MAPPING_MAX_NUM).each do |i|
|
47
|
+
next unless conf["mapping#{i}"]
|
48
|
+
from, to = conf["mapping#{i}"].split(/ +/, 2)
|
49
|
+
raise Fluent::ConfigError, "mapping#{i} does not contain 2 parameters" unless to
|
50
|
+
@mapping[from] = to
|
51
|
+
end
|
52
|
+
@client = MultiForecast::Client.new('mapping' => @mapping) unless @mapping.empty?
|
53
|
+
end
|
54
|
+
raise Fluent::ConfigError, "Either of `base_uri` or `mapping1` must be specified" unless @client
|
55
|
+
|
56
|
+
if @key_pattern
|
57
|
+
key_pattern, @key_pattern_path = @key_pattern.split(/ +/, 2)
|
58
|
+
raise Fluent::ConfigError, "key_pattern does not contain 2 parameters" unless @key_pattern_path
|
59
|
+
@key_pattern = Regexp.compile(key_pattern)
|
60
|
+
else
|
61
|
+
@keys = {}
|
62
|
+
(1..KEY_MAX_NUM).each do |i|
|
63
|
+
next unless conf["key#{i}"]
|
64
|
+
key, path = conf["key#{i}"].split(/ +/, 2)
|
65
|
+
raise Fluent::ConfigError, "key#{i} does not contain 2 parameters" unless path
|
66
|
+
@keys[key] = path
|
67
|
+
end
|
68
|
+
end
|
69
|
+
raise Fluent::ConfigError, "Either of `key_pattern` or `key1` must be specified" if (@key_pattern.nil? and @keys.empty?)
|
70
|
+
|
71
|
+
@hostname = Socket.gethostname
|
72
|
+
rescue => e
|
73
|
+
raise Fluent::ConfigError, "#{e.class} #{e.message} #{e.backtrace.first}"
|
74
|
+
end
|
75
|
+
|
76
|
+
def start
|
77
|
+
super
|
78
|
+
end
|
79
|
+
|
80
|
+
def shutdown
|
81
|
+
super
|
82
|
+
end
|
83
|
+
|
84
|
+
def post(path, number)
|
85
|
+
if @enable_float_number
|
86
|
+
@client.post_graph(path, { 'number' => number.to_f, 'mode' => @mode.to_s })
|
87
|
+
else
|
88
|
+
@client.post_graph(path, { 'number' => number.to_i, 'mode' => @mode.to_s })
|
89
|
+
end
|
90
|
+
rescue => e
|
91
|
+
$log.warn "out_yohoushi: #{e.class} #{e.message} #{e.backtrace.first}"
|
92
|
+
end
|
93
|
+
|
94
|
+
def emit(tag, es, chain)
|
95
|
+
tags = tag.split('.')
|
96
|
+
if @key_pattern
|
97
|
+
es.each do |time, record|
|
98
|
+
record.each do |key, value|
|
99
|
+
next unless key =~ @key_pattern
|
100
|
+
path = expand_placeholder(@key_pattern_path, record, tag, tags, time, key)
|
101
|
+
post(path, value)
|
102
|
+
end
|
103
|
+
end
|
104
|
+
else # keys
|
105
|
+
es.each do |time, record|
|
106
|
+
@keys.each do |key, path|
|
107
|
+
next unless value = record[key]
|
108
|
+
path = expand_placeholder(path, record, tag, tags, time, key)
|
109
|
+
post(path, value)
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
chain.next
|
115
|
+
rescue => e
|
116
|
+
$log.warn "out_yohoushi: #{e.class} #{e.message} #{e.backtrace.first}"
|
117
|
+
end
|
118
|
+
|
119
|
+
private
|
120
|
+
|
121
|
+
def expand_placeholder(str, record, tag, tags, time, key)
|
122
|
+
struct = UndefOpenStruct.new(record)
|
123
|
+
struct.tag = tag
|
124
|
+
struct.tags = tags
|
125
|
+
struct.time = time
|
126
|
+
struct.key = key
|
127
|
+
struct.hostname = @hostname
|
128
|
+
str = str.gsub(/\$\{([^}]+)\}/, '#{\1}') # ${..} => #{..}
|
129
|
+
eval "\"#{str}\"", struct.instance_eval { binding }
|
130
|
+
end
|
131
|
+
|
132
|
+
class UndefOpenStruct < OpenStruct
|
133
|
+
(Object.instance_methods).each do |m|
|
134
|
+
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/
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
@@ -0,0 +1,140 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
require_relative 'spec_helper'
|
3
|
+
|
4
|
+
shared_context "stub_yohoushi_post_graph" do |path|
|
5
|
+
before do
|
6
|
+
stub_request(:post, "#{yohoushi_base_uri}/api/graphs/#{path}").
|
7
|
+
to_return(:status => 200, :body => { "error" => 0, "data" => "blahblah" }.to_json)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
shared_context "stub_growthforecast_post_graph" do |path|
|
11
|
+
before do
|
12
|
+
stub_request(:post, "#{growthforecast_base_uri}/api/#{path}").
|
13
|
+
to_return(:status => 200, :body => { "error" => 0, "data" => "blahblah" }.to_json)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe Fluent::YohoushiOutput do
|
18
|
+
before { Fluent::Test.setup }
|
19
|
+
let(:yohoushi_base_uri) { 'http://localhost:4804' }
|
20
|
+
let(:growthforecast_base_uri) { 'http://localhost:5125' }
|
21
|
+
let(:tag) { 'test' }
|
22
|
+
let(:driver) { Fluent::Test::OutputTestDriver.new(Fluent::YohoushiOutput, tag).configure(config) }
|
23
|
+
let(:emit) { driver.run { messages.each {|message| driver.emit(message, time) } } }
|
24
|
+
|
25
|
+
describe 'test configure' do
|
26
|
+
context "empty" do
|
27
|
+
let(:config) { '' }
|
28
|
+
it { expect { driver }.to raise_error(Fluent::ConfigError) }
|
29
|
+
end
|
30
|
+
|
31
|
+
context "no uri" do
|
32
|
+
let(:config) { %[key1 foo_count /foobar/foo_count] }
|
33
|
+
it { expect { driver }.to raise_error(Fluent::ConfigError) }
|
34
|
+
end
|
35
|
+
|
36
|
+
context "no keys" do
|
37
|
+
let(:config) { %[base_uri #{yohoushi_base_uri}] }
|
38
|
+
it { expect { driver }.to raise_error(Fluent::ConfigError) }
|
39
|
+
end
|
40
|
+
|
41
|
+
context "base_uri" do
|
42
|
+
subject { driver.instance }
|
43
|
+
let(:config) {%[
|
44
|
+
base_uri #{yohoushi_base_uri}
|
45
|
+
key1 foo_count /foobar/foo_count
|
46
|
+
]}
|
47
|
+
it { subject.client.class == Yohoushi::Client }
|
48
|
+
end
|
49
|
+
|
50
|
+
context "mapping" do
|
51
|
+
subject { driver.instance }
|
52
|
+
let(:config) {%[
|
53
|
+
mapping1 / #{growthforecast_base_uri}
|
54
|
+
key1 foo_count /foobar/foo_count
|
55
|
+
]}
|
56
|
+
it { subject.client.class == GrowthForecast::Client }
|
57
|
+
end
|
58
|
+
|
59
|
+
context "keys" do
|
60
|
+
subject { driver.instance }
|
61
|
+
let(:config) {%[
|
62
|
+
base_uri #{yohoushi_base_uri}
|
63
|
+
key1 foo_count /foobar/foo_count
|
64
|
+
key2 bar_count /foobar/bar_count
|
65
|
+
]}
|
66
|
+
it { subject.keys["foo_count"].should == "/foobar/foo_count" }
|
67
|
+
it { subject.keys["bar_count"].should == "/foobar/bar_count" }
|
68
|
+
end
|
69
|
+
|
70
|
+
context "key_pattern" do
|
71
|
+
subject { driver.instance }
|
72
|
+
let(:config) {%[
|
73
|
+
base_uri #{yohoushi_base_uri}
|
74
|
+
key_pattern _count$ /foobar/${key}
|
75
|
+
]}
|
76
|
+
it { subject.key_pattern.should == Regexp.compile("_count$") }
|
77
|
+
it { subject.key_pattern_path.should == "/foobar/${key}" }
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
describe 'test emit' do
|
82
|
+
let(:time) { Time.now.to_i }
|
83
|
+
let(:messages) do
|
84
|
+
[
|
85
|
+
{ 'foo_count' => "1", 'bar_count' => "1" },
|
86
|
+
{ 'foo_count' => "2", 'bar_count' => "2" },
|
87
|
+
]
|
88
|
+
end
|
89
|
+
|
90
|
+
context 'base_uri and keys' do
|
91
|
+
let(:config) {%[
|
92
|
+
base_uri #{yohoushi_base_uri}
|
93
|
+
key1 foo_count /path/to/foo_count
|
94
|
+
key2 bar_count /path/to/bar_count
|
95
|
+
]}
|
96
|
+
|
97
|
+
include_context "stub_yohoushi_post_graph", "path/to/foo_count" unless ENV["MOCK"] == "off"
|
98
|
+
include_context "stub_yohoushi_post_graph", "path/to/bar_count" unless ENV["MOCK"] == "off"
|
99
|
+
before { Fluent::Engine.stub(:now).and_return(time) }
|
100
|
+
it { emit }
|
101
|
+
end
|
102
|
+
|
103
|
+
context 'base_uri and key_pattern' do
|
104
|
+
let(:config) {%[
|
105
|
+
base_uri #{yohoushi_base_uri}
|
106
|
+
key_pattern _count$ /path/to/${key}
|
107
|
+
]}
|
108
|
+
|
109
|
+
include_context "stub_yohoushi_post_graph", "path/to/foo_count" unless ENV["MOCK"] == "off"
|
110
|
+
include_context "stub_yohoushi_post_graph", "path/to/bar_count" unless ENV["MOCK"] == "off"
|
111
|
+
before { Fluent::Engine.stub(:now).and_return(time) }
|
112
|
+
it { emit }
|
113
|
+
end
|
114
|
+
|
115
|
+
context 'mapping and keys' do
|
116
|
+
let(:config) {%[
|
117
|
+
mapping1 / #{growthforecast_base_uri}
|
118
|
+
key1 foo_count /path/to/${key}
|
119
|
+
key2 bar_count /path/to/${key}
|
120
|
+
]}
|
121
|
+
|
122
|
+
include_context "stub_growthforecast_post_graph", "path/to/foo_count" unless ENV["MOCK"] == "off"
|
123
|
+
include_context "stub_growthforecast_post_graph", "path/to/bar_count" unless ENV["MOCK"] == "off"
|
124
|
+
before { Fluent::Engine.stub(:now).and_return(time) }
|
125
|
+
it { emit }
|
126
|
+
end
|
127
|
+
|
128
|
+
context 'maping and key_pattern' do
|
129
|
+
let(:config) {%[
|
130
|
+
mapping1 / #{growthforecast_base_uri}
|
131
|
+
key_pattern _count$ /path/to/${key}
|
132
|
+
]}
|
133
|
+
|
134
|
+
include_context "stub_growthforecast_post_graph", "path/to/foo_count" unless ENV["MOCK"] == "off"
|
135
|
+
include_context "stub_growthforecast_post_graph", "path/to/bar_count" unless ENV["MOCK"] == "off"
|
136
|
+
before { Fluent::Engine.stub(:now).and_return(time) }
|
137
|
+
it { emit }
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
require 'rubygems'
|
3
|
+
require 'bundler'
|
4
|
+
Bundler.setup(:default, :test)
|
5
|
+
Bundler.require(:default, :test)
|
6
|
+
|
7
|
+
require 'fluent/test'
|
8
|
+
require 'rspec'
|
9
|
+
require 'pry'
|
10
|
+
require 'multiforecast-client'
|
11
|
+
require 'webmock/rspec'
|
12
|
+
WebMock.allow_net_connect! if ENV['MOCK'] == 'off'
|
13
|
+
|
14
|
+
$TESTING=true
|
15
|
+
$:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
|
16
|
+
require 'fluent/plugin/out_yohoushi'
|
metadata
ADDED
@@ -0,0 +1,157 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fluent-plugin-yohoushi
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Naotoshi Seo
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-08-29 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'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: multiforecast-client
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
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: yohoushi-client
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
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: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
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
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: pry
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: pry-nav
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
description: fluentd plugin to post data to yohoushi
|
112
|
+
email:
|
113
|
+
- sonots@gmail.com
|
114
|
+
executables: []
|
115
|
+
extensions: []
|
116
|
+
extra_rdoc_files: []
|
117
|
+
files:
|
118
|
+
- .gitignore
|
119
|
+
- .pryrc
|
120
|
+
- .rspec
|
121
|
+
- .travis.yml
|
122
|
+
- CHANGELOG.md
|
123
|
+
- Gemfile
|
124
|
+
- LICENSE
|
125
|
+
- README.md
|
126
|
+
- Rakefile
|
127
|
+
- fluent-plugin-yohoushi.gemspec
|
128
|
+
- lib/fluent/plugin/out_yohoushi.rb
|
129
|
+
- spec/out_yohoushi_spec.rb
|
130
|
+
- spec/spec_helper.rb
|
131
|
+
homepage: https://github.com/sonots/fluent-plugin-yohoushi
|
132
|
+
licenses: []
|
133
|
+
metadata: {}
|
134
|
+
post_install_message:
|
135
|
+
rdoc_options: []
|
136
|
+
require_paths:
|
137
|
+
- lib
|
138
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
139
|
+
requirements:
|
140
|
+
- - '>='
|
141
|
+
- !ruby/object:Gem::Version
|
142
|
+
version: '0'
|
143
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
144
|
+
requirements:
|
145
|
+
- - '>='
|
146
|
+
- !ruby/object:Gem::Version
|
147
|
+
version: '0'
|
148
|
+
requirements: []
|
149
|
+
rubyforge_project: fluent-plugin-yohoushi
|
150
|
+
rubygems_version: 2.0.2
|
151
|
+
signing_key:
|
152
|
+
specification_version: 4
|
153
|
+
summary: fluentd plugin to post data to yohoushi
|
154
|
+
test_files:
|
155
|
+
- spec/out_yohoushi_spec.rb
|
156
|
+
- spec/spec_helper.rb
|
157
|
+
has_rdoc:
|