GCP Part 2 - Sending Data to BigQuery
This chapter describes sending data from deviceWISE to Google Cloud's BigQuery.
Creating Datasets in BigQuery
In this section you need to create a dataset and will later send data from deviceWISE to BigQuery.
- Open the BigQuery web UI in the Google's Cloud Console.
You will view the connected project at the left-hand side of the screen. - Click on the project.
- Click CREATE DATASET.
- Enter Dataset ID. For example: Factory_Line2_Dataset.
- Click Create dataset.
The dataset gets created. - Click on the created dataset.
- Click Create table.
- Enter Table name.
- Click Add field.
- Enter the name of the fields (RPM - INTEGER, Tag - STRING, Timestamp - TIMESTAMP).
- Click Create table.
Setting up deviceWISE to send data to BigQuery
This section provides a step-by-step guide to create the logic, to send the deviceWISE data to BigQuery. To create a trigger, do the following:
- Right-click on Projects and select New.
- Enter a Name and Description.
- Right-click on the new project and click Start.
The project state changes to Started. - Double-click on the project you just started, to open the project on a new tab.
- Click New, to start defining a new Trigger.
The Trigger screen appears. The yellow box contains the event types, the blue box contains the actions, and the green box is the canvas. To define the trigger do the following:- Enter Name of the trigger.
- Click Trigger Event Type drop-down and select On-Demand as the event type.
- Expand Google Cloud action group and drag & drop the BigQuery - InsertAll action onto the canvas.
- Drag & drop the end execution block, located above the Trigger action group.
- Connect the Start, to the BigQuery - InsertAll action block.Connect the BigQuery - InsertAll action block to the End Execution.
- Connect the grey arrow to the End Execution.
- Double-click the BigQuery - InsertAll action block to edit the action.
- In the BigQuery - InsertAll window, you will notice all the fields are populated from the dataset, that you created from the previous section.
- Enter the values for all the Input variables. Map the Data Point Timestamp to the $EVENT_TIME macro.
- Save and close the Trigger editor.
- Right-click on the trigger and click Start.
The trigger is started. You will notice 1 in the success count indicating the row is added to the BigQuery. - Open the BigQuery web UI in the Google's Cloud Console and go to the project you created.
- In the Query editor, enter the following query:
Select * from Factory_Line2_Dataset.Machine1
. - Click Run.
The rows with the values you entered in the Workbench is displayed.