All Products
Search
Document Center

ApsaraDB for SelectDB:Use Managed Service for Grafana to visualize data

Last Updated:Feb 10, 2025

If you want to efficiently analyze and view the metrics, logs, and traces of an ApsaraDB for SelectDB instance but do not want to consider tedious operations such as server configurations and software updates, you can use Managed Service for Grafana to monitor the SelectDB instance. This topic describes how to add a ApsaraDB for SelectDB instance as a data source to Managed Service for Grafana and how to use the data source.

Prerequisites

  • A SelectDB instance is added to Managed Service for Grafana over the Internet. For more information about how to apply for a public endpoint for a SelectDB instance, see Apply for or release a public endpoint.

  • The username and password that are used to log on to the SelectDB instance are obtained.

    Note

    We recommend that you use a read-only account with low-level permissions. Otherwise, server security may be threatened.

  • A workspace is created in Managed Service for Grafana. For more information, see Create and manage a Grafana workspace.

  • The public IP address of the workspace on Managed Service for Grafana is added to the IP address whitelist of the SelectDB instance.

    1. Obtain the public IP address of the workspace on Managed Service for Grafana.

      1. Log on to the ARMS console. In the left-side navigation pane, choose Managed Service for Grafana > Workspace Management.

      2. On the Workspace Management page, click the ID or name of the workspace that you want to manage. On the page that appears, view the information in the Public IP Address section.

    2. Add the public IP address of the workspace to the IP address whitelist of the SelectDB instance. For more information, see Configure an IP address whitelist.

Billing rules

If you use Managed Service for Grafana Shared Edition, no fees are generated. For more information, see Billing rules.

Procedure

Step 1: Add a data source

  1. Log on to the ARMS console. In the left-side navigation pane, choose Managed Service for Grafana > Workspace Management.

  2. On the Workspace Management page, find the workspace that you want to manage and click the URL in the URL column to go to Grafana.

    Note

    You can log on to Grafana with the administrator account of Grafana and the password that you configured when you created the workspace. You can also click Sign in with Alibaba Cloud to log on to Grafana with the current Alibaba Cloud account.

  3. Managed Service for Grafana 9.x

    In the left-side navigation pane of Managed Service for Grafana, click the image icon. On the page that appears, click Add data source and then MySQL.

    Note

    Managed Service for Grafana does not support SelectDB data sources. You can connect Managed Service for Grafana to a MySQL data source because the SelectDB is compatible with MySQL 5.7 connection protocols and syntax.

    Managed Service for Grafana 10.x

    1. On the Grafana homepage, click the image icon in the upper-left corner.

    2. In the left-side navigation pane, choose Management > Data sources.

    3. On the Data sources tab, click Add data source. Click MySQL.

      Note

      Managed Service for Grafana does not support SelectDB data sources. You can connect Managed Service for Grafana to a MySQL data source because the SelectDB is compatible with MySQL 5.7 connection protocols and syntax.

  4. On the Settings page, configure the following parameters.

    The following table describes common parameters. For more information about other parameters, see Grafana documentation.

    Parameter

    Description

    Name

    The name of the data source.

    Host

    The public endpoint of the SelectDB instance. You can obtain the public endpoint on the details page of the SelectDB instance.

    Format: <Public endpoint>:<[MySQL port>.

    Example: selectdb-cn-bcd****-public.selectdbfe.rds.aliyuncs.com:9030.

    Database

    The name of the SelectDB instance.

    User

    The username of that is used to log on to the SelectDB instance.

    Important

    We recommend that you use a read-only account with low-level permissions. Otherwise, server security may be threatened.

    Password

    The password that is used to log on to the SelectDB instance.

  5. Click Save & Test.

    If the Database Connection OK message appears, the data source is added to Managed Service for Grafana.

    If an error message appears after you click Save & Test, perform the following steps to resolve the error:

    1. Check whether the public endpoint, instance name, username, and password are correctly configured.

    2. Check whether the public IP address of the workspace on Managed Service for Grafana is added to the IP address whitelist of the SelectDB instance. For more information, see How do I add the public IP address of Managed Service for Grafana to the IP address whitelist of an SelectDB instance?

Step 2: Use the data source to create a dashboard

The following information provides an example on how to create a dashboard panel in the table format and a time series chart on the dashboard for SelectDB data.

SELECT * FROM `test_table` where operate_time<'2022-07-20 03:00:00';

ID

place

user

operate

operate_time

count

1

China (Hangzhou)

User A

Browse

2022/7/20 0:00

3

2

China (Hangzhou)

User A

Browse

2022/7/20 1:00

8

3

China (Hangzhou)

User A

Browse

2022/7/20 2:00

13

11

China (Beijing)

User A

Browse

2022/7/20 0:00

23

12

China (Beijing)

User B

Browse

2022/7/20 1:00

18

13

China (Beijing)

User B

Browse

2022/7/20 2:00

3

21

China (Beijing)

User C

Browse

2022/7/20 0:00

13

22

China (Beijing)

User C

Browse

2022/7/20 1:00

22

23

China (Beijing)

User C

Browse

2022/7/20 2:00

23

Create a dashboard panel in the table format

  1. In the left-side navigation pane, click the 34 icon, and then click New dashboard.

  2. On the New dashboard page, click Add a new panel.

  3. On the Visualizations tab that is on the right side of the Edit Panel page, select Table.

  4. On the Query tab, select the data source that you added in Step 1.

  5. In Section A, enter the following query statements and select Format as Table:

    SELECT
      id AS "Serial number",
      place AS "City",
      user AS "User",
      operation AS "Operation",
      count AS "Number of occurrences",
      operate_time AS "Operation time"
    FROM test_table

  6. Click Apply in the upper-right corner.

Create a time series chart

  1. In the upper-right corner of the dashboard, click the Add panel icon, and then click Add a new panel.

  2. In the Visualizations tab of the Edit Panel page, select Time series.

  3. On the Query tab, select the data source that you added in Step 1.

  4. In A collapsible panel, configure query settings:

    • Time column: the column in which the time values of the table are displayed. Set this parameter to operate_time.

    • Metric column: the column in which the metrics are displayed. Set this parameter to user.

    • SELECT: the additional columns that you want to display in the chart and the functions that you want to use to generate the chart. Set this parameter to count.

    • Format as: the formatting method of the chart. Set this parameter to Time Series.

    Time series

  5. Optional. In the Graph styles section of the right-side panel, set the Style parameter to Bars to display data in a column chart.柱状图

  6. Click Apply in the upper-right corner.