fluent-plugin-splunk-hec 1.2.3 → 1.2.7

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: e144a9789e7458c60740d05f2a53cbf18787991f19f61aeff224c0114d6f5001
4
- data.tar.gz: 96edae330175b273c041c933a03fa052a6a41f9fb736bb28549d2405668dac71
3
+ metadata.gz: 82583190560421481d9200800ba359a624e90e9abcfb8c34ff192e3a030802b7
4
+ data.tar.gz: 83b5d8718c249a48771f6baee0e0ff7519aacd1122c80598e67bd615a02f0727
5
5
  SHA512:
6
- metadata.gz: fe149f5fe894e6cccbae1c17d181f84bb7ec0ce4a71d7f4da0c71eb663e6d82134bd1783eb8901c10183face7c713f4b0d60117f76d5647180eeea345deac774
7
- data.tar.gz: 7bbda982e056231f17adc319045d6321d70641b0fc11d19d58dbbf5291251b79cdb0f2f84f6ed6fb69d06cdaf731bb44cc296e4e7de945df72a20d69090e75db
6
+ metadata.gz: 149aef4f611a186754d61eb04a1329615f811ad2f9a6c4b07c0a2153f2d0b30564fd7166beadcd233ff87900d2cf75d6d51e347725f1bbf657a01a9d07b6f42d
7
+ data.tar.gz: 5f2f8109fb5c3ed10c88f9d3b95f94d10c52c3df4c812f480780e7f7234c3339c69c0451a931c0da94ba42ab58a5894f7f8cfb9a1534fcac51322d21fedda3bc
data/Gemfile.lock CHANGED
@@ -1,62 +1,64 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fluent-plugin-splunk-hec (1.2.3)
4
+ fluent-plugin-splunk-hec (1.2.7)
5
5
  fluentd (>= 1.4)
6
6
  multi_json (~> 1.13)
7
7
  net-http-persistent (~> 3.1)
8
8
  openid_connect (~> 1.1.8)
9
- prometheus-client (< 0.10.0)
9
+ prometheus-client (>= 2.1.0)
10
10
 
11
11
  GEM
12
12
  remote: https://rubygems.org/
13
13
  specs:
14
- activemodel (5.2.4.3)
15
- activesupport (= 5.2.4.3)
16
- activesupport (5.2.4.3)
14
+ activemodel (6.1.4)
15
+ activesupport (= 6.1.4)
16
+ activesupport (6.1.4)
17
17
  concurrent-ruby (~> 1.0, >= 1.0.2)
18
- i18n (>= 0.7, < 2)
19
- minitest (~> 5.1)
20
- tzinfo (~> 1.1)
21
- addressable (2.7.0)
18
+ i18n (>= 1.6, < 2)
19
+ minitest (>= 5.1)
20
+ tzinfo (~> 2.0)
21
+ zeitwerk (~> 2.3)
22
+ addressable (2.8.0)
22
23
  public_suffix (>= 2.0.2, < 5.0)
23
- aes_key_wrap (1.0.1)
24
- ast (2.4.0)
24
+ aes_key_wrap (1.1.0)
25
+ ast (2.4.2)
25
26
  attr_required (1.0.1)
26
- bindata (2.4.4)
27
- concurrent-ruby (1.1.6)
28
- connection_pool (2.2.2)
29
- cool.io (1.6.0)
30
- crack (0.4.3)
31
- safe_yaml (~> 1.0.0)
32
- docile (1.3.2)
33
- fluentd (1.9.2)
27
+ bindata (2.4.10)
28
+ concurrent-ruby (1.1.9)
29
+ connection_pool (2.2.5)
30
+ cool.io (1.7.1)
31
+ crack (0.4.5)
32
+ rexml
33
+ docile (1.4.0)
34
+ fluentd (1.13.2)
35
+ bundler
34
36
  cool.io (>= 1.4.5, < 2.0.0)
35
- http_parser.rb (>= 0.5.1, < 0.7.0)
37
+ http_parser.rb (>= 0.5.1, < 0.8.0)
36
38
  msgpack (>= 1.3.1, < 2.0.0)
37
- serverengine (>= 2.0.4, < 3.0.0)
39
+ serverengine (>= 2.2.2, < 3.0.0)
38
40
  sigdump (~> 0.2.2)
39
41
  strptime (>= 0.2.2, < 1.0.0)
40
42
  tzinfo (>= 1.0, < 3.0)
41
43
  tzinfo-data (~> 1.0)
44
+ webrick (>= 1.4.2, < 1.8.0)
42
45
  yajl-ruby (~> 1.0)
43
- hashdiff (1.0.0)
44
- http_parser.rb (0.5.3)
46
+ hashdiff (1.0.1)
47
+ http_parser.rb (0.7.0)
45
48
  httpclient (2.8.3)
46
- i18n (1.8.2)
49
+ i18n (1.8.10)
47
50
  concurrent-ruby (~> 1.0)
48
51
  jaro_winkler (1.5.4)
49
- json (2.3.0)
50
- json-jwt (1.11.0)
52
+ json-jwt (1.13.0)
51
53
  activesupport (>= 4.2)
52
54
  aes_key_wrap
53
55
  bindata
54
56
  mail (2.7.1)
55
57
  mini_mime (>= 0.1.1)
56
- mini_mime (1.0.2)
57
- minitest (5.14.0)
58
- msgpack (1.3.3)
59
- multi_json (1.14.1)
58
+ mini_mime (1.1.0)
59
+ minitest (5.14.4)
60
+ msgpack (1.4.2)
61
+ multi_json (1.15.0)
60
62
  net-http-persistent (3.1.0)
61
63
  connection_pool (~> 2.2)
62
64
  openid_connect (1.1.8)
@@ -69,24 +71,23 @@ GEM
69
71
  validate_email
70
72
  validate_url
71
73
  webfinger (>= 1.0.1)
72
- parallel (1.19.1)
73
- parser (2.7.0.2)
74
- ast (~> 2.4.0)
75
- power_assert (1.1.5)
76
- powerpack (0.1.2)
77
- prometheus-client (0.9.0)
78
- quantile (~> 0.2.1)
79
- public_suffix (4.0.3)
80
- quantile (0.2.1)
74
+ parallel (1.20.1)
75
+ parser (3.0.2.0)
76
+ ast (~> 2.4.1)
77
+ power_assert (2.0.0)
78
+ powerpack (0.1.3)
79
+ prometheus-client (2.1.0)
80
+ public_suffix (4.0.6)
81
81
  rack (2.2.3)
82
- rack-oauth2 (1.10.1)
82
+ rack-oauth2 (1.17.0)
83
83
  activesupport
84
84
  attr_required
85
85
  httpclient
86
86
  json-jwt (>= 1.11.0)
87
- rack
87
+ rack (>= 2.1.0)
88
88
  rainbow (3.0.0)
89
- rake (12.3.3)
89
+ rake (13.0.6)
90
+ rexml (3.2.5)
90
91
  rubocop (0.63.1)
91
92
  jaro_winkler (~> 1.5.1)
92
93
  parallel (~> 1.10)
@@ -95,33 +96,32 @@ GEM
95
96
  rainbow (>= 2.2.2, < 4.0)
96
97
  ruby-progressbar (~> 1.7)
97
98
  unicode-display_width (~> 1.4.0)
98
- ruby-progressbar (1.10.1)
99
- safe_yaml (1.0.5)
100
- serverengine (2.2.1)
99
+ ruby-progressbar (1.11.0)
100
+ serverengine (2.2.4)
101
101
  sigdump (~> 0.2.2)
102
102
  sigdump (0.2.4)
103
- simplecov (0.16.1)
103
+ simplecov (0.21.2)
104
104
  docile (~> 1.1)
105
- json (>= 1.8, < 3)
106
- simplecov-html (~> 0.10.0)
107
- simplecov-html (0.10.2)
108
- strptime (0.2.3)
109
- swd (1.1.2)
105
+ simplecov-html (~> 0.11)
106
+ simplecov_json_formatter (~> 0.1)
107
+ simplecov-html (0.12.3)
108
+ simplecov_json_formatter (0.1.3)
109
+ strptime (0.2.5)
110
+ swd (1.2.0)
110
111
  activesupport (>= 3)
111
112
  attr_required (>= 0.0.5)
112
113
  httpclient (>= 2.4)
113
- test-unit (3.3.5)
114
+ test-unit (3.4.4)
114
115
  power_assert
115
- thread_safe (0.3.6)
116
- tzinfo (1.2.6)
117
- thread_safe (~> 0.1)
118
- tzinfo-data (1.2019.3)
116
+ tzinfo (2.0.4)
117
+ concurrent-ruby (~> 1.0)
118
+ tzinfo-data (1.2021.1)
119
119
  tzinfo (>= 1.0.0)
120
120
  unicode-display_width (1.4.1)
121
121
  validate_email (0.1.6)
122
122
  activemodel (>= 3.0)
123
123
  mail (>= 2.2.5)
124
- validate_url (1.0.8)
124
+ validate_url (1.0.13)
125
125
  activemodel (>= 3.0.0)
126
126
  public_suffix
127
127
  webfinger (1.1.0)
@@ -131,7 +131,9 @@ GEM
131
131
  addressable (>= 2.3.6)
132
132
  crack (>= 0.3.2)
133
133
  hashdiff
134
+ webrick (1.7.0)
134
135
  yajl-ruby (1.4.1)
136
+ zeitwerk (2.4.2)
135
137
 
136
138
  PLATFORMS
137
139
  ruby
@@ -147,4 +149,4 @@ DEPENDENCIES
147
149
  webmock (~> 3.5.0)
148
150
 
149
151
  BUNDLED WITH
150
- 2.1.4
152
+ 2.2.23
data/README.md CHANGED
@@ -260,6 +260,10 @@ Cannot set both `source` and `source_key` parameters at the same time.
260
260
 
261
261
  Field name that contains the sourcetype. Cannot set both `source` and `source_key` parameters at the same time.
262
262
 
263
+ ### time_key (string) (optional)
264
+
265
+ Field name to contain Splunk event time. By default will use fluentd\'d time.
266
+
263
267
  ### fields (init) (optional)
264
268
 
265
269
  Lets you specify the index-time fields for the event data type, or metric dimensions for the metric data type. Null value fields are removed.
@@ -293,7 +297,7 @@ In this case, parameters inside `<fields>` are used as indexed fields and remove
293
297
  <fields>
294
298
  file
295
299
  level
296
- app applicatioin
300
+ app application
297
301
  </fields>
298
302
  </match>
299
303
  ```
@@ -340,7 +344,7 @@ For metrics, parameters inside `<fields>` are used as dimensions. If `<fields>`
340
344
  <fields>
341
345
  file
342
346
  level
343
- app applicatioin
347
+ app application
344
348
  </fields>
345
349
  </match>
346
350
  ```
@@ -432,6 +436,14 @@ List of SSl ciphers allowed.
432
436
 
433
437
  Specifies whether an insecure SSL connection is allowed. If set to false, Splunk does not verify an insecure server certificate. This parameter is set to `false` by default. Ensure parameter `ca_file` is not configured in order to allow insecure SSL connections when this value is set to `true`.
434
438
 
439
+ #### require_ssl_min_version (bool)
440
+
441
+ When set to true, TLS version 1.1 and above is required.
442
+
443
+ #### consume_chunk_on_4xx_errors (bool)
444
+
445
+ Specifies whether any 4xx HTTP response status code consumes the buffer chunks. If set to false, Splunk will fail to flush the buffer on such status codes. This parameter is set to `true` by default for backwards compatibility.
446
+
435
447
  ## About Buffer
436
448
 
437
449
  This plugin sends events to HEC using [batch mode](https://docs.splunk.com/Documentation/Splunk/7.1.0/Data/FormateventsforHTTPEventCollector#Event_data).
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.2.3
1
+ 1.2.7
@@ -37,7 +37,7 @@ Gem::Specification.new do |spec|
37
37
  spec.add_runtime_dependency 'multi_json', '~> 1.13'
38
38
  spec.add_runtime_dependency 'net-http-persistent', '~> 3.1'
39
39
  spec.add_runtime_dependency 'openid_connect', '~> 1.1.8'
40
- spec.add_runtime_dependency 'prometheus-client', '< 0.10.0'
40
+ spec.add_runtime_dependency 'prometheus-client', '>= 2.1.0'
41
41
 
42
42
  spec.add_development_dependency 'bundler', '~> 2.0'
43
43
  spec.add_development_dependency 'rake', '>= 12.0'
@@ -13,7 +13,7 @@ module Fluent::Plugin
13
13
  autoload :VERSION, 'fluent/plugin/out_splunk/version'
14
14
  autoload :MatchFormatter, 'fluent/plugin/out_splunk/match_formatter'
15
15
 
16
- KEY_FIELDS = %w[index host source sourcetype metric_name metric_value].freeze
16
+ KEY_FIELDS = %w[index host source sourcetype metric_name metric_value time].freeze
17
17
  TAG_PLACEHOLDER = '${tag}'
18
18
 
19
19
  desc 'The host field for events, by default it uses the hostname of the machine that runnning fluentd. This is exclusive with `host_key`.'
@@ -51,6 +51,9 @@ module Fluent::Plugin
51
51
  # this is blank on purpose
52
52
  end
53
53
 
54
+ desc 'Indicates if 4xx errors should consume chunk'
55
+ config_param :consume_chunk_on_4xx_errors, :bool, :default => true
56
+
54
57
  config_section :format do
55
58
  config_set_default :usage, '**'
56
59
  config_set_default :@type, 'json'
@@ -97,11 +100,11 @@ module Fluent::Plugin
97
100
  write_to_splunk(chunk)
98
101
  end
99
102
 
100
- @metrics[:record_counter].increment(metric_labels, chunk.size_of_events)
101
- @metrics[:bytes_counter].increment(metric_labels, chunk.bytesize)
102
- @metrics[:write_records_histogram].observe(metric_labels, chunk.size_of_events)
103
- @metrics[:write_bytes_histogram].observe(metric_labels, chunk.bytesize)
104
- @metrics[:write_latency_histogram].observe(metric_labels, t)
103
+ @metrics[:record_counter].increment(labels: metric_labels, by: chunk.size_of_events)
104
+ @metrics[:bytes_counter].increment(labels: metric_labels, by: chunk.bytesize)
105
+ @metrics[:write_records_histogram].observe(chunk.size_of_events, labels: metric_labels)
106
+ @metrics[:write_bytes_histogram].observe(chunk.bytesize, labels: metric_labels, )
107
+ @metrics[:write_latency_histogram].observe(t, labels: metric_labels, )
105
108
  end
106
109
 
107
110
  def write_to_splunk(_chunk)
@@ -150,13 +153,14 @@ module Fluent::Plugin
150
153
  def process_response(response, _request_body)
151
154
  log.trace { "[Response] POST #{@api}: #{response.inspect}" }
152
155
 
153
- @metrics[:status_counter].increment(metric_labels(status: response.code.to_s))
156
+ @metrics[:status_counter].increment(labels: metric_labels(status: response.code.to_s))
157
+
158
+ raise_err = response.code.to_s.start_with?('5') || (!@consume_chunk_on_4xx_errors && response.code.to_s.start_with?('4'))
154
159
 
155
160
  # raise Exception to utilize Fluentd output plugin retry mechanism
156
- raise "Server error (#{response.code}) for POST #{@api}, response: #{response.body}" if response.code.to_s.start_with?('5')
161
+ raise "Server error (#{response.code}) for POST #{@api}, response: #{response.body}" if raise_err
157
162
 
158
- # For both success response (2xx) and client errors (4xx), we will consume the chunk.
159
- # Because there probably a bug in the code if we get 4xx errors, retry won't do any good.
163
+ # For both success response (2xx) we will consume the chunk.
160
164
  unless response.code.to_s.start_with?('2')
161
165
  log.error "#{self.class}: Failed POST to #{@api}, response: #{response.body}"
162
166
  log.error { "#{self.class}: Failed request body: #{post.body}" }
@@ -205,7 +209,7 @@ module Fluent::Plugin
205
209
  # This loop looks dump, but it is used to suppress the unused parameter configuration warning
206
210
  # Learned from `filter_record_transformer`.
207
211
  conf.elements.select { |element| element.name == 'fields' }.each do |element|
208
- element.each_pair { |k, _v| element.key?(k) }
212
+ element.each_pair { |k, _v| element.has_key?(k) }
209
213
  end
210
214
 
211
215
  return unless @fields
@@ -231,28 +235,34 @@ module Fluent::Plugin
231
235
 
232
236
  @metrics = {
233
237
  record_counter: register_metric(::Prometheus::Client::Counter.new(
234
- :splunk_output_write_records_count,
235
- 'The number of log records being sent'
238
+ :splunk_output_write_records_count, docstring:
239
+ 'The number of log records being sent',
240
+ labels: metric_label_keys
236
241
  )),
237
242
  bytes_counter: register_metric(::Prometheus::Client::Counter.new(
238
- :splunk_output_write_bytes_count,
239
- 'The number of log bytes being sent'
243
+ :splunk_output_write_bytes_count, docstring:
244
+ 'The number of log bytes being sent',
245
+ labels: metric_label_keys
240
246
  )),
241
247
  status_counter: register_metric(::Prometheus::Client::Counter.new(
242
- :splunk_output_write_status_count,
243
- 'The count of sends by response_code'
248
+ :splunk_output_write_status_count, docstring:
249
+ 'The count of sends by response_code',
250
+ labels: metric_label_keys(status: "")
244
251
  )),
245
252
  write_bytes_histogram: register_metric(::Prometheus::Client::Histogram.new(
246
- :splunk_output_write_payload_bytes,
247
- 'The size of the write payload in bytes', {}, [1024, 23_937, 47_875, 95_750, 191_500, 383_000, 766_000, 1_149_000]
253
+ :splunk_output_write_payload_bytes, docstring:
254
+ 'The size of the write payload in bytes', buckets: [1024, 23_937, 47_875, 95_750, 191_500, 383_000, 766_000, 1_149_000],
255
+ labels: metric_label_keys
248
256
  )),
249
257
  write_records_histogram: register_metric(::Prometheus::Client::Histogram.new(
250
- :splunk_output_write_payload_records,
251
- 'The number of records written per write', {}, [1, 10, 25, 100, 200, 300, 500, 750, 1000, 1500]
258
+ :splunk_output_write_payload_records, docstring:
259
+ 'The number of records written per write', buckets: [1, 10, 25, 100, 200, 300, 500, 750, 1000, 1500],
260
+ labels: metric_label_keys
252
261
  )),
253
262
  write_latency_histogram: register_metric(::Prometheus::Client::Histogram.new(
254
- :splunk_output_write_latency_seconds,
255
- 'The latency of writes'
263
+ :splunk_output_write_latency_seconds, docstring:
264
+ 'The latency of writes',
265
+ labels: metric_label_keys
256
266
  ))
257
267
  }
258
268
  end
@@ -262,6 +272,10 @@ module Fluent::Plugin
262
272
  @metric_labels.merge other_labels
263
273
  end
264
274
 
275
+ def metric_label_keys(other_labels = {})
276
+ (@metric_labels.merge other_labels).keys
277
+ end
278
+
265
279
  # Encode as UTF-8. If 'coerce_to_utf8' is set to true in the config, any
266
280
  # non-UTF-8 character would be replaced by the string specified by
267
281
  # 'non_utf8_replacement_string'. If 'coerce_to_utf8' is set to false, any
@@ -63,6 +63,9 @@ module Fluent::Plugin
63
63
  desc 'List of SSL ciphers allowed.'
64
64
  config_param :ssl_ciphers, :array, default: nil
65
65
 
66
+ desc 'When set to true, TLS version 1.1 and above is required.'
67
+ config_param :require_ssl_min_version, :bool, default: true
68
+
66
69
  desc 'Indicates if insecure SSL connection is allowed.'
67
70
  config_param :insecure_ssl, :bool, default: false
68
71
 
@@ -97,7 +100,10 @@ module Fluent::Plugin
97
100
  config_section :fields, init: false, multi: false, required: false do
98
101
  # this is blank on purpose
99
102
  end
100
-
103
+
104
+ desc 'Indicates if 4xx errors should consume chunk'
105
+ config_param :consume_chunk_on_4xx_errors, :bool, :default => true
106
+
101
107
  config_section :format do
102
108
  config_set_default :usage, '**'
103
109
  config_set_default :@type, 'json'
@@ -140,6 +146,8 @@ module Fluent::Plugin
140
146
  c.ca_file = @ca_file
141
147
  c.ca_path = @ca_path
142
148
  c.ciphers = @ssl_ciphers
149
+ c.proxy = :ENV
150
+ c.min_version = OpenSSL::SSL::TLS1_1_VERSION if @require_ssl_min_version
143
151
 
144
152
  c.override_headers['Content-Type'] = 'application/json'
145
153
  c.override_headers['User-Agent'] = "fluent-plugin-splunk_hec_out/#{VERSION}"
@@ -179,7 +187,7 @@ module Fluent::Plugin
179
187
  end
180
188
 
181
189
  def format_event(tag, time, record)
182
- MultiJson.dump({
190
+ d = {
183
191
  host: @host ? @host.(tag, record) : @default_host,
184
192
  # From the API reference
185
193
  # http://docs.splunk.com/Documentation/Splunk/latest/RESTREF/RESTinput#services.2Fcollector
@@ -212,7 +220,12 @@ module Fluent::Plugin
212
220
  record = formatter.format(tag, time, record)
213
221
  end
214
222
  payload[:event] = convert_to_utf8 record
215
- })
223
+ }
224
+ if d[:event] == "{}"
225
+ log.warn { "Event after formatting was blank, not sending" }
226
+ return ""
227
+ end
228
+ MultiJson.dump(d)
216
229
  end
217
230
 
218
231
  def format_metric(tag, time, record)
@@ -224,7 +237,7 @@ module Fluent::Plugin
224
237
  # That's why we use `to_s` here.
225
238
  time: time.to_f.to_s,
226
239
  event: 'metric'
227
- }.tap do |payload|
240
+ }.tap do |payload|
228
241
  if @time
229
242
  time_value = @time.(tag, record)
230
243
  # if no value is found don't override and use fluentd's time
@@ -279,9 +292,11 @@ module Fluent::Plugin
279
292
  c.ca_file = @ca_file
280
293
  c.ca_path = @ca_path
281
294
  c.ciphers = @ssl_ciphers
295
+ c.proxy = :ENV
282
296
  c.idle_timeout = @idle_timeout
283
297
  c.read_timeout = @read_timeout
284
298
  c.open_timeout = @open_timeout
299
+ c.min_version = OpenSSL::SSL::TLS1_1_VERSION if @require_ssl_min_version
285
300
 
286
301
  c.override_headers['Content-Type'] = 'application/json'
287
302
  c.override_headers['User-Agent'] = "fluent-plugin-splunk_hec_out/#{VERSION}"
@@ -302,11 +317,12 @@ module Fluent::Plugin
302
317
  response = @conn.request @api, post
303
318
  t2 = Time.now
304
319
 
305
- # raise Exception to utilize Fluentd output plugin retry machanism
306
- raise "Server error (#{response.code}) for POST #{@api}, response: #{response.body}" if response.code.start_with?('5')
320
+ raise_err = response.code.to_s.start_with?('5') || (!@consume_chunk_on_4xx_errors && response.code.to_s.start_with?('4'))
321
+
322
+ # raise Exception to utilize Fluentd output plugin retry mechanism
323
+ raise "Server error (#{response.code}) for POST #{@api}, response: #{response.body}" if raise_err
307
324
 
308
- # For both success response (2xx) and client errors (4xx), we will consume the chunk.
309
- # Because there probably a bug in the code if we get 4xx errors, retry won't do any good.
325
+ # For both success response (2xx) we will consume the chunk.
310
326
  if not response.code.start_with?('2')
311
327
  log.error "Failed POST to #{@api}, response: #{response.body}"
312
328
  log.debug { "Failed request body: #{post.body}" }
@@ -340,7 +356,7 @@ module Fluent::Plugin
340
356
  invalid: :replace,
341
357
  undef: :replace,
342
358
  replace: @non_utf8_replacement_string)
343
- else
359
+ else
344
360
  begin
345
361
  input.encode('utf-8')
346
362
  rescue EncodingError
@@ -57,6 +57,9 @@ describe Fluent::Plugin::SplunkHecOutput do
57
57
  assert_nil(create_hec_output_driver('hec_host hec_token').instance.index_key)
58
58
  expect(create_hec_output_driver('hec_host hec_token').instance.index_key).is_a? String
59
59
  end
60
+ it 'should consume chunks on 4xx errors' do
61
+ expect(create_hec_output_driver('hec_host hec_token').instance.consume_chunk_on_4xx_errors).must_equal true
62
+ end
60
63
  end
61
64
 
62
65
  describe 'hec_host validation' do
@@ -139,6 +142,7 @@ describe Fluent::Plugin::SplunkHecOutput do
139
142
  host_key from
140
143
  source_key file
141
144
  sourcetype_key agent.name
145
+ time_key timestamp
142
146
  CONF
143
147
  batch.each do |item|
144
148
  expect(item['index']).must_equal 'info'
@@ -147,7 +151,7 @@ describe Fluent::Plugin::SplunkHecOutput do
147
151
  expect(item['sourcetype']).must_equal 'test'
148
152
 
149
153
  JSON.load(item['event']).tap do |event|
150
- %w[level from file].each { |field| expect(event).wont_include field }
154
+ %w[level from file timestamp].each { |field| expect(event).wont_include field }
151
155
  expect(event['agent']).wont_include 'name'
152
156
  end
153
157
  end
@@ -220,6 +224,24 @@ describe Fluent::Plugin::SplunkHecOutput do
220
224
  end
221
225
  end
222
226
 
227
+ it 'should not send blank events' do
228
+ verify_sent_events(<<~CONF) do |batch|
229
+ <fields>
230
+ from
231
+ logLevel level
232
+ nonexist
233
+ log
234
+ file
235
+ value
236
+ id
237
+ agent
238
+ timestamp
239
+ </fields>
240
+ CONF
241
+ expect(batch.length).must_equal 0
242
+ end
243
+ end
244
+
223
245
  describe 'metric' do
224
246
  it 'should check related configs' do
225
247
  expect(
@@ -349,7 +371,8 @@ describe Fluent::Plugin::SplunkHecOutput do
349
371
  'agent' => {
350
372
  'name' => 'test',
351
373
  'version' => '1.0.0'
352
- }
374
+ },
375
+ 'timestamp' => 'time'
353
376
  }
354
377
  events = [
355
378
  ['tag.event1', event_time, { 'id' => '1st' }.merge(Marshal.load(Marshal.dump(event)))],
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-splunk-hec
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.3
4
+ version: 1.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Splunk Inc.
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-27 00:00:00.000000000 Z
11
+ date: 2021-07-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fluentd
@@ -70,16 +70,16 @@ dependencies:
70
70
  name: prometheus-client
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - "<"
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
- version: 0.10.0
75
+ version: 2.1.0
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - "<"
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
- version: 0.10.0
82
+ version: 2.1.0
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: bundler
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -215,7 +215,7 @@ homepage: https://github.com/splunk/fluent-plugin-splunk-hec
215
215
  licenses:
216
216
  - Apache-2.0
217
217
  metadata: {}
218
- post_install_message:
218
+ post_install_message:
219
219
  rdoc_options: []
220
220
  require_paths:
221
221
  - lib
@@ -230,8 +230,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
230
230
  - !ruby/object:Gem::Version
231
231
  version: '0'
232
232
  requirements: []
233
- rubygems_version: 3.0.6
234
- signing_key:
233
+ rubygems_version: 3.1.4
234
+ signing_key:
235
235
  specification_version: 4
236
236
  summary: Fluentd plugin for Splunk HEC.
237
237
  test_files: