Predicting the primary keys exhaustion in MySQL based on rate of insertion
Find tables that have an AUTO_INCREMENT column.
Discover the datatype of that column, including SIGNED vs UNSIGNED.
Use that to establish the drop-dead limit.
SELECT MAX(id) FROM tbl; to see where you are now.


At that point, you can go one of two directions.

Plan A:  Compute what percent of the limit the id already is, and sort on that.

Plan B:  Check MAX(id) a week later, then compute how many weeks before the limit will be hit.

When you do find a table that is threatening to hit the limit, find out if the ids are being "burned".  Do this by comparing COUNT(*) versus MAX(id).  Either the table is really big (compared to the datatype used), or there are a lot of gaps.

If there are a lot of gaps, then dig into what the code does.  There are many flavors of INSERT that "burn" ids.  REPLACE burns a id because it is effectively DELETE + INSERT.  INSERT IGNORE, if the row is present, burns the id that it otherwise would use.  IODKU burns when it updates.  Etc.

If you are burning ids due to Normalization, see this.