Learn more about SFTP Server Export Integration.

The Data Connector for SFTP enables you to import files stored on your SFTP server to Treasure Data.

For sample workflows of importing files from your STFP server, view Treasure Boxes.


Prerequisites

  • Basic knowledge of Treasure Data.

  • Before using this connector, determine valid protocols for your environment.
    If you intend to SFTP, you can use this integration for SFTP.
    If FTP/FTPS, try connect with FTP Import Integration.

    • If you are using a firewall, check your accepted IP range/port. Server administrators sometimes change the default port number from TCP/22 for security reasons.

    • “PuTTY” and other formats are not supported.
  • After installation and configuration, review the job log. Warning and errors provide information about the success of your import. For example, you can identify the source file names associated with import errors.

Limitation

  • Support only the STORED and DEFLATE compression methods.
  • Multi-part gzip file may not work

Use the TD Console to Create your Connection

You can use TD Console to create your data connector.

Create a New Connection

When you configure a data connection, you provide authentication to access the integration. In Treasure Data, you configure the authentication and then specify the source information.

  1. Open TD Console.

  2. Navigate to Integrations Hub > Catalog.

  3. Search and select SFTP.


  4. Select Create 

  5. The following dialog opens.



  6. Enter the required credentials for your remote SFTP instance. Set the following parameters.

    • Host: The host information of the remote SFTP instance, for example an IP address.

    • Port: The connection port on the remote SFTP instance, the default is 22.

    • User: The user name used to connect to the remote FTP instance.

    • Authentication mode: The way you choose to authenticate with your SFTP server.

    • Secret key file: Required if 'public / private key pair' is selected from `Authentication Mode`. (ecdsa key type is supported.)

    • Passphrase for secret key file: (Optional) If required, provide a passphrase for the provided secret file.

    • Retry limit: Number of times to retry a failed connection (default 10).

    • Timeout: Connection timeout in seconds (default 600).


  7. Select Continue. Type a name for your connection.


  8. If you would like to share this connection with other users in your organization, check the Share with others checkbox. If this box is unchecked this connection is visible only to you.

  9. Select Done.

Transfer Data into Treasure Data

To get the data from your SFTP server into Treasure Data, you can set up an ad hoc one-time transfer or a recurring transfer at a regular interval. After creating the authenticated connection, you are automatically taken to Authentications.

  1. Search for the connection you created. 

  2. Select New Source.


     

Connection

  1. Type a name for your Source in the Data Transfer field.



  2. Click Next

Source Table

  1. The Source dialog opens.



  2. Edit the following parameters 

Parameters

Description

User directory root


Path prefix

Prefix of target files (string, required)

Path match pattern

Type a regular expression to query file paths. If a file path doesn’t match with the specified pattern, the file is skipped. For example, if you specify the pattern  .csv$ # , then a file is skipped if its path doesn’t match the pattern.

Incremental

 Enables incremental loading (boolean, optional. default: true. If incremental loading is enabled, the config diff for the next execution will include last_path parameter so that the next execution skips files before the path. Otherwise, last_path is not included.

Start after path

Only paths lexicographically greater than this will be imported.

Data Settings

  1. Select Next.
    The Data Settings page opens.

  2. Optionally, edit the data settings or skip this page of the dialog.



Filters



Import Integration Filters enable you to modify your imported data after you have completed Editing Data Settings for your import.

To apply import integration filters:

Select Next in Data Settings.

The Filters dialog opens.

Select the filter option you want to add.


Select Add Filter.

The parameter dialog for that filter opens.

Edit the parameters.

For information on each filter type, see one of the following:
Retaining Columns Filter
Adding Columns Filter
Dropping Columns Filter
Expanding JSON Filter
Digesting Filter

Optionally, to add another filter of the same type, select Add within the specific column filter dialog.
Optionally, to add another filter of a different type, select the filter option from the list and repeat the same steps.
After you have added the filters you want, select Next.
The Data Preview dialog opens.

Preview


You can see a preview of your data before running the import by selecting Generate Preview.

Data shown in the data preview is approximated from your source. It is not the actual data that is imported.

  1. Select Next.
    Data preview is optional and you can safely skip to the next page of the dialog if you want.

  2. To preview your data, select Generate Preview. Optionally, select Next

  3. Verify that the data looks approximately like you expect it to.


  4. Select Next.


Data Placement

For data placement, select the target database and table where you want your data placed and indicate how often the import should run.

  1.  Select Next. Under Storage you will create a new or select an existing database and create a new or select an existing table for where you want to place the imported data.

  2. Select a Database > Select an existing or Create New Database.

  3. Optionally, type a database name.

  4. Select a Table> Select an existing or Create New Table.

  5. Optionally, type a table name.

  6. Choose the method for importing the data.

    • Append (default)-Data import results are appended to the table.
      If the table does not exist, it will be created.

    • Always Replace-Replaces the entire content of an existing table with the result output of the query. If the table does not exist, a new table is created. 

    • Replace on New Data-Only replace the entire content of an existing table with the result output when there is new data.

  7. Select the Timestamp-based Partition Key column.
    If you want to set a different partition key seed than the default key, you can specify the long or timestamp column as the partitioning time. As a default time column, it uses upload_time with the add_time filter.

  8. Select the Timezone for your data storage.

  9. Under Schedule, you can choose when and how often you want to run this query.

    • Run once:
      1. Select Off.

      2. Select Scheduling Timezone.

      3. Select Create & Run Now.

    • Repeat the query:

      1. Select On.

      2. Select the Schedule. The UI provides these four options: @hourly, @daily and @monthly or custom cron.

      3. You can also select Delay Transfer and add a delay of execution time.

      4. Select Scheduling Timezone.

      5. Select Create & Run Now.

 After your transfer has run, you can see the results of your transfer in Data Workbench > Databases.