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
MySQL5.7 master-slave configuration implementatio...
Vue parent component calls the function of the ch...
1.Jenkins installation steps: https://www.jb51.ne...
Ubuntu 20.04 has been released, bringing many new...
>1 Start the database In the cmd command windo...
This article shares the specific code of the WeCh...
Wildcard categories: %Percent wildcard: indicates...
Preface In a common business scenario, we need to...
[LeetCode] 196.Delete Duplicate Emails Write a SQ...
When nginx receives a request, it will first matc...
Nowadays, whether you are on the sofa at home or ...
Table of contents 1. Introduction 2. Solution 2.1...
Table of contents defineComponent overload functi...
Preface Sometimes you need to keep the height of ...
Table of contents Docker container data volume Us...