home/blog/2023-02-11-monitor-mysql.md
MySQL is an open source relational database management system developed by the Swedish company MySQL AB and a product of Oracle. MySQL is one of the most popular open source relational database management systems. In terms of WEB applications, MySQL is one of the best RDBMS (Relational Database Management System, relational database management system) application software.
HertzBeat is an open source, easy-to-use and friendly real-time monitoring tool that does not require Agent and has powerful custom monitoring capabilities.
Click Add Mysql Monitoring
Path: Menu -> Database Monitoring -> Mysql Database -> Add Mysql Database Monitoring
Configure the parameters required for the new monitoring Mysql database
On the monitoring page, fill in Mysql service IP, monitoring port (default 3306), account password, etc., and finally click OK to add. For other parameters such as collection interval, timeout period, etc., please refer to Help Documentation https://hertzbeat.apache.org/docs/help /mysql/
Complete ✅, now we have added the monitoring of the Mysql database, check the monitoring list to see our added items.
Click Operation->Monitoring Details Icon of the monitoring list item to browse the real-time monitoring metric data of the Mysql database.
Click Monitoring History Details TAB to browse the historical monitoring metric data chart of Mysql database📈.
DONE! Done! Through the above steps, in fact, it only takes one step to sum up
:::tip Through the above two steps, we have completed the monitoring of the Mysql database. We can view the monitoring details and metrics in HertzBeat at any time to observe its service status. Of course, just looking at it is definitely not perfect. Monitoring is often accompanied by alarm thresholds. When the metrics of the Mysql database exceed our expectations or are abnormal, we can promptly notify our corresponding person in charge. The person in charge receives the notification and handles the problem. It is a complete monitoring and alarm process. :::
Next, we will demonstrate step by step how to configure the threshold alarm notification in the HertzBeat system, so that when the metrics of the Mysql database are found to be abnormal, they will be notified to us in time
Configure an alarm threshold for an important metric
Path: Menu -> Threshold Rules -> Add Threshold
query cache hit rate cache -> query_cache_hit_rate. When the query cache hit rate of Mysql is very low An alarm is issued when it is less than 30%.query_cache_hit_rate<30 of this metric cache, the alarm level is serious alarm, and it will be triggered after three times, as shown in the figure below.Add message notification recipients
Configure the receiver to let the alarm message know who to send and how to send it.
Path: Menu -> Alarm Notification -> Alarm Recipient -> Add New Recipient
Message notification methods support email, DingTalk, WeChat Work, Feishu, WebHook, SMS, etc. Here we take the commonly used DingTalk as an example.
HertzBeat, get the corresponding access_token value.【Alarm Notification】->【New Recipient】->【Select DingTalk Robot Notification Method】->【Set DingTalk Robot ACCESS_TOKEN】->【OK】
Configure the associated alarm notification strategy ⚠️ [Add notification strategy] -> [Associate the recipient just set] -> [OK]
Configure the alarm notification policy to bind the alarm message with the receiver, so that you can decide which alarms to send to whom.
[HertzBeat warning notification]
Alarm target object: mysql.cahce.query_cache_hit_rate
Affiliated monitoring ID: 205540620394932
Belonging monitoring name: Mysql_localhost
Alarm level: major alarm
Alarm trigger time: 2023-02-11 21:13:44
Content details: mysql db query_cache_hit_rate is too low, now is 20.
:::tip
This practical article took us to experience how to use the open source real-time monitoring tool HertzBeat to monitor Mysql database metric data. We can find that HertzBeat, which integrates monitoring-alarm-notification, is more convenient in operation and use, just click on the page The Mysql database can be included in the monitoring and alarm notification, and the tedious operations of deploying multiple components and writing configuration files are no longer needed.
:::
Mysql Github: https://github.com/mysql/mysql-server HertzBeat Github: https://github.com/apache/hertzbeat
Welcome to learn, use and star!
Only one docker command is needed to install and experience heartbeat:
docker run -d -p 1157:1157 --name hertzbeat apache/hertzbeat