# HTTPプロトコルを介したログ収集のためのTD Agent
HTTPを使用して、多くの場所からTreasure Agent(td-agent)にログを追加できます。
* [前提条件](/ja/products/customer-data-platform/integration-hub/streaming/td-agent/td-agent-collecting-logs-through-an-http-protocol#prerequisites)
* [設定](/ja/products/customer-data-platform/integration-hub/streaming/td-agent/td-agent-collecting-logs-through-an-http-protocol#configuration)
* [HTTP経由でのデータアップロード](/ja/products/customer-data-platform/integration-hub/streaming/td-agent/td-agent-collecting-logs-through-an-http-protocol#uploading-data-via-http)
# 前提条件
* [TD Toolbelt](/tools/cli-and-sdks/td-toolbelt)を含むTreasure Dataの基本的な知識。
# 設定
_/etc/td-agent/td-agent.conf_ファイルに以下の行を追加してください。
```conf
# HTTP input
type http
port 8888
# Treasure Data output
type tdlog
endpoint api.treasuredata.com
apikey ...
auto_create_table
buffer_type file
buffer_path /var/log/td-agent/buffer/td
use_ssl true
```
# HTTP経由でのデータアップロード
JSONデータを送信することで、HTTP経由でログを追加できます。POSTメソッドを使用し、URLでdatabaseとtable名を指定してください。
```bash
$ curl -X POST -d 'json={"action":"login","user":2}' \
http://localhost:8888/td.testdb.www_access
```
td-agentは毎分継続的にログをアップロードします。SIGUSR1シグナルを送信すると、バッファがフラッシュされます。アップロードは即座に開始されます。
```bash
kill -USR1 `cat /var/run/td-agent/td-agent.pid`
```
データが正常にアップロードされたことを確認するには、以下のように_td tables_コマンドを実行してください。
```bash
$ td tables
+------------+------------+------+-----------+
| Database | Table | Type | Count |
+------------+------------+------+-----------+
| testdb | www_access | log | 1 |
+------------+------------+------+-----------+
```
問題が発生した場合は、ログ(/var/log/td-agent.log)がトラブルシューティングの開始点として適しています。