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

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: 65548cae758782bc23022e7078dbab4a7c566b6175a652e7c5cee348a3b1ef93
4
- data.tar.gz: e5fe401babbfe22ac5038130dd72d29135a794c155e4a294c59fbc4b5898dd41
3
+ metadata.gz: f2da1d6e9e9b821b5992d1e6989d034d04f074bc10a11ecd35d2842207a77754
4
+ data.tar.gz: c71b5a5c8ad4a33328b4c542d00a2a562639fa9f9b646db3bd9c66cf922c2b53
5
5
  SHA512:
6
- metadata.gz: 6991cae004f796934cd0b4dd7d5d1ef9f175798c7c799ac0c417860451b6c4c04deb2d9c9fb0776a20eae180f826854b8c089b31ea79cdc2ea1ced376defe1a1
7
- data.tar.gz: 28fd06e6a2df8d259aab80eff36a27cc2bd3a2155e47c45170c6d5704c24882d42226d3ff1f8f55fd8e6a73c1825adb45d1e05d46cffae0bea56e7b1097edd51
6
+ metadata.gz: 5cd27f38bb9ea19e325589293f29cf13b07bf3158adb0d21febc502d6f5c2e76ed8841ebea47436478890c79fa9ac546918abd91bce17f48ef2970a71695bc38
7
+ data.tar.gz: 6661de3897ecac7c2a07a5765dbf16f9c6876e6ab2d6ae80d789793473c67ca91ac3fe4a8091335f99dcc517c4343253e3369c5cdd2c977d3d4141a85b82fd19
data/README.md CHANGED
@@ -44,12 +44,6 @@ 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
-
53
47
  ### format_to_splunk_metric (bool) (optional)
54
48
 
55
49
  format to Splunk metrics
@@ -58,6 +52,26 @@ format to Splunk metrics
58
52
 
59
53
  dimensions key
60
54
 
55
+
56
+ ### \<fields\> section (optional) (single)
57
+
58
+ This secsion is used for adding extra fields into cmetrics msgpack payload parsed records.
59
+
60
+ For example, the following configuration should add hostname records into parsed records:
61
+
62
+ ```aconf
63
+ <filter super.awesome.tag.**>
64
+ @type cmetrics_parser
65
+ format_to_splunk_metric true
66
+ dimensions_key dims
67
+ <fields>
68
+ hostname
69
+ </fields>
70
+ </filter>
71
+ ```
72
+
73
+ On later data pipeline, `hostname` key can be used as some additional work.
74
+
61
75
  ## Fluent::Plugin::CMetricsSplunkMetricPayloadFormatter
62
76
 
63
77
  ### cmetrics_name_key (string) (optional)
@@ -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.rc6"
6
+ spec.version = "0.1.0.rc7"
7
7
  spec.authors = ["Hiroshi Hatake"]
8
8
  spec.email = ["cosmo0920.oucc@gmail.com"]
9
9
 
@@ -30,19 +30,27 @@ 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"
35
33
  desc "format to Splunk metrics"
36
34
  config_param :format_to_splunk_metric, :bool, default: false
37
35
  desc "dimensions key"
38
36
  config_param :dimensions_key, :string, default: nil
37
+ desc "Add additional records for Splunk dimensions"
38
+ config_section :fields, init: false, multi: false,required: false do
39
+ # Nothing here. For later purpose.
40
+ end
39
41
 
40
42
  def configure(conf)
41
43
  super
42
44
  @serde = ::CMetrics::Serde.new
43
45
  @record_accessor = record_accessor_create(@cmetrics_metric_key)
44
46
  @labels_accessor = record_accessor_create(@cmetrics_labels_key)
45
- @hostname_accessor = record_accessor_create(@host_key)
47
+ @fields_accessors = {}
48
+ conf.elements(name: "fields").each do |e|
49
+ e.each_pair{|k, _v|
50
+ e.has_key?(k) # Suppress unused warnings.
51
+ @fields_accessors[k] = record_accessor_create(k)
52
+ }
53
+ end
46
54
  end
47
55
 
48
56
  def format_to_splunk_style_with_dims(inner)
@@ -62,7 +70,10 @@ module Fluent
62
70
  new_es = Fluent::MultiEventStream.new
63
71
  es.each do |time, record|
64
72
  data = @record_accessor.call(record)
65
- hostname = @hostname_accessor.call(record)
73
+ extra_fields = {}
74
+ @fields_accessors.each do |key, accessor|
75
+ extra_fields[key] = accessor.call(record)
76
+ end
66
77
  @serde.feed_each(data) do |cmetrics|
67
78
  metrics = cmetrics.metrics
68
79
  metrics.each do |metric|
@@ -77,8 +88,8 @@ module Fluent
77
88
  inner.merge!(dims)
78
89
  end
79
90
  end
80
- if hostname
81
- inner[@host_key] = hostname
91
+ if @fields_accessors
92
+ inner.merge!(extra_fields)
82
93
  end
83
94
  time = Time.at(inner.delete("timestamp"))
84
95
  new_es.add(Fluent::EventTime.new(time.to_i, time.nsec), inner)
@@ -61,16 +61,18 @@ class CmetricsParserTest < Test::Unit::TestCase
61
61
  test "#filter_stream with host_key" do |data|
62
62
  use_dimensions = data
63
63
  d = if use_dimensions
64
- create_driver(%[
65
- format_to_splunk_metric true
66
- dimensions_key dims
67
- host_key hostname
68
- ])
64
+ create_driver(Fluent::Config::Element.new('ROOT', '', {
65
+ "format_to_splunk_metric" => true,
66
+ "dimensions_key" => "dims",
67
+ }, [
68
+ Fluent::Config::Element.new('fields', '', {"hostname" => ""}, [])
69
+ ]))
69
70
  else
70
- create_driver(%[
71
- format_to_splunk_metric true
72
- host_key hostname
73
- ])
71
+ create_driver(Fluent::Config::Element.new('ROOT', '', {
72
+ "format_to_splunk_metric" => true,
73
+ }, [
74
+ Fluent::Config::Element.new('fields', '', {"hostname" => ""}, [])
75
+ ]))
74
76
  end
75
77
  time = event_time("2012-01-02 13:14:15")
76
78
  record = {"cmetrics" => @binary, "hostname" => Socket.gethostname}
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-cmetrics
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.rc6
4
+ version: 0.1.0.rc7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hiroshi Hatake