Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TiDB Cloud: add a tutorial for Looker Studio #16111

Merged
merged 22 commits into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
f6ffc68
TiDB Cloud: add a tutorial for Looker Studio
bohnen Jan 11, 2024
de82576
TiDB Cloud: fix support link
bohnen Jan 11, 2024
da6d79e
Update TOC-tidb-cloud.md
bohnen Jan 11, 2024
e838521
Update develop/dev-guide-bi-looker-stduio.md
bohnen Jan 11, 2024
9d286a8
Update develop/dev-guide-bi-looker-stduio.md
bohnen Jan 11, 2024
3d197c1
fix filename typo
bohnen Jan 11, 2024
77836d6
add separate connection description for a dedicated cluster
bohnen Jan 11, 2024
0754c61
change support link to /support.md
bohnen Jan 11, 2024
b337bf6
revert support link change due to braking CI
bohnen Jan 11, 2024
f686612
restrict access from specific IP range
bohnen Jan 11, 2024
328ba79
fix lint error: double space after list marker
bohnen Jan 11, 2024
d040ac3
Apply suggestions from code review
bohnen Jan 11, 2024
911db94
Apply suggestions from code review
zhangyangyu May 11, 2024
bbfbc22
Update develop/dev-guide-bi-looker-studio.md
zhangyangyu May 12, 2024
cee640f
Apply suggestions from code review
zhangyangyu May 12, 2024
8efcb86
refine the content and update the instructions for TiDB Dedicated
qiancai May 13, 2024
631a756
move the doc to the tidb-cloud folder as it is only for TiDB Cloud
qiancai May 13, 2024
ad69eb9
Update dev-guide-bi-looker-studio.md
qiancai May 13, 2024
0254ba5
Update dev-guide-bi-looker-studio.md
qiancai May 13, 2024
87745cd
Update looker-studio-simple-chart.png
qiancai May 14, 2024
2dea8f0
Apply suggestions from code review
qiancai May 14, 2024
95f2ca7
format udpates
qiancai May 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions TOC-tidb-cloud.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
- [MySQL Workbench](/develop/dev-guide-gui-mysql-workbench.md)
- [Navicat](/develop/dev-guide-gui-navicat.md)
- [Choose Driver or ORM](/develop/dev-guide-choose-driver-or-orm.md)
- BI
- [Looker Studio](/tidb-cloud/dev-guide-bi-looker-studio.md)
- Java
- [JDBC](/develop/dev-guide-sample-application-java-jdbc.md)
- [MyBatis](/develop/dev-guide-sample-application-java-mybatis.md)
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added media/tidb-cloud/looker-studio-custom-query.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added media/tidb-cloud/looker-studio-simple-chart.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
128 changes: 128 additions & 0 deletions tidb-cloud/dev-guide-bi-looker-studio.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
---
title: Connect to TiDB Serverless with Looker Studio
summary: Learn how to connect to TiDB Serverless using Looker Studio.
---

# Connect to TiDB Serverless with Looker Studio

TiDB is a MySQL-compatible database, TiDB Serverless is a fully managed TiDB offering, and [Looker Studio](https://lookerstudio.google.com/) is a free web-based BI tool that can visualize data from various sources.

In this tutorial, you can learn how to connect to your TiDB Serverless cluster with Looker Studio.

> **Note:**
>
> Most steps in this tutorial work with TiDB Dedicated as well. However, for TiDB Dedicated, you need to import your dataset following [Import data from files to TiDB Cloud](/tidb-cloud/tidb-cloud-migration-overview.md#import-data-from-files-to-tidb-cloud) and get the connection information for your cluster following [Connect to TiDB Dedicated](/tidb-cloud/connect-via-standard-connection.md). In addition, when connecting to TiDB Dedicated, you need to allow access from `142.251.74.0/23`. For more information about connection from Looker Studio, see [Looker Studio documentation](https://support.google.com/looker-studio/answer/7088031#zippy=%2Cin-this-article).
qiancai marked this conversation as resolved.
Show resolved Hide resolved

## Prerequisites

To complete this tutorial, you need:

- A Google account
- A TiDB Serverless cluster

**If you don't have a TiDB Serverless cluster, you can create one as follows:**

- [Create a TiDB Serverless cluster](/develop/dev-guide-build-cluster-in-cloud.md)
qiancai marked this conversation as resolved.
Show resolved Hide resolved

## Step 1. Import a dataset

You can import the S&P 500 dataset provided in the interactive tutorial of TiDB Serverless.

1. Navigate to the [**Clusters**](https://tidbcloud.com/console/clusters) page, and click **?** in the lower-right corner. A **Help** dialog is displayed.

2. In the dialog, click **Interactive Tutorials**, and then click **S&P 500 Analysis**.

3. Select your TiDB Serverless cluster, and then click **Import Dataset** to import the S&P 500 dataset to your cluster.
qiancai marked this conversation as resolved.
Show resolved Hide resolved

4. After the import status changes to **IMPORTED**, click **Exit Tutorial** to close this dialog.
qiancai marked this conversation as resolved.
Show resolved Hide resolved

## Step 2. Get the connection information for your cluster

1. Navigate to the [**Clusters**](https://tidbcloud.com/console/clusters) page, and then click the name of your target cluster to go to its overview page.

2. Click **Connect** in the upper-right corner. A connection dialog is displayed.

3. In the connection dialog, Set **Connect With** to `General`, and then click **Generate Password** to create a random password.

> **Tip:**
>
> If you have created a password before, use the original password or click **Reset Password** to generate a new one.

4. Download the [CA cert](https://letsencrypt.org/certs/isrgrootx1.pem).

> **Tip:**
>
> TiDB Serverless requires a secure TLS connection between the client and the cluster, so you need this CA cert for connection settings in Looker Studio.

## Step 3. Connect to your TiDB cluster with Looker Studio

1. Log into [Looker Studio](https://lookerstudio.google.com/), and then click **Create** > **Report** in the left navigation pane.

2. On the displayed page, select the **MySQL** connector, and then click **AUTHORIZE**.
qiancai marked this conversation as resolved.
Show resolved Hide resolved

3. In the **BASIC** setting pane, configure the connection parameters.

- **Host Name or IP**: enter the `HOST` parameter from the TiDB Serverless connection dialog.
- **Port(Optional)**: enter the `PORT` parameter from the TiDB Serverless connection dialog.
- **Database**: enter the database you want to connect to. For this tutorial, enter `sp500insight`.
- **Username**: enter the `USERNAME` parameter from the TiDB Serverless connection dialog.
- **Password**: enter the `PASSWORD` parameter from the TiDB Serverless connection dialog.
- **Enable SSL**: select this option, and then click the upload icon to the right of **MySQL SSL Client Configuration Files** to upload the CA file downloaded from [Step 2](#step-2-get-the-connection-information-for-your-cluster).

![Looker Studio: configure connection settings for TiDB Serverless](/media/tidb-cloud/looker-studio-configure-connection.png)

4. Click **AUTHENTICATE**.

If the authentication succeeds, you can see tables in the database.

## Step 4. Create a simple chart

Now, you can use the TiDB cluster as a data source and create a simple chart with data.

1. In the right pane, click **CUSTOM QUERY**.

![Looker Studio: custom query](/media/tidb-cloud/looker-studio-custom-query.png)

2. Copy the following code to the **Enter Custom Query** area, then click **Add** in the lower-right corner.

```sql
SELECT sector,
COUNT(*) AS companies,
ROW_NUMBER() OVER (ORDER BY COUNT(*) DESC ) AS companies_ranking,
SUM(market_cap) AS total_market_cap,
ROW_NUMBER() OVER (ORDER BY SUM(market_cap) DESC ) AS total_market_cap_ranking,
SUM(revenue_growth * weight) / SUM(weight) AS avg_revenue_growth,
ROW_NUMBER() OVER (ORDER BY SUM(revenue_growth * weight) / SUM(weight) DESC ) AS avg_revenue_growth_ranking
FROM companies
LEFT JOIN index_compositions ic ON companies.stock_symbol = ic.stock_symbol
GROUP BY sector
ORDER BY 5 ASC;
```

If you see the **You are about to add data to this report** dialog, click **ADD TO REPORT**. Then, a table is displayed in the report.

3. In the toolbar of the report, click **Add a chart**, and then select `Combo chart` in the `Line` category.

4. In the **Chart** settings pane on the right, configure the following parameters:

- In the **SETUP** Tab:
- **Dimension**: `sector`.
- **Metric**: `companies` and `total_market_cap`.
- In the **STYLE** Tab:
- Series #1: select the `Line` option and the `Right` axis.
- Series #2: select the `Bars` option and the `Left` axis.
- Leave other fields as defaults.

Then, you can see a combo chart similar as follows:

![Looker Studio: A simple Combo chart](/media/tidb-cloud/looker-studio-simple-chart.png)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This figure is blurry. Can you get a better one?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hfxsd Yes, I can, but if I make the image clearer, its file size and image size will be bigger. Please see the attached and take a look at whether it fits on the page.
スクリーンショット 2024-05-14 12 46 54

Copy link
Collaborator

@hfxsd hfxsd May 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resized it to 60%

Image 60%

Copy link
Collaborator

@qiancai qiancai May 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've uploaded a clear image in 87745cd (#16111). The browser will show the image with full width by default. We can resize it like the following after this PR is merged.

<img src="https://download.pingcap.com/images/docs/tidb-cloud/looker-studio-simple-chart.png" alt="Looker Studio: A simple Combo chart" width="500"></img>


## Next steps

- Learn more usage of Looker Studio from [Looker Studio Help](https://support.google.com/looker-studio).
- Learn the best practices for TiDB application development with the chapters in the [Developer guide](/develop/dev-guide-overview.md), such as [Insert data](/develop/dev-guide-insert-data.md), [Update data](/develop/dev-guide-update-data.md), [Delete data](/develop/dev-guide-delete-data.md), [Single table reading](/develop/dev-guide-get-data-from-single-table.md), [Transactions](/develop/dev-guide-transaction-overview.md), and [SQL performance optimization](/develop/dev-guide-optimize-sql-overview.md).
- Learn through the professional [TiDB developer courses](https://www.pingcap.com/education/) and earn [TiDB certifications](https://www.pingcap.com/education/certification/) after passing the exam.

## Need help?

Ask questions on [Discord](https://discord.gg/DQZ2dy3cuc?utm_source=doc) or [create a support ticket](https://support.pingcap.com/).
Loading