製品をチェック

無償トライアル:

無償トライアルへ

製品の情報と無償トライアルへ:

Azure Data Lake Storage JDBC Driver

Azure Data Lake Storage データに連携するJava アプリケーションを素早く、簡単に開発できる便利なドライバー。

データ連携でお困りですか?

お問い合わせ

Elasticsearch へLogstash 経由でAzure Data Lake Storage データをロードする方法


全文検索のElasticsearch のETL/ELT モジュールのLogstash とJDBC Driver を使い、Azure Data Lake Storage データを簡単にロードする方法。


azuredatalake ロゴ画像
jdbc ロゴ画像

JDBC

Elasticsearch Logstash ロゴ画像

Elasticsearch は、人気の分散型の全文検索エンジンです。データを一元的に格納することで、超高速検索や、関連性の細かな調整、パワフルな分析が大規模に、手軽に実行可能になります。Elasticsearch にはデータのローディングを行うパイプラインツール「Logstash」があります。CData Drivers を利用することができるので、30日の無償評価版をダウンロードしてあらゆるデータソースを簡単にElasticsearch に取り込んで検索・分析を行うことができます。

この記事では、CData Driver for ADLS を使って、Azure Data Lake Storage のデータをLogstash 経由でElasticsearch にロードする手順を説明します。

Elasticsearch Logstash でCData JDBC Driver for ADLS を使用

  • CData JDBC Driver for ADLS をLogstash が稼働するマシンにインストールします。
  • 以下のパスにJDBC Driver がインストールされます。後ほどこのパスを使います。この.jar ファイルと製品版の場合は.lic ファイルをLogstash に配置して使います。
    C:\Program Files\CData\CData JDBC Driver for ADLS 2019J\lib\cdata.jdbc.adls.jar
  • 次に、Logstash とCData JDBC Driver をつなぐ、JDBC Input Plugin をインストールします。JDBC Plugin は最新のLogstash だとデフォルトでついてきますが、バージョンによっては追加する必要があります。
    https://www.elastic.co/guide/en/logstash/5.4/plugins-inputs-jdbc.html
  • CData JDBC Driver の.jar ファイルと.lic ファイルを、Logstashの「/logstash-core/lib/jars/」に移動します。

Logstash でElasticsearch にAzure Data Lake Storage データを送る

それでは、LogstashでElasticsearch にAzure Data Lake Storage データ転送を行うための設定ファイルを作成していきます。

  • Logstash のデータ処理定義であるlogstash.conf ファイルにAzure Data Lake Storage データを取得する処理書きます。Input はJDBC、Output はElasticsearch にします。データローディングジョブの起動間隔は30秒に設定しています。
  • CData JDBC Driver の.jar をjdbc driver ライブラリにして、クラス名を設定、Azure Data Lake Storage への接続プロパティをJDBC URL の形でせっていします。JDBC URL ではほかにも詳細な設定を行うことができるので、細かくは製品ドキュメントをご覧ください。
  • Authenticating to a Gen 1 DataLakeStore Account

    Gen 1 uses OAuth 2.0 in Azure AD for authentication.

    For this, an Active Directory web application is required. You can create one as follows:

    1. Sign in to your Azure Account through the .
    2. Select "Azure Active Directory".
    3. Select "App registrations".
    4. Select "New application registration".
    5. Provide a name and URL for the application. Select Web app for the type of application you want to create.
    6. Select "Required permissions" and change the required permissions for this app. At a minimum, "Azure Data Lake" and "Windows Azure Service Management API" are required.
    7. Select "Key" and generate a new key. Add a description, a duration, and take note of the generated key. You won't be able to see it again.

    To authenticate against a Gen 1 DataLakeStore account, the following properties are required:

    • Schema: Set this to ADLSGen1.
    • Account: Set this to the name of the account.
    • OAuthClientId: Set this to the application Id of the app you created.
    • OAuthClientSecret: Set this to the key generated for the app you created.
    • TenantId: Set this to the tenant Id. See the property for more information on how to acquire this.
    • Directory: Set this to the path which will be used to store the replicated file. If not specified, the root directory will be used.

    Authenticating to a Gen 2 DataLakeStore Account

    To authenticate against a Gen 2 DataLakeStore account, the following properties are required:

    • Schema: Set this to ADLSGen2.
    • Account: Set this to the name of the account.
    • FileSystem: Set this to the file system which will be used for this account.
    • AccessKey: Set this to the access key which will be used to authenticate the calls to the API. See the property for more information on how to acquire this.
    • Directory: Set this to the path which will be used to store the replicated file. If not specified, the root directory will be used.
                
                    input {
                        jdbc {
                          jdbc_driver_library => "../logstash-core/lib/jars/cdata.jdbc.adls.jar"
                          jdbc_driver_class => "Java::cdata.jdbc.adls.ADLSDriver"
                          jdbc_connection_string => "jdbc:adls:Schema=ADLSGen2;Account=myAccount;FileSystem=myFileSystem;AccessKey=myAccessKey;InitiateOAuth=REFRESH"
                          jdbc_user => ""
                          jdbc_password => ""
                          schedule => "*/30 * * * * *"
                          statement => "SELECT FullPath, Permission FROM Resources WHERE Type = 'FILE'"
                        }
                      }
                      
                     
                      output {
                        Elasticsearch {
                            index => "adls_Resources"
                            document_id => "xxxx"
                        }
                      }
                
            

Logstash でAzure Data Lake Storage のローディングを実行

それでは作成した「logstash.conf」ファイルを元にLogstash を実行してみます。

> logstash-7.8.0\bin\logstash -f logstash.conf

成功した旨のログが出ます。これでAzure Data Lake Storage データがElasticsearch にロードされました。

例えばKibana で実際にElasticsearch に転送されたデータを見てみます。

        
            GET adls_Resources/_search
            {
            "query": {
                "match_all": {}
            }
            }
        
    
Elasticsearch にロードされたAzure Data Lake Storage データをクエリ

データがElasticsearch に格納されていることが確認できました。

Elasticsearch にロードされたAzure Data Lake Storage データを確認

CData JDBC Driver for ADLS をLogstash で使うことで、Azure Data Lake Storage コネクタとして機能し、簡単にデータをElasticsearch にロードすることができました。ぜひ、30日の無償評価版をお試しください。