Fortinet black logo

User Guide

MySQL monitoring

24.2.0
Copy Link
Copy Doc ID af1daa65-c273-11ec-9fd1-fa163e15d75b:432741
Download PDF

MySQL monitoring

MySQL includes several metrics that you can use to monitor connection, query, and overall database health. Regularly monitoring MySQL metrics can help you gather information that you can use when troubleshooting MySQL-related issues, such as:

  • Connectivity - Monitor your MySQL server's availability, connections, and latency.

  • Performance - Investigate and pinpoint performance issues.

For certain metrics, it is important to set up alerts when thresholds are breached. In the following sections, key MySQL metrics are described in detail to help you develop an alerting strategy suitable to your infrastructure.

MySQL metrics and alerts

For a list of all available metrics, see MySQL.

Synthetic checks

Synthetic checks allow you to monitor servers, endpoints, and other network-based services from behind your firewall with an OnSight vCollector or from a Monitoring location. Synthetically monitoring your MySQL instance provides insights into its availability, ensuring that the instance is reachable and properly responding to requests.

To perform synthetic checks on your MySQL instance, add the following metric:

Metric

Description

Monitor

Alert

MySQL session

Checks if a session can be initiated and terminated from an OnSight vCollector or an external monitoring location.



MySQL application metrics

Configuring monitoring and alerting for MySQL can help you identify and investigate potential problems on the MySQL application itself. The metrics described in the following sections gather data to help you answer questions such as:

  • Is the database available and effectively providing service to clients?

  • Are there queries performing poorly?

  • What is the connection load?

In addition, monitoring metrics like caches, threads, and connections can help you identify if your proper resources are sufficient. Click the following links to review the recommended monitoring and alerting strategy for each metric:

Availability metrics

The following metrics validate that your MySQL instance is working and can be reached by clients.

Metric

Description

Monitor

Alert

MySQL connections

The total number of processes (threads) connected to the MySQL server.

This metric can help you assess the number of connections your instance will support. When the configured maximum number of connections has been reached, new client connections will be refused. Consider increasing the maximum connections limit or adding more resources if client connections are frequently refused.


MySQL slave server is connected to the master

The status of the slave-master servers connection, when applicable.

MySQL replication spreads out the load among multiple slaves to improve query performance. Performance issues may occur if replication threads fail to run on slave instances.


MySQL slave server is replicating

Checks if the master server is replicating to the slave server.

MySQL replication spreads out the load among multiple slaves to improve query performance. Performance issues may occur if replication threads fail to run on slave instances.


Uptime

The number of seconds since the MySQL server was started.

This metric can be used to detect restarts. A consistent low uptime value suggests that the instance is frequently being restarted, causing service interruptions.



Query performance metrics

The following metrics measure the performance of your MySQL instance. Monitoring metrics that track queries, threads, and server latency can be added to the instance.

Metric

Description

Monitor

Alert

Slow queries/second

The average number of queries per second that took more than the configured query time to execute.

A high metric value suggests that queries are not being executed optimally. Check the slow query log and identify the slow queries for optimization.



Queries/second

The average number of queries per second.

If you are getting consistently high values and experiencing performance degradation, consider scaling up your infrastructure to handle more queries.



MySQL slave server latency (seconds)

The latency between the slave and the master servers.

Threads connected

The current number of open connections.

This metric provides real-time insight into the number of clients connected to the instance. Monitoring the metric can help you analyze traffic or evaluate when to do a restart.



Threads created

The total number of processes (threads) created to handle MySQL connections.

Threads running

The total number of processes (threads) running on the MySQL instance.

Questions - count of statements executed from the client

The number of statements executed by the server from the client.



Other metrics

InnoDB locks and cache status metrics are described in the following table.

Metric

Description

Monitor

Alert

InnoDB row lock current waits

The current number of times operations on the InnoDB tables had to wait for a row lock.

To improve the performance of MySQL read and write operations, tune the size of the buffer pool used by InnoDB to cache table and index data.


InnoDB row lock time avg

The average time, in milliseconds, to get a row lock for InnoDB tables.

MySQL query cache amount free (KB)

The amount of free space (in KB) in the MySQL query cache.

MySQL query cache percent free

The percentage of free space in the MySQL query cache.

MySQL monitoring

MySQL includes several metrics that you can use to monitor connection, query, and overall database health. Regularly monitoring MySQL metrics can help you gather information that you can use when troubleshooting MySQL-related issues, such as:

  • Connectivity - Monitor your MySQL server's availability, connections, and latency.

  • Performance - Investigate and pinpoint performance issues.

For certain metrics, it is important to set up alerts when thresholds are breached. In the following sections, key MySQL metrics are described in detail to help you develop an alerting strategy suitable to your infrastructure.

MySQL metrics and alerts

For a list of all available metrics, see MySQL.

Synthetic checks

Synthetic checks allow you to monitor servers, endpoints, and other network-based services from behind your firewall with an OnSight vCollector or from a Monitoring location. Synthetically monitoring your MySQL instance provides insights into its availability, ensuring that the instance is reachable and properly responding to requests.

To perform synthetic checks on your MySQL instance, add the following metric:

Metric

Description

Monitor

Alert

MySQL session

Checks if a session can be initiated and terminated from an OnSight vCollector or an external monitoring location.



MySQL application metrics

Configuring monitoring and alerting for MySQL can help you identify and investigate potential problems on the MySQL application itself. The metrics described in the following sections gather data to help you answer questions such as:

  • Is the database available and effectively providing service to clients?

  • Are there queries performing poorly?

  • What is the connection load?

In addition, monitoring metrics like caches, threads, and connections can help you identify if your proper resources are sufficient. Click the following links to review the recommended monitoring and alerting strategy for each metric:

Availability metrics

The following metrics validate that your MySQL instance is working and can be reached by clients.

Metric

Description

Monitor

Alert

MySQL connections

The total number of processes (threads) connected to the MySQL server.

This metric can help you assess the number of connections your instance will support. When the configured maximum number of connections has been reached, new client connections will be refused. Consider increasing the maximum connections limit or adding more resources if client connections are frequently refused.


MySQL slave server is connected to the master

The status of the slave-master servers connection, when applicable.

MySQL replication spreads out the load among multiple slaves to improve query performance. Performance issues may occur if replication threads fail to run on slave instances.


MySQL slave server is replicating

Checks if the master server is replicating to the slave server.

MySQL replication spreads out the load among multiple slaves to improve query performance. Performance issues may occur if replication threads fail to run on slave instances.


Uptime

The number of seconds since the MySQL server was started.

This metric can be used to detect restarts. A consistent low uptime value suggests that the instance is frequently being restarted, causing service interruptions.



Query performance metrics

The following metrics measure the performance of your MySQL instance. Monitoring metrics that track queries, threads, and server latency can be added to the instance.

Metric

Description

Monitor

Alert

Slow queries/second

The average number of queries per second that took more than the configured query time to execute.

A high metric value suggests that queries are not being executed optimally. Check the slow query log and identify the slow queries for optimization.



Queries/second

The average number of queries per second.

If you are getting consistently high values and experiencing performance degradation, consider scaling up your infrastructure to handle more queries.



MySQL slave server latency (seconds)

The latency between the slave and the master servers.

Threads connected

The current number of open connections.

This metric provides real-time insight into the number of clients connected to the instance. Monitoring the metric can help you analyze traffic or evaluate when to do a restart.



Threads created

The total number of processes (threads) created to handle MySQL connections.

Threads running

The total number of processes (threads) running on the MySQL instance.

Questions - count of statements executed from the client

The number of statements executed by the server from the client.



Other metrics

InnoDB locks and cache status metrics are described in the following table.

Metric

Description

Monitor

Alert

InnoDB row lock current waits

The current number of times operations on the InnoDB tables had to wait for a row lock.

To improve the performance of MySQL read and write operations, tune the size of the buffer pool used by InnoDB to cache table and index data.


InnoDB row lock time avg

The average time, in milliseconds, to get a row lock for InnoDB tables.

MySQL query cache amount free (KB)

The amount of free space (in KB) in the MySQL query cache.

MySQL query cache percent free

The percentage of free space in the MySQL query cache.