質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Elasticsearch

Elasticsearchは、クラウド向けに構築された、RESTful な API を提供する分散型のサーチエンジンアプリケーションです。

AWS(Amazon Web Services)

Amazon Web Services (AWS)は、仮想空間を機軸とした、クラスター状のコンピュータ・ネットワーク・データベース・ストーレッジ・サポートツールをAWSというインフラから提供する商用サービスです。

Fluentd

Fluentdは、オープンソースのログ収集ツールです。ログの収集方法、ログの記録先などのログデータ処理を柔軟にカスタマイズでき、インプットおよびアウトプットが全てプラグインとして実装されています。

Q&A

解決済

1回答

2283閲覧

Fluented ー> AWS ElasticSerachに接続できない

k.nakazono

総合スコア4

Elasticsearch

Elasticsearchは、クラウド向けに構築された、RESTful な API を提供する分散型のサーチエンジンアプリケーションです。

AWS(Amazon Web Services)

Amazon Web Services (AWS)は、仮想空間を機軸とした、クラスター状のコンピュータ・ネットワーク・データベース・ストーレッジ・サポートツールをAWSというインフラから提供する商用サービスです。

Fluentd

Fluentdは、オープンソースのログ収集ツールです。ログの収集方法、ログの記録先などのログデータ処理を柔軟にカスタマイズでき、インプットおよびアウトプットが全てプラグインとして実装されています。

0グッド

0クリップ

投稿2021/07/04 00:59

編集2021/07/04 04:23

データレイクの入門ハンズオンである aws-s3-datalake-handson を進めておりますが、Lab2のセクションで、Fluentd から Elasticsearch Service にログデータを送信するための設定がどうしても失敗して原因が解明できておりません。

/etc/td-agent/td-agent.conf の設定ファイルは以下のように設定しております。

<source> @type tail path /root/es-demo/testapp.log pos_file /var/log/td-agent/testapp.log.pos format /^[(?<timestamp>[^ ]* [^ ]*)] (?<alarmlevel>[^ ]*) *? (?<host>[^ ]*) * (?<user>[^ ]*) * (?<number>.*) [(?<text>.*)]$/ time_format %d/%b/%Y:%H:%M:%S %z types size:integer, status:integer, reqtime:float, runtime:float, time:time tag testappec2.log </source> <match testappec2.log> type_name testappec2log @type elasticsearch include_tag_key true tag_key @log_name host search-handson-minilake-jvzlsqtbqnp523uvvuhpmh54dq.ap-northeast-1.es.amazonaws.com port 443 scheme https logstash_format true logstash_prefix testappec2log flush_interval 10s retry_limit 5 buffer_type file buffer_path /var/log/td-agent/buffer/testapp.log.buffer reload_connections false user aesadmin password My#Password1 </match>

ハンズオンの手順と異なるのは、ElasticSearchのマスターパスワード設定時に特殊文字を含めなければならなくなっていたので「#」をパスワード内に付け加えました。それ以外は手順通り進め、2回繰り返したので間違いないかと思います。
他にも色々記事をあたり、URLパラメーターに特殊文字が使えないために、「#」 => 「%23」に設定変更してみましたがダメでした。
こちらのエラーが出力されます。

[root@ip-10-0-0-21 td-agent]# tail -f /var/log/td-agent/td-agent.log 2021-07-04 09:44:16 +0900 [warn]: #0 failed to flush the buffer. retry_time=1 next_retry_seconds=2021-07-04 09:44:15 +0900 chunk="5c6417c2103f99dd31bf3c6481127b03" error_class=Elasticsearch::Transport::Transport::Errors::Unauthorized error="[401] " 2021-07-04 09:44:16 +0900 [warn]: #0 suppressed same stacktrace 2021-07-04 09:44:18 +0900 [warn]: #0 failed to flush the buffer. retry_time=2 next_retry_seconds=2021-07-04 09:44:17 +0900 chunk="5c6417c2103f99dd31bf3c6481127b03" error_class=Elasticsearch::Transport::Transport::Errors::Unauthorized error="[401] " 2021-07-04 09:44:18 +0900 [warn]: #0 suppressed same stacktrace 2021-07-04 09:44:23 +0900 [warn]: #0 failed to flush the buffer. retry_time=3 next_retry_seconds=2021-07-04 09:44:23 +0900 chunk="5c6417c2103f99dd31bf3c6481127b03" error_class=Elasticsearch::Transport::Transport::Errors::Unauthorized error="[401] " 2021-07-04 09:44:23 +0900 [warn]: #0 suppressed same stacktrace 2021-07-04 09:44:31 +0900 [warn]: #0 failed to flush the buffer. retry_time=4 next_retry_seconds=2021-07-04 09:44:30 +0900 chunk="5c6417c2103f99dd31bf3c6481127b03" error_class=Elasticsearch::Transport::Transport::Errors::Unauthorized error="[401] " 2021-07-04 09:44:31 +0900 [warn]: #0 suppressed same stacktrace 2021-07-04 09:44:49 +0900 [error]: #0 failed to flush the buffer, and hit limit for retries. dropping all chunks in the buffer queue. retry_times=5 records=6 error_class=Elasticsearch::Transport::Transport::Errors::Unauthorized error="[401] " 2021-07-04 09:44:49 +0900 [error]: #0 suppressed same stacktrace 2021-07-04 09:46:13 +0900 [warn]: #0 failed to flush the buffer. retry_time=0 next_retry_seconds=2021-07-04 09:46:14 +0900 chunk="5c64183499986a4c8755cf63f5fafb51" error_class=Elasticsearch::Transport::Transport::Errors::Unauthorized error="[401] " 2021-07-04 09:46:13 +0900 [warn]: #0 suppressed same stacktrace 2021-07-04 09:46:14 +0900 [warn]: #0 failed to flush the buffer. retry_time=0 next_retry_seconds=2021-07-04 09:46:14 +0900 chunk="5c64183499986a4c8755cf63f5fafb51" error_class=Elasticsearch::Transport::Transport::Errors::Unauthorized error="[401] " 2021-07-04 09:46:14 +0900 [warn]: #0 suppressed same stacktrace 2021-07-04 09:46:16 +0900 [warn]: #0 failed to flush the buffer. retry_time=1 next_retry_seconds=2021-07-04 09:46:15 +0900 chunk="5c64183499986a4c8755cf63f5fafb51" error_class=Elasticsearch::Transport::Transport::Errors::Unauthorized error="[401] " 2021-07-04 09:46:16 +0900 [warn]: #0 suppressed same stacktrace 2021-07-04 09:46:19 +0900 [warn]: #0 failed to flush the buffer. retry_time=2 next_retry_seconds=2021-07-04 09:46:18 +0900 chunk="5c64183499986a4c8755cf63f5fafb51" error_class=Elasticsearch::Transport::Transport::Errors::Unauthorized error="[401] " 2021-07-04 09:46:19 +0900 [warn]: #0 suppressed same stacktrace 2021-07-04 09:46:23 +0900 [warn]: #0 failed to flush the buffer. retry_time=3 next_retry_seconds=2021-07-04 09:46:23 +0900 chunk="5c64183499986a4c8755cf63f5fafb51" error_class=Elasticsearch::Transport::Transport::Errors::Unauthorized error="[401] " 2021-07-04 09:46:23 +0900 [warn]: #0 suppressed same stacktrace 2021-07-04 09:46:31 +0900 [warn]: #0 failed to flush the buffer. retry_time=4 next_retry_seconds=2021-07-04 09:46:31 +0900 chunk="5c64183499986a4c8755cf63f5fafb51" error_class=Elasticsearch::Transport::Transport::Errors::Unauthorized error="[401] " 2021-07-04 09:46:31 +0900 [warn]: #0 suppressed same stacktrace 2021-07-04 09:46:46 +0900 [error]: #0 failed to flush the buffer, and hit limit for retries. dropping all chunks in the buffer queue. retry_times=5 records=18 error_class=Elasticsearch::Transport::Transport::Errors::Unauthorized error="[401] " 2021-07-04 09:46:46 +0900 [error]: #0 suppressed same stacktrace

成功すれば以下のログが出力されるようです

[info]: #0 Connection opened to Elasticsearch cluster => {.....

handsonを同じようにして進めた方で突破された方、解決策に心当たりのある方は、ご教示頂けると幸いです。
宜しくお願いします。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

ベストアンサー

パスワードを'My#Password1'のようにシングルクォーテーションで囲ってはどうでしょうか?

投稿2021/07/04 15:08

編集2021/07/04 15:09
yu_1985

総合スコア7447

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

k.nakazono

2021/07/04 15:20 編集

ご回答誠にありがとうございます。 早速試してみました! 今度は別のエラーが出てしまいました。 シングルクオーテーション内で「#」も「%23」も試してみましたが結果は同じ以下のエラーでした。。 何か見落としているのでしょうか。。。 ``` 2021-07-05 00:14:36 +0900 [warn]: #0 suppressed same stacktrace 2021-07-05 00:14:39 +0900 [warn]: #0 failed to flush the buffer. retry_time=3 next_retry_seconds=2021-07-05 00:14:39 +0900 chunk="5c64da3882f37e817ff4f0f1bbd5f1ae" error_class=URI::InvalidURIError error="bad URI(is not URI?): https://aesadmin:My#Password1@search-handson-minilake-jvzlsqtbqnp523uvvuhpmh54dq.ap-northeast-1.es.amazonaws.com:443/" 2021-07-05 00:14:39 +0900 [warn]: #0 suppressed same stacktrace 2021-07-05 00:14:47 +0900 [warn]: #0 failed to flush the buffer. retry_time=4 next_retry_seconds=2021-07-05 00:14:47 +0900 chunk="5c64da3882f37e817ff4f0f1bbd5f1ae" error_class=URI::InvalidURIError error="bad URI(is not URI?): https://aesadmin:My#Password1@search-handson-minilake-jvzlsqtbqnp523uvvuhpmh54dq.ap-northeast-1.es.amazonaws.com:443/" ``` 上記URLをChromeで直接開いて、ユーザー名とパスワードを入力して開けるので、EC2のアクセス権限や設定周りでの見落としだと思うのですが。。。
k.nakazono

2021/07/05 00:51

ありがとうございます。 参考にさせて頂いて、設定を変更しました。 やはり結果はエラーとなってしまいました。 ■設定 ``` types size:integer, status:integer, reqtime:float, runtime:float, time:time tag testappec2.log </source> <match testappec2.log> type_name testappec2log @type elasticsearch include_tag_key true tag_key @log_name host search-handson-minilake-jvzlsqtbqnp523uvvuhpmh54dq.ap-northeast-1.es.amazonaws.com port 443 scheme https logstash_format true logstash_prefix testappec2log flush_interval 10s retry_limit 5 buffer_type file buffer_path /var/log/td-agent/buffer/testapp.log.buffer reload_connections false user %{aesadmin} password %{My#Password1} </match> ``` ■エラー [ec2-user@ip-10-0-0-21 ~]$ sudo su [root@ip-10-0-0-21 ec2-user]# vi /etc/td-agent/td-agent.conf [root@ip-10-0-0-21 ec2-user]# vi /etc/td-agent/td-agent.conf [root@ip-10-0-0-21 ec2-user]# service td-agent reload Reloading td-agent: td-agent [ OK ] [root@ip-10-0-0-21 ec2-user]# tail -f /var/log/td-agent/td-agent.log 2021-07-05 09:48:52 +0900 [info]: gem 'fluent-plugin-td' version '1.0.0' 2021-07-05 09:48:52 +0900 [info]: gem 'fluent-plugin-td-monitoring' version '0.2.3' 2021-07-05 09:48:52 +0900 [info]: gem 'fluent-plugin-webhdfs' version '1.2.2' 2021-07-05 09:48:52 +0900 [info]: gem 'fluentd' version '1.0.2' 2021-07-05 09:48:52 +0900 [info]: adding match pattern="testappec2.log" type="elasticsearch" 2021-07-05 09:48:52 +0900 [info]: #0 'flush_interval' is configured at out side of <buffer>. 'flush_mode' is set to 'interval' to keep existing behaviour 2021-07-05 09:48:52 +0900 [info]: adding source type="tail" 2021-07-05 09:48:52 +0900 [info]: #0 starting fluentd worker pid=2978 ppid=2460 worker=0 2021-07-05 09:48:52 +0900 [info]: #0 following tail of /root/es-demo/testapp.log 2021-07-05 09:48:52 +0900 [info]: #0 fluentd worker is now running worker=0 2021-07-05 09:50:12 +0900 [warn]: #0 failed to flush the buffer. retry_time=0 next_retry_seconds=2021-07-05 09:50:13 +0900 chunk="5c655af6b2885fb5f217d4a9f09c966c" error_class=Elasticsearch::Transport::Transport::Errors::Unauthorized error="[401] " 2021-07-05 09:50:12 +0900 [warn]: #0 /opt/td-agent/embedded/lib/ruby/gems/2.4.0/gems/elasticsearch-transport-5.0.4/lib/elasticsearch/transport/transport/base.rb:202:in `__raise_transport_error' 2021-07-05 09:50:12 +0900 [warn]: #0 /opt/td-agent/embedded/lib/ruby/gems/2.4.0/gems/elasticsearch-transport-5.0.4/lib/elasticsearch/transport/transport/base.rb:319:in `perform_request' 2021-07-05 09:50:12 +0900 [warn]: #0 /opt/td-agent/embedded/lib/ruby/gems/2.4.0/gems/elasticsearch-transport-5.0.4/lib/elasticsearch/transport/transport/http/faraday.rb:20:in `perform_request' 2021-07-05 09:50:12 +0900 [warn]: #0 /opt/td-agent/embedded/lib/ruby/gems/2.4.0/gems/elasticsearch-transport-5.0.4/lib/elasticsearch/transport/client.rb:131:in `perform_request' 2021-07-05 09:50:12 +0900 [warn]: #0 /opt/td-agent/embedded/lib/ruby/gems/2.4.0/gems/elasticsearch-api-5.0.4/lib/elasticsearch/api/actions/ping.rb:20:in `ping' 2021-07-05 09:50:12 +0900 [warn]: #0 /opt/td-agent/embedded/lib/ruby/gems/2.4.0/gems/fluent-plugin-elasticsearch-2.6.0/lib/fluent/plugin/out_elasticsearch.rb:218:in `client' 2021-07-05 09:50:12 +0900 [warn]: #0 /opt/td-agent/embedded/lib/ruby/gems/2.4.0/gems/fluent-plugin-elasticsearch-2.6.0/lib/fluent/plugin/out_elasticsearch.rb:451:in `rescue in send_bulk' 2021-07-05 09:50:12 +0900 [warn]: #0 /opt/td-agent/embedded/lib/ruby/gems/2.4.0/gems/fluent-plugin-elasticsearch-2.6.0/lib/fluent/plugin/out_elasticsearch.rb:445:in `send_bulk' 2021-07-05 09:50:12 +0900 [warn]: #0 /opt/td-agent/embedded/lib/ruby/gems/2.4.0/gems/fluent-plugin-elasticsearch-2.6.0/lib/fluent/plugin/out_elasticsearch.rb:432:in `write' 2021-07-05 09:50:12 +0900 [warn]: #0 /opt/td-agent/embedded/lib/ruby/gems/2.4.0/gems/fluentd-1.0.2/lib/fluent/plugin/output.rb:1093:in `try_flush' 2021-07-05 09:50:12 +0900 [warn]: #0 /opt/td-agent/embedded/lib/ruby/gems/2.4.0/gems/fluentd-1.0.2/lib/fluent/plugin/output.rb:1318:in `flush_thread_run' 2021-07-05 09:50:12 +0900 [warn]: #0 /opt/td-agent/embedded/lib/ruby/gems/2.4.0/gems/fluentd-1.0.2/lib/fluent/plugin/output.rb:439:in `block (2 levels) in start' 2021-07-05 09:50:12 +0900 [warn]: #0 /opt/td-agent/embedded/lib/ruby/gems/2.4.0/gems/fluentd-1.0.2/lib/fluent/plugin_helper/thread.rb:78:in `block in thread_create' 2021-07-05 09:50:13 +0900 [warn]: #0 failed to flush the buffer. retry_time=0 next_retry_seconds=2021-07-05 09:50:13 +0900 chunk="5c655af6b2885fb5f217d4a9f09c966c" error_class=Elasticsearch::Transport::Transport::Errors::Unauthorized error="[401] " 2021-07-05 09:50:13 +0900 [warn]: #0 suppressed same stacktrace 2021-07-05 09:50:16 +0900 [warn]: #0 failed to flush the buffer. retry_time=1 next_retry_seconds=2021-07-05 09:50:15 +0900 chunk="5c655af6b2885fb5f217d4a9f09c966c" error_class=Elasticsearch::Transport::Transport::Errors::Unauthorized error="[401] " 2021-07-05 09:50:16 +0900 [warn]: #0 suppressed same stacktrace 2021-07-05 09:50:19 +0900 [warn]: #0 failed to flush the buffer. retry_time=2 next_retry_seconds=2021-07-05 09:50:18 +0900 chunk="5c655af6b2885fb5f217d4a9f09c966c" error_class=Elasticsearch::Transport::Transport::Errors::Unauthorized error="[401] " 2021-07-05 09:50:19 +0900 [warn]: #0 suppressed same stacktrace 2021-07-05 09:50:24 +0900 [warn]: #0 failed to flush the buffer. retry_time=3 next_retry_seconds=2021-07-05 09:50:23 +0900 chunk="5c655af6b2885fb5f217d4a9f09c966c" error_class=Elasticsearch::Transport::Transport::Errors::Unauthorized error="[401] " 2021-07-05 09:50:24 +0900 [warn]: #0 suppressed same stacktrace 2021-07-05 09:50:33 +0900 [warn]: #0 failed to flush the buffer. retry_time=4 next_retry_seconds=2021-07-05 09:50:32 +0900 chunk="5c655af6b2885fb5f217d4a9f09c966c" error_class=Elasticsearch::Transport::Transport::Errors::Unauthorized error="[401] " 2021-07-05 09:50:33 +0900 [warn]: #0 suppressed same stacktrace 2021-07-05 09:50:48 +0900 [error]: #0 failed to flush the buffer, and hit limit for retries. dropping all chunks in the buffer queue. retry_times=5 records=315 error_class=Elasticsearch::Transport::Transport::Errors::Unauthorized error="[401] " 2021-07-05 09:50:48 +0900 [error]: #0 suppressed same stacktrace
yu_1985

2021/07/05 07:54

よく読んだらそこはそうやって書いてくれという意味ではなく、プラグイン内でそういうふうにエスケープされますという意味っぽいですね。 元のシングルクォーテーションで囲ったときのエラーでは内部的に入力値を組み合わせて使用していると思いますが、それがうまくパースできてないということのようなのでプラグインの仕様に関わりそうですね。 どうしてもわからなかったらGitHubのIssueに投げてもいいかもしれません。 ちなみにこちらではユーザを作成せずにやっているようですが、ユーザとパスワードの項を消すとどうなりますか。 https://dev.classmethod.jp/articles/aws-datalake-handson-1/
k.nakazono

2021/07/05 11:10

上記記事のようにユーザー作成せずに、ドメインへのオープンアクセスを許可したところ、正常に接続が完了しました。ハンズオンとしては前に進めますので大変助かりました。 ありがとうございました。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問