MySQL Performance Inspection
Background
For increasingly complex application architectures, the current trend is that more and more customers are adopting maintenance-free cloud databases. Therefore, inspecting the performance of MySQL is a top priority. Regular intelligent inspections of MySQL are performed to identify performance issues for anomaly alerts.
Prerequisites
- Offline deployment of self-built DataFlux Func
- Enable the [Script Market] in self-built DataFlux Func (../script-market-basic-usage/)
- Create an API Key in TrueWatch under 「Manage / API Key Management」 for operations.
- Install the 「Self-built Inspection Core Package」「Algorithm Library」「Self-built Inspection (MySQL Performance)」 via 「Script Market」 in your self-built DataFlux Func.
- Write self-built inspection processing functions in your self-built DataFlux Func.
- In your self-built DataFlux Func, use 「Manage / Scheduled Tasks (Old Version: Automatic Trigger Configuration)」 to create scheduled tasks (Old Version: Automatic Trigger Configuration) for the written functions.
If you consider using a cloud server for offline deployment of DataFlux Func, please ensure it is deployed with the currently used TrueWatch SaaS in the same operator and region
Configure Inspection
Create a new script set in self-built DataFlux Func to enable MySQL performance inspection configuration.
Python | |
---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
|
Start Inspection
After configuring the inspection in DataFlux Func, you can test it by selecting the run()
method directly on the page. After publishing, you can view and configure it in DataFlux Func 「Manage / Scheduled Tasks」.
View Events
This inspection scans memory usage information from the last 6 hours. If it predicts that usage will exceed the warning threshold within the next 2 hours, the intelligent inspection generates corresponding events which can be viewed in the 「Event Center」.
Event Details
- Event Overview: Describes the object and content of the abnormal inspection event.
- CPU Utilization Line Chart: Shows the CPU utilization of the current abnormal host over the past 30 minutes.
- Memory Utilization Line Chart: Shows the memory utilization of the current abnormal host over the past 30 minutes.
- SQL Execution Count Line Chart: Displays the execution counts of replace, update, delete, insert, select over the past 30 minutes.
- Slow SQL Line Chart: Displays the number of slow SQL queries discovered over the past 30 minutes.
- SQL Time Ranking: Displays the top 5 slow SQL rankings and related information for abnormal MySQL instances. You can jump to view related logs via digest.
Common Issues
1. How to configure the detection frequency of MySQL Performance Inspection
- When writing the self-built inspection processing function in DataFlux Func, add
fixed_crontab='*/30 * * * *', timeout=900
in the decorator. Then configure it in 「Manage / Scheduled Tasks (Old Version: Automatic Trigger Configuration)」.
2. Why might there be no abnormal analysis when MySQL Performance Inspection triggers
If there is no abnormal analysis in the inspection report, please check the data collection status of the current datakit
.
3. Under what circumstances does a MySQL Performance Inspection event occur
If the configured host experiences a CPU utilization exceeding 95% continuously for 10 minutes, or memory utilization exceeding 95% continuously for 10 minutes, or SQL execution count increases by 5 times compared to the previous period, or slow SQL occurrences increase by 5 times compared to the previous period, then an alert event is generated.
4. During the inspection process, previously normal scripts may encounter abnormal errors
Please update the referenced script sets in the Script Market of DataFlux Func. You can view the update records of the Script Market through the Change Log to facilitate timely updates of scripts.