How to view basic MySQL metrics. Queries per second etc

All we need is an easy explanation of the problem, so here it is.

Not sure how but is there a way to get basic metric data from MySQL. Show processlist list is a snap shot if now. But I was looking for average stats for a time frame. Last 10 minutes etc. I am using MySQL 8 on unbuntu 20

How to solve :

I know you bored from this bug, So we are here to help you! Take a deep breath and look at the explanation of your problem. We have many solutions to this problem, But we recommend you to use the first method because it is tested & true method that will 100% work for you.

Method 1

SHOW GLOBAL STATUS;

However, there are many issues. You need to, for example, know that Queries or Questions is a count of queries (in/out of stored procs) since the server was restarted. And that Uptime is in seconds. Hence, division is needed for "per second".

Dozens need that division; dozens are in bytes; dozens are in numbers (Max_used_connections)

But… That is only from start. To get the "last 10 minutes", you needed to have captured value(s) 10 minutes ago. That is not automatically available. Various monitoring services (many cost money) do that for you.

(The above information applies to all versions.)

Method 2

Command STATUS; will return a brief summary for uptime and average q/s value. More comprehensive data returned by SHOW GLOBAL STATUS;

Note: Use and implement method 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply