fluent-plugin-yohoushi 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +4 -3
- data/fluent-plugin-yohoushi.gemspec +1 -1
- data/lib/fluent/plugin/out_yohoushi.rb +6 -7
- data/spec/out_yohoushi_spec.rb +19 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e999a6aedf4bd3f07f2a40298b9826da39a5dd68
|
4
|
+
data.tar.gz: abd025986465c4ee61f437f656a2439c6f12d3d0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7ba26bb0f27b83ac24b059e24989e12097b5cf8e5f50b039da0059e85952856820c5082f5d474fd1767180fa27363be9e553c7af308987ab2a5779a544d8954c
|
7
|
+
data.tar.gz: 48f200e029d13f71655c13bf18301616aa80eb66ce69c289a0af0f199e7542a902e641eebb013c9458f406180279fd3c3c9b2dfc495d2f78bcb705114f080f76
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# fluent-plugin-yohoushi [![Build Status](https://secure.travis-ci.org/
|
1
|
+
# fluent-plugin-yohoushi [![Build Status](https://secure.travis-ci.org/yohoushi/fluent-plugin-yohoushi.png?branch=master)](http://travis-ci.org/sonots/fluent-plugin-yohoushi) [![Dependency Status](https://gemnasium.com/yohoushi/fluent-plugin-yohoushi.png)](https://gemnasium.com/yohoushi/fluent-plugin-yohoushi)
|
2
2
|
|
3
3
|
Fluentd plugin to post data to yohoushi where [yohoushi](http://yohoushi.github.io/yohoushi/) is a visualization graph tool.
|
4
4
|
|
@@ -77,14 +77,15 @@ shall be available. In addition, following placeholders are reserved:
|
|
77
77
|
|
78
78
|
* ${hostname} hostname
|
79
79
|
* ${tag} input tag
|
80
|
-
* ${
|
80
|
+
* ${tag\_parts} input tag splitted by '.'
|
81
|
+
* ${tags} input tag splitted by '.' (obsolete)
|
81
82
|
* ${time} time of the event
|
82
83
|
* ${key} the matched key value with `key_pattern` or `key1`, `key2`, ...
|
83
84
|
|
84
85
|
It is also possible to write a ruby code in placeholders, so you may write some codes as
|
85
86
|
|
86
87
|
* ${time.strftime('%Y-%m-%dT%H:%M:%S%z')}
|
87
|
-
* ${
|
88
|
+
* ${tag\_parts.last}
|
88
89
|
|
89
90
|
## ChangeLog
|
90
91
|
|
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "fluent-plugin-yohoushi"
|
6
|
-
s.version = "0.0.
|
6
|
+
s.version = "0.0.3"
|
7
7
|
s.authors = ["Naotoshi Seo"]
|
8
8
|
s.email = ["sonots@gmail.com"]
|
9
9
|
s.homepage = "https://github.com/sonots/fluent-plugin-yohoushi"
|
@@ -94,12 +94,12 @@ class Fluent::YohoushiOutput < Fluent::Output
|
|
94
94
|
end
|
95
95
|
|
96
96
|
def emit(tag, es, chain)
|
97
|
-
|
97
|
+
tag_parts = tag.split('.')
|
98
98
|
if @key_pattern
|
99
99
|
es.each do |time, record|
|
100
100
|
record.each do |key, value|
|
101
101
|
next unless key =~ @key_pattern
|
102
|
-
path = expand_placeholder(@key_pattern_path, record, tag,
|
102
|
+
path = expand_placeholder(@key_pattern_path, record, tag, tag_parts, time, key)
|
103
103
|
post(path, value)
|
104
104
|
end
|
105
105
|
end
|
@@ -107,7 +107,7 @@ class Fluent::YohoushiOutput < Fluent::Output
|
|
107
107
|
es.each do |time, record|
|
108
108
|
@keys.each do |key, path|
|
109
109
|
next unless value = record[key]
|
110
|
-
path = expand_placeholder(path, record, tag,
|
110
|
+
path = expand_placeholder(path, record, tag, tag_parts, time, key)
|
111
111
|
post(path, value)
|
112
112
|
end
|
113
113
|
end
|
@@ -118,12 +118,11 @@ class Fluent::YohoushiOutput < Fluent::Output
|
|
118
118
|
$log.warn "out_yohoushi: #{e.class} #{e.message} #{e.backtrace.first}"
|
119
119
|
end
|
120
120
|
|
121
|
-
|
122
|
-
|
123
|
-
def expand_placeholder(str, record, tag, tags, time, key)
|
121
|
+
def expand_placeholder(str, record, tag, tag_parts, time, key)
|
124
122
|
struct = UndefOpenStruct.new(record)
|
125
123
|
struct.tag = tag
|
126
|
-
struct.tags =
|
124
|
+
struct.tags = tag_parts # obsolete
|
125
|
+
struct.tag_parts = tag_parts
|
127
126
|
struct.time = time
|
128
127
|
struct.key = key
|
129
128
|
struct.hostname = @hostname
|
data/spec/out_yohoushi_spec.rb
CHANGED
@@ -20,6 +20,7 @@ describe Fluent::YohoushiOutput do
|
|
20
20
|
let(:growthforecast_base_uri) { 'http://localhost:5125' }
|
21
21
|
let(:tag) { 'test' }
|
22
22
|
let(:driver) { Fluent::Test::OutputTestDriver.new(Fluent::YohoushiOutput, tag).configure(config) }
|
23
|
+
let(:instance) { driver.instance }
|
23
24
|
let(:emit) { driver.run { messages.each {|message| driver.emit(message, time) } } }
|
24
25
|
|
25
26
|
describe 'test configure' do
|
@@ -137,4 +138,22 @@ describe Fluent::YohoushiOutput do
|
|
137
138
|
it { emit }
|
138
139
|
end
|
139
140
|
end
|
141
|
+
|
142
|
+
describe 'expand_placeholder' do
|
143
|
+
let(:config) { %[mapping1 / http://foo\nkey1 foo bar] }
|
144
|
+
let(:tag) { 'fluent.error' }
|
145
|
+
let(:record) { { 'foo_count' => "1", 'bar_count' => "1" } }
|
146
|
+
let(:tag_parts) { tag.split('.') }
|
147
|
+
let(:time) { Time.now.to_i }
|
148
|
+
|
149
|
+
context 'tags (obsolete)' do
|
150
|
+
let(:path) { '/path/to/${tags[-1]}' }
|
151
|
+
it { instance.expand_placeholder(path, record, tag, tag_parts, time, 'foo_count').should == '/path/to/error' }
|
152
|
+
end
|
153
|
+
|
154
|
+
context 'tag_parts' do
|
155
|
+
let(:path) { '/path/to/${tag_parts[-1]}' }
|
156
|
+
it { instance.expand_placeholder(path, record, tag, tag_parts, time, 'foo_count').should == '/path/to/error' }
|
157
|
+
end
|
158
|
+
end
|
140
159
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-yohoushi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
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-12-
|
11
|
+
date: 2013-12-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fluentd
|
@@ -148,7 +148,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
148
148
|
version: '0'
|
149
149
|
requirements: []
|
150
150
|
rubyforge_project: fluent-plugin-yohoushi
|
151
|
-
rubygems_version: 2.
|
151
|
+
rubygems_version: 2.0.3
|
152
152
|
signing_key:
|
153
153
|
specification_version: 4
|
154
154
|
summary: fluentd plugin to post data to yohoushi
|