2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Fluentd s3 TreasureData::AuthError: Import failed: Unauthorized

Posted at

AWSでfluentd(td-agent)を初めて使った際に、デフォルトの設定を残していたら、s3への転送に失敗。
ハマったので、メモを残しておきます。

経緯

こちらを参考にs3への転送をテスト。EC2はAmazonLinux2を利用。EC2にはIAM Profileを設定済み。

Version

[ec2-user@ip-172-30-1-66 td-agent]$ td-agent -v
'fluent-plugin-elasticsearch' version '4.3.3'
'fluent-plugin-flowcounter-simple' version '0.1.0'
'fluent-plugin-kafka' version '0.16.0'
'fluent-plugin-prometheus' version '1.8.5'
'fluent-plugin-prometheus_pushgateway' version '0.0.2'
'fluent-plugin-record-modifier' version '2.1.0'
'fluent-plugin-rewrite-tag-filter' version '2.3.0'
'fluent-plugin-s3' version '1.5.1'
'fluent-plugin-sd-dns' version '0.1.0'
'fluent-plugin-systemd' version '1.0.2'
'fluent-plugin-td' version '1.1.0'
'fluent-plugin-webhdfs' version '1.4.0'
'fluentd' version '1.12.1'

Error in td-agent.log

[warn]: #0 [output_td] failed to flush the buffer. retry_time=0 next_retry_seconds=2021-03-08 17:54:38.162296818 +0900 chunk="5bd0270ab634d5f61a7b9e8a3ebd55b9" error_class=RuntimeError error="Failed to upload to Treasure Data 'messages.access' table: #<TreasureData::AuthError: Import failed: Unauthorized> (828 bytes; 0.888921353 seconds)"
[warn]: #0 /opt/td-agent/lib/ruby/gems/2.7.0/gems/td-client-1.0.7/lib/td/client/api.rb:662:in `raise_error'
[warn]: #0 /opt/td-agent/lib/ruby/gems/2.7.0/gems/td-client-1.0.7/lib/td/client/api/import.rb:30:in `import'
[warn]: #0 /opt/td-agent/lib/ruby/gems/2.7.0/gems/td-client-1.0.7/lib/td/client.rb:456:in `import'
[warn]: #0 /opt/td-agent/lib/ruby/gems/2.7.0/gems/fluent-plugin-td-1.1.0/lib/fluent/plugin/out_tdlog.rb:217:in `upload'
[warn]: #0 /opt/td-agent/lib/ruby/gems/2.7.0/gems/fluent-plugin-td-1.1.0/lib/fluent/plugin/out_tdlog.rb:166:in `write'
[warn]: #0 /opt/td-agent/lib/ruby/gems/2.7.0/gems/fluentd-1.12.1/lib/fluent/plugin/output.rb:1136:in `try_flush'
[warn]: #0 /opt/td-agent/lib/ruby/gems/2.7.0/gems/fluentd-1.12.1/lib/fluent/plugin/output.rb:1448:in `flush_thread_run'
[warn]: #0 /opt/td-agent/lib/ruby/gems/2.7.0/gems/fluentd-1.12.1/lib/fluent/plugin/output.rb:462:in `block (2 levels) in start'
[warn]: #0 /opt/td-agent/lib/ruby/gems/2.7.0/gems/fluentd-1.12.1/lib/fluent/plugin_helper/thread.rb:78:in `block in thread_create'

td-agent.conf

## 以下追加したもの
<source>
  @type tail
  path /var/log/messages
  tag td.messages.access
  pos_file /var/log/td-agent/messages.pos
  format syslog
</source>

<match td.messages.access>
  @type s3
  s3_bucket fullspeed-polymorphic-artifact
  s3_region ap-northeast-1
  path fluentd/
  time_slice_format %Y%m%d%H%M
  ssl_verify_peer false
  @log_level trace
</match>

# 以下デフォルトのtd-agent.confにあったものの一部
<match td.*.*>
  @type tdlog
  @id output_td
  apikey YOUR_API_KEY

  auto_create_table
  <buffer>
    @type file
    path /var/log/td-agent/buffer/td
  </buffer>

  <secondary>
    @type file
    path /var/log/td-agent/failed_records
  </secondary>
</match>

## match tag=debug.** and dump to console
<match debug.**>
  @type stdout
  @id output_stdout
</match>

...

解決方法 How to solve

デフォルトで用意されていたmatchのディレクティブを削除するだけ(特に@type tdlogの部分)。
Just remove default directives, especially the directive of @type tdlog.

こちらに解決方法が書いてあったのだが、最初意味がわからなかった。
https://github.com/fluent/fluent-plugin-s3/issues/362

結果、3時間くらいハマりました。初期設定のtd-agent.confに追記したら動かないというのはキツかった。おまけにエラーはUnauthorized.
おかげでキャッチアップもできました笑

メモとして残しておきます。

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?