fluent-plugin-opensearch 1.0.4 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/History.md +4 -0
- data/fluent-plugin-opensearch.gemspec +1 -1
- data/lib/fluent/plugin/opensearch_error_handler.rb +6 -9
- data/lib/fluent/plugin/out_opensearch.rb +4 -7
- data/lib/fluent/plugin/out_opensearch_data_stream.rb +2 -2
- data/test/plugin/test_out_opensearch_data_stream.rb +17 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0dc7a8e74a02c8940f19855c7377b7022e62ba0a9645e63eb2df366b0e085bb1
|
4
|
+
data.tar.gz: 482ed0c66522385c60a0765fbd0852e6158050ed4f803b7fed8a7045faf67beb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
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
|
69
|
-
|
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
|
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
|
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
|
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
|
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
|
469
|
-
|
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
|
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
|
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
|
+
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-
|
11
|
+
date: 2022-05-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fluentd
|