Help Center/ Application Operations Management/ Best Practices/ Using Prometheus to Monitor MySQL Metrics
Updated on 2026-01-31 GMT+08:00

Using Prometheus to Monitor MySQL Metrics

MySQL Exporter is designed to collect MySQL database metrics. Core database metrics can be collected through the Exporter for monitoring and alarm sending. This section describes how to use Prometheus to monitor MySQL metrics on AOM.

Scenario

Install the MySQL Exporter provided by AOM, and then create a collection task by setting a metric ingestion rule. MySQL metrics on a host can then be reported to AOM. After MySQL metrics are reported to AOM, monitor the metrics through metric browsing.

Practice

Connect MySQL Exporter to AOM. MySQL metrics can then be reported to AOM. Next, monitor MySQL metrics through metric browsing.

Prerequisites

Connecting MySQL Exporter to AOM

  1. Log in to the AOM 2.0 console.
  2. In the navigation pane on the left, choose Access Center > Access Center to go to the new access center.
  3. Locate the MySQL card under Self-built middleware and click Ingest Metric (AOM).
  4. On the displayed page, set parameters.

    1. Set the Prometheus instance.
      1. Instance Type: Select Common instance.
      2. Instance Name: Select the Prometheus instance prepared in Prerequisites from the drop-down list and click Next.
    2. Install the plug-in and test the connectivity.
      1. Install the plug-in by referring to the following table.
        Table 1 Parameters

        Operation

        Parameter

        Description

        Example Value

        Basic Settings

        Ingestion Rule Name

        Name of a custom metric ingestion rule. Enter 1 to 50 characters starting with a letter. Only letters, digits, underscores (_), and hyphens (-) are allowed.

        MySQL_metric

        Set Collection Plug-in

        OS

        Operating system of the host. Only Linux is supported.

        Linux

        Collection Plug-in

        The default value is MySQL Exporter. Select a plug-in version.

        MySQL Exporter

        1.0.1

        Select Server to Install Plug-in

        Select Server

        Click Select Server to select a running server to configure a collection task and install Exporter.

        • On the Select Server page, search for servers by server ID, name, status, or IP address.
        • Ensure that the UniAgent of the selected server is running. Otherwise, no data can be collected.
        • If there is no server you want to select, the UniAgent may not be installed on your server. In this case, install the UniAgent first. In addition, ensure that the UniAgent version is 1.1.3 or later. If the UniAgent version is earlier than 1.1.3, upgrade the UniAgent to the latest version.

        -

        Connect MySQL Instance

        MySQL Username

        Username of MySQL.

        root

        MySQL Password

        Password of MySQL.

        -

        MySQL Address

        IP address and port number of MySQL.

        192.168.0.0:3306

      2. Click Install & Test Collection Plug-in to deliver the Exporter installation task.
        • After the plug-in is installed, click Next.
        • Click View Log to view Exporter installation logs if the installation fails.
    3. Set an ingestion rule.
      Set a metric ingestion rule by referring to the following table. After the metric collection rule parameters are configured, you can click YAML to view the configuration data.
      Table 2 Parameters

      Operation

      Parameter

      Description

      Example Value

      Metric Collection Rule

      Metric Collection Interval (s)

      Interval for collecting metrics, in seconds. Options: 10, 30, and 60 (default).

      60

      Metric Collection Timeout (s)

      Timeout period for executing a metric collection task, in seconds. Options: 10, 30, and 60 (default).

      The timeout period cannot exceed the collection interval.

      60

      Executor

      User who executes the metric ingestion rule, that is, the user of the selected server. By default, the executor is root.

      root

      Other

      Custom Dimensions

      Dimensions (key-value pairs) added to specify additional metric attributes. You can click Add Dimension to add multiple custom dimensions (key-value pairs).
      • Key: key of the additional attribute of a metric. Only letters, digits, and underscores (_) are allowed. Each name must start with a letter or underscore. Each key must be unique.
      • Value: corresponds to the key of the additional attribute of a metric. The following characters are not allowed: &|><$;'!-()

      Up to 10 dimensions can be added. Example: Set the key to app and value to abc.

      -

  5. Click Next to connect MySQL Exporter.

    It takes about 5 minutes for MySQL metrics to be reported to AOM. You can go to the Metric Browsing page to view MySQL metrics.

Viewing MySQL Metrics

  1. Log in to the AOM 2.0 console.
  2. In the navigation pane, choose Metric Browsing.
  3. On the Metric Sources tab page, select the Prometheus instance prepared in Prerequisites on the right.
  4. Click Interaction and Multiple Metrics, enter a MySQL metric name in the search box, and view the metric details.

    In the following example, you can view the values and trends of the mysql_exporter_collector_duration_seconds metric from different dimensions.
    Figure 1 Viewing the MySQL metric