adp-fluent-plugin-graphite 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +32 -0
- data/.travis.yml +12 -0
- data/Gemfile +3 -0
- data/LICENSE +20 -0
- data/README.md +145 -0
- data/Rakefile +11 -0
- data/adp-fluent-plugin-graphite.gemspec +25 -0
- data/lib/fluent/plugin/out_graphite.rb +116 -0
- data/test/helper.rb +29 -0
- data/test/plugin/test_out_graphite.rb +131 -0
- metadata +124 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 66ea8fa9a5c94707aeb094d4615bc5868d30b3a84a2a1df2918fe7f38b7d687e
|
4
|
+
data.tar.gz: 7c11a161f98d059a57834ecd300d611b1381417278062b46eb90f39a35a1c246
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9edc6e64ad578294e63eb4d32a2e2a2ff428346acb9cc8dfb64bf2c365093a50bca13019dc5f01ffa1b1b01f552c61b9d383453d70e9b3300abac7b9ed218e37
|
7
|
+
data.tar.gz: 6614451a63fd144a78c1794a0ca5a2a51ad68b5c206e0f7ac9d492725be89aa5af4405f4009edabfd531b65e1ab53885f2f964cf8eaf19503b57ab012e683090
|
data/.gitignore
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
/*.gem
|
2
|
+
~*
|
3
|
+
#*
|
4
|
+
*~
|
5
|
+
.bundle
|
6
|
+
Gemfile.lock
|
7
|
+
.rbenv-version
|
8
|
+
vendor
|
9
|
+
doc/*
|
10
|
+
tmp/*
|
11
|
+
coverage
|
12
|
+
.yardoc
|
13
|
+
pkg/
|
14
|
+
.ruby-version
|
15
|
+
*.gem
|
16
|
+
*.rbc
|
17
|
+
.bundle
|
18
|
+
.config
|
19
|
+
coverage
|
20
|
+
InstalledFiles
|
21
|
+
lib/bundler/man
|
22
|
+
pkg
|
23
|
+
rdoc
|
24
|
+
spec/reports
|
25
|
+
test/tmp
|
26
|
+
test/version_tmp
|
27
|
+
tmp
|
28
|
+
|
29
|
+
# YARD artifacts
|
30
|
+
.yardoc
|
31
|
+
_yardoc
|
32
|
+
doc/
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2014 studio3104
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
7
|
+
the Software without restriction, including without limitation the rights to
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
9
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
10
|
+
subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
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, FITNESS
|
17
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
18
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
19
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
20
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,145 @@
|
|
1
|
+
# fluent-plugin-graphite [![Build Status](https://travis-ci.org/studio3104/fluent-plugin-graphite.png)](https://travis-ci.org/studio3104/fluent-plugin-graphite) [![Code Climate](https://codeclimate.com/github/studio3104/fluent-plugin-graphite.png)](https://codeclimate.com/github/studio3104/fluent-plugin-graphite)
|
2
|
+
|
3
|
+
fluentd output plugin to send metrics to graphite
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'fluent-plugin-graphite'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install fluent-plugin-graphite
|
18
|
+
|
19
|
+
## Configuration
|
20
|
+
|
21
|
+
#### Example
|
22
|
+
|
23
|
+
message: `metrics { "f1":"100", "f2":"200", "f3":"300" }`
|
24
|
+
|
25
|
+
###### Specify name_keys
|
26
|
+
|
27
|
+
- configuration
|
28
|
+
|
29
|
+
```
|
30
|
+
<match metrics>
|
31
|
+
type graphite
|
32
|
+
host localhost
|
33
|
+
port 2003
|
34
|
+
tag_for prefix
|
35
|
+
name_keys f1,f3
|
36
|
+
</match>
|
37
|
+
```
|
38
|
+
|
39
|
+
- output graph_name
|
40
|
+
|
41
|
+
```
|
42
|
+
metrics.f1
|
43
|
+
metrics.f3
|
44
|
+
```
|
45
|
+
|
46
|
+
###### Specify name_key_pattern
|
47
|
+
|
48
|
+
- configuration
|
49
|
+
|
50
|
+
```
|
51
|
+
<match metrics>
|
52
|
+
type graphite
|
53
|
+
host localhost
|
54
|
+
port 2003
|
55
|
+
tag_for prefix
|
56
|
+
name_key_pattern f\d
|
57
|
+
</match>
|
58
|
+
```
|
59
|
+
|
60
|
+
- output graph_name
|
61
|
+
|
62
|
+
```
|
63
|
+
metrics.f1
|
64
|
+
metrics.f2
|
65
|
+
metrics.f3
|
66
|
+
```
|
67
|
+
|
68
|
+
###### tag_for suffix
|
69
|
+
|
70
|
+
- configuration
|
71
|
+
|
72
|
+
```
|
73
|
+
<match metrics>
|
74
|
+
type graphite
|
75
|
+
host localhost
|
76
|
+
port 2003
|
77
|
+
tag_for suffix
|
78
|
+
name_keys f1,f2
|
79
|
+
</match>
|
80
|
+
```
|
81
|
+
|
82
|
+
- output graph_name
|
83
|
+
|
84
|
+
```
|
85
|
+
f1.metrics
|
86
|
+
f2.metrics
|
87
|
+
```
|
88
|
+
|
89
|
+
###### tag_for ignore
|
90
|
+
|
91
|
+
- configuration
|
92
|
+
|
93
|
+
```
|
94
|
+
<match metrics>
|
95
|
+
type graphite
|
96
|
+
host localhost
|
97
|
+
port 2003
|
98
|
+
tag_for ignore
|
99
|
+
name_keys f1,f2
|
100
|
+
</match>
|
101
|
+
```
|
102
|
+
|
103
|
+
- output graph_name
|
104
|
+
|
105
|
+
```
|
106
|
+
f1
|
107
|
+
f2
|
108
|
+
```
|
109
|
+
|
110
|
+
#### Parameter
|
111
|
+
|
112
|
+
###### host
|
113
|
+
- required.
|
114
|
+
- ip address or hostname of graphite server.
|
115
|
+
|
116
|
+
###### port
|
117
|
+
- Default is `2003`.
|
118
|
+
- listening port of carbon-cache.
|
119
|
+
|
120
|
+
###### tag_for
|
121
|
+
- Default is `prefix`.
|
122
|
+
- Either of `prefix`, `suffix` or `ignore`.
|
123
|
+
- `prefix` uses the tag name as graph_name prefix.
|
124
|
+
- `suffix` uses the tag name as graph_name suffix.
|
125
|
+
- `ignore` uses the tag name for nothing.
|
126
|
+
|
127
|
+
###### name_keys
|
128
|
+
- Either of `name_keys` or `name_key_pattern` is required.
|
129
|
+
- Specify field names of the input record. Separate by , (comma). The values of these fields are posted as numbers, and names of thease fields are used as parts of grame_names.
|
130
|
+
|
131
|
+
###### name_key_pattern
|
132
|
+
- Either of `name_keys` or `name_key_pattern` is required.
|
133
|
+
- Specify the field names of the input record by a regular expression. The values of these fields are posted as numbers, and names of thease fields are used as parts of grame_names.
|
134
|
+
|
135
|
+
###### remove_tag_prefix, remove_tag_suffix, add_tag_prefix, add_tag_suffix
|
136
|
+
- Setting for rewriting the tag.
|
137
|
+
- For more information: https://github.com/y-ken/fluent-mixin-rewrite-tag-name
|
138
|
+
|
139
|
+
## Contributing
|
140
|
+
|
141
|
+
1. Fork it ( http://github.com/studio3104/fluent-plugin-graphite/fork )
|
142
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
143
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
144
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
145
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
$:.push File.expand_path('../lib', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.name = 'adp-fluent-plugin-graphite'
|
6
|
+
gem.version = '0.0.1'
|
7
|
+
gem.authors = ['Satoshi SUZUKI']
|
8
|
+
gem.email = 'studio3104.com@gmail.com'
|
9
|
+
gem.homepage = 'https://github.com/studio3104/fluent-plugin-graphite'
|
10
|
+
gem.description = 'fluentd output plugin to send metrics to graphite'
|
11
|
+
gem.summary = gem.description
|
12
|
+
gem.licenses = ['MIT']
|
13
|
+
gem.has_rdoc = false
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split("\n")
|
16
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
17
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
18
|
+
gem.require_paths = ['lib']
|
19
|
+
|
20
|
+
gem.add_runtime_dependency 'fluentd', '>= 0.10.17'
|
21
|
+
gem.add_runtime_dependency 'fluent-mixin-rewrite-tag-name'
|
22
|
+
gem.add_runtime_dependency 'graphite-api'
|
23
|
+
gem.add_development_dependency 'rake'
|
24
|
+
gem.add_development_dependency 'test-unit', '~> 3.2.0'
|
25
|
+
end
|
@@ -0,0 +1,116 @@
|
|
1
|
+
require 'fluent/mixin/rewrite_tag_name'
|
2
|
+
|
3
|
+
class Fluent::GraphiteOutput < Fluent::Output
|
4
|
+
Fluent::Plugin.register_output('graphite', self)
|
5
|
+
|
6
|
+
include Fluent::HandleTagNameMixin
|
7
|
+
include Fluent::Mixin::RewriteTagName
|
8
|
+
|
9
|
+
config_param :host, :string
|
10
|
+
config_param :port, :integer, default: 2003
|
11
|
+
config_param :tag_for, :string, default: 'prefix'
|
12
|
+
config_param :name_keys, :string, default: nil
|
13
|
+
config_param :name_key_pattern, :string, default: nil
|
14
|
+
|
15
|
+
# Define `log` method for v0.10.42 or earlier
|
16
|
+
unless method_defined?(:log)
|
17
|
+
define_method(:log) { $log }
|
18
|
+
end
|
19
|
+
|
20
|
+
def initialize
|
21
|
+
super
|
22
|
+
require 'graphite-api'
|
23
|
+
end
|
24
|
+
|
25
|
+
def start
|
26
|
+
super
|
27
|
+
connect_client!
|
28
|
+
end
|
29
|
+
|
30
|
+
def configure(conf)
|
31
|
+
super
|
32
|
+
|
33
|
+
if !['prefix', 'suffix', 'ignore'].include?(@tag_for)
|
34
|
+
raise Fluent::ConfigError, 'out_graphite: can specify to tag_for only prefix, suffix or ignore'
|
35
|
+
end
|
36
|
+
|
37
|
+
if !@name_keys && !@name_key_pattern
|
38
|
+
raise Fluent::ConfigError, 'out_graphite: missing both of name_keys and name_key_pattern'
|
39
|
+
end
|
40
|
+
if @name_keys && @name_key_pattern
|
41
|
+
raise Fluent::ConfigError, 'out_graphite: cannot specify both of name_keys and name_key_pattern'
|
42
|
+
end
|
43
|
+
|
44
|
+
if @name_keys
|
45
|
+
@name_keys = @name_keys.split(',')
|
46
|
+
end
|
47
|
+
if @name_key_pattern
|
48
|
+
@name_key_pattern = Regexp.new(@name_key_pattern)
|
49
|
+
end
|
50
|
+
# How many times to retry the call if timeout raised
|
51
|
+
@max_retries ||= 3
|
52
|
+
end
|
53
|
+
|
54
|
+
def emit(tag, es, chain)
|
55
|
+
es.each do |time, record|
|
56
|
+
emit_tag = tag.dup
|
57
|
+
filter_record(emit_tag, time, record)
|
58
|
+
next unless metrics = format_metrics(emit_tag, record)
|
59
|
+
|
60
|
+
# implemented to immediate call post method in this loop, because graphite-api.gem has the buffers.
|
61
|
+
post(metrics, time)
|
62
|
+
end
|
63
|
+
|
64
|
+
chain.next
|
65
|
+
end
|
66
|
+
|
67
|
+
def format_metrics(tag, record)
|
68
|
+
filtered_record = if @name_keys
|
69
|
+
record.select { |k,v| @name_keys.include?(k.to_s) }
|
70
|
+
else # defined @name_key_pattern
|
71
|
+
record.select { |k,v| @name_key_pattern.match(k.to_s) }
|
72
|
+
end
|
73
|
+
|
74
|
+
return nil if filtered_record.empty?
|
75
|
+
|
76
|
+
metrics = {}
|
77
|
+
tag = tag.sub(/\.$/, '') # may include a dot at the end of the emit_tag fluent-mixin-rewrite-tag-name returns. remove it.
|
78
|
+
filtered_record.each do |k, v|
|
79
|
+
key = case @tag_for
|
80
|
+
when 'ignore' then k.to_s
|
81
|
+
when 'prefix' then "#{tag}.#{k}"
|
82
|
+
when 'suffix' then "#{k}.#{tag}"
|
83
|
+
end
|
84
|
+
|
85
|
+
key = key.gsub(/(\s|\/)+/, '_') # cope with in the case of containing symbols or spaces in the key of the record like in_dstat.
|
86
|
+
metrics[key] = v.to_f
|
87
|
+
end
|
88
|
+
metrics
|
89
|
+
end
|
90
|
+
|
91
|
+
def post(metrics, time)
|
92
|
+
trial ||= 1
|
93
|
+
@client.metrics(metrics, time)
|
94
|
+
log.debug "Sending metrics: #{metrics}"
|
95
|
+
rescue Errno::ETIMEDOUT
|
96
|
+
# after long periods with nothing emitted, the connection will be closed and result in timeout
|
97
|
+
if trial <= @max_retries
|
98
|
+
log.warn "out_graphite: connection timeout to #{@host}:#{@port}. Reconnecting... "
|
99
|
+
trial += 1
|
100
|
+
connect_client!
|
101
|
+
retry
|
102
|
+
else
|
103
|
+
log.error "out_graphite: ERROR: connection timeout to #{@host}:#{@port}. Exceeded max_retries #{@max_retries}"
|
104
|
+
end
|
105
|
+
rescue Errno::ECONNREFUSED
|
106
|
+
log.warn "out_graphite: connection refused by #{@host}:#{@port}"
|
107
|
+
rescue SocketError => se
|
108
|
+
log.warn "out_graphite: socket error by #{@host}:#{@port} :#{se}"
|
109
|
+
rescue StandardError => e
|
110
|
+
log.error "out_graphite: ERROR: #{e}"
|
111
|
+
end
|
112
|
+
|
113
|
+
def connect_client!
|
114
|
+
@client = GraphiteAPI.new(graphite: "#{@host}:#{@port}")
|
115
|
+
end
|
116
|
+
end
|
data/test/helper.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
|
4
|
+
begin
|
5
|
+
Bundler.setup(:default, :development)
|
6
|
+
rescue Bundler::BundlerError => e
|
7
|
+
$stderr.puts e.message
|
8
|
+
$stderr.puts 'Run `bundle install` to install missing gems'
|
9
|
+
exit e.status_code
|
10
|
+
end
|
11
|
+
require 'test/unit'
|
12
|
+
|
13
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
14
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
15
|
+
require 'fluent/test'
|
16
|
+
unless ENV.has_key?('VERBOSE')
|
17
|
+
nulllogger = Object.new
|
18
|
+
nulllogger.instance_eval {|obj|
|
19
|
+
def method_missing(method, *args)
|
20
|
+
# pass
|
21
|
+
end
|
22
|
+
}
|
23
|
+
$log = nulllogger
|
24
|
+
end
|
25
|
+
|
26
|
+
require 'fluent/plugin/out_graphite'
|
27
|
+
|
28
|
+
class Test::Unit::TestCase
|
29
|
+
end
|
@@ -0,0 +1,131 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class GraphiteOutputTest < Test::Unit::TestCase
|
4
|
+
TCP_PORT = 42003
|
5
|
+
CONFIG_NAME_KEY_PATTERN = %[
|
6
|
+
host localhost
|
7
|
+
port #{TCP_PORT}
|
8
|
+
name_key_pattern ^((?!hostname).)*$
|
9
|
+
]
|
10
|
+
CONFIG_NAME_KEYS = %[
|
11
|
+
host localhost
|
12
|
+
port #{TCP_PORT}
|
13
|
+
name_keys dstat.total cpu usage.usr,dstat.total cpu usage.sys,dstat.total cpu usage.idl
|
14
|
+
]
|
15
|
+
CONFIG_TAG_FOR_IGNORE = %[
|
16
|
+
host localhost
|
17
|
+
port #{TCP_PORT}
|
18
|
+
name_keys dstat.total cpu usage.usr,dstat.total cpu usage.sys,dstat.total cpu usage.idl
|
19
|
+
tag_for ignore
|
20
|
+
]
|
21
|
+
CONFIG_TAG_FOR_SUFFIX = %[
|
22
|
+
host localhost
|
23
|
+
port #{TCP_PORT}
|
24
|
+
name_keys dstat.total cpu usage.usr,dstat.total cpu usage.sys,dstat.total cpu usage.idl
|
25
|
+
tag_for suffix
|
26
|
+
]
|
27
|
+
CONFIG_INVALID_TAG_FOR = %[
|
28
|
+
host localhost
|
29
|
+
port #{TCP_PORT}
|
30
|
+
name_key_pattern ^((?!hostname).)*$
|
31
|
+
tag_for invalid
|
32
|
+
]
|
33
|
+
CONFIG_SPECIFY_BOTH_NAME_KEYS_AND_NAME_KEY_PATTERN = %[
|
34
|
+
host localhost
|
35
|
+
port #{TCP_PORT}
|
36
|
+
name_keys dstat.total cpu usage.usr,dstat.total cpu usage.sys,dstat.total cpu usage.idl
|
37
|
+
name_key_pattern ^((?!hostname).)*$
|
38
|
+
]
|
39
|
+
|
40
|
+
def setup
|
41
|
+
Fluent::Test.setup
|
42
|
+
@server = TCPServer.new(TCP_PORT)
|
43
|
+
end
|
44
|
+
|
45
|
+
def teardown
|
46
|
+
@server.close
|
47
|
+
end
|
48
|
+
|
49
|
+
def create_driver(conf = CONFIG_NAME_KEY_PATTERN, tag='test')
|
50
|
+
Fluent::Test::OutputTestDriver.new(Fluent::GraphiteOutput, tag).configure(conf)
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_configure
|
54
|
+
d = create_driver
|
55
|
+
assert_equal d.instance.host, 'localhost'
|
56
|
+
assert_equal d.instance.port, TCP_PORT
|
57
|
+
assert_equal d.instance.tag_for, 'prefix'
|
58
|
+
assert_equal d.instance.name_keys, nil
|
59
|
+
assert_equal d.instance.name_key_pattern, /^((?!hostname).)*$/
|
60
|
+
|
61
|
+
d = create_driver(CONFIG_NAME_KEYS)
|
62
|
+
assert_equal d.instance.host, 'localhost'
|
63
|
+
assert_equal d.instance.port, TCP_PORT
|
64
|
+
assert_equal d.instance.tag_for, 'prefix'
|
65
|
+
assert_equal d.instance.name_keys, ['dstat.total cpu usage.usr', 'dstat.total cpu usage.sys', 'dstat.total cpu usage.idl']
|
66
|
+
assert_equal d.instance.name_key_pattern, nil
|
67
|
+
|
68
|
+
d = create_driver(CONFIG_TAG_FOR_IGNORE)
|
69
|
+
assert_equal d.instance.host, 'localhost'
|
70
|
+
assert_equal d.instance.port, TCP_PORT
|
71
|
+
assert_equal d.instance.tag_for, 'ignore'
|
72
|
+
assert_equal d.instance.name_keys, ['dstat.total cpu usage.usr', 'dstat.total cpu usage.sys', 'dstat.total cpu usage.idl']
|
73
|
+
assert_equal d.instance.name_key_pattern, nil
|
74
|
+
|
75
|
+
d = create_driver(CONFIG_TAG_FOR_SUFFIX)
|
76
|
+
assert_equal d.instance.host, 'localhost'
|
77
|
+
assert_equal d.instance.port, TCP_PORT
|
78
|
+
assert_equal d.instance.tag_for, 'suffix'
|
79
|
+
assert_equal d.instance.name_keys, ['dstat.total cpu usage.usr', 'dstat.total cpu usage.sys', 'dstat.total cpu usage.idl']
|
80
|
+
assert_equal d.instance.name_key_pattern, nil
|
81
|
+
|
82
|
+
assert_raise(Fluent::ConfigError) { d = create_driver(CONFIG_INVALID_TAG_FOR) }
|
83
|
+
assert_raise(Fluent::ConfigError) { d = create_driver(CONFIG_SPECIFY_BOTH_NAME_KEYS_AND_NAME_KEY_PATTERN) }
|
84
|
+
end
|
85
|
+
|
86
|
+
def test_format_metrics_strings
|
87
|
+
record = {
|
88
|
+
'hostname' => 'localhost.localdomain',
|
89
|
+
'dstat.total cpu usage.usr' => '0.0',
|
90
|
+
'dstat.total cpu usage.sys' => '0.0',
|
91
|
+
'dstat.total cpu usage.idl' => '100.0',
|
92
|
+
'dstat.total cpu usage.wai' => '0.0',
|
93
|
+
'dstat.total cpu usage.hiq' => '0.0',
|
94
|
+
'dstat.total cpu usage.siq' => '0.0'
|
95
|
+
}
|
96
|
+
|
97
|
+
run_format_metrics_assertions(record)
|
98
|
+
end
|
99
|
+
|
100
|
+
def test_format_metrics_symbols
|
101
|
+
record = {
|
102
|
+
:'hostname' => 'localhost.localdomain',
|
103
|
+
:'dstat.total cpu usage.usr' => '0.0',
|
104
|
+
:'dstat.total cpu usage.sys' => '0.0',
|
105
|
+
:'dstat.total cpu usage.idl' => '100.0',
|
106
|
+
:'dstat.total cpu usage.wai' => '0.0',
|
107
|
+
:'dstat.total cpu usage.hiq' => '0.0',
|
108
|
+
:'dstat.total cpu usage.siq' => '0.0'
|
109
|
+
}
|
110
|
+
|
111
|
+
run_format_metrics_assertions(record)
|
112
|
+
end
|
113
|
+
|
114
|
+
def run_format_metrics_assertions(record)
|
115
|
+
d = create_driver
|
116
|
+
m1 = d.instance.format_metrics('test.', record)
|
117
|
+
assert_equal m1, { 'test.dstat.total_cpu_usage.usr' => 0.0, 'test.dstat.total_cpu_usage.sys' => 0.0, 'test.dstat.total_cpu_usage.idl' => 100.0, 'test.dstat.total_cpu_usage.wai' => 0.0, 'test.dstat.total_cpu_usage.hiq' => 0.0, 'test.dstat.total_cpu_usage.siq' => 0.0 }
|
118
|
+
|
119
|
+
d = create_driver(CONFIG_NAME_KEYS)
|
120
|
+
m1 = d.instance.format_metrics('test.', record)
|
121
|
+
assert_equal m1, { 'test.dstat.total_cpu_usage.usr' => 0.0, 'test.dstat.total_cpu_usage.sys' => 0.0, 'test.dstat.total_cpu_usage.idl' => 100.0 }
|
122
|
+
|
123
|
+
d = create_driver(CONFIG_TAG_FOR_IGNORE)
|
124
|
+
m1 = d.instance.format_metrics('test.', record)
|
125
|
+
assert_equal m1, { 'dstat.total_cpu_usage.usr' => 0.0, 'dstat.total_cpu_usage.sys' => 0.0, 'dstat.total_cpu_usage.idl' => 100.0 }
|
126
|
+
|
127
|
+
d = create_driver(CONFIG_TAG_FOR_SUFFIX)
|
128
|
+
m1 = d.instance.format_metrics('test.', record)
|
129
|
+
assert_equal m1, { 'dstat.total_cpu_usage.usr.test' => 0.0, 'dstat.total_cpu_usage.sys.test' => 0.0, 'dstat.total_cpu_usage.idl.test' => 100.0 }
|
130
|
+
end
|
131
|
+
end
|
metadata
ADDED
@@ -0,0 +1,124 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: adp-fluent-plugin-graphite
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Satoshi SUZUKI
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-10-19 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.10.17
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.10.17
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: fluent-mixin-rewrite-tag-name
|
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: graphite-api
|
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: test-unit
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 3.2.0
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 3.2.0
|
83
|
+
description: fluentd output plugin to send metrics to graphite
|
84
|
+
email: studio3104.com@gmail.com
|
85
|
+
executables: []
|
86
|
+
extensions: []
|
87
|
+
extra_rdoc_files: []
|
88
|
+
files:
|
89
|
+
- ".gitignore"
|
90
|
+
- ".travis.yml"
|
91
|
+
- Gemfile
|
92
|
+
- LICENSE
|
93
|
+
- README.md
|
94
|
+
- Rakefile
|
95
|
+
- adp-fluent-plugin-graphite.gemspec
|
96
|
+
- lib/fluent/plugin/out_graphite.rb
|
97
|
+
- test/helper.rb
|
98
|
+
- test/plugin/test_out_graphite.rb
|
99
|
+
homepage: https://github.com/studio3104/fluent-plugin-graphite
|
100
|
+
licenses:
|
101
|
+
- MIT
|
102
|
+
metadata: {}
|
103
|
+
post_install_message:
|
104
|
+
rdoc_options: []
|
105
|
+
require_paths:
|
106
|
+
- lib
|
107
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - ">="
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0'
|
112
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0'
|
117
|
+
requirements: []
|
118
|
+
rubygems_version: 3.0.3
|
119
|
+
signing_key:
|
120
|
+
specification_version: 4
|
121
|
+
summary: fluentd output plugin to send metrics to graphite
|
122
|
+
test_files:
|
123
|
+
- test/helper.rb
|
124
|
+
- test/plugin/test_out_graphite.rb
|