Recently, a database in the production environment wrote log data crazily, causing primary key value overflow, so it is necessary to monitor this indicator. mysqld_exporter comes with this feature. Here are the startup parameters I use:
The parameters highlighted in red are used to collect the usage of the auto-increment ID. The SQL actually executed is similar to this: SELECT table_schema, table_name, column_name, AUTO_INCREMENT, POW(2, CASE data_type WHEN 'tinyint' THEN 7 WHEN 'smallint' THEN 15 WHEN 'mediumint' THEN 23 WHEN 'int' THEN 31 WHEN 'bigint' THEN 63 END+(column_type LIKE '% unsigned'))-1 AS max_int FROM information_schema.tables t JOIN information_schema.columns c USING (table_schema,table_name) WHERE c.extra = 'auto_increment' AND t.TABLE_SCHEMA NOT IN ('information_schema','mysql', 'sys','test','performance_schema') AND t.auto_increment IS NOT NULL; In the Prometheus web interface, we can test and write the following promql to find the library + table name of the instance with the remaining auto-increment ID rate less than 40%
After obtaining the data, we can configure relevant alarms in the alertmanager, or draw a graph on grafana, as follows: This is the end of this article about using prometheus to count the remaining available percentage of MySQL auto-increment primary keys. For more relevant prometheus statistics on MySQL auto-increment primary keys, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: Detailed Explanation of JavaScript Framework Design Patterns
>>: Modularity in Node.js, npm package manager explained
Table of contents Preface use Component Writing D...
use <div id="app"> <router-lin...
This article shares the specific code of jQuery t...
When using the font-family property in CSS to ref...
Result: html <nav id="nav-1"> <...
Table of contents MutationObserver API Features I...
This article takes Centos7.6 system and Oracle11g...
The ultimate way to solve the parsererror error o...
Preface In many MySQL test scenarios, some test d...
This article records the installation and configu...
Docker installs MySQL version 8.0.20 for your ref...
In this section, the author describes the special...
With the continuous development of the Internet ec...
Table of contents Preface know Practice makes per...
Table of contents Overview 1. Application-level m...