{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-@l10n/ja/sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":["admonition"]},"type":"markdown"},"seo":{"title":"Scala Apps Import Integration","description":"Treasure Data Product Documentation · Collect and Unify · Segment and Activate · Experiment and Analyze · Decisioning Automate with AI Scale and Trust.","siteUrl":"https://docs.treasuredata.com","lang":"en-US","llmstxt":{"hide":false,"sections":[{"title":"Table of contents","includeFiles":["**/*"],"excludeFiles":[]}],"excludeFiles":[]}},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"scala-apps-import-integration","__idx":0},"children":["Scala Apps Import Integration"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Treasure Dataは、サーバー側のログとイベントを収集し、Scalaアプリケーションからデータをインポートするために",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://docs.treasuredata.com/smart/project-product-documentation/about-treasure-data-s-server-side-agent"},"children":["td-agent"]},"を提供しています。"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"前提条件","__idx":1},"children":["前提条件"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Scalaの基本知識"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://toolbelt.treasuredata.com/"},"children":["TD Toolbelt"]},"を含むTreasure Dataの基本知識"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["JVM、Scala、",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/harrah/xsbt"},"children":["sbt"]}," v0.11以降"]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"td-agentのインストール","__idx":2},"children":["td-agentのインストール"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["アプリケーションサーバーに",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["td-agent"]},"をインストールします。td-agentはアプリケーションサーバー内に配置され、アプリケーションログをクラウドにアップロードすることに重点を置いています。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"http://github.com/treasure-data/td-logger-java"},"children":["td-logger-java"]},"ライブラリを使用すると、Scalaアプリケーションがローカルのtd-agentにレコードを投稿できます。td-agentは、5分ごとにデータをクラウドにアップロードします。デーモンはローカルノードで実行されるため、ロギングのレイテンシは無視できます。"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"td-agentインストールオプション","__idx":3},"children":["td-agentインストールオプション"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["td-agent"]},"をインストールするには、環境に基づいて次のコマンドのいずれかを実行します。エージェントプログラムは、rpm/deb/dmgなどの各プラットフォームのパッケージ管理ソフトウェアを使用して自動的にインストールされます。"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"rhelcentos-567","__idx":4},"children":["RHEL/CentOS 5,6,7"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"$ curl -L https://toolbelt.treasuredata.com/sh/install-redhat-td-agent3.sh | sh\n"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"ubuntuとdebian","__idx":5},"children":["UbuntuとDebian"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"# 18.04 Bionic\n$ curl -L https://toolbelt.treasuredata.com/sh/install-ubuntu-bionic-td-agent3.sh | sh\n# 16.04 Xenial (64bit only)\n$ curl -L https://toolbelt.treasuredata.com/sh/install-ubuntu-xenial-td-agent3.sh | sh\n"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":5,"id":"eolバージョンのレガシーサポートは引き続き利用可能です","__idx":6},"children":["EOLバージョンのレガシーサポートは引き続き利用可能です"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"# 14.04 Trusty\n$ curl -L https://toolbelt.treasuredata.com/sh/install-ubuntu-trusty-td-agent3.sh | sh\n# 12.04 Precise\n$ curl -L https://toolbelt.treasuredata.com/sh/install-ubuntu-precise-td-agent3.sh | sh\n# Debian Stretch (64-bit only) $ curl -L https://toolbelt.treasuredata.com/sh/install-debian-stretch-td-agent3.sh | sh\n# Debian Jessie (64-bit only)\n$ curl -L https://toolbelt.treasuredata.com/sh/install-debian-jessie-td-agent3.sh | sh\n# Debian Squeeze (64-bit only)\n$ curl -L https://toolbelt.treasuredata.com/sh/install-debian-squeeze-td-agent2.sh | sh\n"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"amazon-linux","__idx":7},"children":["Amazon Linux"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Amazon Linux 1またはAmazon Linux 2を選択できます。",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://docs.treasuredata.com/smart/project-product-documentation/installing-td-agent-on-aws-linux"},"children":["Installing td-agent on Amazon Linux"]},"を参照してください。"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"macos-x-1011","__idx":8},"children":["MacOS X 10.11+"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"$ open 'https://td-agent-package-browser.herokuapp.com/3/macosx/td-agent-3.1.1-0.dmg'\n"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["MacOS X 10.11.1（El Capitan）では、いくつかのセキュリティ変更が導入されました。td-agentをインストールした後、",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["/Library/LaunchDaemons/td-agent.plist"]},"ファイルを編集して、",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["/usr/sbin/td-agent"]},"を**/opt/td-agent/usr/sbin/td-agent**に変更してください。"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"windows-server-2012","__idx":9},"children":["Windows Server 2012+"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Windowsのインストールには複数の手順が必要です。次のドキュメントに記載されている手順を完了してください:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://docs.fluentd.org/installation/install-by-msi"},"children":["Installing Treasure Agent using .msi Installer (Windows)"]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":4,"id":"opscode-chef-repository","__idx":10},"children":["Opscode Chef (repository)"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/treasure-data/chef-td-agent"},"children":["リポジトリの詳細"]},"を参照できます。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"$ echo 'cookbook \"td-agent\"' >> Berksfile\n$ berks install\n"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/treasure-data/elastic-beanstalk-td-agent"},"children":["AWS Elastic Beanstalk"]},"もサポートされています。Windowsはサポートされていません。"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"etctd-agenttd-agentconfの変更","__idx":11},"children":["/etc/td-agent/td-agent.confの変更"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["次に、",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["apikey"]},"オプションを設定してAPIキーを指定します。Treasure コンソールのプロフィールからAPIキーを取得できます。td-agent.confファイルに",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["apikey"]},"オプションを設定します。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"conf","header":{"controls":{"copy":{}}},"source":"# Treasure Data Input and Output\n<source>\n  type forward\n  port 24224\n</source>\n<match td.*.*>\n  type tdlog\n  endpoint api.treasuredata.com\n  apikey YOUR_API_KEY\n  auto_create_table\n  buffer_type file\n  buffer_path /var/log/td-agent/buffer/td\n  use_ssl true\n</match>\n","lang":"conf"},"children":[]},{"$$mdtype":"Tag","name":"Admonition","attributes":{"type":"info"},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["YOUR_API_KEY"]}," should be your actual apikey string. You can retrieve your API key from your profiles in Treasure Console. Using a ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/products/my-settings/getting-your-api-keys"},"children":["write-only API key"]}," is recommended."]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["次の行が配置されたら、エージェントを再起動します。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"# Linux\n$ sudo /etc/init.d/td-agent restart\n\n# MacOS X\n$ sudo launchctl unload /Library/LaunchDaemons/td-agent.plist\n$ sudo launchctl load /Library/LaunchDaemons/td-agent.plist\n"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["td-agentは、ポート24224を介してデータを受け入れ、データをバッファリングし(",{"$$mdtype":"Tag","name":"em","attributes":{},"children":["var/log/td-agent/buffer/td"]},")、自動的にデータをクラウドにアップロードします。"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"td-logger-javaの使用","__idx":12},"children":["td-logger-javaの使用"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["まず、build.sbtに次の行を追加します。ロガーのリビジョン情報は、",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/treasure-data/td-logger-java/blob/master/CHANGES.txt"},"children":["CHANGES.txt"]},"で確認できます。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["オールインワンjarファイルが必要な場合は、",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://repo1.maven.org/maven2/com/treasuredata/"},"children":["http://central.maven.org/maven2/com/treasuredata/"]},"で提供しています。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"/* in build.sbt */\n// Dependencies\nlibraryDependencies ++= Seq(\n  \"com.treasuredata\" % \"td-logger\" % \"${logger.version}\"\n)\n"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["次に、次のコマンドを使用して",{"$$mdtype":"Tag","name":"em","attributes":{},"children":["treasure-data.properties"]},"ファイルを設定します:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"td.logger.agentmode=true\ntd.logger.agent.host=localhost\ntd.logger.agent.port=24224\ntd.logger.agent.tag=td\n"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["最後に、次の行をアプリケーションに挿入して、初期化してレコードを投稿します。",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/treasure-data/td-logger-java"},"children":["APIの詳細情報"]},"を参照できます。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"import java.util.Properties\nimport com.treasure_data.logger.TreasureDataLogger\nimport scala.collection.JavaConverters._\n\nobject Main {\n  def main(args: Array[String]) {\n    var props = System.getProperties();\n    props.load(getClass.getResourceAsStream(\"treasure-data.properties\"));\n    var LOG = TreasureDataLogger.getLogger(\"test_db\");\n\n    var map = Map(\"from\" -> \"userA\", \"to\" -> \"userB\");\n    LOG.log(\"follow\", map.asJava.asInstanceOf[java.util.Map[String, java.lang.Object]]);\n  }\n}\n"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["この例では、次の構造を想定しています。"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["project_dir/build.sbt"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["project_dir/src/main/scala/Main.scala"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["project_dir/src/main/resources/treasure-data.properties"]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"データインポートの確認","__idx":13},"children":["データインポートの確認"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["まず、前述のプログラムを実行します。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"$ sbt compile run\n"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["SIGUSR1シグナルを送信すると、td-agentのバッファがフラッシュされます。アップロードはすぐに開始されます。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"# Linux\n$ kill -USR1 `cat /var/run/td-agent/td-agent.pid`\n\n# MacOS X\n$ sudo kill -USR1 `sudo launchctl list | grep td-agent | cut -f 1`\n"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["データのアップロードを確認するには、",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["td tables"]},"を使用します。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"$ td tables\n+------------+------------+------+-----------+\n| Database   | Table      | Type | Count     |\n+------------+------------+------+-----------+\n| test_db    | follow     | log  | 1         |\n+------------+------------+------+-----------+\n"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"本番デプロイメント","__idx":14},"children":["本番デプロイメント"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"td-agentの高可用性構成","__idx":15},"children":["td-agentの高可用性構成"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["高トラフィックのウェブサイト（5つ以上のアプリケーションノード）の場合、td-agentの高可用性構成を使用して、データ転送の信頼性とクエリのパフォーマンスを向上させます。"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://docs.treasuredata.com/smart/project-product-documentation/configuring-td-agent-for-high-availability"},"children":["High-Availability Configurations of td-agent"]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"td-agentの監視","__idx":16},"children":["td-agentの監視"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["td-agent自体の監視も重要です。td-agentの一般的な監視方法については、次のドキュメントを参照してください:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://docs.treasuredata.com/smart/project-product-documentation/monitoring-td-agent"},"children":["Monitoring td-agent"]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["td-agentは、",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"http://fluentd.org/"},"children":["Fluentdプロジェクト"]},"の下で完全にオープンソース化されています。"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"次のステップ","__idx":17},"children":["次のステップ"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["従来のRDBMSよりも柔軟なスキーマメカニズムを提供しています。クエリには、HiveおよびTrinoクエリ言語を活用しています。"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://docs.treasuredata.com/smart/project-product-documentation/schema-management"},"children":["Schema Management"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/products/customer-data-platform/data-workbench/queries/trino/quickstart"},"children":["Trino Query Language"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/products/customer-data-platform/data-workbench/queries/hive/quickstart"},"children":["Hive Query Language"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/apis/td-api"},"children":["Programmatic Access with REST API and its Bindings"]}]}]}]},"headings":[{"value":"Scala Apps Import Integration","id":"scala-apps-import-integration","depth":1},{"value":"前提条件","id":"前提条件","depth":1},{"value":"td-agentのインストール","id":"td-agentのインストール","depth":1},{"value":"td-agentインストールオプション","id":"td-agentインストールオプション","depth":2},{"value":"RHEL/CentOS 5,6,7","id":"rhelcentos-567","depth":3},{"value":"UbuntuとDebian","id":"ubuntuとdebian","depth":3},{"value":"EOLバージョンのレガシーサポートは引き続き利用可能です","id":"eolバージョンのレガシーサポートは引き続き利用可能です","depth":5},{"value":"Amazon Linux","id":"amazon-linux","depth":3},{"value":"MacOS X 10.11+","id":"macos-x-1011","depth":3},{"value":"Windows Server 2012+","id":"windows-server-2012","depth":3},{"value":"Opscode Chef (repository)","id":"opscode-chef-repository","depth":4},{"value":"/etc/td-agent/td-agent.confの変更","id":"etctd-agenttd-agentconfの変更","depth":2},{"value":"td-logger-javaの使用","id":"td-logger-javaの使用","depth":2},{"value":"データインポートの確認","id":"データインポートの確認","depth":2},{"value":"本番デプロイメント","id":"本番デプロイメント","depth":1},{"value":"td-agentの高可用性構成","id":"td-agentの高可用性構成","depth":2},{"value":"td-agentの監視","id":"td-agentの監視","depth":2},{"value":"次のステップ","id":"次のステップ","depth":1}],"frontmatter":{"seo":{"title":"Scala Apps Import Integration"}},"lastModified":"2026-06-01T09:34:27.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/ja/int/scala-apps-import-integration","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}