fluent-plugin-opensearch 1.0.4 → 1.0.5

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: 6d2bf385e2b57f561be89d6ccb74da8a95870668368643321c9217a83683d3ca
4
- data.tar.gz: a5e622af13e62991eac0845ef4e0d33e12252f18c5073d335b78b8dc7055c2f1
3
+ metadata.gz: 0dc7a8e74a02c8940f19855c7377b7022e62ba0a9645e63eb2df366b0e085bb1
4
+ data.tar.gz: 482ed0c66522385c60a0765fbd0852e6158050ed4f803b7fed8a7045faf67beb
5
5
  SHA512:
6
- metadata.gz: 88ad2347a77fdd8a95851f53514def3396e424634a1e906c7700b875000881e5cd6825d8441cc765912e838dc9b2068702949d6722343fac0d476b9993fb3c35
7
- data.tar.gz: b0f852ea5f3b42778ebfcad0d32a657a554077806e3e500dc9eb4bb7625cc95188aded8437d6ba7ca43eeafdecfa4dd40f01220f2956d78b9eb9b476d2e6ece9
6
+ metadata.gz: ddab26f5bd880a43a29a345db493e7ceb39aafd5d6a583fd895975808041ee2856b125d579ffa64e8716f46e340e6a0e8d4079bc790b9a8b60f3ebcba1f53168
7
+ data.tar.gz: 4e2e566e012edcab487b66c6e5ca2cfe0e0e87d4470bbc79704d830ee561789a16e537967d549a1d0ea687cf59a7cf86781de1ae7dfdd15928934a2fc86ecae0
data/History.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  ### [Unreleased]
4
4
 
5
+ ### 1.0.5
6
+ - Use if clause to detect requirements for emitting error label events (#57)
7
+ - opensearch_data_stream: Align lowercases for data_stream and its template names (#50)
8
+
5
9
  ### 1.0.4
6
10
  - Automatically create data streams (#44)
7
11
 
@@ -3,7 +3,7 @@ $:.push File.expand_path('../lib', __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = 'fluent-plugin-opensearch'
6
- s.version = '1.0.4'
6
+ s.version = '1.0.5'
7
7
  s.authors = ['Hiroshi Hatake']
8
8
  s.email = ['cosmo0920.wp@gmail.com']
9
9
  s.description = %q{Opensearch output plugin for Fluent event collector}
@@ -65,11 +65,8 @@ class Fluent::Plugin::OpenSearchErrorHandler
65
65
  end
66
66
  end
67
67
 
68
- def emit_error_label_event(&block)
69
- # If `emit_error_label_event` is specified as false, error event emittions are not occurred.
70
- if @plugin.emit_error_label_event
71
- block.call
72
- end
68
+ def emit_error_label_event?
69
+ !!@plugin.emit_error_label_event
73
70
  end
74
71
 
75
72
  def handle_error(response, tag, chunk, bulk_message_count, extracted_values)
@@ -138,14 +135,14 @@ class Fluent::Plugin::OpenSearchErrorHandler
138
135
  reason += " [reason]: \'#{item[write_operation]['error']['reason']}\'"
139
136
  end
140
137
  end
141
- emit_error_label_event do
138
+ if emit_error_label_event?
142
139
  @plugin.router.emit_error_event(tag, time, rawrecord, OpenSearchError.new("400 - Rejected by OpenSearch#{reason}"))
143
140
  end
144
141
  else
145
142
  if item[write_operation]['error'].is_a?(String)
146
143
  reason = item[write_operation]['error']
147
144
  stats[:errors_block_resp] += 1
148
- emit_error_label_event do
145
+ if emit_error_label_event?
149
146
  @plugin.router.emit_error_event(tag, time, rawrecord, OpenSearchError.new("#{status} - #{reason}"))
150
147
  end
151
148
  next
@@ -156,7 +153,7 @@ class Fluent::Plugin::OpenSearchErrorHandler
156
153
  raise OpenSearchRequestAbortError, "Rejected OpenSearch due to #{type}"
157
154
  end
158
155
  if unrecoverable_record_error?(type)
159
- emit_error_label_event do
156
+ if emit_error_label_event?
160
157
  @plugin.router.emit_error_event(tag, time, rawrecord, OpenSearchError.new("#{status} - #{type}: #{reason}"))
161
158
  end
162
159
  next
@@ -167,7 +164,7 @@ class Fluent::Plugin::OpenSearchErrorHandler
167
164
  # When we don't have a type field, something changed in the API
168
165
  # expected return values.
169
166
  stats[:errors_bad_resp] += 1
170
- emit_error_label_event do
167
+ if emit_error_label_event?
171
168
  @plugin.router.emit_error_event(tag, time, rawrecord, OpenSearchError.new("#{status} - No error type provided in the response"))
172
169
  end
173
170
  next
@@ -465,11 +465,8 @@ module Fluent::Plugin
465
465
  placeholder_validities.include?(true)
466
466
  end
467
467
 
468
- def emit_error_label_event(&block)
469
- # If `emit_error_label_event` is specified as false, error event emittions are not occurred.
470
- if @emit_error_label_event
471
- block.call
472
- end
468
+ def emit_error_label_event?
469
+ !!@emit_error_label_event
473
470
  end
474
471
 
475
472
  def compression
@@ -588,7 +585,7 @@ module Fluent::Plugin
588
585
  def parse_time(value, event_time, tag)
589
586
  @time_parser.call(value)
590
587
  rescue => e
591
- emit_error_label_event do
588
+ if emit_error_label_event?
592
589
  router.emit_error_event(@time_parse_error_tag, Fluent::Engine.now, {'tag' => tag, 'time' => event_time, 'format' => @time_key_format, 'value' => value}, e)
593
590
  end
594
591
  return Time.at(event_time).to_datetime
@@ -882,7 +879,7 @@ module Fluent::Plugin
882
879
  end
883
880
  end
884
881
  rescue => e
885
- emit_error_label_event do
882
+ if emit_error_label_event?
886
883
  router.emit_error_event(tag, time, record, e)
887
884
  end
888
885
  end
@@ -157,8 +157,8 @@ module Fluent::Plugin
157
157
  else
158
158
  extract_placeholders(@host, chunk)
159
159
  end
160
- data_stream_name = extract_placeholders(@data_stream_name, chunk)
161
- data_stream_template_name = extract_placeholders(@data_stream_template_name, chunk)
160
+ data_stream_name = extract_placeholders(@data_stream_name, chunk).downcase
161
+ data_stream_template_name = extract_placeholders(@data_stream_template_name, chunk).downcase
162
162
  unless @data_stream_names.include?(data_stream_name)
163
163
  begin
164
164
  create_index_template(data_stream_name, data_stream_template_name, host)
@@ -439,6 +439,23 @@ class OpenSearchOutputDataStreamTest < Test::Unit::TestCase
439
439
  assert_equal 1, @bulk_records
440
440
  end
441
441
 
442
+ def test_placeholder_with_capital_letters
443
+ dsname = "foo_test.capital_letters"
444
+ tplname = "foo_tpl_test.capital_letters"
445
+ stub_default(dsname, tplname)
446
+ stub_bulk_feed(dsname, tplname)
447
+ conf = config_element(
448
+ 'ROOT', '', {
449
+ '@type' => OPENSEARCH_DATA_STREAM_TYPE,
450
+ 'data_stream_name' => 'foo_${tag}',
451
+ 'data_stream_template_name' => "foo_tpl_${tag}"
452
+ })
453
+ driver(conf).run(default_tag: 'TEST.CAPITAL_LETTERS') do
454
+ driver.feed(sample_record)
455
+ end
456
+ assert_equal 1, @bulk_records
457
+ end
458
+
442
459
  def test_placeholder_params_unset
443
460
  dsname = "foo_test"
444
461
  tplname = "foo_test_template"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-opensearch
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hiroshi Hatake
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-04-12 00:00:00.000000000 Z
11
+ date: 2022-05-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fluentd