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

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: f2da1d6e9e9b821b5992d1e6989d034d04f074bc10a11ecd35d2842207a77754
4
- data.tar.gz: c71b5a5c8ad4a33328b4c542d00a2a562639fa9f9b646db3bd9c66cf922c2b53
3
+ metadata.gz: e207c02b8b1d7751c344573ec09c0d1ccf56c83d99776b2dade2e3b1366cb3d7
4
+ data.tar.gz: 448a06563a66ff12155a5059598c6fb99334f178f4564c0220c7baaecbc19eed
5
5
  SHA512:
6
- metadata.gz: 5cd27f38bb9ea19e325589293f29cf13b07bf3158adb0d21febc502d6f5c2e76ed8841ebea47436478890c79fa9ac546918abd91bce17f48ef2970a71695bc38
7
- data.tar.gz: 6661de3897ecac7c2a07a5765dbf16f9c6876e6ab2d6ae80d789793473c67ca91ac3fe4a8091335f99dcc517c4343253e3369c5cdd2c977d3d4141a85b82fd19
6
+ metadata.gz: a7219f2904e99a3b8f48f6fbaaa89d4261169563919be1d02552322b78b2756e56218e1982ef36bb93932813659e7c20ef40724f2768d6c2568f0b2fab24fc7f
7
+ data.tar.gz: fee515f5d3ae1cf09ce5af4fe4e45a6a471255d9db3ab4e9226c53cf74ea5146e764956fba8e78d16ddb65fee5e6a8b48530213d9c1d0e075cd54864d5fc4ec5
data/README.md CHANGED
@@ -110,6 +110,10 @@ Specify splunk source name
110
110
 
111
111
  Specify splunk sourcetype name
112
112
 
113
+ ### \<fields\> section (optional) (single)
114
+
115
+ This secsion is used for adding extra fields as dimensions into cmetrics msgpack Splunk metric payload.
116
+
113
117
  ## Copyright
114
118
 
115
119
  * Copyright(c) 2021- Calyptia Inc.
@@ -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.rc7"
6
+ spec.version = "0.1.0.rc8"
7
7
  spec.authors = ["Hiroshi Hatake"]
8
8
  spec.email = ["cosmo0920.oucc@gmail.com"]
9
9
 
@@ -44,6 +44,9 @@ module Fluent
44
44
  config_param :source, :string, default: nil
45
45
  desc "Specify splunk sourcetype name"
46
46
  config_param :sourcetype, :string, default: nil
47
+ config_section :fields, init: false, multi: false,required: false do
48
+ # Nothing here. For later purpose.
49
+ end
47
50
 
48
51
  def initialize
49
52
  super
@@ -57,6 +60,13 @@ module Fluent
57
60
  @cmetrics_value_accessor = record_accessor_create(@cmetrics_value_key)
58
61
  @cmetrics_dims_accessor = record_accessor_create(@cmetrics_dims_key)
59
62
  @host_key_accessor = record_accessor_create(@host_key)
63
+ @fields_accessors = {}
64
+ conf.elements(name: "fields").each do |e|
65
+ e.each_pair{|k, _v|
66
+ e.has_key?(k) # Suppress unused warnings.
67
+ @fields_accessors[k] = record_accessor_create(k)
68
+ }
69
+ end
60
70
  end
61
71
 
62
72
  def format(tag, time, record)
@@ -65,6 +75,11 @@ module Fluent
65
75
  else
66
76
  @default_host
67
77
  end
78
+ extra_fields = {}
79
+
80
+ @fields_accessors.each do |key, accessor|
81
+ extra_fields[key] = accessor.call(record)
82
+ end
68
83
  payload = {
69
84
  host: host,
70
85
  # From the API reference
@@ -81,6 +96,9 @@ module Fluent
81
96
  if dims = @cmetrics_dims_accessor.call(record)
82
97
  fields.merge!(dims)
83
98
  end
99
+ if @fields_accessors
100
+ fields.merge!(extra_fields)
101
+ end
84
102
  payload.merge!(fields)
85
103
  Yajl.dump(payload)
86
104
  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.rc7
4
+ version: 0.1.0.rc8
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-30 00:00:00.000000000 Z
11
+ date: 2021-10-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler