# Scribeプロトコルを使用したログ保存のためのTD Agent Treasure Agent(td-agent)はScribeプロトコル(Thriftベース)を理解します。td-agentは、既存のScribeインフラストラクチャと共存または置き換えることができます。 [fluent-plugin-scribe](https://github.com/fluent/fluent-plugin-scribe)を参照してください。このpluginはScribe _output_もサポートしています。 * [前提条件](/ja/products/customer-data-platform/integration-hub/streaming/td-agent/td-agent-using-scribe-protocol-to-store-logs#prerequisites) * [Scribe入力の使用の指定](/ja/products/customer-data-platform/integration-hub/streaming/td-agent/td-agent-using-scribe-protocol-to-store-logs#specifying-use-of-scribe-input) * [JSON文字列としてのメッセージ](/ja/products/customer-data-platform/integration-hub/streaming/td-agent/td-agent-using-scribe-protocol-to-store-logs#messages-as-json-string) * [その他のフォーマット](/ja/products/customer-data-platform/integration-hub/streaming/td-agent/td-agent-using-scribe-protocol-to-store-logs#other-formats) # 前提条件 * [TD Toolbelt](http://docs.treasuredata.com/display/PD/Using+TD+Toolbelt?atlOrigin=https://treasuredata.clickhelp.co/articles/#!project-product-documentation/td-toolbelt)を含むTreasure Dataの基本的な知識。 * td-agentの基本的な知識。 # Scribe入力の使用の指定 以下の設定により、Scribe入力pluginが有効になります: ```conf type scribe port 1463 ``` Scribeプロトコルの`category`フィールドは、td-agentの`tag`として使用されます。test_db database内のwww_access tableにデータを保存する場合は、以下のようにLogEntryを送信してください(Ruby例)。 ```ruby LogEntry.new entry.category = 'td.test_db.www_access' entry.message = 'abcde' client.Log([entry]) ``` このメッセージは次のように編成されます。 ```ruby { message => 'abcde' } ``` # JSON文字列としてのメッセージ 半構造化データのメッセージフィールドには、多くの場合JSON文字列が含まれます。td-agentは_msg_format_オプションを使用して、JSON文字列をその場で解析します。 ```conf type scribe port 1463 msg_format json ``` 以下のようにレコードを送信してください。entry.messageがJSON文字列であることに注意してください。 ```ruby entry = LogEntry.new entry.category = 'td.test_db.www_access' entry.message = {'a' => 'b', 'c' => d}.to_json client.Log([entry]) ``` このメッセージは次のように編成されます。 ```ruby { 'a' => 'b', 'c' => 'd', } ``` # その他のフォーマット _msg_format_オプションは、`text`、`json`、`url_param`をサポートしています。`url_param`のフォーマットは次のとおりです。 `key1=val1&key2=val2&key3=val3`