Exporting reports to SFTP server
The Reports module in Synerise gives lots of opportunities to create custom reports adjusted to your business needs and the data you store in the workspace. Thanks to data transformation and automation, you can create the mechanism of exporting reports to your external resource cyclically.
In this use case we will describe how to export a report to an SFTP server every day. We will also create a data transformation diagram which changes the name of a column in the report before sending it.
Prerequisites
- Create a catalog in your SFTP server in which your reports will be stored.
- Create a report that will be exported to the SFTP server.
Tip: The time scope of the report should be adjusted to the frequency of exporting data. For example, if you export the report every day, it should have the time scope set to Yesterday - thanks to this, you will export data each day from the previous day.
- Create a workspace API key with the permission required by the “Preview report as CSV method.
Process
Prepare a file with sample data
In this part of the process, you need to prepare a file with sample data which will be used to create Data Transformation later.
- Go to Analytics > Reports.
- From the list, select the report you created for exporting.
- Click the Preview tab.
- Click Download CSV.
- Open the file in text editor and remove rows from it until 10 are left. This copy is only needed as a file sample for creating the Data Transformation.
Create data transformation diagram
In this part of the process, we define the rules of modifying data before sending it to the SFTP server. Each report exported from Synerise has a column named Value
, which contains the value of metric used in the report. For the purposes of this use case, we will change the name of this column to number of clicks
.
The data transformation diagram which is the output of this part of the process is used later to automate sending the data.
- Go to Automation > Data Transformation > Create transformation.
- Enter the name of the transformation.
- Click Add input.
Add file with sample data
The Data input node allows you to add a data sample. In further steps, you define how the data must be modified. Later, when this transformation is used in the Automation workflow, the system uses the rules created with the sample data as a pattern for modifying actual data.
- On the pop-up, click Add example.
- Upload the file prepared in this step.
- Change the default delimiter to
;
. - Click Generate.
Change the name of the column
- On the canvas, click the right mouse button.
- From the dropdown list, select Rename column.
- Click the Rename column node.
- In the configuration of the node:
- Click Add rule.
- Click Add column.
- Select the Value column.
- Under Edit values by, from the dropdown list, select Replacing.
- In the text field, enter
number of clicks
. - Confirm by clicking Apply.
Add the finishing node
This node lets you preview the output of the modifications to the sample data.
- On the canvas, click the right mouse button.
- From the dropdown list, select Data output.
- In the upper right corner, click Save and publish.
Result: You have published a Data Transformation diagram and it can now be used in a Workflow.
Create a workflow
In this part of the process, you will create the workflow that exports report data to SFTP server every day at 6:00 AM.
- Go to Automation > Workflows > New workflow.
- Enter the name of the workflow.
Define the launch date
-
As the trigger node, add Scheduled Run.
-
In the configuration of the node:
- Leave the Run trigger option at default (all time).
- From the Timezone dropdown list, select the time zone consistent with the timezone selected for your workspace.
- Define the frequency of the workflow. In this use case, it’s every day at 6:00 AM. The workflow will automatically launch everyday at 6:00 AM.
- Confirm by clicking Apply.
Define the report that will be exported
In this part of the process, we need to define an HTTPS request in the Get File node which retrieves a CSV file with report data. The full documentation of this request is available here.
- Click THEN and from the dropdown list, select HTTPS > Get File.
- In the configuration of the node:
- From the Method dropdown menu, select POST.
- Enter the URL:
https://api.synerise.com/analytics-backend/analytics/v4/reports/preview-csv
- From the File format dropdown menu, select CSV.
- Change the default Delimiter to
;
. - Add the JSON body of the request:
- In a new browser tab, open the report you want to export.
- Open the browser’s developer tools and go to the tab where you can preview HTTP requests.
- In the report, go to the Preview tab.
- In the developer tools, locate the request to the
analytics/v4/reports/preview-csv
endpoint and copy its request body. - Paste the request body into the Body field of the automation node.
Tip: You can also build the request body manually, according to the documentation.
- In the Authorization section, choose the API key with the required permissions (according to the documentation).
- Leave the rest of the settings as default.
- Confirm by clicking Apply.
Select the data transformation rules
-
Add a Data Transformation node.
-
In the configuration of the node, select the data transformation you have created before.
-
Confirm by clicking Apply.
Configure settings for SFTP protocol
In this part of the process, we will configure the settings for an SFTP connection so that your report, after passing through transformation rules, can be stored in the external resource.
- Add the Send File node by clicking THEN > SFTP.
- In the configuration of the node:
- Enter the path to your server.
- Select the port.
- Enter the path to the directory.
- Enter the name of the file that the report will be saved as.
- If needed, in the File name suffix, select the suffix of the file name.
Tip: We recommend choosing the Date suffix, which adds the current date to the file name, so that the names of your files do not repeat in the catalog (files will be sent every day) and are easier to browse. - From the File format dropdown list, select the CSV format.
- Change the default Delimiter to
;
. - In the Authentication section, select the method of authentication.
- Confirm by clicking Apply.
Add the finishing node
- Add the End node.
- In the upper right corner, click Save & Run.
You can monitor the flow of the workflow in the Transformation logs tab. It contains information about each execution of the workflow.
Check the use case set up on the Synerise Demo workspace
You can check the configuration of use case in Synerise Demo workspace:
If you don’t have access to the Synerise Demo workspace, please leave your contact details in this form, and our representative will contact you shortly.