fluent-plugin-cmetrics 0.1.0.rc5 → 0.1.0.rc6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 14dc765336d42503cd80ded601ff4c275a38cec0cc754b31f1f1a86d333520ac
4
- data.tar.gz: 89cac70e738c7b3a4d65189be8a78ab9cba97210864e38e8ef47bf11aa5c7940
3
+ metadata.gz: 65548cae758782bc23022e7078dbab4a7c566b6175a652e7c5cee348a3b1ef93
4
+ data.tar.gz: e5fe401babbfe22ac5038130dd72d29135a794c155e4a294c59fbc4b5898dd41
5
5
  SHA512:
6
- metadata.gz: e11f1f3c56baba25406a0294e8c84458c26f15d1070b3f9a125838e9ac536386f32b705a5cbcbbddf242234a728be397bb0f12e5dd8e72c89a09917e4799bc69
7
- data.tar.gz: 28a10bb177b9758ac19a25abce5f04746051fb26e23842b6eef488b18c390e309ddba487656fb5df01c6975a0b34a4d5a829a1ec5add63be5f58b5fabb42ad36
6
+ metadata.gz: 6991cae004f796934cd0b4dd7d5d1ef9f175798c7c799ac0c417860451b6c4c04deb2d9c9fb0776a20eae180f826854b8c089b31ea79cdc2ea1ced376defe1a1
7
+ data.tar.gz: 28fd06e6a2df8d259aab80eff36a27cc2bd3a2155e47c45170c6d5704c24882d42226d3ff1f8f55fd8e6a73c1825adb45d1e05d46cffae0bea56e7b1097edd51
data/README.md CHANGED
@@ -44,6 +44,12 @@ cmetrics labels key
44
44
 
45
45
  Default value: `labels`.
46
46
 
47
+ ### host_key (string) (optional)
48
+
49
+ hostname key
50
+
51
+ Default value: `host`.
52
+
47
53
  ### format_to_splunk_metric (bool) (optional)
48
54
 
49
55
  format to Splunk metrics
@@ -3,7 +3,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
3
 
4
4
  Gem::Specification.new do |spec|
5
5
  spec.name = "fluent-plugin-cmetrics"
6
- spec.version = "0.1.0.rc5"
6
+ spec.version = "0.1.0.rc6"
7
7
  spec.authors = ["Hiroshi Hatake"]
8
8
  spec.email = ["cosmo0920.oucc@gmail.com"]
9
9
 
@@ -30,6 +30,8 @@ module Fluent
30
30
  config_param :cmetrics_metric_key, :string, default: "cmetrics"
31
31
  desc "cmetrics labels key"
32
32
  config_param :cmetrics_labels_key, :string, default: "labels"
33
+ desc "hostname key"
34
+ config_param :host_key, :string, default: "host"
33
35
  desc "format to Splunk metrics"
34
36
  config_param :format_to_splunk_metric, :bool, default: false
35
37
  desc "dimensions key"
@@ -40,6 +42,7 @@ module Fluent
40
42
  @serde = ::CMetrics::Serde.new
41
43
  @record_accessor = record_accessor_create(@cmetrics_metric_key)
42
44
  @labels_accessor = record_accessor_create(@cmetrics_labels_key)
45
+ @hostname_accessor = record_accessor_create(@host_key)
43
46
  end
44
47
 
45
48
  def format_to_splunk_style_with_dims(inner)
@@ -59,6 +62,7 @@ module Fluent
59
62
  new_es = Fluent::MultiEventStream.new
60
63
  es.each do |time, record|
61
64
  data = @record_accessor.call(record)
65
+ hostname = @hostname_accessor.call(record)
62
66
  @serde.feed_each(data) do |cmetrics|
63
67
  metrics = cmetrics.metrics
64
68
  metrics.each do |metric|
@@ -73,6 +77,9 @@ module Fluent
73
77
  inner.merge!(dims)
74
78
  end
75
79
  end
80
+ if hostname
81
+ inner[@host_key] = hostname
82
+ end
76
83
  time = Time.at(inner.delete("timestamp"))
77
84
  new_es.add(Fluent::EventTime.new(time.to_i, time.nsec), inner)
78
85
  end
@@ -1,5 +1,6 @@
1
1
  require "helper"
2
2
  require "fluent/plugin/filter_cmetrics_parser.rb"
3
+ require 'socket'
3
4
 
4
5
  class CmetricsParserTest < Test::Unit::TestCase
5
6
  setup do
@@ -49,6 +50,35 @@ class CmetricsParserTest < Test::Unit::TestCase
49
50
  d.feed(time, record)
50
51
  end
51
52
  d.filtered.map {|e| assert_equal(!!use_dimensions, e.last.has_key?("dims"))}
53
+ d.filtered.map {|e| assert_false(e.last.has_key?("hostname"))}
54
+ assert do
55
+ d.filtered.size > 0
56
+ end
57
+ end
58
+
59
+ data("with dimensions" => "dims",
60
+ "without dimensions" => nil)
61
+ test "#filter_stream with host_key" do |data|
62
+ use_dimensions = data
63
+ d = if use_dimensions
64
+ create_driver(%[
65
+ format_to_splunk_metric true
66
+ dimensions_key dims
67
+ host_key hostname
68
+ ])
69
+ else
70
+ create_driver(%[
71
+ format_to_splunk_metric true
72
+ host_key hostname
73
+ ])
74
+ end
75
+ time = event_time("2012-01-02 13:14:15")
76
+ record = {"cmetrics" => @binary, "hostname" => Socket.gethostname}
77
+ d.run(default_tag: 'test') do
78
+ d.feed(time, record)
79
+ end
80
+ d.filtered.map {|e| assert_equal(!!use_dimensions, e.last.has_key?("dims"))}
81
+ d.filtered.map {|e| assert_true(e.last.has_key?("hostname"))}
52
82
  assert do
53
83
  d.filtered.size > 0
54
84
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-cmetrics
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.rc5
4
+ version: 0.1.0.rc6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hiroshi Hatake
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-09-24 00:00:00.000000000 Z
11
+ date: 2021-09-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler