From 9aa8ae1524cac497f135d9d293f24b9db6e2888d Mon Sep 17 00:00:00 2001 From: Tom Sparrow <793763+sparrowt@users.noreply.github.com> Date: Fri, 5 Jan 2024 15:49:32 +0000 Subject: [PATCH] Avoid long worrying log line at info level Currently there is an info level log line when checking if a datastream exists, but it includes the entire error even though it is caught and expected. This results in long worrying looking log messages which are in fact not a problem (once you notice that they are info level) e.g. like this: ``` [info]: #0 Specified data stream does not exist. Will be created: <[404] {"error":{"root_cause":[{"type":"index_not_found_exception","reason":"no such index [my.datastream.name]","resource.type":"index_or_alias","resource.id":"my.datastream.name","index_uuid":"_na_","index":"my.datastream.name"}],"type":"index_not_found_exception","reason":"no such index [my.datastream.name]","resource.type":"index_or_alias","resource.id":"my.datastream.name","index_uuid":"_na_","index":"my.datastream.name"},"status":404}> ``` so simplify it to instead just log the name of the datastream. We know what the error is going to be given it is being caught explicitly. --- lib/fluent/plugin/out_elasticsearch_data_stream.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/fluent/plugin/out_elasticsearch_data_stream.rb b/lib/fluent/plugin/out_elasticsearch_data_stream.rb index d2d7f0a..8061eb9 100644 --- a/lib/fluent/plugin/out_elasticsearch_data_stream.rb +++ b/lib/fluent/plugin/out_elasticsearch_data_stream.rb @@ -142,7 +142,7 @@ def data_stream_exist?(datastream_name, host = nil) response = client(host).indices.get_data_stream(params) return (not response.is_a?(TRANSPORT_CLASS::Transport::Errors::NotFound)) rescue TRANSPORT_CLASS::Transport::Errors::NotFound => e - log.info "Specified data stream does not exist. Will be created: <#{e}>" + log.info "Specified data stream does not exist. Will be created: <#{datastream_name}>" return false end end