Database Visualization using Metabase Part 2 - Use Metabase to Get Insights

本文涉及的产品
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
云数据库 RDS MySQL,集群系列 2核4GB
推荐场景:
搭建个人博客
云数据库 RDS MySQL,高可用系列 2核4GB
简介: In this tutorial, we will install Metabase on an Alibaba Cloud ECS Ubuntu 16.04 server to achieve data visualization.

By Liptan Biswas, Alibaba Cloud Tech Share Author. Tech Share is Alibaba Cloud’s incentive program to encourage the sharing of technical knowledge and best practices within the cloud community.

In the first part of the tutorial, we looked at how to install Metabase for production use on Ubuntu 16.04. In this part of the tutorial, we will learn the basic uses of Metabase. We will run some sample queries on sample database hosted on a MySQL server. We will learn to create saved questions and dashboards. We will also configure emails into Metabase so that our application can send us updated insights on a regular basis.

Using Metabase to Get Insights

Metabase is able to run queries over multiple types of database such as MySQL, PostgreSQL, Presto, MongoDB, MSSQL etc. Because of this feature, you can directly add your database into Metabase and ask questions from it. In a production environment, it is best to create a new user with read-only access just for the Metabase instance. If your database contains sensitive information, you can also create table views according to preferences to display only selected columns.

Although, Metabase provides a sample database on which you can run queries to learn about the platform. In this tutorial, I am using a sample MySQL database server with Employees database to demonstrate the usage of Metabase. Let’s suppose your company has a database named “employees” hosted on MySQL database server. Running these queries will create a new user named “metabase_user” with read-only access to the database. Access will be granted only to the instance with IP address “192.168.0.101”, which is the actual public IP address of your ECS instance.

CREATE USER 'metabase_user'@'192.168.0.101' IDENTIFIED BY 'StrongPassword';
GRANT SELECT ON employees.* to 'metabase_user'@'192.168.0.101' IDENTIFIED BY 'StrongPassword';

Now that our read-only user is ready, let’s add the database into Metabase. Login to your Metabase instance and goto Metabase Admin >> Databases >> Add Database. Select database type and provide connection details.

1

Once the database is added, you can go to the Data Model tab to check the schema of the database. You can hide the tables or columns which contain redundant or sensitive information. Exit the admin panel and go back to the dashboard so that you can ask questions and learn the insights from the data.

Asking Questions on Metabase

We will start by asking a simple question. Click on New Question button at the top and select custom questions. Now, select the database on which you want to run the query. Select a filter for your query if required. Select the view, you can choose to see the raw data, basic metrics or run custom expressions. Basic metrics include the count of the number of rows, the sum or average of rows, cumulative sum or average, and standard deviation etc. Finally, group your data according to your choice. The following screenshot displays the output of the number of employees by gender in the example database I used. The output is generated by a query on the Employees database with no filter, view set to count the rows and grouped by Gender. The output can be visualized in multiple formats such as a table, bar chart, line and area graph, pie chart etc.

2

Metabase automatically provides suggestions for filters according to the data. For example, if you are using a filter on a column containing birth date of your employees, you can filter the data by born on a specific date, born in a specific month or a specific year. You can also apply filters such as born before or after a specific date or born between two specific dates. In the next query, I have filtered the data to match the hire date year to “1995”. I also grouped the output by the months. The output is visualized in area graph.

3

If you want, you can also visualize the data by running native SQL query on the database. Click on New Question and select SQL. Select the database and write your query in SQL format. The output from the SQL statements can also be visualized in different graphs and charts.

4

Metabase allows you to save the questions you ask for future use, simply click on save link once the output of question is obtained. If you want to run the same question again on updated data, you can simply browse through the saved questions and click on the question to get answers quickly.

5

Metabase also lets you create custom dashboards, which gives you quick insights into your current data. You can also share these dashboards with your colleagues. To create a new dashboard, move over to the Dashboard tab from the top menu. Create a new dashboard and name it according to your choice. Now add graphs and charts by selecting the saved questions and your dashboard will be ready in minutes.

6

Setting up Pulses

Pulse is a Metabase feature which enables you to send regular emails or Slack notifications containing important updates to the insights. For Metabase to send emails, you need to configure mail settings in the Metabase administration panel. Setting up emails is also important as it is also used to send password reset emails and invitations. Metabase uses SMTP or Simple Mail Transfer Protocol to send emails. If you do not have an existing SMTP server, you can use the SMTP service provided by Alibaba Cloud DirectMail. It is very cost effective, easy to set up and provides 200 free emails per day.

To create an SMTP server with Alibaba Cloud Direct mail, follow the steps 1 to 3 from this tutorial. Change the email domain, sender address and SMTP credentials, according to your environment. Once you have followed the steps in that tutorial, you will have the following information with you.

SMTP Host: smtpdm-ap-southeast-1.aliyun.com
SMTP Port: 465
SMTP Security: SSL
SMTP Username: mail@example.com
SMTP Password: StrongPassword

The above values are example values, you should find the real values in the DirectMail web console. Go to Admin >> Settings >> Email and provide your SMTP server details.

7

To create a new pulse, exit the admin and go to Pulses from the top menu. Click on Create a pulse button. Provide a descriptive name for your pulse, select the saved questions whose output is to be sent. Now select recipients and the frequency of the email. You can check if the email is being delivered by clicking Send mail now button. Finally, click Create Pulse button and Metabase will deliver the updated insights regularly right into your inbox.

8

Conclusion

Though Metabase does not do anything by itself, the insights provided by Metabase are very helpful in understanding different aspects of the organization. We have gone through the basic uses of the Metabase application. We have also configured emails and create scheduled pulses. The next step for you is to invite your colleagues to the platform. Go to Admin dashboard and to people tab, you will find the option to invite your team members. You can also create new groups and restrict the databases accessible to users of certain groups. You can learn more about the uses of Metabase from its official user guide.

相关实践学习
如何在云端创建MySQL数据库
开始实验后,系统会自动创建一台自建MySQL的 源数据库 ECS 实例和一台 目标数据库 RDS。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助     相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
目录
相关文章
|
关系型数据库 Java 应用服务中间件
Database Visualization using Metabase Part 1 - Install Metabase on Ubuntu 16.04
In this tutorial, we will install Metabase on an Alibaba Cloud ECS Ubuntu 16.04 server to achieve data visualization.
1941 0
Database Visualization using Metabase Part 1 - Install Metabase on Ubuntu 16.04
|
Java 数据库连接 数据库
### Error querying database. Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is jav
数据库连接超时,是数据库连接时的相关配置写错,例如:数据库密码,驱动等问题
3346 0
|
SQL Oracle 关系型数据库
FAQ: How to Use AWR reports to Diagnose Database Performance Issues [ID 1359094.1]
FAQ: How to Use AWR reports to Diagnose Database Performance Issues [ID 1359094.
1361 0
|
6月前
|
SQL Oracle 关系型数据库
WARNING: Too Many Parse Errors With error=911 When Running a JDBC Application Connected to an Oracle 19c database
WARNING: Too Many Parse Errors With error=911 When Running a JDBC Application Connected to an Oracle 19c database (
88 2
|
6月前
|
Oracle 关系型数据库
19c 开启Oracle Database Vault
19c 开启Oracle Database Vault
158 1
|
6月前
|
SQL Oracle 关系型数据库
Connect to Autonomous Database Using Oracle Database Tools
Connect to Autonomous Database Using Oracle Database Tools
59 1