Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use template_file for Data Streams #20

Merged
merged 3 commits into from Feb 16, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
34 changes: 20 additions & 14 deletions lib/fluent/plugin/out_opensearch_data_stream.rb
Expand Up @@ -46,7 +46,7 @@ def configure(conf)

def validate_data_stream_parameters
{"data_stream_name" => @data_stream_name,
"data_stream_template_name"=> @data_stream_template_name}.each do |parameter, value|
"data_stream_template_name" => @data_stream_template_name}.each do |parameter, value|
unless valid_data_stream_parameters?(value)
unless start_with_valid_characters?(value)
if not_dots?(value)
Expand All @@ -69,19 +69,25 @@ def validate_data_stream_parameters
end

def create_index_template(datastream_name, template_name, host = nil)
return if data_stream_exist?(datastream_name, host) or template_exists?(template_name, host)
body = {
"index_patterns" => ["#{datastream_name}*"],
"data_stream" => {},
}
params = {
name: template_name,
body: body
}
retry_operate(@max_retry_putting_template,
@fail_on_putting_template_retry_exceed,
@catch_transport_exception_on_retry) do
client(host).indices.put_index_template(params)
# Create index template from file
if @template_file
template_installation_actual(template_name, @customize_template, @application_name, datastream_name, host)
cosmo0920 marked this conversation as resolved.
Show resolved Hide resolved
else # Create default index template
return if data_stream_exist?(datastream_name, host) or template_exists?(template_name, host)
body = {
"index_patterns" => ["#{datastream_name}*"],
"data_stream" => {},
}

params = {
name: template_name,
body: body
}
retry_operate(@max_retry_putting_template,
@fail_on_putting_template_retry_exceed,
@catch_transport_exception_on_retry) do
client(host).indices.put_index_template(params)
end
end
end

Expand Down