{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-@l10n/ja/sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":[]},"type":"markdown"},"seo":{"title":"Embedded Apps CおよびC++インポート連携","description":"C++アプリケーションからFluent Bitを使用してTreasure AIにデータをインポートする方法を詳しく解説します。設定手順と組み込み方法を学べます。","siteUrl":"https://docs.treasure.ai","lang":"en-US","jsonLd":{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://www.treasure.ai/","name":"Treasure AI","url":"https://www.treasure.ai/","logo":"https://www.treasure.ai/hubfs/assets/images/logos/primary-logo.svg"},{"@type":"WebSite","@id":"https://docs.treasure.ai/#website","name":"Treasure AI Documentation","url":"https://docs.treasure.ai/","inLanguage":["en","ja"],"publisher":{"@id":"https://www.treasure.ai/"}}]}},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"embedded-apps-cおよびcインポート連携","__idx":0},"children":["Embedded Apps CおよびC++インポート連携"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["C++をベースとするサーバーサイドアプリケーション、ゲーム、およびIoTデバイスからデータを収集できます。この記事では、",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"http://fluentbit.io/"},"children":["Fluent Bit"]},"を使用して、CおよびC++アプリケーションからデータを確実にインポートする方法について説明します。"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/ja/int/embedded-apps-c-and-c-import-integration#h1_1644201065"},"children":["前提条件"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/ja/int/embedded-apps-c-and-c-import-integration#h1__1874598616"},"children":["Fluent Bitについて"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/ja/int/embedded-apps-c-and-c-import-integration#h1_899088197"},"children":["Fluent Bitの組み込みとTreasure Dataへの接続"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/ja/int/embedded-apps-c-and-c-import-integration#h2_1456347407"},"children":["Treasure APIキーの取得"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/ja/int/embedded-apps-c-and-c-import-integration#h2_1550180863"},"children":["設定ファイルの準備"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/ja/int/embedded-apps-c-and-c-import-integration#h2__622390659"},"children":["fluent-bitをアプリケーションに組み込む"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/ja/int/embedded-apps-c-and-c-import-integration#h1__78781730"},"children":["関連情報"]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"前提条件","__idx":1},"children":["前提条件"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["C/C++アプリケーション開発の基礎知識"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Treasure Dataの基礎知識"]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"fluent-bitについて","__idx":2},"children":["Fluent Bitについて"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Fluent Bitは、組み込みオペレーティングシステム向けに特化したオープンソースのデータコレクターツールで、Treasure Dataによって開発されています。Fluent Bitはスタンドアロンツールとして使用できるほか、CまたはC++アプリケーションに組み込むこともできます。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["C/C++アプリケーションにFluent Bitを組み込むことで、アプリケーション内に堅牢で軽量なデータ収集メカニズム(バッファリング、リトライなど)を実装できます。"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"fluent-bitの組み込みとtreasure-dataへの接続","__idx":3},"children":["Fluent Bitの組み込みとTreasure Dataへの接続"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"treasure-apiキーの取得","__idx":4},"children":["Treasure APIキーの取得"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Write-Only APIキーを",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/products/my-settings/getting-your-api-keys"},"children":["こちら"]},"から取得してください。"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"設定ファイルの準備","__idx":5},"children":["設定ファイルの準備"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Treasure DataのWrite-Only APIキー、宛先のdatabase、およびtable名を指定して設定ファイルを準備してください。設定例は",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/fluent/fluent-bit/blob/master/conf/out_td.conf"},"children":["こちら"]},"で入手できます。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"# Treasure Data Output\n# ===================\n# This configuration file specifies the information to be used\n# when flushing information to TreasureData.com service. All\n# key fields in the 'TD' section are mandatory.\n[TD]\n    # API\n    # ===\n    # The TreasureData API key. To obtain the TD API Key log into your\n    # Treasure Data Console:\n    #\n    # 1. Go to https://console.treasuredata.com/users/current\n    # 2. API Keys box: copy the API key hash\n    API YOUR_WRITE_ONLY_API_KEY\n\n    # Database\n    # ========\n    # Specify the name of your database. The database must exist.\n    Database db_example\n\n    # Table\n    # =====\n    # Specify the database table name where the records will be stored\n    Table    table_example\n"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"fluent-bitをアプリケーションに組み込む","__idx":6},"children":["fluent-bitをアプリケーションに組み込む"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["GitHubからソースコード全体を取得してください。"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/fluent/fluent-bit"},"children":["https://github.com/fluent/fluent-bit"]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Fluent Bitをビルドすると、最終的なバイナリと、プロジェクトにリンクできるlibfluent-bit.soという共有ライブラリバージョンが作成されます。このライブラリを使用すると、エンジンにデータをエンキューして素早く戻ることができます。すべての処理は、非同期モードで動作する単一のposixスレッドで実行されます。呼び出し元のプロセスやスレッドはブロックされません。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["以下は、Treasure Dataにデータを送信するサンプルプログラムです。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"#include <unistd.h>\n#include <fluent-bit.h>\n\nint main(int argc, char **argv)\n{\n    int i;\n    int n;\n    int ret;\n    char tmp[256];\n    struct flb_config *config;\n\n    if (argc < 2) {\n        fprintf(stderr, \"Usage: td /path/to/configuration.file\\n\");\n        exit(EXIT_FAILURE);\n    }\n\n    /* Create configuration context */\n    config = flb_config_init();\n    if (!config) {\n        exit(EXIT_FAILURE);\n    }\n\n    /* Enable verbose messages */\n    flb_config_verbose(FLB_TRUE);\n\n    /* Load a configuration file (required by TD output plugin) */\n    ret = flb_lib_config_file(config, argv[1]);\n\n    /* Initialize library */\n    ret = flb_lib_init(config, (char *) \"td\");\n    if (ret != 0) {\n        exit(EXIT_FAILURE);\n    }\n\n    /* Start the background worker */\n    flb_lib_start(config);\n\n    /* Push some data */\n    for (i = 0; i < 100; i++) {\n        n = snprintf(tmp, sizeof(tmp) - 1, \"{\\\"key\\\": \\\"val %i\\\"}\", i);\n        flb_lib_push(config, tmp, n);\n    }\n\n    flb_lib_stop(config);\n    return 0;\n}\n"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["fluent-bit.h"]},"ヘッダーをインクルードし、正しい順序で関数を使用するだけです。各関数の説明は以下で入手できます:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"http://fluentbit.io/documentation/"},"children":["Fluent Bit Documentation for Developers"]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"関連情報","__idx":7},"children":["関連情報"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["詳細情報は以下のリンクで入手できます:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"http://fluentbit.io/"},"children":["Fluent Bit"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"http://github.com/fluent/fluent-bit/"},"children":["Fluent Bit Source Code"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"http://fluentbit.io/documentation/"},"children":["Fluent Bit Documentation for Developers"]}]}]}]},"headings":[{"value":"Embedded Apps CおよびC++インポート連携","id":"embedded-apps-cおよびcインポート連携","depth":1},{"value":"前提条件","id":"前提条件","depth":1},{"value":"Fluent Bitについて","id":"fluent-bitについて","depth":1},{"value":"Fluent Bitの組み込みとTreasure Dataへの接続","id":"fluent-bitの組み込みとtreasure-dataへの接続","depth":1},{"value":"Treasure APIキーの取得","id":"treasure-apiキーの取得","depth":2},{"value":"設定ファイルの準備","id":"設定ファイルの準備","depth":2},{"value":"fluent-bitをアプリケーションに組み込む","id":"fluent-bitをアプリケーションに組み込む","depth":2},{"value":"関連情報","id":"関連情報","depth":1}],"frontmatter":{"seo":{"title":"Embedded Apps CおよびC++インポート連携","description":"C++アプリケーションからFluent Bitを使用してTreasure AIにデータをインポートする方法を詳しく解説します。設定手順と組み込み方法を学べます。"}},"lastModified":"2026-06-17T07:22:53.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/ja/int/embedded-apps-c-and-c-import-integration","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}