Skip to main content

BigQuery Setup and link with Glific

3 minutes read                                                                                                                         Intermediate

Many NGOs are concerned about the cost of setting up BigQuery. They are worried about running up a bill. In reality BigQuery provides a very generous free tier that you will find will suffice for several months. You need not worry till your storage exceeds 10GB and queries 1TB / month!


Google also sends notifications before billing you and provides you mechanisms like quotas to help control price. Learn more about these here :

Now that we have that out of the way, let's help you set up your account!

Creating your BigQuery Account

The following steps needs to follow for creating your BigQuery account.

1 . Go to Google Cloud Console and sign in with your GSuite account.

image


2 . After signing in you will be redirected to Google Cloud console. Use the given link if not redirected: https://console.cloud.google.com/getting-started

3 . Click on TRY FOR FREE and fill in Billing Details.

1 TryForFree

4 . Select Country and check to agree to Terms and Conditions.

2 Country

5 . Fill in the rest of the details to verify.

3 Card1

6 . On the same page, fill in Primary contact details and payment method details and click on the Start my free trial

4 Card2

7 . If it does not redirect, you can go to the Google Cloud Console Dashboard directly

8 . Click My First Project in the dropdown in the Top Bar to create a new project.

5 My First Project

9 . Click on New Project at top right corner.

6 New Project

10 . Fill in your project details and click on the CREATE button.

7  Create

11 . Select BigQuery from the side panel of Google Cloud Console Dashboard or use link to reach Bigquery Dashboard,

8 BigQuery
  1. Select the project.9 Select a project

13 . Now Go to https://console.cloud.google.com/apis/credentials/serviceaccountkey to generate project API keys

14 . From the drop select your project. Next, select a new service account and choose Role as Project -> Owner. And Click on the Create Serive Account button below.

10 Create a Serive account
  1. Enter serivce account details and click on 'Done'11 Serive Account details and done

  1. Add Grant this service account access to project is not optional. Along with it, owner access to the email should be added as well while creating a service account.

    image1

image2
image3
  1. Create serive Key. CLick on Manage Keys from 3 dot dropdown.12 Serive Key

  1. Click on 'Add Key'
13  Create new Key
  1. Save the JSON file downloaded and copy its content.14 Json Create and download

20 . To integrate BigQuery in Glific. Click on the NGO main account button(bottom left corner) and find Settings and select BigQuery from the list.

Screenshot 2024-03-04 at 2 32 00 PM

22 . Paste the copied JSON content inside Goth Credentials input

23 . Click on is active checkmark and click on the SAVE button. Then send a message to the bot. BigQuery sync starts when a message is sent from or to the bot after adding credentials.

Screenshot 2024-03-04 at 2 33 04 PM

24 . Go to BigQuery console or use link https://console.cloud.google.com/bigquery


25 . You can see a new Dataset with two tables is automatically created. Contacts and messages will be populating automatically.

image


You can refer to this small video to know how to setup BigQuery for your organisation

Big Query Schema - https://github.com/glific/glific/blob/master/lib/glific/third_party/bigquery/bigquery_schema.ex

Export Data in Excel format from Google BigQuery

There are generally 3 ways to export data from Google BigQuery

  1. Export data in the data studio and then export the results. Help Article https://support.google.com/datastudio/answer/7398375?hl=en

2. How to send data from Google BigQuery to Google Sheets and Excel

https://towardsdatascience.com/how-to-send-data-from-google-bigquery-to-google-sheets-and-excel-eb58436bc398

  1. Exporting Data tables https://cloud.google.com/bigquery/docs/exporting-data#console

Troubleshoot Checklist for BigQuery Data Update failure

  1. Check notification - Check system logs to see if there is any error.
    1. Click on Notification tab from left pane.
    2. Check if there is any errors or warning related to your google account.
Screenshot 2024-03-04 at 2 35 31 PM

Sample error message.

image

2 . Check the BQ account is active.

Screenshot 2024-03-04 at 2 33 04 PM

3 . Check if there is any billing issue at the GCS end.

a. Go to https://console.cloud.google.com/

b. Click on billings from left pane.

c. Check to see if you have any billing related notification from Google.

image

4 . If not able to save credentials and it is showing Account does not have sufficient permissions to insert data to BigQuery as shown in the image

a. Click on three bars on the left hand side and go to IAM & Admin and choose Service Accounts. image

b. Click on CREATE SERVICE ACCOUNT button.

image

c. Enter Service account name e.g. Glific and click on CREATE AND CONTINUE.

image

d. Click on Select a role, type owner, choose OWNER from the list and click on DONE.

image

e. Again click on DONE. This will create a new service account.

image

f. Choose the service account created from list of service accounts.

image

g. Click on KEYS, ADD KEYS and then Create new key.

image

h. Choose JSON as key type and click on CREATE.

image

i. Use the downloaded key and add that as credentials in Bigquery.