Alert Configuration

Grafana's alerting feature detects whether monitored metrics meet defined threshold conditions, based on configured monitoring rules. It helps notify users and quickly identify or resolve issues, ensuring your MatrixDB cluster remains secure and stable.

This section describes how to configure alert components and manage their usage. MatrixDB supports alerting on the following metrics:

  • Database connectivity status
  • Instance failure in the cluster
  • Data directory disk usage exceeds a specified threshold
  • Disk read/write I/O exceeds a specified threshold

Four notification methods are available for each metric. You may choose one or combine multiple methods:

  • SMS alerts
  • Voice call alerts
  • Email alerts
  • DingTalk alerts

To use alerting, you must first deploy and enable monitoring. For detailed steps, see: Monitor Deployment

After deployment, you will see an interface similar to the following:
Default Alert Dashboard

1. Deployment

Before importing predefined alert dashboards, you must copy the alert.json file from the server to your local machine. Similar to importing dashboard.json and database.json in Grafana, the process involves locating the file on the server, copying it, and uploading it locally. Follow these steps:

Log in to the server and switch to the mxadmin user. Locate the alert.json file at the path shown in the image. You can use the cd command, find command, or any other method you prefer.

[mxadmin@mdw ~]$ cd /usr/local/matrixdb/share/doc/postgresql/extension

##or

[mxadmin@mdw ~]$ find /usr/local/matrixdb/share/doc/postgresql/extension -name alert.json

Next, use the scp command to copy the file to your local machine. Permission issues may arise, so consider first copying the file to the shared /tmp/ directory, then transferring it from /tmp/ to your local system.

Note!
When copying from /tmp/, ensure you switch users appropriately to avoid permission errors.

[mxadmin@mdw]$ scp mxadmin@<server IP>:/usr/local/matrixdb/share/doc/postgresql/extension/"alert.json" mxadmin@<server IP>:/tmp/

~ scp waq@<server IP>:/tmp/"alert.json" /Users/akkepler/workplace/Grafana

Finally, open your local folder or use the command line to verify the file was copied successfully. After confirmation, modify all instances of the variable $host in the local alert.json file to include all actual hostnames in your cluster. For example, if your cluster consists of one master and two segments named mdw, sdw1, and sdw2, replace every occurrence of $host with 'mdw','sdw1','sdw2'. Once modified, import the file into Grafana.

Note!
The dashboard.json and database.json files uploaded to your Grafana interface must also have their variables modified, and they must be imported before alert.json. In dashboard.json, replace all ${cluster} with local and $host with the actual hostnames. In database.json, only replace ${cluster}.

Import Alert Dashboard

The alert dashboard functions the same as the monitoring dashboard and can be switched between using the dropdown menu located in the upper-right corner of each panel.

2. Configuration Guide

2.1 Configure Notification Channels

First, set up notification channels (Notification Channels). The entry point is shown below:
Default Alert Dashboard - Notification Channels

2.1.1 SMS Alerts

MatrixDB includes built-in SMS alerting via Alibaba Cloud SMS service, which is recommended. When an alert is triggered, a message is sent to your configured phone number(s). Bulk sending is supported. Before using this feature, you must apply for and configure Alibaba Cloud SMS service. For details, refer to:

Alibaba Cloud Documentation: Quick Start for Domestic SMS

Alternatively, you can implement custom SMS alerts using webhooks by programming your own webhook logic. See Grafana Alert Documentation: Webhook Notifications for more information.

2.1.1.1 Create Configuration File

Create an alert.yaml file under /etc/matrixdb/:

# aliyun service config
aliyun_service:
  access_key_id: "your access_key_id"
  access_key_secret: " access_key_secret"
  signature: "signature"
  sms_template_code: "SMS_123445678"

Here:

  • access_key_id and access_key_secret are issued after activating Alibaba Cloud services.
  • signature is the approved signature text registered in the Alibaba Cloud SMS console.
  • sms_template_code is the template ID starting with "SMS_", approved in the Alibaba Cloud SMS console. The template content can be viewed on the Alibaba Cloud platform. Use ${name} as the variable placeholder for the alert message.

Example template:

尊敬的管理员您好,贵公司的数据库系统发生${name}报警,请登陆网站查看详情,并及时处理。
2.1.1.2 Configure Webhook in Grafana

As shown:
Notification Channel - Alibaba SMS

We recommend naming the channel using the following format:

Aliyun Batch Short Message - For SuperAdministrators

"SuperAdministrators" represents a group of recipients. To define another group, create a separate rule. Note that the phoneNumbers parameter is case-sensitive. Multiple numbers can be specified, separated by commas:

http://:/api/alert/batch-sms?phoneNumbers=18311111111,13811111111

2.1.2 Voice Call Alerts

In addition to SMS, MatrixDB supports voice call alerts via Alibaba Cloud’s voice service. When triggered, a call is made to your configured number(s). Bulk calling is supported. Before use, apply for and configure Alibaba Cloud voice service. For details, see: Alibaba Cloud Documentation: Quick Start for Domestic Voice Service

Custom voice alerts via webhook are possible but require custom programming. For details, see Grafana Alert Documentation: Webhook Notifications.

2.1.2.1 Edit Configuration File

Add tts_template_code and region_id to the alert.yaml file under /etc/matrixdb/:

# aliyun service config
aliyun_service:
  access_key_id: "your access_key_id"
  access_key_secret: " access_key_secret"
  signature: "signature"
  sms_template_code: "SMS_123445678"
  tts_template_code: "TTS_123456788"
  region_id: "cn-hangzhou"
  • access_key_id and access_key_secret are shared with SMS service.
  • tts_template_code starts with "TTS_" and refers to the approved TTS voice template in the Alibaba Cloud console. Use ${name} as the variable for the alert message.

Example template:

尊敬的管理员您好,贵公司的数据库系统发生${name}报警,请登陆网站查看详情,并及时处理。
2.1.2.2 Configure Webhook in Grafana

Notification Channel - Alibaba Voice

Name the channel according to this format:

Aliyun Voice Message - For SuperAdministrators

"SuperAdministrators" denotes a recipient group. Define additional groups as needed. The phoneNumbers parameter is case-sensitive and supports multiple comma-separated numbers:

http://:/api/alert/vms?phoneNumbers=18311111111,13811111111

2.1.3 Email Alerts

Grafana provides built-in email alerting, which is simple to configure and use.

2.1.3.1 Create Configuration File

Since email alerting is a native Grafana feature, SMTP settings are configured in Grafana’s configuration file. The location may vary depending on deployment. On CentOS 7, the default path is:

/usr/local/etc/grafana/grafana.ini

For more information, see: Grafana Official Documentation: Configuration

Below is a sample configuration:

#################################### SMTP / Emailing #####################
[smtp]
enabled = true
host = <your smtp host>
user = <your user>
# If the password contains # or ; you have to wrap it with triple quotes. Ex """#password;"""
password = <your password>
;cert_file =
;key_file =
skip_verify = true
from_address = <your email address>
from_name = Grafana
;ehlo_identity =
;startTLS_policy =

[emails]
welcome_email_on_sign_up = false
templates_pattern = emails/*.html
2.1.3.2 Configure Email Notification Channel in Grafana

As shown:
Notification Channel - Email

Name the channel using this format:

Email - For SuperAdministrators

"SuperAdministrators" refers to a group of recipients. Define additional groups as needed.

2.1.4 DingTalk Alerts

MatrixDB supports DingTalk-based alerts. When triggered, a pre-configured DingTalk robot sends a message to the designated group. To fully utilize this feature, configure both DingTalk and Grafana.

2.1.4.1 Configure DingTalk

As shown:
Create a DingTalk group and add one or more alert robots.

Notification Channel - DingTalk
Notification Channel - DingTalk
Notification Channel - DingTalk

Click "Settings" in the "Add Robot" interface, select "Custom", customize the robot name, add alert keywords, and save the webhook URL.

Notification Channel - DingTalk
Notification Channel - DingTalk
Notification Channel - DingTalk
Notification Channel - DingTalk

2.1.4.2 Create Alert Rule in Grafana

First, create a notification rule in Grafana and fill in the required fields.
Notification Channel - DingTalk
Notification Channel - DingTalk

After configuration, click "Test" to verify connectivity between Grafana and DingTalk. If successful, clicking the alert message in the DingTalk group should redirect to the Grafana dashboard. If you see an error like "localhost refused the connection", you likely forgot to replace localhost with your actual IP address.
Notification Channel - DingTalk
Notification Channel - DingTalk

2.2 Configure Alerts

After setting up notification channels, configure alert rules for each monitoring panel.

For more details on alert configuration, see: Grafana Official Documentation: Alert

Hover over the panel title to reveal a dropdown arrow on the right. Click "Edit" to enter edit mode.
Edit

Switch from "Query" to the "Alert" tab under "Edit Panel". If a popup appears saying "Notifier with invalid ID is detected", do not click "Delete", as this may remove the entire panel. Click "Cancel" and close the window instead.
Cancel

Scroll down to the "Notifications" section. Enter a concise alert message (4–6 characters recommended). This message appears in emails and replaces the ${name} variable in SMS and voice templates. Keep it short due to message length limits. Select one or more notification channels (configured earlier) under "Send to".

Alert-Send-to

2.2.1 Connection Alert

Time-series databases aggregate data over time intervals. "No Data" may occur due to timing issues (e.g., Grafana time is 5 minutes ahead of system time while querying the last minute). Data collection failures can also result in missing data. The "No Data" condition is handled by the "Alerting" mechanism.
Connection Alert Configuration

2.2.2 Instance Status Alert

As shown:
Instance Alert Configuration

2.2.3 Disk Space Alert

The red threshold line in the "Used Disk Space" alert indicates the trigger level. Areas shaded in red exceed this threshold and represent critical conditions. The default alert threshold is 85%, but you can customize the "IS ABOVE" value as needed.
Disk Space Alert Configuration

2.2.4 Disk I/O Read/Write Alert

Disk I/O read and write alerts (Disk IO Reading, Disk IO Writing) are disabled by default, allowing you to define custom thresholds.
Disk I/O Read Alert Configuration
Disk I/O Write Alert Configuration

FAQ

  1. If you modify the alert.yaml configuration file, run the following commands to apply the changes:
source /usr/local/matrixdb/greenplum_path.sh
supervisorctl stop mxui
supervisorctl start mxui