Prometheus Monitoring of Application Real-Time Monitoring Service (ARMS) allows you to monitor MySQL by capturing MySQL data and displaying the captured data on the ARMS Prometheus Grafana dashboard.

Background information

The following figure shows the workflow.

How it works

Step 1: Capture MySQL data through an external application

Deploy an application by using the mysqld-exporter image officially provided by Prometheus to the Container Service Kubernetes cluster to capture MySQL data.

  1. In the left-side navigation pane, choose Clusters > Clusters. On the Clusters page, find the target cluster, and click Dashboard in the Actions column.
    Kubernetes cluster console button
  2. In the left-side navigation pane, choose Workloads > Deployments. In the upper-right corner, click CREATE, and enter the following information in the CREATE FROM TEXT INPUT section:
    Note Change the values of <yourMySQLUsername>, <yourMySQLPassword>, <IP>, and <port> to those of MySQL.
    apiVersion: extensions/v1beta1
    kind: Deployment
    metadata:
      name: mysqld-exporter
    spec:
      replicas: 1
      template:
        metadata:
          labels:
            app: mysqld-exporter
        spec:
          containers:
          - name: mysqld-exporter
            imagePullPolicy: Always
            env:
              - name: DATA_SOURCE_NAME
                value: "<yourMySQLUsername>:<yourMySQLPassword>@(<IP>:<port>)/"
            image: prom/mysqld-exporter
            ports:
            - containerPort: 9104
              name: mysqld-exporter
    In this step, the mysqld-exporter application is deployed to the Container Service Kubernetes cluster.
  3. In the left-side navigation pane, choose Discovery and Load Balancing > Services. In the upper-right corner, click CREATE, and enter the following information in the CREATE FROM TEXT INPUT section:
    apiVersion: v1
    kind: Service
    metadata:
      labels:
        app: mysqld-exporter
      name: mysqld-exporter
    spec:
      ports:
      - name: mysqld-exporter
        port: 9104
        protocol: TCP
        targetPort: 9104
      type: NodePort
      selector:
        app: mysqld-exporter

Step 2: Configure ARMS Prometheus Monitoring to receive MySQL data

Configure ARMS Prometheus Monitoring in the ARMS console to receive MySQL data captured through external applications.

  1. In the left-side navigation pane, click Prometheus Monitoring.
  2. On the top of the Prometheus monitoring page, select the region where the Container Service Kubernetes cluster is located. Find the target cluster, and click Installation in the Actions column.
  3. After the ARMS Prometheus agent is installed, find the target cluster, and click Settings in the Actions column.
  4. On the Details tab, click Add ServiceMonitor. In the Add ServiceMonitor dialog box, enter the following information:
    apiVersion: monitoring.coreos.com/v1
    kind: ServiceMonitor
    metadata:
      labels:
        app: mysqld-exporter
        release: p
      name: mysqld-exporter
    # namespace: monitoring
    # The Prometheus namespace
    spec:
      endpoints:
      - interval: 30s
        # The Mysqld Grafana template ID is 7362.
        # Enter the value of the Name field for Port of Prometheus Exporter in the service.yaml file.
        port: mysqld-exporter
        # Enter the path exposed in Prometheus Exporter code.
        path: /metrics
      namespaceSelector:
        any: true
        # The namespace of the NGINX Demo
      selector:
        matchLabels:
          app: mysqld-exporter

Step 3: Display the MySQL data on the Grafana dashboard

Import the Grafana dashboard template in the ARMS console and specify the Container Service Kubernetes cluster where the Prometheus data source is located.

  1. Go to Host Dashboard.
  2. In the left-side navigation pane, choose + > Import, enter 7362 in the Grafana.com Dashboard field, and click Load.
    Import Grafana dashboard
  3. On the Import page, set the following information and click Import.
    Import Grafana dashboard with options
    1. Enter a custom dashboard name in the Name field.
    2. Select your Container Service Kubernetes cluster from the Folder drop-down list.
    3. Select your Container Service Kubernetes cluster from the prometheus drop-down list.
    After the configuration is complete, the ARMS Prometheus Grafana MySQL dashboard appears, as shown in the following figure.ARMS Prometheus Grafana MySQL

Step 4: Create an alert

What to do next

After the ARMS Prometheus Grafana MySQL dashboard is configured, you can view Prometheus Monitoring metrics and customize the dashboard. For more information, see the following documents.