...
The Data Connector for SFTP enables you to import files stored on your SFTP server to Arm Treasure Data.
Prerequisites
Basic knowledge of Treasure Data
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.
...
Click Create Authentication to complete the connection. If the connection is a success, then the connection you just created appears in your list of authentications with the name you provided.
Transfer data into Treasure Data.
Now that you have created the connection to your remote SFTP instance, the next step is getting 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. In this section, you specify source details as described in the following steps.
...
Enter SFTP Server details.
Provide the details of the database and table that you want to ingest data from.
...
Click Next to preview the data in the next step.
Preview
If there are no errors with the connection, you see a preview of the data to be imported. If you are unable to see the preview, read more. If you have issues viewing the preview, contact support.
...
If you need to use non-standard options for your import, select Advanced Settings.
Advanced Settings
Advanced Settings allow to you modify aspects of your transfer to allow for special requirements.
Transfer to
Select the Treasure Data target database and table that you want to import your data to. You can create a new database or table using the Create new database
or Create new table
checkboxes.
Mode: Append – Allows you to add records into existing table.
Mode: Replace – Replace the existing data in the table with the data being imported.
Partition key Seed: Choose the long or timestamp column that you would like to use as the partitioning time column. If you do not specify a time column, the upload time of the transfer is used in conjunction with the addition of a
time
column.
...
Data Transfer Frequency
You can choose to run the transfer only one time or schedule it to run on a given frequency of your choosing.
...
After selecting the frequency, click Start Transfer to begin the transfer. If there are no errors, the transfer into Treasure Data will complete and the data will be available. Jobs are kicked off when a transfer runs. You can used the Jobs or the My Input Transfers section to monitor the progress of your data transfer.
My Input Transfers
If you need to review the transfer you have just completed for other data connector jobs, you can view a list of your transfers in the My Input Transfers
section. You can also edit the details of data transfers.You can use the Jobs or the Sources section to monitor the progress of your data transfer.
Appendix
A) Optional Alternative: Use the CLI to Configure the Connector
You can also use the FTP data connector from the command line interface. The following instructions show you how to import data using the CLI.
Install ‘td’ command v0.11.9 or later
Install the most current Treasure Data Toolbelt.
Code Block |
---|
$ td --version 0.11.10 |
Create Seed Config File (seed.yml)
Prepare seed.yml as shown in the following example, with your SFTP details. We support two authentication methods: Public / Private Key Pair, and Password.
Case 1: Public / Private Key Pair Authentication
Create seed.yml with the following content.
...
`secret_key_file` requires OpenSSH format. |
Case 2: Password Authentication
Create seed.yml with the following content.
...
For more details on available out modes, see Appendix B.
Guess Fields (Generate load.yml)
Use connector:guess. This command automatically reads the source file, and assesses (uses logic to guess) the file format.
...
Code Block |
---|
$ td database:create td_sample_db $ td table:create td_sample_db td_sample_table |
Execute Load Job
Submit the load job. It may take a couple of hours depending on the size of the data. Specify the Treasure Data database and table where the data should be stored.
...
Code Block |
---|
$ td connector:issue load.yml --database td_sample_db --table td_sample_table |
Scheduled execution
You can schedule periodic Data Connector execution for incremental SFTP file import. We configure our scheduler carefully to ensure high availability. By using this feature, you no longer need a crondaemon on your local data center.
...
On the second and on subsequent runs, it imports only files that comes after the last path in alphabetical (lexicographic) order. (path/to/sample_201506.csv.gz
, …)
Create the schedule
A new schedule can be created using the td connector:create command. The following are required: the name of the schedule, the cron-style schedule, the database and table where the data will be stored, and the Data Connector configuration file.
...
By default, schedule is setup in UTC timezone. You can set the schedule in a timezone using -t or --timezone option. The `--timezone` option supports only extended timezone formats like 'Asia/Tokyo', 'America/Los_Angeles' etc. Timezone abbreviations like PST, CST are *not* supported and may lead to unexpected schedules.
List the Schedules
You can see the list of currently scheduled entries by running the command td connector:list.
Code Block |
---|
$ td connector:list +--------------+--------------+----------+-------+--------------+-----------------+--------------------------------------------+ | Name | Cron | Timezone | Delay | Database | Table | Config | +--------------+--------------+----------+-------+--------------+-----------------+--------------------------------------------+ | daily_import | 10 0 * * * | UTC | 0 | td_sample_db | td_sample_table | {"in"=>{"type"=>"sftp", "access_key_id"... | +--------------+--------------+----------+-------+--------------+-----------------+--------------------------------------------+ |
Show the Setting and Schedule History
td connector:show shows the execution setting of a schedule entry.
...
Code Block |
---|
% td connector:history daily_import +--------+---------+---------+--------------+-----------------+----------+---------------------------+----------+ | JobID | Status | Records | Database | Table | Priority | Started | Duration | +--------+---------+---------+--------------+-----------------+----------+---------------------------+----------+ | 578066 | success | 10000 | td_sample_db | td_sample_table | 0 | 2015-04-18 00:10:05 +0000 | 160 | | 577968 | success | 10000 | td_sample_db | td_sample_table | 0 | 2015-04-17 00:10:07 +0000 | 161 | | 577914 | success | 10000 | td_sample_db | td_sample_table | 0 | 2015-04-16 00:10:03 +0000 | 152 | | 577872 | success | 10000 | td_sample_db | td_sample_table | 0 | 2015-04-15 00:10:04 +0000 | 163 | | 577810 | success | 10000 | td_sample_db | td_sample_table | 0 | 2015-04-14 00:10:04 +0000 | 164 | | 577766 | success | 10000 | td_sample_db | td_sample_table | 0 | 2015-04-13 00:10:04 +0000 | 155 | | 577710 | success | 10000 | td_sample_db | td_sample_table | 0 | 2015-04-12 00:10:05 +0000 | 156 | | 577610 | success | 10000 | td_sample_db | td_sample_table | 0 | 2015-04-11 00:10:04 +0000 | 157 | +--------+---------+---------+--------------+-----------------+----------+---------------------------+----------+ 8 rows in set |
Delete the Schedule
td connector:delete will remove the schedule.
Code Block |
---|
$ td connector:delete daily_import |
B) Modes for out plugin
You can specify file import mode in out section of seed.yml.
append (default)
This is the default mode and records are appended to the target table.
Code Block |
---|
in: ... out: mode: append |
replace (In td 0.11.10 and later)
This mode replaces data in the target table. Note that any manual schema changes made to the target table will remain intact with this mode.
Code Block |
---|
in: ... out: mode: replace |
FAQ for the SFTP Data Connector
I can’t connect to my SFTP server, what can I do?
Check what is valid protocol. If you intend to SFTP, you can use this Data Connector for SFTP. If FTP/FTPS, try connect with FTP Data Connector.
If you’re using firewall, check your accepted IP range/port. Server administrators sometimes change the default port number from TCP/22 for the security reason.
Be sure that your private key has OpenSSH format. We don’t support other formats like “PuTTY”.
How do I troubleshoot data import problems?
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.