fluent-plugin-mackerel 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YmUyN2IyOTAzYjEwYTBmZGViNzkzYWEzYzY0MjMwNjE1MTE1OTFkNw==
4
+ MTczNjMxMzUzMzlmYjc4YjlhMjFkYzQ3MzEzN2Y0Y2Q5OGEzYWM0OA==
5
5
  data.tar.gz: !binary |-
6
- NTVlZTE0ZDc3N2M0OWY2YTE2ZWE4ZDhjYzU2ZTJkN2RjMzllMmYxOQ==
6
+ MDc2YjNmMzViNWZlZGE0MzA2ZDUyZmQ4YjdkYzA3OWFjZWY0MTE2ZQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NGQ1ODE0MjRmZGMzNDlkNmU4YmZhY2RmN2IwYzQ2MDYwNWMyOWY1NGYwZTY4
10
- NTA5YTc1N2I3NDBhNjU1NGJlODJlODg2ZWNjYTdmNDhhNjIzMjg2ZGI0YThk
11
- Y2FjMWEyNzVkNDZkOThlN2RiNzQ5MDM5ZTA1MjUxNDk4N2I2ZWU=
9
+ YTFiZjQ0OGIzZTA3NjUzYzllYTQzYzU2MmIyYWVkNTUwNzE4NWUzZjYyMjcw
10
+ M2QzZDdhNDQ1NzJkYjBjZGMxZGFjMTFlMTVhMDRkYWFmZGFmMWE2YTZhMDhh
11
+ NTg0NDIyOTg0NjQ3OWMxOGFlZjc3MTA1M2YzZTMxZThmM2QyOTA=
12
12
  data.tar.gz: !binary |-
13
- OWNjZWZlNjYzZjdmMDBjMWM0MWM2NzJjMWVhNTYwZDMxZTM4YTc4Y2FmZTk0
14
- MTNlYWNjMTFiOWI1YjIyNGUzZjMwYWNiOTQ2NWI2MGMwM2EyODkyYTk3ZDdj
15
- YTc5OTk2YjFhMTFhNDBhMDg2Yjk0MjM4Y2Y5ODZiZTZlZjg3Nzc=
13
+ MjdjODdjMTc5ODIyNGE3M2VhYmI4YmU4YTlhMDM0MGRmNjI3ZmYzZmJjZDNk
14
+ MzlhODc0MGZmYjk4MGVjZTMxM2M1YjM4NTIwNTk5ZDRkOGZmOGI1ODA1MmY3
15
+ YjNkZDQzZTI2Y2FkNGVmN2RhMzMzNDU5MDIzNWRhZDc1MDZhNTQ=
data/README.md CHANGED
@@ -42,7 +42,30 @@ Then the sent metric data will look like this:
42
42
  "value": 100.0
43
43
  }
44
44
  ```
45
- As shown above, metric name will be a concatenation of `metrics_name` and `out_keys` values when you use ${out_key} in metrics_name definition. In addition, "custom" will be appended before sending metrics to mackerel automatically.
45
+ As shown above, `${out_key}` will be replaced with out_key like "2xx_count" when sending metrics.
46
+
47
+ You can use `${[n]}` for `mackerel_name` where `n` represents any decimal number including negative value,
48
+
49
+ ```
50
+ <match mackerel.*>
51
+ type mackerel
52
+ api_key 123456
53
+ hostid xyz
54
+ metrics_name ${[1]}.${out_key}
55
+ out_keys 2xx_count,3xx_count,4xx_count,5xx_count
56
+ </match>
57
+ ```
58
+
59
+ then it indicates value of the `n` th index of the array got by splitting the tag by `.` (dot) and get the following output when the tag is `mackerel.http_status`.
60
+ ```
61
+ {
62
+ "hostId": "xyz",
63
+ "name": "custom.http_status.2xx_count",
64
+ "time": 1399997498,
65
+ "value": 100.0
66
+ }
67
+ ```
68
+ "custom" will be appended to the `name` attribute before sending metrics to mackerel automatically.
46
69
 
47
70
  You can also send ["service" metric](http://help-ja.mackerel.io/entry/spec/api/v0#service-metric-value-post) as follows.
48
71
  ```
@@ -54,7 +77,7 @@ You can also send ["service" metric](http://help-ja.mackerel.io/entry/spec/api/v
54
77
  out_keys 2xx_count,3xx_count,4xx_count,5xx_count
55
78
  </match>
56
79
  ```
57
- `flush_interval` is not allowed to set less than 60 secs not to send API requests more than once in a minute.
80
+ `flush_interval` is not allowed to be set less than 60 secs not to send API requests more than once in a minute.
58
81
 
59
82
  Since version 0.0.4, metrics_prefix was removed and you should use metrics_name instead.
60
83
 
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "fluent-plugin-mackerel"
7
- spec.version = "0.0.4"
7
+ spec.version = "0.0.5"
8
8
  spec.authors = ["tksmd","hatz48"]
9
9
  spec.email = ["someda@isenshi.com"]
10
10
  spec.description = %q{fluent plugin to send metrics to mackerel.io}
@@ -89,6 +89,9 @@ module Fluent
89
89
 
90
90
  tokens = tag.split('.')
91
91
  out_keys.map do |key|
92
+
93
+ next unless record.has_key?(key)
94
+
92
95
  name = @name_processor.nil? ? key :
93
96
  @name_processor.map{ |p| p.call(:out_key => key, :tokens => tokens) }.join('.')
94
97
 
@@ -68,19 +68,22 @@ class MackerelOutputTest < Test::Unit::TestCase
68
68
 
69
69
  def test_write
70
70
  d = create_driver()
71
- stub(d.instance.mackerel).post_metrics([
71
+ mock(d.instance.mackerel).post_metrics([
72
72
  {"hostId"=>"xyz", "value"=>1.0, "time"=>1399997498, "name"=>"custom.service.val1"},
73
73
  {"hostId"=>"xyz", "value"=>2.0, "time"=>1399997498, "name"=>"custom.service.val2"},
74
74
  {"hostId"=>"xyz", "value"=>3.0, "time"=>1399997498, "name"=>"custom.service.val3"},
75
75
  {"hostId"=>"xyz", "value"=>5.0, "time"=>1399997498, "name"=>"custom.service.val1"},
76
76
  {"hostId"=>"xyz", "value"=>6.0, "time"=>1399997498, "name"=>"custom.service.val2"},
77
77
  {"hostId"=>"xyz", "value"=>7.0, "time"=>1399997498, "name"=>"custom.service.val3"},
78
+ {"hostId"=>"xyz", "value"=>9.0, "time"=>1399997498, "name"=>"custom.service.val1"},
79
+ {"hostId"=>"xyz", "value"=>10.0, "time"=>1399997498, "name"=>"custom.service.val2"},
78
80
  ])
79
81
 
80
82
  ENV["TZ"]="Asia/Tokyo"
81
83
  t = Time.strptime('2014-05-14 01:11:38', '%Y-%m-%d %T')
82
84
  d.emit({'val1' => 1, 'val2' => 2, 'val3' => 3, 'val4' => 4}, t)
83
85
  d.emit({'val1' => 5, 'val2' => 6, 'val3' => 7, 'val4' => 8}, t)
86
+ d.emit({'val1' => 9, 'val2' => 10}, t)
84
87
  d.run()
85
88
  end
86
89
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-mackerel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - tksmd
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-08-10 00:00:00.000000000 Z
12
+ date: 2014-08-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mackerel-client