fluent-plugin-metricsense 0.2.7 → 0.2.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- MTBlNzEzYzFlZjFlYjVjOGYyZmFjYjY5NDgzYzcwZDU2YzMzNTY5ZQ==
5
- data.tar.gz: !binary |-
6
- NDgxZDc4NjViMGZkZjZmZTVkZTRmNzc0YTYwOGIzZGU3ZTUxMzVjYQ==
2
+ SHA1:
3
+ metadata.gz: 6c643fbeba22178c8a8885ec35a75cf440d32030
4
+ data.tar.gz: 7785e0dc9b06c13df3fa970cf706d1f1cb5c42b8
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- N2UxOWM1MmYzMmM4NDM4YjI4NTQzNTIyZDFmZjVmNjY0OWU5NmFkODk5NDRk
10
- MTYwMTA2NzM0ZGE3Y2FkMDIxNjZhZmQ5YWY0MTQ2ZGNhM2E2MjFlNjQzNGI0
11
- NWYyY2M5Y2M5ZjAxZDQzY2VmMDNhNWY5OGVhMjllOTQxMzU0ZTk=
12
- data.tar.gz: !binary |-
13
- Y2NjNTU4MTVjNTliYmIwYTNmM2RmMzAxZDhlOTY4ZDIxYzRlMWY5ZDNhYzVj
14
- YTBjMWE1NWEzZGQ3NmJlYzRmYTkxMDMxZmNhMzM4OTdjNmM4NTA2NWFjZDBl
15
- MzBkM2I3MmI3Mjk0MzU1Y2M1NThmN2UzNjE3YjUxMzMyZDZmNWU=
6
+ metadata.gz: b626f5ea31a320dd2ea666e78f30c12d4bebf3d37851c961623edaccd4937767d5b396e7247e514678068923491c1f2f71add3326c3b8a19f9eb85d5677642e8
7
+ data.tar.gz: f55ca38fc8cb7c0b9cd0d79ce80b9b2627432c128a58cb99991529021a49cc29f7f1b7d1949c09fed41eabf856c91dde3d986e54ed7126f8dab59de31a8132bd
data/LICENSE ADDED
@@ -0,0 +1,14 @@
1
+ Copyright (C) 2012 FURUHASHI Sadayuki
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
14
+
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.7
1
+ 0.2.8
@@ -8,6 +8,7 @@ Gem::Specification.new do |s|
8
8
  s.version = File.read("VERSION").strip
9
9
  s.authors = ["Sadayuki Furuhashi"]
10
10
  s.email = "sf@treasure-data.com"
11
+ s.license = "Apache-2.0"
11
12
  s.has_rdoc = false
12
13
  s.require_paths = ['lib']
13
14
  #s.platform = Gem::Platform::RUBY
@@ -16,6 +17,7 @@ Gem::Specification.new do |s|
16
17
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
17
18
 
18
19
  s.add_dependency "fluentd", "~> 0.10.6"
20
+ s.add_dependency "dogapi"
19
21
  s.add_development_dependency "rake", ">= 0.8.7"
20
22
  s.add_development_dependency 'bundler', ['>= 1.0.0']
21
23
  s.add_development_dependency "simplecov", ">= 0.5.4"
@@ -0,0 +1,85 @@
1
+ #
2
+ # fluent-plugin-metricsense
3
+ #
4
+ # Copyright (C) 2012 Sadayuki Furuhashi
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+ module Fluent::MetricSenseOutput::Backends
19
+
20
+ class DatadogBackend < Fluent::MetricSenseOutput::Backend
21
+ Fluent::MetricSenseOutput.register_backend('datadog', self)
22
+
23
+ config_param :dd_api_key, :string
24
+ config_param :dd_app_key, :string, :default => nil
25
+ config_param :host, :string, :default => nil
26
+ config_param :tags, :array, :default => []
27
+ config_param :batch_size, :integer, :default => 200
28
+
29
+ def initialize()
30
+ super
31
+ require "dogapi"
32
+ end
33
+
34
+ def configure(conf)
35
+ super
36
+
37
+ if @dd_api_key.nil?
38
+ raise Fluent::ConfigError, "missing Datadog API key"
39
+ end
40
+
41
+ client_args = [@dd_api_key]
42
+ client_args << @dd_app_key if @dd_app_key
43
+ @dog = Dogapi::Client.new(*client_args)
44
+ end
45
+
46
+ def write(data)
47
+ data.each_slice(@batch_size) do |slice|
48
+ metric_points = {}
49
+ slice.each do |tag, time, value, seg_key, seg_val|
50
+ if seg_key and seg_val
51
+ # segmented values
52
+ segment = "#{seg_key}:#{seg_val}"
53
+ else
54
+ # simple values
55
+ segment = "simple"
56
+ end
57
+ metric = tag # use fluentd's tag as metric name on datadog
58
+ metric_points[metric] ||= {}
59
+ metric_points[metric][segment] ||= []
60
+ metric_points[metric][segment].push([Time.at(time), value])
61
+ end
62
+
63
+ metric_points.each do |metric, segment_points|
64
+ segment_points.each do |segment, points|
65
+ seg_key, seg_val = segment.split(":", 2)
66
+
67
+ tags = @tags.dup
68
+ tags.push(segment)
69
+ if seg_key and seg_val
70
+ # add seg_key as a tag to allow calculating metrics over the segment name
71
+ tags.push(seg_key)
72
+ end
73
+
74
+ options = {}
75
+ options["tags"] = tags
76
+ options["host"] = @host if @host
77
+ options["type"] = "gauge"
78
+
79
+ @dog.emit_points(metric, points, options)
80
+ end
81
+ end
82
+ end
83
+ end
84
+ end
85
+ end
@@ -111,6 +111,14 @@ module Fluent::MetricSenseOutput::Backends
111
111
  }
112
112
  }.to_json
113
113
 
114
+ METRIC_INITIALIZE_REQUEST_PER_MODE[UpdateMode::COUNT] = {
115
+ "type" => "gauge",
116
+ "attributes" => {
117
+ "aggregate" => false,
118
+ "source_aggregate" => false,
119
+ }
120
+ }.to_json
121
+
114
122
  def ensure_metric_initialized(http, name, mode)
115
123
  return if @initialized_metrics[name]
116
124
 
@@ -31,6 +31,7 @@ module Fluent
31
31
  ADD = 0
32
32
  MAX = 1
33
33
  AVERAGE = 2
34
+ COUNT = 3
34
35
  end
35
36
 
36
37
  class Backend
@@ -47,6 +48,7 @@ module Fluent
47
48
 
48
49
  module Backends
49
50
  backend_dir = "#{File.dirname(__FILE__)}/backends"
51
+ require "#{backend_dir}/datadog_backend"
50
52
  require "#{backend_dir}/librato_backend"
51
53
  require "#{backend_dir}/rdb_tsdb_backend"
52
54
  require "#{backend_dir}/stdout_backend"
@@ -149,6 +151,8 @@ module Fluent
149
151
  update_mode = UpdateMode::MAX
150
152
  when "average"
151
153
  update_mode = UpdateMode::AVERAGE
154
+ when "count"
155
+ update_mode = UpdateMode::COUNT
152
156
  else
153
157
  # default is add
154
158
  update_mode = UpdateMode::ADD
@@ -200,6 +204,25 @@ module Fluent
200
204
  end
201
205
  end
202
206
 
207
+ class CountUpdater
208
+ def initialize
209
+ @value = 0
210
+ end
211
+ attr_reader :value
212
+
213
+ def normalized_value(n)
214
+ @value
215
+ end
216
+
217
+ def add(value)
218
+ @value += 1
219
+ end
220
+
221
+ def mode
222
+ UpdateMode::ADD
223
+ end
224
+ end
225
+
203
226
  class MaxUpdater
204
227
  def initialize
205
228
  @value = 0
@@ -254,6 +277,8 @@ module Fluent
254
277
  updater = MaxUpdater
255
278
  when UpdateMode::AVERAGE # AVERAGE uses MaxUpdater and calculate average on server-side aggregation
256
279
  updater = AverageUpdater
280
+ when UpdateMode::COUNT
281
+ updater = CountUpdater
257
282
  else # default is AddUpdater
258
283
  updater = AddUpdater
259
284
  end
metadata CHANGED
@@ -1,69 +1,83 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-metricsense
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.7
4
+ version: 0.2.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sadayuki Furuhashi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-17 00:00:00.000000000 Z
11
+ date: 2015-01-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fluentd
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: 0.10.6
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: 0.10.6
27
+ - !ruby/object:Gem::Dependency
28
+ name: dogapi
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'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: rake
29
43
  requirement: !ruby/object:Gem::Requirement
30
44
  requirements:
31
- - - ! '>='
45
+ - - ">="
32
46
  - !ruby/object:Gem::Version
33
47
  version: 0.8.7
34
48
  type: :development
35
49
  prerelease: false
36
50
  version_requirements: !ruby/object:Gem::Requirement
37
51
  requirements:
38
- - - ! '>='
52
+ - - ">="
39
53
  - !ruby/object:Gem::Version
40
54
  version: 0.8.7
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: bundler
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
- - - ! '>='
59
+ - - ">="
46
60
  - !ruby/object:Gem::Version
47
61
  version: 1.0.0
48
62
  type: :development
49
63
  prerelease: false
50
64
  version_requirements: !ruby/object:Gem::Requirement
51
65
  requirements:
52
- - - ! '>='
66
+ - - ">="
53
67
  - !ruby/object:Gem::Version
54
68
  version: 1.0.0
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: simplecov
57
71
  requirement: !ruby/object:Gem::Requirement
58
72
  requirements:
59
- - - ! '>='
73
+ - - ">="
60
74
  - !ruby/object:Gem::Version
61
75
  version: 0.5.4
62
76
  type: :development
63
77
  prerelease: false
64
78
  version_requirements: !ruby/object:Gem::Requirement
65
79
  requirements:
66
- - - ! '>='
80
+ - - ">="
67
81
  - !ruby/object:Gem::Version
68
82
  version: 0.5.4
69
83
  description: MetricSense - application metrics aggregation plugin for Fluentd
@@ -72,18 +86,21 @@ executables: []
72
86
  extensions: []
73
87
  extra_rdoc_files: []
74
88
  files:
75
- - .gitignore
89
+ - ".gitignore"
76
90
  - Gemfile
91
+ - LICENSE
77
92
  - README.rdoc
78
93
  - Rakefile
79
94
  - VERSION
80
95
  - fluent-plugin-metricsense.gemspec
96
+ - lib/fluent/plugin/backends/datadog_backend.rb
81
97
  - lib/fluent/plugin/backends/librato_backend.rb
82
98
  - lib/fluent/plugin/backends/rdb_tsdb_backend.rb
83
99
  - lib/fluent/plugin/backends/stdout_backend.rb
84
100
  - lib/fluent/plugin/out_metricsense.rb
85
101
  homepage: https://github.com/treasure-data/fluent-plugin-metricsense
86
- licenses: []
102
+ licenses:
103
+ - Apache-2.0
87
104
  metadata: {}
88
105
  post_install_message:
89
106
  rdoc_options: []
@@ -91,19 +108,18 @@ require_paths:
91
108
  - lib
92
109
  required_ruby_version: !ruby/object:Gem::Requirement
93
110
  requirements:
94
- - - ! '>='
111
+ - - ">="
95
112
  - !ruby/object:Gem::Version
96
113
  version: '0'
97
114
  required_rubygems_version: !ruby/object:Gem::Requirement
98
115
  requirements:
99
- - - ! '>='
116
+ - - ">="
100
117
  - !ruby/object:Gem::Version
101
118
  version: '0'
102
119
  requirements: []
103
120
  rubyforge_project:
104
- rubygems_version: 2.2.2
121
+ rubygems_version: 2.4.4
105
122
  signing_key:
106
123
  specification_version: 4
107
124
  summary: MetricSense - application metrics aggregation plugin for Fluentd
108
125
  test_files: []
109
- has_rdoc: false