Skip to content
Last updated

AWS Elastic Beanstalk インポート統合

AWS Elastic BeanstalkとTreasure Dataを組み合わせることで、フロントエンドとバックエンドの両方のシステムにおいて、即座にスケーラビリティを実現できます。

前提条件

  • Treasure Dataの基本知識
  • AWS Elastic Beanstalkの基本知識

Treasure Agentのインストール

以下の手順に従って、Treasure Agent(td-agent)ストリーミングデータコレクターをアプリケーションにインストールします。

td-agentとは?

Treasure DataのTd-agentは、AWS Elastic Beanstalkコンテナ上でTreasure Dataを使用するために必要な分散ログコレクターです。td-agentを使用して、AWS Elastic BeanstalkアプリケーションからTreasure Dataのクラウドデータウェアハウスにログをインポートします。

インストール

コンテナ内にtd-agentをインストールするためのボイラープレートアプリケーションは、次のリポジトリで利用できます:

.ebextensionsスクリプトのインストール

以下の例に示すように、GitHubから2つのファイルをダウンロードし、.ebextensionsディレクトリに配置します。

$ cd $YOUR\_REPO
$ mkdir -p .ebextensions
$ wget -O.ebextensions/0-td-agent-gen-config.config '<https://raw.github.com/treasure-data/elastic-beanstalk-td-agent/master/.ebextensions/0-td-agent-gen-config.config>'
$ wget -O.ebextensions/1-td-agent-install.config '<https://raw.github.com/treasure-data/elastic-beanstalk-td-agent/master/.ebextensions/1-td-agent-install.config>'

APIキーの設定

次に、設定ファイル内の適切な場所にAPIキーを配置します。

$ td apikey:show
$ emacs .ebextensions/0-td-agent-gen-config.config

デプロイ

最後に、変更を本番環境にデプロイします。

$ git add .ebextensions/0-td-agent-gen-config.config
$ git add .ebextensions/1-td-agent-install.config
$ git commit -a -m 'custom extensions to install td-agent'
$ git aws.push

データアップロードの確認

curlコマンドを発行して、ローカルシステムからTreasure Dataにログをインポートできます。

$ curl -X POST -d 'json={"action":"login","user":2}' http://localhost:8888/td.testdb.www\_access
$ curl -X POST -d 'json={"action":"login","user":2}' http://localhost:8888/td.testdb.www\_access
$ curl -X POST -d 'json={"action":"login","user":2}' http://localhost:8888/td.testdb.www\_access
$ curl -X POST -d 'json={"action":"login","user":2}' http://localhost:8888/td.testdb.www\_access
$ curl -X POST -d 'json={"action":"login","user":2}' http://localhost:8888/td.testdb.www\_access

数分後(通常は約5分)、次のコマンドを発行して、データがクラウドにアップロードされたことを確認できます。カウントがゼロより大きい場合、データのアップロードは成功しています。

$ td tables testdb
+----------+-------------------------+------+-------+----------------+
| Database | Table | Type | Count | Schema |
+----------+-------------------------+------+-------+----------------+
| testdb | www\_access | log | 5 | |
+----------+-------------------------+------+-------+----------------+

アプリケーションからのデータインポート

これで、td-agent経由でアプリケーションからTreasure Dataにデータをインポートする準備が整いました。アプリケーションの言語に適したロガーを選択してください。

Supported Languages