Updated on 2025-02-14 GMT+08:00

Using Superset to Obtain Data from MySQL for Analysis

Application Scenario

Superset is an open-source data exploration and visualization platform. This tool provides a quick way to intuitively visualize datasets by allowing you to create and share interactive dashboards. Supported By FlexusL, the Superset application image uses Ubuntu 22.04 and is deployed using Docker. The Nginx, Redis, pgAdmin, and Docker have been preconfigured in the image. This section describes how to use Superset to obtain data from MySQL databases for analysis.

Resource Planning and Costs

This practice uses the following resource planning as an example. You can adjust it as required.

Resource

Configuration

Description

Cloud server

vCPUs: 2

Memory: 8 GiB

A Superset application image requires at least 2 vCPUs and 8 GiB of memory. Select appropriate instance specifications accordingly.

Image

Superset

Select the Superset application image.

Security group

Inbound rule:
  • Protocol/Application: TCP
  • Port: 80, 9000, 9001, 3306
  • Source: 0.0.0.0/0
  • 80: Specifies the internal forwarding port of application images.
  • 9000: Allows external access to the application O&M page.
  • 9001: Allows external access to the application management page.
  • 3306: Allows access to MySQL databases.

Procedure

Procedure

Description

Step 1: Purchase a FlexusL Instance

Purchase a FlexusL instance and select the Superset application image.

Step 2: Configure Security Groups

Add inbound security group rules to ensure that the application preinstalled in the image can be accessed.

Step 3: Reset the Password and Log In to the FlexusL Instance

A FlexusL instance does not have an initial password. After creating a FlexusL instance, set a password for the FlexusL instance.

Step 4: Initialize Superset

Set the language, log in to Superset, and reset the password.

Step 5: Obtain Data from MySQL Databases for Analysis

To use Superset to obtain data from MySQL databases for analysis, you need to connect to a database, add datasets, and create charts.

Step 1: Purchase a FlexusL Instance

  1. Log in to the FlexusLconsole and click Buy FlexusL.
  2. Specify required parameters for the FlexusL instance.

    Parameter

    Example

    Description

    Region

    CN-Hong Kong

    For low network latency and quick resource access, select the region nearest to your target users. After a FlexusL instance is created, the region cannot be changed. Exercise caution when selecting a region.

    Application Image

    Superset

    Select the Superset application image.

    Instance Specifications

    2 vCPUs | 8 GiB memory

    Select instance specifications as needed.

    Instance Name

    Superset-Example

    Customize an instance name that is easy to identify, for example, Superset-Example.

    (Optional) Associated Services

    • Data disk: 10 GiB
    • Host security
    • Cloud backup vault: 170 GiB

    You can bundle any of EVS, HSS (basic edition), and CBR to your FlexusL instances as needed and set specifications as needed.

    Required Duration

    1 month

    The minimum duration of a purchase is one month and the maximum duration is three years.

    Auto-renew is enabled by default, which means the purchased FlexusL instances will be automatically renewed before they expire. If you do not enable auto-renew during the purchase process, you can still enable it later after the instances are created. For more information about auto-renewal rules, see Auto-Renewal Rules.

    Quantity

    1

    Set the number of FlexusL instances to be purchased.

  3. Click Buy Now and complete the payment as prompted.
  4. Go back to the FlexusL console and view the purchased FlexusL instance.

Step 2: Configure Security Groups

Add inbound security group rules to ensure that the application preinstalled in the image can be accessed.

  1. Log in to the FlexusL console and click a resource card to go to the instance details page.
  2. In the navigation pane on the left, choose Cloud Servers. Locate the server and click its name.

  3. On the Security Groups tab, click Add Rule. In the displayed dialog box, add rules displayed in the following figure and click OK.

    The following figure only displays common rules. You can add more rules as needed.

    Table 1 Security group rules

    Priority

    Action

    Type

    Protocol & Port

    Source

    Description

    1

    Allow

    IPv4

    TCP: 80

    0.0.0.0/0

    Specifies the internal forwarding port of application images

    1

    Allow

    IPv4

    TCP: 3306

    0.0.0.0/0

    Allows access to MySQL databases.

    1

    Allow

    IPv4

    TCP: 9000

    0.0.0.0/0

    Allows external access to the application O&M page.

    1

    Allow

    IPv4

    TCP: 9001

    0.0.0.0/0

    Allows external access to the application dashboard.

Step 3: Reset a Password

A FlexusL instance does not have an initial password. After creating a FlexusL instance, set a password for the FlexusL instance. The password of the FlexusL instance is also used for logging in to the O&M page of the application.

  1. In the Image area on the Overview page of the FlexusL console, click Access to go to the application dashboard and check whether the application has been up and running. If yes, go to the next step.

    Wait for several minutes until the image with the pre-installed application is up and running. Then, you can perform operations such as restarting or stopping the instance, or resetting the password. Otherwise, the initial password may become invalid and you cannot log in to the application dashboard.

    Figure 1 Entry to the application dashboard

    After the application is started, the initialization wizard page of the dashboard is displayed, as shown in Figure 2.

    Figure 2 Initialization wizard page of the Superset dashboard

    If the dashboard is not properly displayed, check the following causes:

    • The port for accessing the dashboard is not allowed. Check whether the port is allowed based on Step 2: Configure Security Groups.
    • The dashboard is being started. Try again later.
  2. Locate the resource card and choose > Reset Password to reset the password.

    For details, see Resetting the Password for a FlexusL Instance.

    Figure 3 Resetting a password

    The password for logging in to the FlexusL instance is also the password for logging in to the O&M page of the application.

Step 4: Initialize Superset

Application images use code-based Ubuntu. They provide graphical user interfaces to make your operations easier. You need to initialize the application dashboard upon the first login. Then you can directly log in to the dashboard from the FlexusL console afterwards.

  1. In the address bar of a local browser, enter http://<Server-EIP>:9000 to log in to the application O&M page.

    The initial username and password for logging in to the application dashboard are stored on the O&M page of the application. You need to log in to the O&M page first to obtain the username and password. The username for logging in to the O&M page is root, and the login password is the password reset in 2.

    For details about the FlexusL instances, O&M page, and dashboard, see What Is the Relationship Among FlexusL Instances, the Dashboard, and the O&M Page?

  2. On the My Apps page, click the application icon, choose Access, and click Initial Account to view the username and password for logging in to the application management page.

    The initial password is a randomly generated strong password. After the application is initialized, change the password on the dashboard for easy management. If the password is changed, the initial password will be invalid. Remember the new password.

  3. In the Image area on the Overview page of the FlexusL console, click Access to go to the application dashboard.

    If the dashboard is not properly displayed, check the following causes:

    • The port for accessing the dashboard is not allowed. Check whether the port is allowed based on Step 2: Configure Security Groups.
    • The dashboard is being started. Try again later.
  4. Enter the username and password obtained in 2 to access the dashboard.

    You can set the language on the login page or on the management page.

    Figure 4 Initialization wizard page of the Superset dashboard

    If a message is displayed indicating that the username or password you entered is invalid when you attempt to log in to the application dashboard, refer to Why Can't I Access the Dashboard of the Application Pre-installed in the Application Image After Entering the Initial Username and Password?

  5. In the upper right corner of the page, choose Settings > User > Info and click RESET MY PASSWORD.

    Preset passwords are usually difficult to remember, so you are advised to set a password that is easy to remember, and please keep it safe.

    After the Superset application is initialized, you can deploy your applications on the dashboard.

Step 5: Obtain Data from MySQL Databases for Analysis

This section describes some basic operations of Superset. For more information, see Superset Documentation.

You can only analyze data after connecting to a database first.

  1. On the management page, choose Data > Databases and click +DATABASE.
  2. Select the database to be connected, for example, the MySQL database.
  3. Enter the information about the database to be connected.
    Table 2 Parameter descriptions

    Parameter

    Description

    HOST/PORT

    Specifies the public IP address and port number of the database. The default MySQL port number is 3306.

    DATABASE NAME

    Specifies the name of the database to be connected.

    USERNAME/PASSWORD

    Specifies the username and password of the database.

    DISPLAY NAME

    Specifies the name displayed on Superset after the database is connected.

  4. Click CONNECT.
  5. Click FINISH and you can view the connected database in the list.

Now that you have configured a data source, you need to register tables (called Datasets in Superset) for subsequent chart creation.

  1. Choose Data > Datasets and click +DATASET.

  2. Click ADD, and you can view your dataset in the list of datasets.

Superset is a powerful visualization builder that allows you to create charts and dashboards. This section is for demonstration only. You can create exquisite charts and dashboards by referring to the official guide.

  1. Click the database name to visualize the chart.

  2. Click SAVE to add the chart to the dashboard.

  3. Click SAVE & GO TO DASHBOARD. The visualized chart is displayed on the dashboard.